Saloni Anchal Final Report On Dmining

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 155

ELECTROMART ANALYSIS USING DATAMINING

TABLE OF CONTENTS
1. INTRODUCTION 3 1.1 Project Summary. . 4 1.2 Scope.. 4 1.3 Objective.. . .4 1.4 Technology and Literature review. . 4 2. REQUIREMENT ANALYSIS 8 2.1 Study of Current System.. .9 2.2 Requirement of New System..... 9 2.3 Requirement Details.10 2.4 Feasibility Analysis...11 3. SYSTEM DESIGN.14 3.1 Design .15 3.1.1 Use case diagram17 3.1.2 Use case specification.18 3.1.3 Activity diagram.19 3.1.4 Sequence diagram.. 22 3.2 System Structure Design . 31 4. PROJECT IMPLEMENTATION.32 4.1 Details of Modules.33 5. TESTING. 34 5.1 Testing Plan .. 35

5.2 Test Case 36


5.3 Testing Strategy and Method....36 5.4 Statistical Testing...37 S.I.M.S INDORE 1

ELECTROMART ANALYSIS USING DATAMINING

5.5 Defect Testing.39 6. CONCLUSION 41 7. SUMMARY 42 8. REFERENCES 45 9. APPENDIX 47 10. SOURCE CODE 50 11. SCREEN SHOTS. 149

INTRODUCTION

S.I.M.S INDORE

ELECTROMART ANALYSIS USING DATAMINING

1.

Introduction

1.1Project Summary
Data mining is the process of extracting patterns from data. As more data are gathered, with the amount of data doubling every three years, data mining is becoming an increasingly important tool to transform these data into information. It is commonly used in a wide range of profiling practices, such as marketing, surveillance, fraud detection and scientific discovery.

As data sets have grown in size and complexity, direct hands-on data analysis has increasingly been augmented with indirect, automatic data processing. Data mining is the process of applying these methods to data with the intention of uncovering hidden patterns. It has been used for many years by businesses, scientists and governments to sift through volumes of data supermarket scanner data to produce market research reports. This is done in order to help reduce, model, understand, or analyze the data. Tasks supported by data mining include prediction, segmentation, dependency modeling, summarization, and change and deviation detection. Traditional manual data analysis and exploration requires highly trained data analysts and is ineffective for massive data sets. Data mining commonly involves four classes of task: Classification - Arranges the data into predefined groups. For example an email program might attempt to classify an
S.I.M.S INDORE 3

ELECTROMART ANALYSIS USING DATAMINING

email as legitimate or spam. Common algorithms include Decision Tree Learning, nearest neighbor, naive Bayesian classification and Neural network. Clustering - Is like classification but the groups are not predefined, so the algorithm will try to group similar items together. Regression - Attempts to find a function which models the data with the least error. A common method is to use Genetic Programming. Association: Searches for relationships between variables. For example a supermarket might gather data on customer purchasing habits. Using association rule learning, the supermarket can determine which products are frequently bought together and use this information for marketing purposes. This is sometimes referred to as market basket analysis. And supermarket is one place where data is so huge and unmanageable as they are updated and depleted at every instance. And they even requirement proper analysis to come to some informative conclusion wherein the data mining concept comes in. information from the rugged data is required to perform many a task as in budgeting, inventory, financing, investments, maintenance n all And usually this process requires human labour to come to conclusions and hence data mining helps in solving these problems. These were data mining and supermarket correlate.
1.2 Scope Data mining techniques are fundamentally data reduction and visualization techniques. And this basic concept can find applications in many aspects of areas relating to the data storage and warehousing. Data mining is a concept of finding intelligent information from the raw data. And the basic aim this project brings in is the extraction of informative data from the large data stored. The supermarket has many a fields storing data and these fields are then correlated to find information which can predict patterns and give out decisions based on these patterns. This project aims at decision making and hence can be applied in any supermarket store to decide the offers. It has a budget management system, and hence can be applied in any areas wherein the budgeting is the prime focus. It has a feature of finding trends based upon the previous years analysis and predicts the upcoming trends. And hence can find application in firms developing analytic researches.

S.I.M.S INDORE

ELECTROMART ANALYSIS USING DATAMINING

1.3 Objective
There is valuable information hidden in data. Since the underlying data is generated much faster than it can be processed and made sense of, this information often remains buried and untapped. It becomes virtually impossible for individuals or groups with limited resources specifically technological to find and gain any insight from the data.

These relationships can also result in predictors of future outcomes by employing data mining, practices to uncover customer buying patterns, purchase history to make product recommendations to shoppers. Data mining can be applied wherever there is an abundance of data available for and in need of analysis. It can be used to buy stock for a store by keeping track of buying pattern, it can help analyze the previous years budget to suggest the outline for future investments. The various applications in the supermarket make this an excellent tool for decision making and hence the purpose of this project is fulfilled.
1.4 Technology and Literature review

1.4.1 Technologies Electromart Analysis using Data Mining is developed using following technologies. 1.4.1.1 JAVA
Java refers to a number of proprietary computer software products and specifications from Sun Microsystems, a subsidiary of Oracle Corporation, that together provide a system for developing application software and deploying it in a cross-platform environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones on the low end, to enterprise servers and supercomputers on the high end. Java is used in mobile phones, Web servers and enterprise applications, and while less common on desktop computers, Java applets are often used to provide improved and secure functionalities while browsing the World Wide Web.

Writing in the Java programming language is the primary way to produce code that will be deployed as Java byte code, though there are byte code compilers available for other languages such as JavaScript, Python, Ruby and Scala, and a native Java scripting language called Groovy. Java syntax borrows heavily from C and C++, but object-oriented features are modeled after Smalltalk and Objective C.[1] Java eliminates certain low-level constructs such as pointers and
S.I.M.S INDORE 5

ELECTROMART ANALYSIS USING DATAMINING

has a very simple memory model where every object is allocated on the heap and all variables of object types are references. Memory management is handled through integrated automatic garbage collection performed by the Java Virtual Machine (JVM).
1.4.1.2 JDK The Java Development Kit (JDK) is a Sun Microsystems product aimed at Java developers. Since the introduction of Java, it has been by far the most widely used Java SDK. On 17 November 2006, Sun announced that it would be released under the GNU General Public License (GPL), thus making it free software. This happened in large part on 8 May 2007[2] and the source code was contributed to the Open JDK.
JDK contents

The JDK has as its primary components a selection of programming tools, including:
java The loader for Java applications. This tool is an interpreter and can interpret the class files generated by the javac compiler. Now a single launcher is used for both development and deployment. The old deployment launcher, jre, no longer comes with Sun JDK. javac The compiler, which converts source code into Java bytecode jar The archiver, which packages related class libraries into a single JAR file. This tool also helps manage JAR files. javadoc The documentation generator, which automatically generates documentation from source code comments jdb The debugger jps The process status tool, which displays process information for current Java processes javap The class file disassembler appletviewer This tool can be used to run and debug Java applets without a web browser. javah The C header and stub generator, used to write native methods javaws The Java Web Start launcher for JNLP applications extcheck This utility can detect JAR-file conflicts. apt The annotation-processing tool jhat (Experimental) Java heap analysis tool jstack (Experimental) This utility prints Java stack traces of Java threads. jstat (Experimental) Java Virtual Machine statistics monitoring tool jstatd (Experimental) jstat daemon jinfo (Experimental) This utility gets configuration information from a running Java process or crash dump.

S.I.M.S INDORE

ELECTROMART ANALYSIS USING DATAMINING

jmap (Experimental) This utility outputs the memory map for Java and can print shared object memory maps or heap memory details of a given process or core dump. idlj The IDL-to-Java compiler. This utility generates Java bindings from a given IDL file. policytool The policy creation and management tool, which can determine policy for a Java runtime, specifying which permissions are available for code from various sources VisualVM visual tool integrating several commandline JDK tools and lightweight performance and memory profiling capabilities wsimport Generates portable JAX-WS artifacts for invoking a web service. jrunscript Java command line script shell.

The JDK also comes with a complete Java Runtime Environment, usually called a private runtime. It consists of a Java Virtual Machine and all of the class libraries present in the production environment, as well as additional libraries only useful to developers, such as the internationalization libraries and the IDL libraries. Also included are a wide selection of example programs demonstrating the use of almost all portions of the Java API. 1.4.2 Tools The following tools were used while developing the project.
1.4.2.1Rational Rose (Analysis and Design)

Rational Rose is an object-oriented Unified Modeling Language (UML) software design tool intended for visual modeling. In much the same way a software designer uses Rational Rose to visually create (model) the framework for an application by blocking out classes with actors (stick figures), and messages/relationships (arrows) in a sequence diagram using drag-and-drop symbols. Rational Rose documents the diagram as it is being constructed and then generates code in the designers choice of C++, Visual Basic, Java, Oracle, CORBA or Data Definition Language. Popular features of Rational Rose are its ability to provide iterative development and round-trip engineering. Rational Rose allows designers to take advantage of iterative development sometimes called evolutionary development.

S.I.M.S INDORE

ELECTROMART ANALYSIS USING DATAMINING

1.4.2.2Net Beans

The NetBeans IDE is an open source integrated development environment written entirely in Java using the Net Beans Platform. NetBeans IDE supports development of all Java application types (Java SE, web, EJB and mobile applications) out of the box. Among other features are an Ant-based project system, version control and refactoring. Modularity: All the functions of the IDE are provided by modules. Each module provides a well defined function, such as support for the Java language, editing, or support for the CVS versioning system, and SVN. NetBeans contains all the modules needed for Java development in a single download, allowing the user to start working immediately. Modules also allow NetBeans to be extended. New features, such as support for other programming languages, can be easily added by installing additional modules.

S.I.M.S INDORE

ELECTROMART ANALYSIS USING DATAMINING

REQUIREMENT ANALYSIS

2.

Requirement Analysis

S.I.M.S INDORE

ELECTROMART ANALYSIS USING DATAMINING

2.1

Study of Current System

In the current scenario, the budgeting and planning for use and development of resources in any organization is a challenging task. Usually a back end team of 1000s of employees is required depending upon the size of organization and the market covered by them. For a supermarket, we can visualize this as a 3 layer system where at the primary level we have the naive user or the staff, who perform the billing and maintenance of the store. Next at the secondary level is the local management for particular stores and finally we have the tertiary level or the backend team at the main office or zonal office who monitors the sales and working of supermarkets under them. The secondary team is interface b/w the billing and product planning stage. The various offers generated in the store are nothing but excellent marketing strategies created by the highly paid professionals. They not only help in boosting the sales but also ensure the clearance of dead stock or low selling goods. Generating offers and planning the budget involve thorough study of sales figures over the time. This not only needs excellent planning strategies but also deep understanding of mathematical tools such as probability and statistics. The back end team not only has to plan offers that appeal the general public who buys the product but also the supermarket as a whole because apart from increasing the sales its important to maintain a fixed proportion of profitability. Presently, the existing systems relating to the supermarket are usually relating the database storage and billing processes involved during the sales transaction.The database of the supermarkets just stores the data. And maintaining that huge amount of data like updating the new data arrived and depleting the ones finished off is quiet a labor some task and it requires intelligent manual work. Not only that, when the data becomes way too large then handling and maintaining it at the human level intelligence is quiet labor some.
S.I.M.S INDORE 10

ELECTROMART ANALYSIS USING DATAMINING

2.2 Requirement of New System


Supermarkets usually offer products at low prices by reducing their economic margins. Certain products (typically staple foods such as bread, milk and sugar) are occasionally sold as loss leaders, that is, with negative profit margins. To maintain a profit, supermarkets attempt to make up for the lower margins by a higher overall volume of sales, and with the sale of higher-margin items. Customers usually shop by placing their selected merchandise into shopping carts (trolleys) or baskets (self-service) and pay for the merchandise at the check-out. At present, many supermarket chains are attempting to further reduce labor costs by shifting to self-service check-out machines, where a single employee can oversee a group of four or five machines at once, assisting multiple customers at a time. Supermarkets can generally retail at lower prices.But how are these prices decided. Supermarkets are also very famous for various deals and offers they provide which are consumer friendly. They are markets wherein offers for various products are available at really economical prices, these markets usually sell their product at really low retail because of the bulk volumes and season demands. But how are these prices decided as if the retail is really low is the supermarket benefited? And how are these prices decided to benefit the consumer and the supermarket and eventually even complete the surplus stock and apparently even favor the market value of the supermarket. We propose a system which avails the solutions of the problems. We propose a system which is a decision making system which decides the specific offers and deals provided to the consumers which in turn benefits the supermarket in its market value and even finishes of the surplus stock.

2.3

Requirement Details

2.3.1 Software requirement


The System has been developed using the following software: Jdk1.6 or higher MySQL (Database)
Application Server Configuration

2.3.1.1

Content Type OS Programming Language

Content Used Windows 2007 Java

Version 2007 JDK 1.6

2.3.1.2 Database Server Configuration

S.I.M.S INDORE

11

ELECTROMART ANALYSIS USING DATAMINING

Content Type OS Back End


2.3.1.3 Front End Configuration

Content Used Windows 2007 MySQL (Version 5.0)

Content Type OS Front End

Content Used Windows 2007 Core Java,swing

2.3.2 Hardware Requirement


A Pentium-class processor running at 400 MHz or faster Random Access Memory (RAM) 256MB recommended

2.4

Feasibility Analysis

The project is certainly feasible as we are using Java as the programming language. This is a object oriented programming language and it also supports many features including GUI and networking. There are built in functions for various packages, which make it easier to organize data in well-defined way.
2.4.1 Cost Analysis

Cost estimation is part of the planning stage of any engineering activity. The difference in cost estimation between engineering the primary cost is for people. In other engineering disciplines, the cost of materials- chips, bricks or aluminum depends on the activity. In software engineering, to estimate the cost we only have to estimate how many engineers are needed. The problem of predicting how many engineers and other resources are needed for given
S.I.M.S INDORE 12

ELECTROMART ANALYSIS USING DATAMINING

software project is know as software cost estimation. Software cost estimation has two uses in software project management. First, during the planning stage, one needs to decide how many engineers are needed for the project and develop a schedule. Second, on monitoring the projects progress, one needs to access whether the project is progressing according to schedule and take corrective action if necessary. Project planning is the primary step in project management. Project complexity has Strong effect on uncertainty that is inherent in planning. A number of quantitative software complexity adjustment factors are the best during this phase. Project size is another factor that can affect the accuracy of the estimates. As size increases, the interdependencies among various elements of the software grow rapidly. In software engineering, to estimate the cost we only have to estimate how many engineers are needed. Problem decomposition becomes difficult because elements become formidable. Thus we have been able to forbid this drawback, as ours in an intermediate size project. Factors used in cost estimation models:
(i) Size attributes - For cost estimation models, following size attributes are required

(a) (b) (c) (d) (e) (f) (g)


(ii)

Source instruction Object instruction Numbers of routines Number of output formats Number of data items Documentation Number of personnel
Program Attributes - For cost estimation models, following program attributes are required.

(a) (b) (c) (d) (e) (f)


(iii)

Type Complexity Language Reuse Required reliability Display requirement


Computer Attributes - For cost estimation models, following computer attributes are required.

S.I.M.S INDORE

13

ELECTROMART ANALYSIS USING DATAMINING

(a) (b) (c) (d) (e)


(iv)

Time constraints Storage constraints Hardware configuration Concurrent h/w development Interfacing equipments
Personal Attributes: For cost estimation models, following personal attributes are required.

(a) (b) (c) (d) (e)


(v)

Personal capability Personal continuity Hardware experience Application experience Language experience
Project Attributes: For cost estimation models, following project attributes are required.

(a) (b) (c) (d) (e) (f) (g) (h)

Tools and techniques Customer interface Requirement definition Requirement volatility Schedule Security Computer access Source instruction

2.4.2 Risk Analysis

Risk Analysis and management are a series of steps that help a software team to understand and manage uncertainty. Many problems can occur in a software project. A risk is a potential problem, it may happen, it might not.
2.4.2.1 Risk Identification

Risk identification is a systematic attempt to specify threats to the project plan (estimates, schedule, resource loading etc.).By identifying the known and predictable risks, the project manager takes a step towards avoiding them as possible & avoiding them when necessary. Problem decomposition becomes difficult because elements become

S.I.M.S INDORE

14

ELECTROMART ANALYSIS USING DATAMINING

formidable. Thus we have been able to forbid this drawback, as ours in an intermediate size project.
2.4.3 Different Categories Of Risks
2.4.3.1 Project Risk

This includes following (i) Risk avoidance -If software team adopts a proactive approach to risk, avoidance is always the best strategy. (ii) Risk Monitoring - We already were prepared fro the size which was not according to estimation and were together and were constantly monitoring us to which size may increase. (iii) Risk Management - I had decided that if the size increases then the new portion due to which size increase would be distributed among myself in time division bases.
2.4.3.2 Technical Risk

This includes following (i) Risk Avoidance - Before starting the project ,I systematically went through all the Java language features & specifications which would be required in development of my project. (ii) Risk Monitoring - This risk will always be with us since the technology on which we are working is a budding one and thus to learn new aspects of the language every time undergoes improvements. We kept in track of improvements in the language by visiting the www.sunmicrosoft.com (iii) Risk Management - I earlier learnt some aspects of the Java language and then learnt the new features subsequently.
2.4.3.3 Business Risk

This includes following (i) Risk avoidance-To avoid risk associated with the technology not meeting expectation. I already anticipated this risk and decided to use the latest development tool kit. (ii) Risk Monitoring-We already aware of the risk and therefore constantly read books to keep myself aware and informed.

S.I.M.S INDORE

15

ELECTROMART ANALYSIS USING DATAMINING

(iii)

Risk Management - As soon as I came across new technology I studied it is feasibility for our project and if feasible incorporated in our project.

SYSTEM DESIGN

S.I.M.S INDORE

16

ELECTROMART ANALYSIS USING DATAMINING

3.

System Design

3.1

Design

Database Design

In database environment, many users share the data available that is authorizing users share data access applications with the database software managing the data an entity. A database and the information as in the interrelated data shared with the minimum redundancy to serve many users quickly and efficiently. The general objectives are to make information access easy, quick and flexible for the user. A database is the collection of the interrelated data. A database system provides the enterprise with centralized control of its operational data. In the database system Database Administrator has the central responsibility for the operational data.
During database design the major issues considered are: 1. 2. 3. 4. 5. 6. 7. Redundancy. Data Independence. Accuracy and Integration. More information at low cost. Recovery from failure. Privacy and Security. Performance.

Database Table
Billing table

S No.
1 2 3

Field Name
Year Date B_no

Data type
Year Date Int

Mandatory
Y Y Y 17

S.I.M.S INDORE

ELECTROMART ANALYSIS USING DATAMINING

4 5 6 7

Prod_no Disc Sp Qty

Int Int Int Int

Y No Y Y

Prices table

S No.
1 2 3 4 5 6

Field Name
Prod_no Cp Sp Disc Profit Mrp

Data type
Int Float Float Float Float float

Mandatory
Y Y Y Y Y Y

Stockinfo table

S No.
1 2 3 4 5 6 7

Field Name
Prod_no Datein Amt Quantityrem Cost Quantity Minimum

Data type
Int Date Float Int Float Int Int

Mandatory
Y Y No No No Y Y

Product table

S No.
1 2 3 4

Field Name
Prod_no Type Company Model

Data type
Int Varchar Varchar Varchar

Mandatory
Y No No Y

Saveoffer table

S No.
1

Field Name
Offer_no

Data type
Int

Mandatory
No 18

S.I.M.S INDORE

ELECTROMART ANALYSIS USING DATAMINING

2 3 4 5 6

Prod_no1 Prod_no2 Model Company Type

Int Int Varchar Varchar Varchar

No No No No No

3.1.1

Use Case Diagram

S.I.M.S INDORE

19

ELECTROMART ANALYSIS USING DATAMINING

3.1.2 Use case specification

S.I.M.S INDORE

20

ELECTROMART ANALYSIS USING DATAMINING

Brief Description: This use case describes how the user shall choose the various operations at the start of application.
Actor: supermarket manager

Preconditions: Proper access to the database of the store should be available.


Basic Flow of Events:

The use case begins when the user starts the application. Use Case: Login is performed which displays the different alternatives that are available thereafter. The user may select any of the following like budget control, buying, determine selling price, see sales trends or generate offers. Alternate courses after that are specified through activity diagrams. The use case ends successfully.
Alternative Flows

If Invalid User then the login error is displayed. The use case: Login does not complete successfully and the use case ends with a error condition

S.I.M.S INDORE

21

ELECTROMART ANALYSIS USING DATAMINING

3.1.3 Activity diagram Login activity:

S.I.M.S INDORE

22

ELECTROMART ANALYSIS USING DATAMINING

Buying activity:

S.I.M.S INDORE

23

ELECTROMART ANALYSIS USING DATAMINING

Offer activity:

S.I.M.S INDORE

24

ELECTROMART ANALYSIS USING DATAMINING

3.1.4 Sequence diagram

Login sequence:

S.I.M.S INDORE

25

ELECTROMART ANALYSIS USING DATAMINING

Buying sequence

Offer sequence

S.I.M.S INDORE

26

ELECTROMART ANALYSIS USING DATAMINING

Sales Trend sequence:

S.I.M.S INDORE

27

ELECTROMART ANALYSIS USING DATAMINING

3.1.5

Data model (E-R diagram, DFD)

S.I.M.S INDORE

28

ELECTROMART ANALYSIS USING DATAMINING

3.1.5

Data model ( DFD)

Data Flow Diagram:

S.I.M.S INDORE

29

ELECTROMART ANALYSIS USING DATAMINING

S.I.M.S INDORE

30

ELECTROMART ANALYSIS USING DATAMINING

S.I.M.S INDORE Level 2 Level 2.1

31

ELECTROMART ANALYSIS USING DATAMINING

Level 2.2

S.I.M.S INDORE

32

ELECTROMART ANALYSIS USING DATAMINING

3.2

System Structure Design

A software design is a description of the structure of the software to be implemented, the data which is a part of the system, the interface between system components and, sometimes the algorithm used. Designers do not arrive at a furnished design immediately but develop the design iteratively through a number different version. The design process involves adding formality and details as the design is developed, with constant backtracking to correct earlier designs.
Input Design:

The input design is the link that ties the System into the real world of its users. The inputs, which are given by the user, will form the core of the processes. So the inputs have to be carefully analyzed and care has to be taken to avoid in correct inputs. The guidelines that have been followed in designing the input forms are minimizing the number of input by collecting only required Data and grouping similar or related data.
Maintain consistent between information display and input. Providing help facilities those are sensitive. The format of the same data in different screens must be same.

Consistent terminologies are to be used throughout the system

S.I.M.S INDORE

33

ELECTROMART ANALYSIS USING DATAMINING

PROJECT IMPLEMENTATION

S.I.M.S INDORE

34

ELECTROMART ANALYSIS USING DATAMINING

4.Project Implementation

4.1 Details Of Modules


The GUI of our project consists of following major forms and modules: Login Form: Allows the Administrator to login with login id and password.He can also reset password. Module Select: This form appears if the administrator is successfully logged in and allows him to perform maintainance work and also access the database. He can also perform datamining.He can add product,buy product,generate bill,can see sales trend of a product ,determine selling price for a particular product,can also decide what offers to be given on a particular product. Selling price determination: This form allows the administrator to determine the selling price of the products and make changes accordingly. Sales trend: This form shows the graphical representation of the sales of the product.we can see and compare the sales trend of a product annually and monthly. Add product: This form is used for entering the products if required. Buying:This form is meant for buying the product if not present in the stock. Billing: This is used for the generation of bill. Billing system in a supermarket:The billing process is made up of three main steps. You may or may not have to do each step depending on your specific needs and/or configurations. Below is a brief overview of how the process should work if your system is configured correctly. Offer: This is used to determine the offer on a particular product on the basis of cost and sales. We propose a system which is a decision making system which decides the specific offers and deals provided to the consumers which in turn benefits the supermarket in its market value and even finishes of the surplus stock. Report: This form gives the overall report of the particular product.User can generate report for each and every module in graphical and textual form. The user has the option to select the time frame for which the report is to be seen.

S.I.M.S INDORE

35

ELECTROMART ANALYSIS USING DATAMINING

The user can select the parameters for the report. For instance they can select the product class for which they want to see the report.

S.I.M.S INDORE

36

ELECTROMART ANALYSIS USING DATAMINING

TESTING

5.

Testing

5.1

Test Plan

A test plan documents the strategy that will be used to verify and ensure that a product or system meets its design specifications and other requirements. A test plan is usually prepared by or with significant input from Test Engineers. Depending on the product and the responsibility of the organization to which the test plan applies, a test plan may include one or more of the following: 1)Design Verification Or Compliance Test. 2)Manufacturing And Production Test. 3)Service And Repair Test. 4)Regression Test.

S.I.M.S INDORE

37

ELECTROMART ANALYSIS USING DATAMINING

A complex system may have a high level test plan to address the overall requirements and supporting test plans to address the design details of subsystems and components. Test plan document formats can be as varied as the products and organizations to which they apply. There are three major elements that should be described in the test plan: Test Coverage, Test Methods, and Test Responsibilities. These are also used in a formal test strategy. Test coverage in the test plan states what requirements will be verified during what stages of the product life. Test Coverage is derived from design specifications and other requirements, such as safety standards or regulatory codes, where each requirement or specification of the design ideally will have one or more corresponding means of verification. Test coverage for different product life stages may overlap, but will not necessarily be exactly the same for all stages. For example, some requirements may be verified during Design Verification test, but not repeated during Acceptance test. Test coverage also feeds back into the design process, since the product may have to be designed to allow test access . Test methods in the test plan state how test coverage will be implemented. Test methods may be determined by standards, regulatory agencies, or contractual agreement, or may have to be created new. Test methods also specify test equipment to be used in the performance of the tests and establish pass/fail criteria. Test methods used to verify hardware design requirements can range from very simple steps, such as visual inspection, to elaborate test procedures that are documented separately. Test responsibilities include what organizations will perform the test methods and at each stage of the product life. This allows test organizations to plan, acquire or develop test equipment and other resources necessary to implement the test methods for which they are responsible. Test responsibilities also includes, what data will be collected, and how that data will be stored and reported (often referred to as deliverables). One outcome of a successful test plan should be a record or report of the verification of all design specifications and requirements as agreed upon by all parties.

5.2 Test Case


A test case in software engineering is a set of conditions or variables under which a tester will determine whether an application or software system is working correctly or not. The mechanism for determining whether a software program or system has passed or failed such a test is known as a test oracle. In some settings, an oracle could be a requirement or use case, while in others it could be a heuristic. It may take many test S.I.M.S INDORE 38

ELECTROMART ANALYSIS USING DATAMINING

cases to determine that a software program or system is functioning correctly. Test cases are often referred to as test scripts, particularly when written. Written test cases are usually collected into test suites.

5.2.1 Formal Test Cases


In order to fully test that all the requirements of an application are met, there must be at least two test cases for each requirement: one positive test and one negative test; unless a requirement has sub-requirements. In that situation, each sub-requirement must have at least two test cases. Keeping track of the link between the requirement and the test is frequently done using a traceability matrix. Written test cases should include a description of the functionality to be tested, and the preparation required to ensure that the test can be conducted. What characterizes a formal, written test case is that there is a known input and an expected output, which is worked out before the test is executed. The known input should test a precondition and the expected output should test a postcondition.

5.2.2 Informal Test Cases


In scenario testing, hypothetical stories are used to help the tester think through a complex problem or system. These scenarios are usually not written down in any detail. They can be as simple as a diagram for a testing environment or they could be description written in prose. The ideal scenario test is a story that is motivating, credible, complex, and easy to evaluate. They are usually different from test cases in that test cases are single steps while scenarios cover a number of steps.

5.2.3 Typically Written Test Case Format


A test case is usually a single step, or occasionally a sequence of steps, to test the correct behaviour/functionalities, features of an application. An expected result or expected outcome is usually given. Additional information that may be included:

test case ID

test case description test step or order of execution number related requirement(s) 39

S.I.M.S INDORE

ELECTROMART ANALYSIS USING DATAMINING

depth test category author check boxes for whether the test is automatable and has been automated.

5.3 Testing Strategy And Method 5.3.1 Unit Testing Unit testing focuses verification effort on the smallest unit of software design, the module. This testing is done in parallel to coding. A piece of code was compiled and tested before inspection. The objective of this inspection is to detect the defects in design and code before they are carried away to the next phase. The defects were then reworked and submitted again for inspection. Each module was carefully inspected and proved defect free before going to next one. Each module was tested independently using the test cases designed for unit testing. 5.3.2 Integration Testing Integration testing is a systematic technique for constructing the program structure while at the same time conducting test to uncover errors associated with interfacing. This testing is done using the bottom-up approach to integrate the software components of the software system in to functioning whole.. 5.3.3 System Testing System testing is actually a series of different tests whose primary purpose is fully to exercise the computer-based system. The system tests that where applied are recovery testing and performance testing. Finally a review or audit is conducted which is a final evaluation that occurs only after operating the system long enough for user to have gained a familiarity with it. System testing was done by the inspection team to verify that all the functionality identified in the software requirement specification has been implemented. Defects that crept in the system has been found defect free and is working well. System testing is concerned with interfaces, design logic, control flow recovery, procedures

S.I.M.S INDORE

40

ELECTROMART ANALYSIS USING DATAMINING

throughput, capacity and timing characteristics of the entire system. 5.3.4 Black Box Testing Administrator window:
Test Cas e No. 1 2 3 4 5 6 Action The administrator login with its password IF admin change the password. Expected Result Success Comments The Action Was Successfully tested. The Action Was Successfully tested. The Action Was Successfully tested The Action Was Successfully tested The Action Was Successfully tested The Action Was Successfully tested The Action Was Successfully tested

If password is correct he will be logged in Yes The database should be update with new password. Yes

Administrator can get Modules will be easily access to all modules accessed Yes The administrator can add,update and save the product The administrator can view,update and generate offers The administrator can view the sales trend and determine selling price The administrator can set the price for each product and also view the report The parameters executed successfully Yes The offers were generated successfully Graph will be displayed properly The parameter successfully. updated Yes Yes

Yes

5.4 Statistical Testing


A statistical test provides a mechanism for making quantitative decisions about a process or processes. The intent is to determine whether there is enough evidence to reject a conjecture or hypothesis about the process. The conjecture is called the null hypothesis. Not rejecting may be a good result if we want to continue to act as if we believe the null hypothesis is true. Or it may be a disappointing result, possibly indicating we may not yet have enough data to prove something by rejecting the null hypothesis.

S.I.M.S INDORE

41

ELECTROMART ANALYSIS USING DATAMINING

5.5 Defect Testing


The goal of defect testing is to observe defects in programme .A successful defect test is a test which causes programmer to behave in an anomalous way .The main aim of defect testing is to discover defects or faults in the software where its behaviour is incorrect or not in performance with its specification. A successful test is a test that makes the system perform incorrectly and so exposes a defect in a system.

S.I.M.S INDORE

42

ELECTROMART ANALYSIS USING DATAMINING

CONCLUSION

6. Conclusion Data mining challenges the long standing viewpoint that computers and internet do bring information but not knowledge. In the new millennium, competitive enterprises will be mining their data with sophisticated data mining tools to find and attract the best customers, to improve and enhance their product offerings, to maximize operating efficiency and to cut costs and improve customer satisfaction. With time and resources in short supply, data mining software will help enterprises maximize resources to remain competitive. In the short-term, the results of data mining will be in profitable, if mundane, business related areas. Micromarketing campaigns will explore new niches. Advertising will target potential customers with new precision. In the medium term, data mining may be as common and easy to use as e-mail. We may use these tools to find the best

S.I.M.S INDORE

43

ELECTROMART ANALYSIS USING DATAMINING

airfare to New York, root out a phone number of a long-lost classmate, or find the best prices on lawn mowers. The longterm prospects are truly exciting. Imagine intelligent agents turned loose on medical research data or on sub-atomic particle data. Computers may reveal new treatments for diseases or new insights into the nature of the universe. Thus we see that with the advancements and deployment of sophisticated data mining tools, computers can think bringing knowledge to our desktops.

S.I.M.S INDORE

44

ELECTROMART ANALYSIS USING DATAMINING

SUMMARY

7. Summary This project aims at decision making and hence can be applied in any supermarket store to decide the offers. It has a budget management system, and hence can be applied in any areas wherein the budgeting is the prime focus. It has a feature of finding trends based upon the previous years analysis and predicts the upcoming trends. And hence can
S.I.M.S INDORE 45

ELECTROMART ANALYSIS USING DATAMINING

find application in firms developing analytic researches. The intended audience for this project is clearly the supermarket management. This is a tool for the back end team to perform the various budgeting and planning tasks. The same algorithms with little modifications can be used for other fields like medical, criminal investigation etc.
The utility of this software can be measured from the fact that it can reduce the man power currently involved in the task of planning. Thorough statistical and probabilistic analysis is done, thus more efficient than human generated reports Marketing team can also use the software, for planning the product offers The finance management team can instantly generate budget report without much analysis as all the work is done by the system. This helps in allocation of funds to various departments.

It includes some limitations as follow:


Time consuming. Expensive to analyze huge amount of data. Involve a lot of human interaction, thus scope for errors and delays Stores all report in random form without any synchronization between various departments.

For the consumers:


It provides them with beneficial and economical offers. For instance the offer is provided in electronics in department. There are two products say, a digital camera and a memory card. These two can be clubbed together and the consumer can have this product at a very reasonable price say worth just like 100 bucks more for what the camera was originally available.

For the user:


Decision making systemthe system is a decision making system which decides on the basis of a few inputs various offers and deals to be generated.. Sales trend this system provides a complete display as per the users requirement of the sales trend over the past few months or years and displays the prediction the upcoming sales based upon the last months sale trend. Buyingthis system facilitates the user by providing him with time to time reminders of the stock depletion and its up gradation too. Send the user the required notification so as to the updating of the stock from the vendors. Selling price determinationdetermines the selling price of the products to maintain the consumer benefits and the supermarkets budget too.

S.I.M.S INDORE

46

ELECTROMART ANALYSIS USING DATAMINING

Report generationthe user can have a report generated for all the functionalities like offer, selling price determination, buying, sales trend et all and above all he can have a monthly or annual view, graphical or database view

Assumptions and Constraints Assumptions:


The offers are generated on the basis of sales of the product. I.e. the products with higher and lower sales percentage are mixed together to generate the offer and also the current market value of the products are not considered in determination of offer. The selling price of the products which are mixed together is determined in such a way that at least 10-20 % profit is earned. And also the selling price is determined on the basis of previous years sales i.e. the price of the product with higher sales can be increased marginally in order to meet the requirement of attaining the desired profit %. Every division of the super market is assigned a fixed budget which cannot be modified or altered. In buying module it is considered that as soon as the number of available products in stock goes below a certain level (minimum) then the buying module is automatically invoked.

Constraints: Offer generation module considers that only 2 products can be clubbed i.e. offers like giving 3 or more products together will not be considered. The maximum profit % is hard coded and there is no provision for the user to provide their own profit % requirement. The sales trend forecast is based previous sales of the given product over the given time line and there is no consideration for the product not been purchased or if the user doesnt want to buy the product for next year.

S.I.M.S INDORE

47

ELECTROMART ANALYSIS USING DATAMINING

REFERENCES

8.References
A Characterization of Data Mining Technologies and processes, Information Discovery Inc. Inmon, W.H. Building the Data Warehouse, New York: John Wiley & Sons, 1993 Data mining and Knowledge discovery in databases: Usama Fayyad, Ramasami Uthurusami. http://www.dmreview.com www.en.wikipedia.org/wiki/Data_mining

S.I.M.S INDORE

48

ELECTROMART ANALYSIS USING DATAMINING

http://technet.microsoft.com/en-us/library/ms175595.aspx

S.I.M.S INDORE

49

ELECTROMART ANALYSIS USING DATAMINING

APPENDIX

9. Appendix
SDS: Software Design Specification. A design specification provides precise and explicit information about the requirements for a product design. A design specification provides in-depth detail about the functional and non-functional design requirements including assumptions, constraints, performance, dimensions, weight, reliability and standards.
RAM: Random Access Memory.

Random-access memory (usually known by its acronym, RAM) is a form of computer data storage. Today, it takes the form of integrated circuits that allow stored data to be accessed in any order (i.e., at random). The word random thus refers to the fact that any piece of data can be returned
S.I.M.S INDORE 50

ELECTROMART ANALYSIS USING DATAMINING

in a constant time, regardless of its physical location and whether or not it is related to the previous piece of data
DBMS: Database Management System.

A Database Management System (DBMS) is a set of computer programs that controls the creation, maintenance, and the use of the database in a computer platform or of an organization and its end users. It allows organizations to place control of organization-wide database development in the hands of database administrators (DBAs) and other specialists.
GUI: Graphical User Interface.

A graphical user interface (GUI) is a type of user interface item that allows people to interact with programs in more ways than typing such as computers; hand-held devices such as MP3 Players, Portable Media Players or Gaming devices; household appliances and office equipment with images rather than text commands.
User ID:

Unique username issued to each user on login.Unix-like operating systems identify users within the kernel by an unsigned integer value called a user identifier, often abbreviated to UID or User ID. The range of UID values varies amongst different systems; at the very least, a UID represents a 15-bit integer, ranging between 0 and 32767, with the following restrictions.
Password:

A password is a secret word or string of characters that is used for authentication, to prove identity or gain access to a resource (example: an access code is a type of password). The password must be kept secret from those not allowed access.

S.I.M.S INDORE

51

ELECTROMART ANALYSIS USING DATAMINING

UML: Unified Modeling Techniques: UML Sequence diagrams are used to show the interaction between objects and to illustrate the activities that are performed in software and how data moves around in this system.

SOURCE CODE
S.I.M.S INDORE 52

ELECTROMART ANALYSIS USING DATAMINING

10. Source Code 10.1 Login Page


/* * * * Login1.java * Created on 17 Apr, 2010, 9:09:13 AM */ package datamining; import javax.swing.JOptionPane; /** @author Anchal */ public class Login1 extends javax.swing.JFrame { /** Creates new form Login1 */ public Login1() { initComponents();}

S.I.M.S INDORE

53

ELECTROMART ANALYSIS USING DATAMINING

/** This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor. */ @SuppressWarnings(unchecked) // <editor-fold defaultstate=collapsed desc=Generated Code> private void initComponents() { jInternalFrame1 = new javax.swing.JInternalFrame(); jLabel2 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); password = new javax.swing.JPasswordField(); ok = new javax.swing.JButton(); reset = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(datamining.DataminingApp.class).getC ontext().getResourceMap(Login1.class); setTitle(resourceMap.getString(Form.title)); // NOI18N setName(Form); // NOI18N jInternalFrame1.setBackground(resourceMap.getColor(jInternalFrame1.background)); // NOI18N jInternalFrame1.setTitle(resourceMap.getString(jInternalFrame1.title)); // NOI18N jInternalFrame1.setName(jInternalFrame1); // NOI18N jInternalFrame1.setVisible(true); jLabel2.setFont(resourceMap.getFont(jLabel2.font)); // NOI18N jLabel2.setText(resourceMap.getString(jLabel2.text)); // NOI18N jLabel2.setName(jLabel2); // NOI18N jLabel1.setText(resourceMap.getString(jLabel1.text)); // NOI18N jLabel1.setName(jLabel1); // NOI18N password.setName(password); // NOI18N ok.setText(resourceMap.getString(ok.text)); // NOI18N ok.setName(ok); // NOI18N ok.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { okActionPerformed(evt); } }); reset.setText(resourceMap.getString(reset.text)); // NOI18N reset.setName(reset); // NOI18N reset.addMouseListener(new java.awt.event.MouseAdapter() {

S.I.M.S INDORE

54

ELECTROMART ANALYSIS USING DATAMINING

public void mouseClicked(java.awt.event.MouseEvent evt) { resetMouseClicked(evt); } }); jLabel3.setIcon(resourceMap.getIcon(jLabel3.icon)); // NOI18N jLabel3.setText(resourceMap.getString(jLabel3.text)); // NOI18N jLabel3.setName(jLabel3); // NOI18N javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane()); jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout); jInternalFrame1Layout.setHorizontalGroup( jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame1Layout.createSequentialGroup() .addGap(38, 38, 38) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addComponent(jLabel2) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.TRAILING) .addGroup(jInternalFrame1Layout.createSequentialGroup() .addComponent(ok) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(reset)) .addGroup(jInternalFrame1Layout.createSequentialGroup() .addComponent(jLabel1) .addGap(5, 5, 5) .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel3) .addContainerGap(27, Short.MAX_VALUE)) ); jInternalFrame1Layout.setVerticalGroup( jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame1Layout.createSequentialGroup() .addGap(19, 19, 19) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addComponent(jLabel3) .addGroup(jInternalFrame1Layout.createSequentialGroup()

S.I.M.S INDORE

55

ELECTROMART ANALYSIS USING DATAMINING

.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(29, 29, 29) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addComponent(jLabel1) .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(ok) .addComponent(reset, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap()) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jInternalFrame1) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void okActionPerformed(java.awt.event.ActionEvent evt) { String s= password.getText(); if(s.equals()) { ModuleSelect ms = new ModuleSelect(); this.setVisible(false); ms.setVisible(true);

S.I.M.S INDORE

56

ELECTROMART ANALYSIS USING DATAMINING

} else { JOptionPane.showMessageDialog(null,Incorrect password,Error,JOptionPane.ERROR_MESSAGE); System.exit(0); } }

login

or

private void resetMouseClicked(java.awt.event.MouseEvent evt) { password.setText(null); } /** @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Login1().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JInternalFrame jInternalFrame1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JButton ok; private javax.swing.JPasswordField password; prive javax.swing.JButton reset; // End of variables declaration }

10.2 Module Select


package datamining; import org.jfree.ui.RefineryUtilities; public class ModuleSelect extends javax.swing.JFrame { public ModuleSelect() { initComponents(); } @SuppressWarnings(unchecked) // <editor-fold defaultstate=collapsed desc=Generated Code> private void initComponents() { S.I.M.S INDORE 57

ELECTROMART ANALYSIS USING DATAMINING

jInternalFrame1 = new javax.swing.JInternalFrame(); salesTrend = new javax.swing.JButton(); offers = new javax.swing.JButton(); budgeting = new javax.swing.JButton(); buying = new javax.swing.JButton(); sellingPriceDetermination = new javax.swing.JButton(); exit = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); addproduct = new javax.swing.JButton(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(datamining.DataminingApp.class).getC ontext().getResourceMap(ModuleSelect.class); setTitle(resourceMap.getString(Form.title)); // NOI18N setName(Form); // NOI18N jInternalFrame1.setTitle(resourceMap.getString(jInternalFrame1.title)); // NOI18N jInternalFrame1.setName(jInternalFrame1); // NOI18N jInternalFrame1.setVisible(true); salesTrend.setText(resourceMap.getString(salesTrend.text)); // NOI18N salesTrend.setName(salesTrend); // NOI18N salesTrend.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { salesTrendMouseClicked(evt); } }); offers.setText(resourceMap.getString(offers.text)); // NOI18N offers.setName(offers); // NOI18N offers.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { offersMouseClicked(evt); } }); budgeting.setText(resourceMap.getString(budgeting.text)); // NOI18N budgeting.setName(budgeting); // NOI18N budgeting.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { budgetingActionPerformed(evt); } });

S.I.M.S INDORE

58

ELECTROMART ANALYSIS USING DATAMINING

buying.setText(resourceMap.getString(buying.text)); // NOI18N buying.setName(buying); // NOI18N buying.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { buyingMouseClicked(evt); } }); sellingPriceDetermination.setText(resourceMap.getString(sellingPriceDetermination.tex t)); // NOI18N sellingPriceDetermination.setName(sellingPriceDetermination); // NOI18N sellingPriceDetermination.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { sellingPriceDeterminationMouseClicked(evt); } }); sellingPriceDetermination.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { sellingPriceDeterminationActionPerformed(evt); } }); exit.setIcon(resourceMap.getIcon(exit.icon)); // NOI18N exit.setText(resourceMap.getString(exit.text)); // NOI18N exit.setName(exit); // NOI18N exit.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { exitMouseClicked(evt); } }); jLabel1.setFont(resourceMap.getFont(jLabel1.font)); // NOI18N jLabel1.setForeground(resourceMap.getColor(jLabel1.foreground)); // NOI18N jLabel1.setText(resourceMap.getString(jLabel1.text)); // NOI18N jLabel1.setName(jLabel1); // NOI18N addproduct.setText(resourceMap.getString(addproduct.text)); // NOI18N addproduct.setName(addproduct); // NOI18N addproduct.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { addproductMouseClicked(evt); } }); jButton1.setText(resourceMap.getString(jButton1.text)); // NOI18N jButton1.setName(jButton1); // NOI18N jButton1.addMouseListener(new java.awt.event.MouseAdapter() {

S.I.M.S INDORE

59

ELECTROMART ANALYSIS USING DATAMINING

public void mouseClicked(java.awt.event.MouseEvent evt) { jButton1MouseClicked(evt); } }); javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane()); jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout); jInternalFrame1Layout.setHorizontalGroup( jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame1Layout.createSequentialGroup() . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addGroup(jInternalFrame1Layout .createSequentialGroup() .addGap(83, 83, 83) .addComponent(jLabel1)) .addGroup(jInternalFrame1Layout .createSequentialGroup() .addGap(70, 70, 70) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE) .addComponent(salesTrend, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING, false) .addComponent(sellingPriceDetermination, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(buying, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(budgeting, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(offers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(addproduct, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)) .addGap(20, 20, 20) .addComponent(exit, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) );

S.I.M.S INDORE

60

ELECTROMART ANALYSIS USING DATAMINING

jInternalFrame1Layout.setVerticalGroup( jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame1Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(sellingPriceDetermination) .addGap(18, 18, 18) .addComponent(buying) .addGap(18, 18, 18) .addComponent(budgeting) .addGap(18, 18, 18) .addComponent(offers) .addGap(18, 18, 18) .addComponent(salesTrend) .addGap(18, 18, 18) .addComponent(addproduct) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.TRAILING) .addComponent(exit, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1)) .addContainerGap(63, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack();

S.I.M.S INDORE

61

ELECTROMART ANALYSIS USING DATAMINING

}// </editor-fold> private void sellingPriceDeterminationActionPerformed(java.awt.event.ActionEvent evt) { } private void sellingPriceDeterminationMouseClicked(java.awt.event.MouseEvent evt) { Selling spd = new Selling(); spd.setVisible(true); this.setVisible(false); } private void exitMouseClicked(java.awt.event.MouseEvent evt) { System.exit(0); } private void budgetingActionPerformed(java.awt.event.ActionEvent evt) { } private void buyingMouseClicked(java.awt.event.MouseEvent evt) { Buying b= new Buying(); jInternalFrame1.setVisible(false); b.setVisible(true); } private void salesTrendMouseClicked(java.awt.event.MouseEvent evt) { //SalesTrend st= new SalesTrend(); //st.setVisible(true); //this.setVisible(false); LineChartDemo1 linechartdemo1 = new LineChartDemo1(JFreeChart: LineChartDemo1.java); linechartdemo1.pack(); RefineryUtilities.centerFrameOnScreen(linechartdemo1); linechartdemo1.setVisible(true); } private void addproductMouseClicked(java.awt.event.MouseEvent evt) { add a= new add(); a.setVisible(true); this.setVisible(false); } private void offersMouseClicked(java.awt.event.MouseEvent evt) { Offer o = new Offer(); o.setVisible(true); this.setVisible(false); /* A n=new A(); n.setVisible(true); this.setVisible(false);*/

S.I.M.S INDORE

62

ELECTROMART ANALYSIS USING DATAMINING

} private void jButton1MouseClicked(java.awt.event.MouseEvent evt) { Bill b =new Bill(); b.setVisible(true); this.setVisible(false); } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ModuleSelect().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton addproduct; private javax.swing.JButton budgeting; private javax.swing.JButton buying; private javax.swing.JButton exit; private javax.swing.JButton jButton1; private javax.swing.JInternalFrame jInternalFrame1; private javax.swing.JLabel jLabel1; private javax.swing.JButton offers; private javax.swing.JButton salesTrend; private javax.swing.JButton sellingPriceDetermination; // End of variables declaration }

10.3 Selling price Determination Module


package datamining; import org.jfree.ui.RefineryUtilities; public class ModuleSelect extends javax.swing.JFrame { public ModuleSelect() { initComponents(); } @SuppressWarnings(unchecked) // <editor-fold defaultstate=collapsed desc=Generated Code> private void initComponents() { jInternalFrame1 = new javax.swing.JInternalFrame(); salesTrend = new javax.swing.JButton(); offers = new javax.swing.JButton(); budgeting = new javax.swing.JButton(); buying = new javax.swing.JButton(); sellingPriceDetermination = new javax.swing.JButton();

S.I.M.S INDORE

63

ELECTROMART ANALYSIS USING DATAMINING

exit = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); addproduct = new javax.swing.JButton(); jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(datamining.DataminingApp.class).getC ontext().getResourceMap(ModuleSelect.class); setTitle(resourceMap.getString(Form.title)); // NOI18N setName(Form); // NOI18N jInternalFrame1.setTitle(resourceMap.getString(jInternalFrame1.title)); // NOI18N jInternalFrame1.setName(jInternalFrame1); // NOI18N jInternalFrame1.setVisible(true); salesTrend.setText(resourceMap.getString(salesTrend.text)); // NOI18N salesTrend.setName(salesTrend); // NOI18N salesTrend.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { salesTrendMouseClicked(evt); } }); offers.setText(resourceMap.getString(offers.text)); // NOI18N offers.setName(offers); // NOI18N offers.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { offersMouseClicked(evt); } }); budgeting.setText(resourceMap.getString(budgeting.text)); // NOI18N budgeting.setName(budgeting); // NOI18N budgeting.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { budgetingActionPerformed(evt); } }); buying.setText(resourceMap.getString(buying.text)); // NOI18N buying.setName(buying); // NOI18N buying.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { buyingMouseClicked(evt); }

S.I.M.S INDORE

64

ELECTROMART ANALYSIS USING DATAMINING

}); sellingPriceDetermination.setText(resourceMap.getString(sellingPriceDetermination.tex t)); // NOI18N sellingPriceDetermination.setName(sellingPriceDetermination); // NOI18N sellingPriceDetermination.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { sellingPriceDeterminationMouseClicked(evt); } }); sellingPriceDetermination.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { sellingPriceDeterminationActionPerformed(evt); } }); exit.setIcon(resourceMap.getIcon(exit.icon)); // NOI18N exit.setText(resourceMap.getString(exit.text)); // NOI18N exit.setName(exit); // NOI18N exit.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { exitMouseClicked(evt); } }); jLabel1.setFont(resourceMap.getFont(jLabel1.font)); // NOI18N jLabel1.setForeground(resourceMap.getColor(jLabel1.foreground)); // NOI18N jLabel1.setText(resourceMap.getString(jLabel1.text)); // NOI18N jLabel1.setName(jLabel1); // NOI18N addproduct.setText(resourceMap.getString(addproduct.text)); // NOI18N addproduct.setName(addproduct); // NOI18N addproduct.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { addproductMouseClicked(evt); } }); jButton1.setText(resourceMap.getString(jButton1.text)); // NOI18N jButton1.setName(jButton1); // NOI18N jButton1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton1MouseClicked(evt); } });

S.I.M.S INDORE

65

ELECTROMART ANALYSIS USING DATAMINING

javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane()); jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout); jInternalFrame1Layout.setHorizontalGroup( jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame1Layout.createSequentialGroup() . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addGroup(jInternalFrame1Layout.createSequentialGroup() .addGap(83, 83, 83) .addComponent(jLabel1)) .addGroup(jInternalFrame1Layout.createSequentialGroup() .addGap(70, 70, 70) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE) .addComponent(salesTrend, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING, false) .addComponent(sellingPriceDetermination, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(buying, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(budgeting, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(offers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(addproduct, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)) .addGap(20, 20, 20) .addComponent(exit, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); jInternalFrame1Layout.setVerticalGroup( jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame1Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1)

S.I.M.S INDORE

66

ELECTROMART ANALYSIS USING DATAMINING

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(sellingPriceDetermination) .addGap(18, 18, 18) .addComponent(buying) .addGap(18, 18, 18) .addComponent(budgeting) .addGap(18, 18, 18) .addComponent(offers) .addGap(18, 18, 18) .addComponent(salesTrend) .addGap(18, 18, 18) .addComponent(addproduct) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.TRAILING) .addComponent(exit, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1)) .addContainerGap(63, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void sellingPriceDeterminationActionPerformed(java.awt.event.ActionEvent evt) { }

S.I.M.S INDORE

67

ELECTROMART ANALYSIS USING DATAMINING

private void sellingPriceDeterminationMouseClicked(java.awt.event.MouseEvent evt) { Selling spd = new Selling(); spd.setVisible(true); this.setVisible(false); } private void exitMouseClicked(java.awt.event.MouseEvent evt) { System.exit(0); } private void budgetingActionPerformed(java.awt.event.ActionEvent evt) { } private void buyingMouseClicked(java.awt.event.MouseEvent evt) { Buying b= new Buying(); jInternalFrame1.setVisible(false); b.setVisible(true); } private void salesTrendMouseClicked(java.awt.event.MouseEvent evt) { //SalesTrend st= new SalesTrend(); //st.setVisible(true); //this.setVisible(false); LineChartDemo1 linechartdemo1 = new LineChartDemo1(JFreeChart: LineChartDemo1.java); linechartdemo1.pack(); RefineryUtilities.centerFrameOnScreen(linechartdemo1); linechartdemo1.setVisible(true); } private void addproductMouseClicked(java.awt.event.MouseEvent evt) { add a= new add(); a.setVisible(true); this.setVisible(false); } private void offersMouseClicked(java.awt.event.MouseEvent evt) { Offer o = new Offer(); o.setVisible(true); this.setVisible(false); /* A n=new A(); n.setVisible(true); this.setVisible(false);*/ } private void jButton1MouseClicked(java.awt.event.MouseEvent evt) { Bill b =new Bill(); b.setVisible(true); this.setVisible(false);

S.I.M.S INDORE

68

ELECTROMART ANALYSIS USING DATAMINING

} public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ModuleSelect().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton addproduct; private javax.swing.JButton budgeting; private javax.swing.JButton buying; private javax.swing.JButton exit; private javax.swing.JButton jButton1; private javax.swing.JInternalFrame jInternalFrame1; private javax.swing.JLabel jLabel1; private javax.swing.JButton offers; private javax.swing.JButton salesTrend; private javax.swing.JButton sellingPriceDetermination; // End of variables declaration }

10.4 Buying module:


package datamining; import java.sql.*; import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.*; import java.util.Calendar; import java.text.SimpleDateFormat; public class Buying extends javax.swing.JFrame { String qr, an, qr1, ans; public Buying() { initComponents(); try { Class.forName(com.mysql.jdbc.Driver); Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining, root, root); qr = select p.type from product p,stock s where p.prod_no=s.prod_no and p.prod_no in (select prod_no from stock where quantityrem<=minimum); Statement stmt = connection.createStatement();

S.I.M.S INDORE

69

ELECTROMART ANALYSIS USING DATAMINING

String typ; ResultSet rs; rs = stmt.executeQuery(qr); System.out.println(product); while (rs.next()) { typ = rs.getString(1); chooseProductType.addItem(typ); } stmt.close(); connection.close(); } catch (Exception e) { } } @SuppressWarnings(unchecked) // <editor-fold defaultstate=collapsed desc=Generated Code> private void initComponents() { jPopupMenu1 = new javax.swing.JPopupMenu(); jPopupMenu2 = new javax.swing.JPopupMenu(); buying = new javax.swing.JInternalFrame(); jLabel1 = new javax.swing.JLabel(); chooseProductType = new javax.swing.JComboBox(); jLabel3 = new javax.swing.JLabel(); ok = new javax.swing.JButton(); exit = new javax.swing.JButton(); jButton1 = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); chooseCompany = new javax.swing.JComboBox(); jLabel2 = new javax.swing.JLabel(); chooseModel = new javax.swing.JComboBox(); jLabel5 = new javax.swing.JLabel(); qty = new javax.swing.JTextField(); costprice = new javax.swing.JTextField(); jPopupMenu1.setName(jPopupMenu1); // NOI18N jPopupMenu2.setName(jPopupMenu2); // NOI18N setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setName(Form); // NOI18N buying.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); buying.setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(datamining.DataminingApp.class).getC ontext().getResourceMap(Buying.class);

S.I.M.S INDORE

70

ELECTROMART ANALYSIS USING DATAMINING

buying.setTitle(resourceMap.getString(buying.title)); // NOI18N buying.setName(buying); // NOI18N buying.setVisible(true); jLabel1.setText(resourceMap.getString(jLabel1.text)); // NOI18N jLabel1.setName(jLabel1); // NOI18N chooseProductType.setName(chooseProductType); // NOI18N chooseProductType.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { chooseProductTypeItemStateChanged(evt); } }); jLabel3.setText(resourceMap.getString(jLabel3.text)); // NOI18N jLabel3.setName(jLabel3); // NOI18N ok.setText(resourceMap.getString(ok.text)); // NOI18N ok.setName(ok); // NOI18N ok.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { okMouseClicked(evt); } }); ok.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { okActionPerformed(evt); } }); exit.setText(resourceMap.getString(exit.text)); // NOI18N exit.setName(exit); // NOI18N exit.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { exitMouseClicked(evt); } }); jButton1.setText(resourceMap.getString(jButton1.text)); // NOI18N jButton1.setName(jButton1); // NOI18N jButton1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton1MouseClicked(evt); } }); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt);

S.I.M.S INDORE

71

ELECTROMART ANALYSIS USING DATAMINING

} }); jLabel4.setText(resourceMap.getString(jLabel4.text)); // NOI18N jLabel4.setName(jLabel4); // NOI18N chooseCompany.setName(chooseCompany); // NOI18N chooseCompany.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { chooseCompanyItemStateChanged(evt); } }); jLabel2.setText(resourceMap.getString(jLabel2.text)); // NOI18N jLabel2.setName(jLabel2); // NOI18N chooseModel.setName(chooseModel); // NOI18N jLabel5.setText(resourceMap.getString(jLabel5.text)); // NOI18N jLabel5.setName(jLabel5); // NOI18N qty.setName(qty); // NOI18N costprice.setText(resourceMap.getString(costprice.text)); // NOI18N costprice.setName(costprice); // NOI18N costprice.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { costpriceActionPerformed(evt); } }); javax.swing.GroupLayout buyingLayout = new javax.swing.GroupLayout(buying.getContentPane()); buying.getContentPane().setLayout(buyingLayout); buyingLayout.setHorizontalGroup( buyingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(buyingLayout.createSequentialGroup() .addContainerGap() . addGroup(buyingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA DING) .addComponent(jLabel1) .addComponent(jLabel3) .addComponent(jLabel4) .addComponent(jLabel2) . addGroup(buyingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRA ILING) .addComponent(ok) .addComponent(jLabel5)))

S.I.M.S INDORE

72

ELECTROMART ANALYSIS USING DATAMINING

. addGroup(buyingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA DING) .addGroup(buyingLayout.createSequentialGroup() .addGap(41, 41, 41) . addGroup(buyingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRA ILING, false) .addComponent(costprice, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(qty, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(chooseModel, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(chooseCompany, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(chooseProductType, javax.swing.GroupLayout.Alignment.LEADING, 0, 117, Short.MAX_VALUE))) .addGroup(buyingLayout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(exit))) .addContainerGap(194, Short.MAX_VALUE)) ); buyingLayout.setVerticalGroup( buyingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(buyingLayout.createSequentialGroup() .addGap(30, 30, 30) . addGroup(buyingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA DING) .addComponent(jLabel1) .addComponent(chooseProductType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) . addGroup(buyingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS ELINE) .addComponent(chooseCompany, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) . addGroup(buyingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS ELINE)

S.I.M.S INDORE

73

ELECTROMART ANALYSIS USING DATAMINING

.addComponent(jLabel2) .addComponent(chooseModel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(28, 28, 28) . addGroup(buyingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA DING) .addComponent(jLabel3) .addComponent(costprice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) . addGroup(buyingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS ELINE) .addComponent(jLabel5) .addComponent(qty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 75, Short.MAX_VALUE) . addGroup(buyingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS ELINE) .addComponent(jButton1) .addComponent(ok) .addComponent(exit)) .addGap(93, 93, 93)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(22, 22, 22) .addComponent(buying, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(370, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(21, 21, 21)

S.I.M.S INDORE

74

ELECTROMART ANALYSIS USING DATAMINING

.addComponent(buying, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(57, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void chooseProductTypeItemStateChanged(java.awt.event.ItemEvent evt) { chooseCompany.removeAllItems(); System.out.println(Hello); try { Class.forName(com.mysql.jdbc.Driver); String mod; Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining, root, root); Statement statement = connection.createStatement(); Object obj = chooseProductType.getSelectedItem(); // qr = SELECT distinct(company) from product where type = + obj.toString() + ; String qr = select distinct(p.company) from product p,stock s where p.type=+obj.toString()+ and p.prod_no=s.prod_no and p.prod_no in (select prod_no from stock where quantityrem<= minimum); ResultSet rs; rs = statement.executeQuery(qr); System.out.println(Again rs= + rs); while (rs.next()) { mod = rs.getString(1); System.out.println(mod); chooseCompany.addItem(mod); } statement.close(); connection.close(); } catch (Exception e) { e.printStackTrace(); } } private void okMouseClicked(java.awt.event.MouseEvent evt) {

S.I.M.S INDORE

75

ELECTROMART ANALYSIS USING DATAMINING

} private void exitMouseClicked(java.awt.event.MouseEvent evt) { System.exit(0); } private void jButton1MouseClicked(java.awt.event.MouseEvent evt) { // ModuleSelect ms= new ModuleSelect(); // ms.setVisible(true); // this.hide(); ModuleSelect m = new ModuleSelect(); m.setVisible(true); this.setVisible(false); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void chooseCompanyItemStateChanged(java.awt.event.ItemEvent evt) { chooseModel.removeAllItems(); try { Class.forName(com.mysql.jdbc.Driver); String mod; Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining, root, root); Statement statement = connection.createStatement(); Object obj = chooseCompany.getSelectedItem(); qr = select distinct(p.model) from product p,stock s where p.company=+obj.toString() + and p.prod_no=s.prod_no and p.prod_no in (select prod_no from stock where quantityrem<=minimum); ResultSet rs; rs = statement.executeQuery(qr); System.out.println(rs= + rs); while (rs.next()) { mod = rs.getString(1); chooseModel.addItem(mod); } statement.close(); connection.close();

S.I.M.S INDORE

76

ELECTROMART ANALYSIS USING DATAMINING

} catch (Exception e) { e.printStackTrace(); } } private void costpriceActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void okActionPerformed(java.awt.event.ActionEvent evt) { try { System.out.println(company); String proname = chooseProductType.getSelectedItem().toString(); int qtyr = Integer.parseInt(qty.getText()); int cp = Integer.parseInt(costprice.getText()); java.util.Date d = new java.util.Date(); SimpleDateFormat sf = new SimpleDateFormat(yyyy-MM-dd); String format = sf.format(d); Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining, root, root); Statement statement = connection.createStatement(); Object obj = chooseCompany.getSelectedItem(); Object obj3 = chooseModel.getSelectedItem(); String sql=update stock set quantityrem=?,cost=?,amt=? where prod_no =(select prod_no from product where type=? and company=? and model=?); PreparedStatement pstmt=connection.prepareStatement(sql); pstmt.setInt(1,qtyr); //pstmt.setString(2, format); pstmt.setFloat(2, cp); pstmt.setFloat(3,( cp*qtyr)); // pstmt.setString(5,proname); pstmt.setString(4, proname.toString()); pstmt.setString(5,obj.toString() ); pstmt.setString(6, obj3.toString()); System.out.println(pstmt); int i= pstmt.executeUpdate(); System.out.println(i=+i); if(i>0) { ok.setEnabled(false); } } catch (SQLException ex) { Logger.getLogger(Buying.class.getName()).log(Level.SEVERE, null, ex); } }

S.I.M.S INDORE

77

ELECTROMART ANALYSIS USING DATAMINING

public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Buying().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JInternalFrame buying; private javax.swing.JComboBox chooseCompany; private javax.swing.JComboBox chooseModel; private javax.swing.JComboBox chooseProductType; private javax.swing.JTextField costprice; private javax.swing.JButton exit; private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JPopupMenu jPopupMenu1; private javax.swing.JPopupMenu jPopupMenu2; private javax.swing.JButton ok; private javax.swing.JTextField qty; // End of variables declaration }

10.5: Offer Module package datamining; import java.sql.*; import javax.swing.JOptionPane; import java.util.*; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTable; import java.awt.*;

S.I.M.S INDORE

78

ELECTROMART ANALYSIS USING DATAMINING

public class Offer extends javax.swing.JFrame { public Offer() { initComponents(); jInternalFrame2.setVisible(false); jInternalFrame3.setVisible(false); try{ String qr,an; Class.forName(com.mysql.jdbc.Driver); Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,root, root); qr=SELECT type from product group by type ; Statement stmt= connection.createStatement(); ResultSet rs; rs=stmt.executeQuery(qr); while(rs.next()) { an=rs.getString(1); jComboBox1.addItem(an); } stmt.close(); connection.close(); } catch(Exception e) { // e.printStackTrace(); } } @SuppressWarnings(unchecked) // <editor-fold defaultstate=collapsed desc=Generated Code> private void initComponents() { buttonGroup1 = new javax.swing.ButtonGroup(); jInternalFrame1 = new javax.swing.JInternalFrame(); jLabel1 = new javax.swing.JLabel(); jComboBox1 = new javax.swing.JComboBox(); jLabel2 = new javax.swing.JLabel(); jComboBox2 = new javax.swing.JComboBox(); jLabel3 = new javax.swing.JLabel(); jComboBox3 = new javax.swing.JComboBox(); jButton1 = new javax.swing.JButton();

S.I.M.S INDORE

79

ELECTROMART ANALYSIS USING DATAMINING

jButton4 = new javax.swing.JButton(); jInternalFrame3 = new javax.swing.JInternalFrame(); jComboBox4 = new javax.swing.JComboBox(); jLabel7 = new javax.swing.JLabel(); jInternalFrame2 = new javax.swing.JInternalFrame(); jLabel4 = new javax.swing.JLabel(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jButton5 = new javax.swing.JButton(); jLabel8 = new javax.swing.JLabel(); jButton6 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(datamining.DataminingApp.class).getC ontext().getResourceMap(Offer.class); setTitle(resourceMap.getString(Form.title)); // NOI18N setName(Form); // NOI18N jInternalFrame1.setTitle(resourceMap.getString(jInternalFrame1.title)); // NOI18N jInternalFrame1.setName(jInternalFrame1); // NOI18N jInternalFrame1.setVisible(true); jLabel1.setText(resourceMap.getString(jLabel1.text)); // NOI18N jLabel1.setName(jLabel1); // NOI18N jComboBox1.setName(jComboBox1); // NOI18N jComboBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox1ActionPerformed(evt); } }); jLabel2.setText(resourceMap.getString(jLabel2.text)); // NOI18N jLabel2.setName(jLabel2); // NOI18N jComboBox2.setName(jComboBox2); // NOI18N jComboBox2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox2ActionPerformed(evt); } }); jLabel3.setText(resourceMap.getString(jLabel3.text)); // NOI18N

S.I.M.S INDORE

80

ELECTROMART ANALYSIS USING DATAMINING

jLabel3.setName(jLabel3); // NOI18N jComboBox3.setName(jComboBox3); // NOI18N jButton1.setText(resourceMap.getString(jButton1.text)); // NOI18N jButton1.setName(jButton1); // NOI18N jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton4.setText(resourceMap.getString(jButton4.text)); // NOI18N jButton4.setName(jButton4); // NOI18N jButton4.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton4MouseClicked(evt); } }); javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane()); jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout); jInternalFrame1Layout.setHorizontalGroup( jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame1Layout.createSequentialGroup() .addContainerGap() . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.TRAILING, false) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton4)) .addGap(53, 53, 53) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING, false)

S.I.M.S INDORE

81

ELECTROMART ANALYSIS USING DATAMINING

.addComponent(jComboBox3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jComboBox2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jComboBox1, 0, 109, Short.MAX_VALUE)) .addComponent(jButton1)) .addContainerGap(1474, Short.MAX_VALUE)) ); jInternalFrame1Layout.setVerticalGroup( jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame1Layout.createSequentialGroup() .addGap(114, 114, 114) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(27, 27, 27) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(27, 27, 27) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jButton4) .addComponent(jButton1)) .addContainerGap(1116, Short.MAX_VALUE))

S.I.M.S INDORE

82

ELECTROMART ANALYSIS USING DATAMINING

); jInternalFrame3.setTitle(resourceMap.getString(jInternalFrame3.title)); // NOI18N jInternalFrame3.setName(jInternalFrame3); // NOI18N jInternalFrame3.setVisible(true); jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new { Cost, Sales, Zero })); jComboBox4.setName(jComboBox4); // NOI18N jComboBox4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox4ActionPerformed(evt); } }); String[]

jLabel7.setText(resourceMap.getString(jLabel7.text)); // NOI18N jLabel7.setName(jLabel7); // NOI18N javax.swing.GroupLayout jInternalFrame3Layout = new javax.swing.GroupLayout(jInternalFrame3.getContentPane()); jInternalFrame3.getContentPane().setLayout(jInternalFrame3Layout); jInternalFrame3Layout.setHorizontalGroup( jInternalFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jInternalFrame3Layout.createSequentialGroup() .addContainerGap(77, Short.MAX_VALUE) .addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(43, 43, 43)) ); jInternalFrame3Layout.setVerticalGroup( jInternalFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame3Layout.createSequentialGroup() .addGap(24, 24, 24) . addGroup(jInternalFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jLabel7) .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(395, Short.MAX_VALUE)) );

S.I.M.S INDORE

83

ELECTROMART ANALYSIS USING DATAMINING

jInternalFrame2.setName(jInternalFrame2); // NOI18N jInternalFrame2.setVisible(true); jLabel4.setText(resourceMap.getString(jLabel4.text)); // NOI18N jLabel4.setName(jLabel4); // NOI18N jButton2.setText(resourceMap.getString(jButton2.text)); // NOI18N jButton2.setName(jButton2); // NOI18N jButton2.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton2MouseClicked(evt); } }); jButton3.setText(resourceMap.getString(jButton3.text)); // NOI18N jButton3.setName(jButton3); // NOI18N jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jScrollPane1.setName(jScrollPane1); // NOI18N jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null} }, new String [] { Product No., Product Model, Product Company, Product Type, Offer price, Discount } ){ Class[] types = new Class [] { java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Float.class, java.lang.Float.class }; boolean[] canEdit = new boolean [] {

S.I.M.S INDORE

84

ELECTROMART ANALYSIS USING DATAMINING

false, false, false, false, false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); jTable1.setName(jTable1); // NOI18N jScrollPane1.setViewportView(jTable1); jTable1.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString(jTabl e1.columnModel.title0)); // NOI18N jTable1.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString(jTabl e1.columnModel.title1)); // NOI18N jTable1.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString(jTabl e1.columnModel.title2)); // NOI18N jTable1.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString(jTabl e1.columnModel.title3)); // NOI18N jTable1.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString(jTabl e1.columnModel.title4)); // NOI18N jTable1.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString(jTabl e1.columnModel.title5)); // NOI18N jLabel5.setText(resourceMap.getString(jLabel5.text)); // NOI18N jLabel5.setName(jLabel5); // NOI18N jLabel6.setText(resourceMap.getString(jLabel6.text)); // NOI18N jLabel6.setName(jLabel6); // NOI18N jButton5.setText(resourceMap.getString(jButton5.text)); // NOI18N jButton5.setName(jButton5); // NOI18N jButton5.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton5MouseClicked(evt); } }); jLabel8.setText(resourceMap.getString(jLabel8.text)); // NOI18N jLabel8.setName(jLabel8); // NOI18N jButton6.setText(resourceMap.getString(jButton6.text)); // NOI18N jButton6.setName(jButton6); // NOI18N jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt); } });

S.I.M.S INDORE

85

ELECTROMART ANALYSIS USING DATAMINING

javax.swing.GroupLayout jInternalFrame2Layout = new javax.swing.GroupLayout(jInternalFrame2.getContentPane()); jInternalFrame2.getContentPane().setLayout(jInternalFrame2Layout); jInternalFrame2Layout.setHorizontalGroup( jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame2Layout.createSequentialGroup() . addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addGroup(jInternalFrame2Layout.createSequentialGroup() .addGap(28, 28, 28) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 485, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jInternalFrame2Layout.createSequentialGroup() .addGap(115, 115, 115) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton6) .addGap(18, 18, 18) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton5)) .addGroup(jInternalFrame2Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 719, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jInternalFrame2Layout.createSequentialGroup() .addGap(1085, 1085, 1085) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE)) . addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.TRAILING, false) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jInternalFrame2Layout.createSequentialGroup() .addGap(19, 19, 19) .addComponent(jScrollPane1)) .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 1060, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) );

S.I.M.S INDORE

86

ELECTROMART ANALYSIS USING DATAMINING

jInternalFrame2Layout.setVerticalGroup( jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame2Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(14, 14, 14) . addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton6) .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton5)) .addGap(46, 46, 46) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(29, 29, 29) .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(jInternalFrame3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(52, 52, 52) .addComponent(jInternalFrame2, javax.swing.GroupLayout.PREFERRED_SIZE, 1420, javax.swing.GroupLayout.PREFERRED_SIZE))

S.I.M.S INDORE

87

ELECTROMART ANALYSIS USING DATAMINING

.addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(86, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(27, 27, 27) .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jInternalFrame3) .addComponent(jInternalFrame2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); pack(); }// </editor-fold> private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) { jComboBox2.removeAllItems(); try{ Class.forName(com.mysql.jdbc.Driver); String an,qr; Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,root, root); Object type=jComboBox1.getSelectedItem(); qr=SELECT company from product where type =+type+group by company; Statement stmt= connection.createStatement(); ResultSet rs; rs=stmt.executeQuery(qr); while(rs.next()) { an=rs.getString(1); jComboBox2.addItem(an); } stmt.close(); connection.close(); } catch(Exception e) {

S.I.M.S INDORE

88

ELECTROMART ANALYSIS USING DATAMINING

//e.printStackTrace(); } } private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) { jComboBox3.removeAllItems(); Object comp=jComboBox2.getSelectedItem(); Object type=jComboBox1.getSelectedItem(); try{ Class.forName(com.mysql.jdbc.Driver); Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,root, root); String qr,an; qr=SELECT model from product where company =+comp+; Statement stmt= connection.createStatement(); ResultSet rs; rs=stmt.executeQuery(qr); while(rs.next()) { an=rs.getString(1); jComboBox3.addItem(an); } stmt.close(); connection.close(); } catch(Exception e) { // e.printStackTrace(); } } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { jComboBox4.setSelectedIndex(-1); jInternalFrame3.setVisible(true); jInternalFrame1.setVisible(false); jInternalFrame2.setVisible(false); } private void jButton2MouseClicked(java.awt.event.MouseEvent evt) { jTable1.removeAll(); jComboBox4.setSelectedIndex(-1); jInternalFrame1.setVisible(true); jInternalFrame2.setVisible(false); }

S.I.M.S INDORE

89

ELECTROMART ANALYSIS USING DATAMINING

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { System.exit(0); } private void jButton4MouseClicked(java.awt.event.MouseEvent evt) { ModuleSelect m = new ModuleSelect(); m.setVisible(true); this.setVisible(false); } private void jComboBox4ActionPerformed(java.awt.event.ActionEvent evt) { jInternalFrame2.setVisible(true); jTable1.removeAll(); String name; // jButton5.setEnabled(false); float price1=0,pricetot=0,offprice=0; int[] x=new int[10]; int[] prod2=new int[10]; float[] price2=new float[100]; //int x=0; jTable1.removeAll(); name = jComboBox1.getSelectedItem().toString()+ jComboBox2.getSelectedItem().toString()+ +jComboBox3.getSelectedItem().toString(); jLabel4.setText(Offers For + name); jInternalFrame2.setVisible(true); jInternalFrame3.setVisible(false); int p1=0,total=0,i=0; int[] p2=new int[100]; float disc=0,mrp2=0,sp2=0;//mrp of 2ns prod int j=0; //int p2=0; String qr, qr7,qr9,qr10,qr11,qr12,qr13,qr14,qr15; Object model=jComboBox3.getSelectedItem(); float minsupp=0,maxsupp=100; double[] support=new double[100]; double[] confidence=new double[100]; // int [] prod_no = new int[10]; int m=0,n=0; int[] sales=new int[100]; int indvsales1=0,indvsales2; float mrp=0,new_profit=0; if(jComboBox4.getSelectedIndex()==2)//Zero sales {

S.I.M.S INDORE

90

ELECTROMART ANALYSIS USING DATAMINING

String qr1,qr3,qr4,qr2; int[] prod_zero=new int[50]; int price_model=0; int price_this=0; int[] prod_zero_true=new int[100]; int pr_zero; try{ Class.forName(com.mysql.jdbc.Driver); Connection connection=DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,ro ot,root); Statement statement=connection.createStatement(); ResultSet rs,rs1,rs2; qr=Select sp from prices where prod_no in (select prod_no from product where model = +model+); rs=statement.executeQuery(qr); while(rs.next()) { price_model=rs.getInt(1); } i=0; qr1= select distinct(prod_no) from stock where prod_no not in(select prod_no from billing); rs1=statement.executeQuery(qr1); while (rs1.next()) { prod_zero[i]=rs1.getInt(1); i++; } int w=0; int p=0; for (i=0;i<prod_zero.length; i++) { qr2= Select sp from prices where prod_no =+prod_zero[i]+ ; rs2=statement.executeQuery(qr2); rs2.next(); price_this = rs2.getInt(1); if ( price_this< price_model) { prod_zero_true[w] = prod_zero[i];

S.I.M.S INDORE

91

ELECTROMART ANALYSIS USING DATAMINING

jTable1.setValueAt(prod_zero_true[w],w,p); qr3=select type, company,model from product where prod_no =+prod_zero[i]+; ResultSet rs3=statement.executeQuery(qr3); while(rs3.next()) { jTable1.setValueAt(rs3.getString(1),w,p+1); jTable1.setValueAt(rs3.getString(2),w,p+2); jTable1.setValueAt(rs3.getString(3),w,p+3); } w++; } } } catch(Exception e) { } } else { try { Class.forName(com.mysql.jdbc.Driver); Connection connection=DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,ro ot,root); Statement statement=connection.createStatement(); ResultSet rs; qr=select prod_no from billing where b_no in(select b_no from billing where prod_no in (select prod_no from product where model = +model+))and prod_no != +(select prod_no from product where model = +model+) group by prod_no; rs=statement.executeQuery(qr); while(rs.next()) { p2[i]=rs.getInt(1); i++; } for(int k=0;k<p2.length;k++) {

S.I.M.S INDORE

92

ELECTROMART ANALYSIS USING DATAMINING

qr=select b_no from billing where prod_no in (select prod_no from product where model = +model+) and b_no in (select distinct(b_no) from billing where prod_no =+p2[k]+); rs=statement.executeQuery(qr); while(rs.next()) { x[k]++; } } String qr2,qr5,qr6,qr8; qr2=select count(prod_no)from billing where prod_no in(select prod_no from product where model = +model+); rs=statement.executeQuery(qr2); while(rs.next()) { p1=rs.getInt(1); } qr2=select count(*) from billing; rs=statement.executeQuery(qr2); while(rs.next()) { total=rs.getInt(1); } for(int k=0;k<p2.length;k++) { if(x[k]!=0 ) { support[k]=x[k]*1000/total; confidence[k]=x[k]*100/p1; jLabel8.setText(support = +support[k]+ confidence = +confidence[k]); if(support[k]>minsupp && support[k]< maxsupp) { if(jComboBox4.getSelectedIndex()==0)//Cost filter { qr5=select mrp from Prices where prod_no in (select prod_no from product where model = +model+); rs=statement.executeQuery(qr5); while(rs.next()) { price1=rs.getFloat(1); }

S.I.M.S INDORE

93

ELECTROMART ANALYSIS USING DATAMINING

qr6=select prod_no from Prices where prod_no=+p2[k]+ and mrp < +price1+; rs=statement.executeQuery(qr6); while(rs.next()) { prod2[k]=rs.getInt(1); } if(prod2[k]!=0) { qr7 = select model, Company,Type from Product where prod_no=+prod2[k]+; rs = statement.executeQuery(qr7); while (rs.next()) { jTable1.setValueAt(prod2[k],n,m); jTable1.setValueAt(rs.getString(1),n,m+1); jTable1.setValueAt(rs.getString(2),n,m+2); jTable1.setValueAt(rs.getString(3),n,m+3); jTable1.setValueAt(confidence[n],n,m+5); } qr8 = select MRP,sp from Prices where prod_no=+prod2[k]+; rs = statement.executeQuery(qr8); while (rs.next()) { mrp2=rs.getFloat(1); sp2=rs.getFloat(2); if((mrp2-sp2)*(1-confidence[n])<200) { jTable1.setValueAt(sp2+price1,n,m+4); jTable1.setValueAt(mrp2-sp2,n,m+5); } else { new_profit=(float) ((mrp2 - sp2) * (1 - confidence[n])); jTable1.setValueAt(sp2+new_profit+price1,n,m+4); jTable1.setValueAt(mrp2-(sp2+new_profit),n,m+5); } } } n++; } if(jComboBox4.getSelectedIndex()==1)// Sales Filter { qr9=select count(*) from billing where prod_no in (select prod_no from product where model = +model+); rs=statement.executeQuery(qr9); while(rs.next())

S.I.M.S INDORE

94

ELECTROMART ANALYSIS USING DATAMINING

{ indvsales1=rs.getInt(1); } qr10=select b_no from billing where prod_no = +p2[k]+; int[] prod3=new int[10]; int a=0; rs=statement.executeQuery(qr10); while(rs.next()) { sales[k]++; } if(sales[k]<indvsales1) { prod3[a]=p2[k]; jTable1.setValueAt(p2[k], n, m); a++; } for (a=0;a<10; a++) { if(prod3[a]!=0) { qr11=select model,company,type from Product where prod_no = +prod3[a]+; rs=statement.executeQuery(qr11); while(rs.next()) { jTable1.setValueAt(rs.getString(1), n, m+1); jTable1.setValueAt(rs.getString(2), n, m+2); jTable1.setValueAt(rs.getString(3), n, m+3); } qr13=select MRP from Prices where prod_no in (select prod_no from product where model = +model+); rs=statement.executeQuery(qr13); while(rs.next()) { price1=rs.getInt(1); } qr12=select MRP from Prices where prod_no = +prod3[a]+; rs=statement.executeQuery(qr12); while(rs.next()) { jTable1.setValueAt(rs.getFloat(1)+price1-1000,n,m+4); } n++; }

S.I.M.S INDORE

95

ELECTROMART ANALYSIS USING DATAMINING

} } } } } } catch(Exception e) { // jLabel6.setText(e.toString()); } } } private void jButton5MouseClicked(java.awt.event.MouseEvent evt) { int offno=0,prod1=0, prod2, r; Object oprice; String model1, company, type1; r=jTable1.getSelectedRow(); Object model=jComboBox3.getSelectedItem(); try{ Class.forName(com.mysql.jdbc.Driver); String an,qr,qr1,qr2; Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,root, root); Statement statement= connection.createStatement(); ResultSet rs; qr=select prod_no from product where model =+model+; rs=statement.executeQuery(qr); while(rs.next()) { prod1=rs.getInt(1); } qr1=select max(offer_no) from saveoffers ; rs=statement.executeQuery(qr1); while(rs.next()) { offno=rs.getInt(1); } offno++; prod2=Integer.parseInt(jTable1.getValueAt(r,0).toString()); model1=(String)jTable1.getValueAt(r,1); company=(String)jTable1.getValueAt(r,2); type1=(String)jTable1.getValueAt(r,3); oprice=jTable1.getValueAt(r,4); qr2=Insert into saveoffers values(+offno+,+prod1+,+prod2+,+model1+,+company+,+type1+ ,+oprice+);

S.I.M.S INDORE

96

ELECTROMART ANALYSIS USING DATAMINING

statement.executeUpdate(qr2); JOptionPane.showMessageDialog(null,Offer ,Information,JOptionPane.INFORMATION_MESSAGE); statement.close(); connection.close(); } catch(Exception e) { //jLabel8.setText(e.toString()); } } private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) { jTable1.removeAll(); // TODO add your handling code here: } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Offer().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JButton jButton6; private javax.swing.JComboBox jComboBox1; private javax.swing.JComboBox jComboBox2; private javax.swing.JComboBox jComboBox3; private javax.swing.JComboBox jComboBox4; private javax.swing.JInternalFrame jInternalFrame1; private javax.swing.JInternalFrame jInternalFrame2; private javax.swing.JInternalFrame jInternalFrame3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8;

Saved

S.I.M.S INDORE

97

ELECTROMART ANALYSIS USING DATAMINING

private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable jTable1; // End of variables declaration } 10.6 Sales Trend Module package datamining; import java.sql.*; import javax.swing.JOptionPane; import java.util.*; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTable; import java.awt.*; public class Offer extends javax.swing.JFrame { public Offer() { initComponents(); jInternalFrame2.setVisible(false); jInternalFrame3.setVisible(false); try{ String qr,an; Class.forName(com.mysql.jdbc.Driver); Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,root, root); qr=SELECT type from product group by type ; Statement stmt= connection.createStatement(); ResultSet rs; rs=stmt.executeQuery(qr); while(rs.next()) { an=rs.getString(1); jComboBox1.addItem(an); } stmt.close(); connection.close(); } catch(Exception e) { // e.printStackTrace(); } }

S.I.M.S INDORE

98

ELECTROMART ANALYSIS USING DATAMINING

@SuppressWarnings(unchecked) // <editor-fold defaultstate=collapsed desc=Generated Code> private void initComponents() { buttonGroup1 = new javax.swing.ButtonGroup(); jInternalFrame1 = new javax.swing.JInternalFrame(); jLabel1 = new javax.swing.JLabel(); jComboBox1 = new javax.swing.JComboBox(); jLabel2 = new javax.swing.JLabel(); jComboBox2 = new javax.swing.JComboBox(); jLabel3 = new javax.swing.JLabel(); jComboBox3 = new javax.swing.JComboBox(); jButton1 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jInternalFrame3 = new javax.swing.JInternalFrame(); jComboBox4 = new javax.swing.JComboBox(); jLabel7 = new javax.swing.JLabel(); jInternalFrame2 = new javax.swing.JInternalFrame(); jLabel4 = new javax.swing.JLabel(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jButton5 = new javax.swing.JButton(); jLabel8 = new javax.swing.JLabel(); jButton6 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(datamining.DataminingApp.class).getC ontext().getResourceMap(Offer.class); setTitle(resourceMap.getString(Form.title)); // NOI18N setName(Form); // NOI18N jInternalFrame1.setTitle(resourceMap.getString(jInternalFrame1.title)); // NOI18N jInternalFrame1.setName(jInternalFrame1); // NOI18N jInternalFrame1.setVisible(true); jLabel1.setText(resourceMap.getString(jLabel1.text)); // NOI18N jLabel1.setName(jLabel1); // NOI18N jComboBox1.setName(jComboBox1); // NOI18N jComboBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox1ActionPerformed(evt);

S.I.M.S INDORE

99

ELECTROMART ANALYSIS USING DATAMINING

} }); jLabel2.setText(resourceMap.getString(jLabel2.text)); // NOI18N jLabel2.setName(jLabel2); // NOI18N jComboBox2.setName(jComboBox2); // NOI18N jComboBox2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox2ActionPerformed(evt); } }); jLabel3.setText(resourceMap.getString(jLabel3.text)); // NOI18N jLabel3.setName(jLabel3); // NOI18N jComboBox3.setName(jComboBox3); // NOI18N jButton1.setText(resourceMap.getString(jButton1.text)); // NOI18N jButton1.setName(jButton1); // NOI18N jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton4.setText(resourceMap.getString(jButton4.text)); // NOI18N jButton4.setName(jButton4); // NOI18N jButton4.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton4MouseClicked(evt); } }); javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane()); jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout); jInternalFrame1Layout.setHorizontalGroup( jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame1Layout.createSequentialGroup() .addContainerGap() . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.TRAILING, false)

S.I.M.S INDORE

100

ELECTROMART ANALYSIS USING DATAMINING

.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton4)) .addGap(53, 53, 53) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING, false) .addComponent(jComboBox3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jComboBox2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jComboBox1, 0, 109, Short.MAX_VALUE)) .addComponent(jButton1)) .addContainerGap(1474, Short.MAX_VALUE)) ); jInternalFrame1Layout.setVerticalGroup( jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame1Layout.createSequentialGroup() .addGap(114, 114, 114) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(27, 27, 27) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18)

S.I.M.S INDORE

101

ELECTROMART ANALYSIS USING DATAMINING

. addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(27, 27, 27) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jButton4) .addComponent(jButton1)) .addContainerGap(1116, Short.MAX_VALUE)) ); jInternalFrame3.setTitle(resourceMap.getString(jInternalFrame3.title)); // NOI18N jInternalFrame3.setName(jInternalFrame3); // NOI18N jInternalFrame3.setVisible(true); jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new { Cost, Sales, Zero })); jComboBox4.setName(jComboBox4); // NOI18N jComboBox4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox4ActionPerformed(evt); } }); String[]

jLabel7.setText(resourceMap.getString(jLabel7.text)); // NOI18N jLabel7.setName(jLabel7); // NOI18N javax.swing.GroupLayout jInternalFrame3Layout = new javax.swing.GroupLayout(jInternalFrame3.getContentPane()); jInternalFrame3.getContentPane().setLayout(jInternalFrame3Layout); jInternalFrame3Layout.setHorizontalGroup( jInternalFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jInternalFrame3Layout.createSequentialGroup() .addContainerGap(77, Short.MAX_VALUE) .addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(43, 43, 43))

S.I.M.S INDORE

102

ELECTROMART ANALYSIS USING DATAMINING

); jInternalFrame3Layout.setVerticalGroup( jInternalFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame3Layout.createSequentialGroup() .addGap(24, 24, 24) . addGroup(jInternalFrame3Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jLabel7) .addComponent(jComboBox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(395, Short.MAX_VALUE)) ); jInternalFrame2.setName(jInternalFrame2); // NOI18N jInternalFrame2.setVisible(true); jLabel4.setText(resourceMap.getString(jLabel4.text)); // NOI18N jLabel4.setName(jLabel4); // NOI18N jButton2.setText(resourceMap.getString(jButton2.text)); // NOI18N jButton2.setName(jButton2); // NOI18N jButton2.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton2MouseClicked(evt); } }); jButton3.setText(resourceMap.getString(jButton3.text)); // NOI18N jButton3.setName(jButton3); // NOI18N jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jScrollPane1.setName(jScrollPane1); // NOI18N jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null},

S.I.M.S INDORE

103

ELECTROMART ANALYSIS USING DATAMINING

{null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null}, {null, null, null, null, null, null} }, new String [] { Product No., Product Model, Product Company, Product Type, Offer price, Discount } ){ Class[] types = new Class [] { java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Float.class, java.lang.Float.class }; boolean[] canEdit = new boolean [] { false, false, false, false, false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); jTable1.setName(jTable1); // NOI18N jScrollPane1.setViewportView(jTable1); jTable1.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString(jTabl e1.columnModel.title0)); // NOI18N jTable1.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString(jTabl e1.columnModel.title1)); // NOI18N jTable1.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString(jTabl e1.columnModel.title2)); // NOI18N jTable1.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString(jTabl e1.columnModel.title3)); // NOI18N jTable1.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString(jTabl e1.columnModel.title4)); // NOI18N jTable1.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString(jTabl e1.columnModel.title5)); // NOI18N jLabel5.setText(resourceMap.getString(jLabel5.text)); // NOI18N jLabel5.setName(jLabel5); // NOI18N jLabel6.setText(resourceMap.getString(jLabel6.text)); // NOI18N jLabel6.setName(jLabel6); // NOI18N jButton5.setText(resourceMap.getString(jButton5.text)); // NOI18N jButton5.setName(jButton5); // NOI18N

S.I.M.S INDORE

104

ELECTROMART ANALYSIS USING DATAMINING

jButton5.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton5MouseClicked(evt); } }); jLabel8.setText(resourceMap.getString(jLabel8.text)); // NOI18N jLabel8.setName(jLabel8); // NOI18N jButton6.setText(resourceMap.getString(jButton6.text)); // NOI18N jButton6.setName(jButton6); // NOI18N jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt); } }); javax.swing.GroupLayout jInternalFrame2Layout = new javax.swing.GroupLayout(jInternalFrame2.getContentPane()); jInternalFrame2.getContentPane().setLayout(jInternalFrame2Layout); jInternalFrame2Layout.setHorizontalGroup( jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame2Layout.createSequentialGroup() . addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addGroup(jInternalFrame2Layout.createSequentialGroup() .addGap(28, 28, 28) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 485, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jInternalFrame2Layout.createSequentialGroup() .addGap(115, 115, 115) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton6) .addGap(18, 18, 18) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton5)) .addGroup(jInternalFrame2Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 719, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jInternalFrame2Layout.createSequentialGroup()

S.I.M.S INDORE

105

ELECTROMART ANALYSIS USING DATAMINING

.addGap(1085, 1085, 1085) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE)) . addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.TRAILING, false) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jInternalFrame2Layout.createSequentialGroup() .addGap(19, 19, 19) .addComponent(jScrollPane1)) .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 1060, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); jInternalFrame2Layout.setVerticalGroup( jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame2Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(14, 14, 14) . addGroup(jInternalFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton6) .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton5)) .addGap(46, 46, 46) .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(29, 29, 29) .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) );

S.I.M.S INDORE

106

ELECTROMART ANALYSIS USING DATAMINING

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(jInternalFrame3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(52, 52, 52) .addComponent(jInternalFrame2, javax.swing.GroupLayout.PREFERRED_SIZE, 1420, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(86, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(27, 27, 27) .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jInternalFrame3) .addComponent(jInternalFrame2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap()) ); pack(); }// </editor-fold> private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) { jComboBox2.removeAllItems(); try{ Class.forName(com.mysql.jdbc.Driver); String an,qr; Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,root, root); Object type=jComboBox1.getSelectedItem();

S.I.M.S INDORE

107

ELECTROMART ANALYSIS USING DATAMINING

qr=SELECT company from product where type =+type+group by company; Statement stmt= connection.createStatement(); ResultSet rs; rs=stmt.executeQuery(qr); while(rs.next()) { an=rs.getString(1); jComboBox2.addItem(an); } stmt.close(); connection.close(); } catch(Exception e) { //e.printStackTrace(); } } private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) { jComboBox3.removeAllItems(); Object comp=jComboBox2.getSelectedItem(); Object type=jComboBox1.getSelectedItem(); try{ Class.forName(com.mysql.jdbc.Driver); Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,root, root); String qr,an; qr=SELECT model from product where company =+comp+; Statement stmt= connection.createStatement(); ResultSet rs; rs=stmt.executeQuery(qr); while(rs.next()) { an=rs.getString(1); jComboBox3.addItem(an); } stmt.close(); connection.close(); } catch(Exception e) { // e.printStackTrace(); } }

S.I.M.S INDORE

108

ELECTROMART ANALYSIS USING DATAMINING

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { jComboBox4.setSelectedIndex(-1); jInternalFrame3.setVisible(true); jInternalFrame1.setVisible(false); jInternalFrame2.setVisible(false); } private void jButton2MouseClicked(java.awt.event.MouseEvent evt) { jTable1.removeAll(); jComboBox4.setSelectedIndex(-1); jInternalFrame1.setVisible(true); jInternalFrame2.setVisible(false); } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { System.exit(0); } private void jButton4MouseClicked(java.awt.event.MouseEvent evt) { ModuleSelect m = new ModuleSelect(); m.setVisible(true); this.setVisible(false); } private void jComboBox4ActionPerformed(java.awt.event.ActionEvent evt) { jInternalFrame2.setVisible(true); jTable1.removeAll(); String name; // jButton5.setEnabled(false); float price1=0,pricetot=0,offprice=0; int[] x=new int[10]; int[] prod2=new int[10]; float[] price2=new float[100]; //int x=0; jTable1.removeAll(); name = jComboBox1.getSelectedItem().toString()+ jComboBox2.getSelectedItem().toString()+ +jComboBox3.getSelectedItem().toString(); jLabel4.setText(Offers For + name); jInternalFrame2.setVisible(true); jInternalFrame3.setVisible(false); int p1=0,total=0,i=0; int[] p2=new int[100]; float disc=0,mrp2=0,sp2=0;//mrp of 2ns prod

S.I.M.S INDORE

109

ELECTROMART ANALYSIS USING DATAMINING

int j=0; //int p2=0; String qr, qr7,qr9,qr10,qr11,qr12,qr13,qr14,qr15; Object model=jComboBox3.getSelectedItem(); float minsupp=0,maxsupp=100; double[] support=new double[100]; double[] confidence=new double[100]; // int [] prod_no = new int[10]; int m=0,n=0; int[] sales=new int[100]; int indvsales1=0,indvsales2; float mrp=0,new_profit=0; if(jComboBox4.getSelectedIndex()==2)//Zero sales { String qr1,qr3,qr4,qr2; int[] prod_zero=new int[50]; int price_model=0; int price_this=0; int[] prod_zero_true=new int[100]; int pr_zero; try{ Class.forName(com.mysql.jdbc.Driver); Connection connection=DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,ro ot,root); Statement statement=connection.createStatement(); ResultSet rs,rs1,rs2; qr=Select sp from prices where prod_no in (select prod_no from product where model = +model+); rs=statement.executeQuery(qr); while(rs.next()) { price_model=rs.getInt(1); } i=0; qr1= select distinct(prod_no) from stock where prod_no not in(select prod_no from billing); rs1=statement.executeQuery(qr1); while (rs1.next()) { prod_zero[i]=rs1.getInt(1);

S.I.M.S INDORE

110

ELECTROMART ANALYSIS USING DATAMINING

i++; } int w=0; int p=0; for (i=0;i<prod_zero.length; i++) { qr2= Select sp from prices where prod_no =+prod_zero[i]+ ; rs2=statement.executeQuery(qr2); rs2.next(); price_this = rs2.getInt(1); if ( price_this< price_model) { prod_zero_true[w] = prod_zero[i]; jTable1.setValueAt(prod_zero_true[w],w,p); qr3=select type, company,model from product where prod_no =+prod_zero[i]+; ResultSet rs3=statement.executeQuery(qr3); while(rs3.next()) { jTable1.setValueAt(rs3.getString(1),w,p+1); jTable1.setValueAt(rs3.getString(2),w,p+2); jTable1.setValueAt(rs3.getString(3),w,p+3); } w++; } } } catch(Exception e) { } } else { try { Class.forName(com.mysql.jdbc.Driver); Connection connection=DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,ro ot,root);

S.I.M.S INDORE

111

ELECTROMART ANALYSIS USING DATAMINING

Statement statement=connection.createStatement(); ResultSet rs; qr=select prod_no from billing where b_no in(select b_no from billing where prod_no in (select prod_no from product where model = +model+))and prod_no != +(select prod_no from product where model = +model+) group by prod_no; rs=statement.executeQuery(qr); while(rs.next()) { p2[i]=rs.getInt(1); i++; } for(int k=0;k<p2.length;k++) { qr=select b_no from billing where prod_no in (select prod_no from product where model = +model+) and b_no in (select distinct(b_no) from billing where prod_no =+p2[k]+); rs=statement.executeQuery(qr); while(rs.next()) { x[k]++; } } String qr2,qr5,qr6,qr8; qr2=select count(prod_no)from billing where prod_no in(select prod_no from product where model = +model+); rs=statement.executeQuery(qr2); while(rs.next()) { p1=rs.getInt(1); } qr2=select count(*) from billing; rs=statement.executeQuery(qr2); while(rs.next()) { total=rs.getInt(1); } for(int k=0;k<p2.length;k++) { if(x[k]!=0 ) { support[k]=x[k]*1000/total; confidence[k]=x[k]*100/p1;

S.I.M.S INDORE

112

ELECTROMART ANALYSIS USING DATAMINING

jLabel8.setText(support = +support[k]+ confidence = +confidence[k]); if(support[k]>minsupp && support[k]< maxsupp) { if(jComboBox4.getSelectedIndex()==0)//Cost filter { qr5=select mrp from Prices where prod_no in (select prod_no from product where model = +model+); rs=statement.executeQuery(qr5); while(rs.next()) { price1=rs.getFloat(1); } qr6=select prod_no from Prices where prod_no=+p2[k]+ and mrp < +price1+; rs=statement.executeQuery(qr6); while(rs.next()) { prod2[k]=rs.getInt(1); } if(prod2[k]!=0) { qr7 = select model, Company,Type from Product where prod_no=+prod2[k]+; rs = statement.executeQuery(qr7); while (rs.next()) { jTable1.setValueAt(prod2[k],n,m); jTable1.setValueAt(rs.getString(1),n,m+1); jTable1.setValueAt(rs.getString(2),n,m+2); jTable1.setValueAt(rs.getString(3),n,m+3); jTable1.setValueAt(confidence[n],n,m+5); } qr8 = select MRP,sp from Prices where prod_no=+prod2[k]+; rs = statement.executeQuery(qr8); while (rs.next()) { mrp2=rs.getFloat(1); sp2=rs.getFloat(2); if((mrp2-sp2)*(1-confidence[n])<200) { jTable1.setValueAt(sp2+price1,n,m+4); jTable1.setValueAt(mrp2-sp2,n,m+5); } else { new_profit=(float) ((mrp2 - sp2) * (1 - confidence[n])); jTable1.setValueAt(sp2+new_profit+price1,n,m+4);

S.I.M.S INDORE

113

ELECTROMART ANALYSIS USING DATAMINING

jTable1.setValueAt(mrp2-(sp2+new_profit),n,m+5); } } } n++; } if(jComboBox4.getSelectedIndex()==1)// Sales Filter { qr9=select count(*) from billing where prod_no in (select prod_no from product where model = +model+); rs=statement.executeQuery(qr9); while(rs.next()) { indvsales1=rs.getInt(1); } qr10=select b_no from billing where prod_no = +p2[k]+; int[] prod3=new int[10]; int a=0; rs=statement.executeQuery(qr10); while(rs.next()) { sales[k]++; } if(sales[k]<indvsales1) { prod3[a]=p2[k]; jTable1.setValueAt(p2[k], n, m); a++; } for (a=0;a<10; a++) { if(prod3[a]!=0) { qr11=select model,company,type from Product where prod_no = +prod3[a]+; rs=statement.executeQuery(qr11); while(rs.next()) { jTable1.setValueAt(rs.getString(1), n, m+1); jTable1.setValueAt(rs.getString(2), n, m+2); jTable1.setValueAt(rs.getString(3), n, m+3); } qr13=select MRP from Prices where prod_no in (select prod_no from product where model = +model+); rs=statement.executeQuery(qr13);

S.I.M.S INDORE

114

ELECTROMART ANALYSIS USING DATAMINING

while(rs.next()) { price1=rs.getInt(1); } qr12=select MRP from Prices where prod_no = +prod3[a]+; rs=statement.executeQuery(qr12); while(rs.next()) { jTable1.setValueAt(rs.getFloat(1)+price1-1000,n,m+4); } n++; } } } } } } } catch(Exception e) { // jLabel6.setText(e.toString()); } } } private void jButton5MouseClicked(java.awt.event.MouseEvent evt) { int offno=0,prod1=0, prod2, r; Object oprice; String model1, company, type1; r=jTable1.getSelectedRow(); Object model=jComboBox3.getSelectedItem(); try{ Class.forName(com.mysql.jdbc.Driver); String an,qr,qr1,qr2; Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,root, root); Statement statement= connection.createStatement(); ResultSet rs; qr=select prod_no from product where model =+model+; rs=statement.executeQuery(qr); while(rs.next()) { prod1=rs.getInt(1); } qr1=select max(offer_no) from saveoffers ; rs=statement.executeQuery(qr1);

S.I.M.S INDORE

115

ELECTROMART ANALYSIS USING DATAMINING

while(rs.next()) { offno=rs.getInt(1); } offno++; prod2=Integer.parseInt(jTable1.getValueAt(r,0).toString()); model1=(String)jTable1.getValueAt(r,1); company=(String)jTable1.getValueAt(r,2); type1=(String)jTable1.getValueAt(r,3); oprice=jTable1.getValueAt(r,4); qr2=Insert into saveoffers values(+offno+,+prod1+,+prod2+,+model1+,+company+,+type1+ ,+oprice+); statement.executeUpdate(qr2); JOptionPane.showMessageDialog(null,Offer Saved ,Information,JOptionPane.INFORMATION_MESSAGE); statement.close(); connection.close(); } catch(Exception e) { //jLabel8.setText(e.toString()); } } private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) { jTable1.removeAll(); // TODO add your handling code here: } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Offer().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.ButtonGroup buttonGroup1; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JButton jButton6; private javax.swing.JComboBox jComboBox1; private javax.swing.JComboBox jComboBox2;

S.I.M.S INDORE

116

ELECTROMART ANALYSIS USING DATAMINING

private javax.swing.JComboBox jComboBox3; private javax.swing.JComboBox jComboBox4; private javax.swing.JInternalFrame jInternalFrame1; private javax.swing.JInternalFrame jInternalFrame2; private javax.swing.JInternalFrame jInternalFrame3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable jTable1; // End of variables declaration }

10.8 Billing Module package datamining; import java.sql.*;/* To change this template, choose Tools | Templates and open the template in the editor. */ /* * */ Bill.java Created on 22 Apr, 2010, 10:41:01 PM

/** *

@author anchal 117

S.I.M.S INDORE

ELECTROMART ANALYSIS USING DATAMINING

*/ public class Bill extends javax.swing.JFrame { /** Creates new form Bill */ public Bill() { initComponents(); try{ Class.forName(com.mysql.jdbc.Driver); Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,root, root); String qr,qr1,an; qr1=select date from billing; Statement stmt1 = connection.createStatement(); ResultSet rs1 = stmt1.executeQuery(qr1); while(rs1.next()) { // jComboBox2.addItem(rs1.getString(1)); } qr=SELECT prod_no from product; Statement stmt= connection.createStatement(); ResultSet rs; rs=stmt.executeQuery(qr); while(rs.next()) { jComboBox1.addItem(rs.getInt(1)); } } catch(Exception e) { e.printStackTrace(); } } /** This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor. */ @SuppressWarnings(unchecked) // <editor-fold defaultstate=collapsed desc=Generated Code> private void initComponents() { jInternalFrame1 = new javax.swing.JInternalFrame(); jLabel1 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel();

S.I.M.S INDORE

118

ELECTROMART ANALYSIS USING DATAMINING

jComboBox1 = new javax.swing.JComboBox(); jLabel3 = new javax.swing.JLabel(); jTextField2 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setName(Form); // NOI18N jInternalFrame1.setName(jInternalFrame1); // NOI18N jInternalFrame1.setVisible(true); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(datamining.DataminingApp.class).getC ontext().getResourceMap(Bill.class); jLabel1.setText(resourceMap.getString(jLabel1.text)); // NOI18N jLabel1.setName(jLabel1); // NOI18N jTextField1.setText(resourceMap.getString(jTextField1.text)); // NOI18N jTextField1.setName(jTextField1); // NOI18N jLabel2.setText(resourceMap.getString(jLabel2.text)); // NOI18N jLabel2.setName(jLabel2); // NOI18N jComboBox1.setName(jComboBox1); // NOI18N jLabel3.setText(resourceMap.getString(jLabel3.text)); // NOI18N jLabel3.setName(jLabel3); // NOI18N jTextField2.setText(resourceMap.getString(jTextField2.text)); // NOI18N jTextField2.setName(jTextField2); // NOI18N jButton1.setText(resourceMap.getString(jButton1.text)); // NOI18N jButton1.setName(jButton1); // NOI18N jButton1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton1MouseClicked(evt); } }); jButton2.setText(resourceMap.getString(jButton2.text)); // NOI18N jButton2.setName(jButton2); // NOI18N jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton3.setText(resourceMap.getString(jButton3.text)); // NOI18N jButton3.setName(jButton3); // NOI18N jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) {

S.I.M.S INDORE

119

ELECTROMART ANALYSIS USING DATAMINING

jButton3ActionPerformed(evt); } }); javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane()); jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout); jInternalFrame1Layout.setHorizontalGroup( jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING) .addGroup(jInternalFrame1Layout.createSequentialGroup() .addContainerGap() . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addGroup(jInternalFrame1Layout.createSequentialGroup() . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.TRAILING) .addComponent(jLabel1) .addGroup(jInternalFrame1Layout.createSequentialGroup() .addComponent(jLabel3) .addGap(9, 9, 9)) .addComponent(jLabel2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.LEADING) .addComponent(jComboBox1, 0, 160, Short.MAX_VALUE) .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE) .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jInternalFrame1Layout.createSequentialGroup() .addComponent(jButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE) .addComponent(jButton3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton2))) .addContainerGap()) ); jInternalFrame1Layout.setVerticalGroup( jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD ING)

S.I.M.S INDORE

120

ELECTROMART ANALYSIS USING DATAMINING

.addGroup(jInternalFrame1Layout.createSequentialGroup() .addGap(27, 27, 27) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jLabel1) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2)) .addGap(34, 34, 34) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jLabel3) .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(70, 70, 70) . addGroup(jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignm ent.BASELINE) .addComponent(jButton2) .addComponent(jButton3) .addComponent(jButton1)) .addContainerGap(136, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(239, Short.MAX_VALUE)) );

S.I.M.S INDORE

121

ELECTROMART ANALYSIS USING DATAMINING

layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jInternalFrame1) .addContainerGap()) ); pack(); }// </editor-fold> private void jButton1MouseClicked(java.awt.event.MouseEvent evt) { try { Class.forName(com.mysql.jdbc.Driver); Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,root, root); String qr,an; int sp=0; qr=SELECT sp from prices where prod_no =+jComboBox1.getSelectedItem()+; Statement stmt= connection.createStatement(); ResultSet rs; rs=stmt.executeQuery(qr); while(rs.next()) { sp=rs.getInt(1); } qr=insert into billing values (+jTextField1.getText()+,+jTextField2.getText() +,+jComboBox1.getSelectedItem()+,0,+sp+,1); stmt.executeUpdate(qr); int bn; bn=Integer.parseInt(jTextField2.getText()); bn=bn+1; jTextField2.setText(bn+); } catch(Exception e) { e.printStackTrace(); }// TODO add your handling code here: jButton1.setEnabled(false); } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { System.exit(0); // TODO add your handling code here: }

S.I.M.S INDORE

122

ELECTROMART ANALYSIS USING DATAMINING

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { ModuleSelect m = new ModuleSelect(); m.setVisible(true); this.setVisible(false); } /** @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Bill().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JComboBox jComboBox1; private javax.swing.JInternalFrame jInternalFrame1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JTextField jTextField1; private javax.swing.JTextField jTextField2; // End of variables declaration }

10.7 Add Product


package datamining; import java.sql.*; import java.util.Random; import javax.swing.*; import java.util.Calendar; import java.text.SimpleDateFormat; public class add extends javax.swing.JFrame { public add() { initComponents(); int p;

S.I.M.S INDORE

123

ELECTROMART ANALYSIS USING DATAMINING

try { Calendar cal = Calendar.getInstance(); SimpleDateFormat formatter= new SimpleDateFormat(ddMMyyyy); String dateNow = formatter.format(cal.getTime()); datein.setText( + dateNow); expdate.setText(+ dateNow); Class.forName(com.mysql.jdbc.Driver); Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,root, root); Statement stmt= connection.createStatement(); ResultSet rs; rs=stmt.executeQuery(Select max(prod_no) from product); rs.next(); p=rs.getInt(1); p++; jTextField1.setText(+p); jTextField1.enable(false); } catch(Exception e) { } } @SuppressWarnings(unchecked) // <editor-fold defaultstate=collapsed desc=Generated Code> private void initComponents() { bevelBorder1 = (javax.swing.border.BevelBorder)javax.swing.BorderFactory.createBevelBorder(javax.s wing.border.BevelBorder.RAISED); jLabel4 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); type = new javax.swing.JComboBox(); jLabel2 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); cp = new javax.swing.JTextField(); company = new javax.swing.JComboBox(); model = new javax.swing.JComboBox(); jButton1 = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jLabel6 = new javax.swing.JLabel();

S.I.M.S INDORE

124

ELECTROMART ANALYSIS USING DATAMINING

jLabel7 = new javax.swing.JLabel(); datein = new javax.swing.JTextField(); expdate = new javax.swing.JTextField(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); qty = new javax.swing.JTextField(); minimum = new javax.swing.JTextField(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(datamining.DataminingApp.class).getC ontext().getResourceMap(add.class); setTitle(resourceMap.getString(Form.title)); // NOI18N setName(Form); // NOI18N jLabel4.setText(resourceMap.getString(jLabel4.text)); // NOI18N jLabel4.setName(jLabel4); // NOI18N jLabel3.setText(resourceMap.getString(jLabel3.text)); // NOI18N jLabel3.setName(jLabel3); // NOI18N type.setModel(new javax.swing.DefaultComboBoxModel(new String[] { Camera, TV, DVD player, Home theatre, Laptop, Desktop, Printer, Cellphone, Memorycard, TV tuner card, Headphone, Speaker, Pendrive, External Harddisk, Webcam, Ipod })); type.setName(type); // NOI18N type.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { typeItemStateChanged(evt); } }); type.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { typeActionPerformed(evt); } }); jLabel2.setText(resourceMap.getString(jLabel2.text)); // NOI18N jLabel2.setName(jLabel2); // NOI18N jLabel5.setText(resourceMap.getString(jLabel5.text)); // NOI18N jLabel5.setName(jLabel5); // NOI18N cp.setName(cp); // NOI18N cp.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseExited(java.awt.event.MouseEvent evt) { cpMouseExited(evt); } }); cp.addFocusListener(new java.awt.event.FocusAdapter() {

S.I.M.S INDORE

125

ELECTROMART ANALYSIS USING DATAMINING

public void focusLost(java.awt.event.FocusEvent evt) { cpFocusLost(evt); } }); company.setName(company); // NOI18N company.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { companyItemStateChanged(evt); } }); model.setName(model); // NOI18N jButton1.setText(resourceMap.getString(jButton1.text)); // NOI18N jButton1.setName(jButton1); // NOI18N jButton1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton1MouseClicked(evt); } }); jLabel1.setText(resourceMap.getString(jLabel1.text)); // NOI18N jLabel1.setName(jLabel1); // NOI18N jTextField1.setText(resourceMap.getString(jTextField1.text)); // NOI18N jTextField1.setName(jTextField1); // NOI18N javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(datamining.DataminingApp.class).getC ontext().getActionMap(add.class, this); jButton2.setAction(actionMap.get( quit )); // NOI18N jButton2.setText(resourceMap.getString(jButton2.text)); // NOI18N jButton2.setName(jButton2); // NOI18N jButton3.setText(resourceMap.getString(jButton3.text)); // NOI18N jButton3.setName(jButton3); // NOI18N jButton3.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButton3MouseClicked(evt); } }); jLabel6.setText(resourceMap.getString(jLabel6.text)); // NOI18N jLabel6.setName(jLabel6); // NOI18N jLabel7.setText(resourceMap.getString(jLabel7.text)); // NOI18N jLabel7.setName(jLabel7); // NOI18N datein.setText(resourceMap.getString(datein.text)); // NOI18N datein.setName(datein); // NOI18N

S.I.M.S INDORE

126

ELECTROMART ANALYSIS USING DATAMINING

expdate.setText(resourceMap.getString(expdate.text)); // NOI18N expdate.setName(expdate); // NOI18N jLabel8.setText(resourceMap.getString(jLabel8.text)); // NOI18N jLabel8.setName(jLabel8); // NOI18N jLabel9.setText(resourceMap.getString(jLabel9.text)); // NOI18N jLabel9.setName(jLabel9); // NOI18N qty.setText(resourceMap.getString(qty.text)); // NOI18N qty.setName(qty); // NOI18N minimum.setText(resourceMap.getString(minimum.text)); // NOI18N minimum.setName(minimum); // NOI18N javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton3) .addContainerGap(48, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addContainerGap(194, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel9) .addComponent(jLabel8) .addComponent(jLabel7)) .addGap(53, 53, 53) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(minimum, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(qty, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE))

S.I.M.S INDORE

127

ELECTROMART ANALYSIS USING DATAMINING

.addComponent(expdate, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE))) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel6) .addComponent(jLabel5)) .addGap(49, 49, 49) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(datein, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE) .addComponent(cp, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE))) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addComponent(jLabel2) .addGap(35, 35, 35) .addComponent(type, 0, 0, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGap(97, 97, 97) .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3) .addComponent(jLabel4)) .addGap(52, 52, 52) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(company, 0, 149, Short.MAX_VALUE) .addComponent(model, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGap(25, 25, 25)))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(23, 23, 23) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addGap(6, 6, 6) .addComponent(jLabel1)) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

S.I.M.S INDORE

128

ELECTROMART ANALYSIS USING DATAMINING

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addGap(6, 6, 6) .addComponent(jLabel2)) .addComponent(type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(17, 17, 17) . addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(company, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(17, 17, 17) . addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(model, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(12, 12, 12) . addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(cp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addGap(6, 6, 6) .addComponent(jLabel6)) .addComponent(datein, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) . addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(expdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel7)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

S.I.M.S INDORE

129

ELECTROMART ANALYSIS USING DATAMINING

. addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(qty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel8)) .addGap(22, 22, 22) . addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(minimum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel9)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 84, Short.MAX_VALUE) . addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(jButton2) .addComponent(jButton3)) .addGap(73, 73, 73)) ); pack(); }// </editor-fold> private void typeItemStateChanged(java.awt.event.ItemEvent evt) { } private void companyItemStateChanged(java.awt.event.ItemEvent evt) { model.removeAllItems(); model.setSelectedIndex(-1); int i,j; i=type.getSelectedIndex(); j=company.getSelectedIndex(); if(i==0) { if(j==0) { model.addItem(Lumix DMC-ZS3); } if(j==1) { model.addItem(Power Shot SD1200IS 10MP); model.addItem(Digital Rebel Xsi 12.2 MP); model.addItem(Power Shot SD780IS 12.1 MP);

S.I.M.S INDORE

130

ELECTROMART ANALYSIS USING DATAMINING

model.addItem(VIXIA HF2); model.addItem(PowerShot s90IS 10 MP); } if(j==2) { model.addItem(UltraHD camcorder 120 Mins); model.addItem(UltraHD camcorder 2nd Generation); } if(j==3) { model.addItem(CoolPics L20 10MP); model.addItem(D3000 10.2MP); } } if(i==1) { if(j==0) { model.addItem(VIERA X1 Series); } if(j==1) { model.addItem(32 Inch 720p LCD); model.addItem(SyncMaster 2333HD); } if(j==2) { model.addItem(LC24VXF60PB 24-Inch 1080p); } if(j==3) { model.addItem(32RV525R 32-Inch); } if(j==4) { model.addItem(32LH30 32-Inch 1080p); } if(j==5) { model.addItem(AXN-8701 7-Inch); } if(j==6) { model.addItem(VO320E 32-Inch);

S.I.M.S INDORE

131

ELECTROMART ANALYSIS USING DATAMINING

} } if(i==2) { if(j==0) { model.addItem(DMP-BD60); } if(j==1) { model.addItem(BDP-S360 Blue-Ray); model.addItem(BDP-N460 Blue-Ray); model.addItem(DVP-FX930 Portable); } if(j==2) { model.addItem(BD390 Network); } if(j==3) { model.addItem(DVP5990/F7 DVD Player); } } if(i==3) { if(j==0) { model.addItem(BDVE500W 5.1-Channel High Defination); model.addItem(Bravia DAV-HDX589W); } if(j==1) { model.addItem(SC-BT300 1250W 7.1 Channel); model.addItem(SC-PT670 1000W 5.1 Channel); } if(j==2) { model.addItem(SKS-HT540 7.1 Channel); } if(j==3) { model.addItem(HT-BD1250 Blu-Ray); } } if(i==4)

S.I.M.S INDORE

132

ELECTROMART ANALYSIS USING DATAMINING

{ if(j==0) { model.addItem(MacBook MC207); model.addItem(MacBook PROMB 13.3 Inch); model.addItem(MacBook PROMB 15.4 Inch); model.addItem(MacBook Air 13.3\ Laptop); } if(j==1) { model.addItem(G60-630US 15.6 Inch); model.addItem(Pavillion DV4-2161NR 14.1 Inch); model.addItem(Pavillion DV6-1354US 15.6 Inch); model.addItem(Pavillion DV7-3160US 17.3 Inch); model.addItem(Pavillion DV4-2160US 14.1 Inch); } if(j==2) { model.addItem(Inspiron 11 11.6-Inch); model.addItem(Inspiron i1545-4583j 15.6-Inch); model.addItem(Inspiron 1545 15.6-Inch); model.addItem(Adamo 13 A13 13.4Inch); model.addItem(Inspiron i1750 17.3-Inch); model.addItem(Studio s1557 15.6 Inch); } if(j==3) { model.addItem(Aspire AS1410); } } if(i==5) { if(j==0) { model.addItem(Inspiron 545 i545); model.addItem(Inspiron One 19 iO19); model.addItem(Studio One 19 Charcoal); } if(j==1) { model.addItem(VAIO VGC-JS430F); model.addItem(VAIO VPC-L111FX); } if(j==2) { model.addItem(One ZX4800-07);

S.I.M.S INDORE

133

ELECTROMART ANALYSIS USING DATAMINING

model.addItem(DX4831-03 Desktop); } if(j==3) { model.addItem(AspireRevo AR3610); } } if(i==6) { if(j==0) { model.addItem(PIXMA MX870); model.addItem(PIXMA MP560); } if(j==1) { model.addItem(Deskjet F4480 Inkjet); model.addItem(PhotoSmart Premium); } } if(i==7) { if(j==0) { model.addItem(2330); model.addItem(3500); model.addItem(3600 Slider); model.addItem(3360); model.addItem(3250 Music Ed); model.addItem(1202); model.addItem(1662); model.addItem(2700); model.addItem(2100); model.addItem(2626); model.addItem(2200); model.addItem(3230); model.addItem(5233 Touch Screen); model.addItem(5800 XpressMusic); model.addItem(5530 Touch Screen); model.addItem(5630 XpressMusic); model.addItem(5130 XpressMusic); model.addItem(6710 Navigator); model.addItem(6700); model.addItem(6760 Slider); model.addItem(6070); model.addItem(6600 Slider);

S.I.M.S INDORE

134

ELECTROMART ANALYSIS USING DATAMINING

model.addItem(6303 Classic); model.addItem(6500); model.addItem(6300); model.addItem(6220); model.addItem(7020 Flip); model.addItem(8800 Sircco); model.addItem(9300i Communicator); model.addItem(E63 QWERTY Mobile); model.addItem(E71x); model.addItem(E72 scratchless); } } if(i==9) { if(j==0) { model.addItem(USB Tv Tuner); model.addItem(Hybrid pro stick 330E); } if(j==1) { model.addItem(USB tv Tuner ); model.addItem(AVER TV Volar); model.addItem(AVER TV Speedy); } if(j==2) { model.addItem(Hybdir Pro Stick); } if(j==3) { model.addItem(EXT XOMBO TV Tuner BOX); } if(j==4) { model.addItem(DAPIC MOBILE MPEG4); } if(j==5) { model.addItem(VideoMate Action USB 2.0); } if(j==6) { model.addItem(USB TV Tuner);

S.I.M.S INDORE

135

ELECTROMART ANALYSIS USING DATAMINING

model.addItem(LCD T-Vision); } if(j==7) { model.addItem(USB TV Tuner for LCD); } if(j==8) { model.addItem(Internal TV Video Capture); } if(j==9) { model.addItem(Screen Play TV Link); } } if(i==10) { switch(j) { case 0: model.addItem(PMX60 Neckband Music ); model.addItem(Classic Line MX 460 ); break; case 1: model.addItem(E3 Amplifier for Bass Heads); model.addItem(Headphone Amplifier E5 - E 5 ); break; case 2: model.addItem(Monitor Headphones MDR-EX35LP); model.addItem(In-Ear Headphones Twin Turbo MDR-ED12LP); break; case 3: model.addItem(HS-62 Stereo Headset HS62 ); model.addItem(3.5 mm Headphone HS-62); break; case 4: model.addItem(Thunder Superior Headphone); model.addItem(Buzz Head Phones); break; case 5: model.addItem(Multimedia Head Phone with mic); model.addItem(i675MV Multimedia Back Headphone); break; case 6: model.addItem(Clear Stereo Headset); break;

S.I.M.S INDORE

136

ELECTROMART ANALYSIS USING DATAMINING

} } if(i==11) { switch(j) { case 0: model.addItem(MP3 MINI SPEAKER 4 MOBILES IPOD IPHONE M201); break; case 1: model.addItem(LS11 2.0 Stereo Speaker System ); model.addItem(Multimedia speakers R 5); model.addItem(R-5 Sleek shielded speakers w/t Headphone Jack); break; case 2: model.addItem(Tarang 2.1 Wood Speaker ); break; case 3: model.addItem(Bug Speaker for ipod,mp3/mp4 player); break; case 4: model.addItem(796 Bluetooth Wireless Stereo Speakers); break; case 5: model.addItem(Street Party lll +Ipod Speaker); break; case 6: model.addItem(Portable Stereo Capsule Speaker USB Charged); break; case 7: model.addItem( Lansing iM600 Portable Ipod Speakers); break; case 8: model.addItem( 5.1 T 6100 Multimedia Speakers Inspire T6100); break; case 9: model.addItem(SPA5200 USB Powered Clip-on Notebook Speakers); break; } } if(i==12) { switch(j) { case 0:

S.I.M.S INDORE

137

ELECTROMART ANALYSIS USING DATAMINING

model.addItem(4GB Kingston New Pen Drive 4 GB Pendrive); model.addItem(4 GB PENDRIVE PEN DRIVE 4GB THUMB FLASH USB); model.addItem(2 GB KINGSTON Micro SD pen drive); model.addItem(500 GB Pen Drive USB Flash Pendrive); break; case 1: model.addItem(4GB Pen Drive HP,Worlds Small Thin ); model.addItem(4GB Pen Drive HP,Cool Ice Design,Tiny ); model.addItem(8GB Pen Drive HP Branded,Super Slim Model); model.addItem(World Smallest HP V155w 4GB pendrive); model.addItem(HP Slim 4GB USB Flash Pen Drive Waterproof ); break; case 2: model.addItem( 8GB TRANSCEND USB 2.0 JETFLASH PEN FLASH DRIVE); break; case 3: model.addItem(SanDisk 16GB USB Drive); model.addItem(SanDisk 8GB USB Drive With 8 GB CZ50 Blade); model.addItem(4 GB SanDisk Cruzer Micro USB Drive ); break; } } if(i==13) { switch(j) { case 0: model.addItem(500GB Portable Hard Disk 500 GB 2.5\); model.addItem(320 GB (2.5\) Portable USB Powered Hard Disk); model.addItem(Portable 1.5TB USB Hard Disk Drive); model.addItem(2TB External USB 3.5\ HDD Hard Disk); break; case 1: model.addItem(Home Media Network Hard Disk Drive); model.addItem(Home Media Network Hard Disk Drive); model.addItem(UltraMax 2TB Desktop Hard Disk Drive); model.addItem(Prestige 500GB Desktop USB External Drive); break; case 2: model.addItem(1TB External Hard disk 1 TB WD 3.5\ 3YR); break; } }

S.I.M.S INDORE

138

ELECTROMART ANALYSIS USING DATAMINING

if(i==14) { switch(j) { case 0: model.addItem(12 Mega Pixel Web Cam Camera 12MP ); model.addItem(480K pixel night vision web cam 1.3 mega pixel); break; case 1: model.addItem(QuickCam E3500 Plus); model.addItem(QuickCam Pro 9000 WebCam); model.addItem(C-500 Webcam); model.addItem(QuickCam E3500 USB Webcam); break; case 2: model.addItem(CREATIVE VISTA IM WEBCAMERA); break; case 3: model.addItem(1.3M DESKTOP LAPTOP NOTEBOOK WEBCAM); break; case 4: model.addItem(FACE 2 FACE C8.0 WEB CAM); break; case 5: model.addItem(NOTEBOOK CAMERA NX3000 NX 3000-WEB CAM); break; case 6: model.addItem(2 MEGA PIXEL-MEGAPIXEL WEB CAM); break; } } if(i==15) { if(j==0) { model.addItem(CLASSIC 160GB 7th Gen BLACK ); model.addItem(NANO 8 GB VIDEO WITH CAMERA+FM -BLACK); model.addItem(Touch 64GB); } } } private void jButton1MouseClicked(java.awt.event.MouseEvent evt) { int cost=Integer.parseInt(cp.getText());

S.I.M.S INDORE

139

ELECTROMART ANALYSIS USING DATAMINING

String di=datein.getText(); String expd=expdate.getText(); int q=Integer.parseInt(qty.getText()); int min= Integer.parseInt(minimum.getText()); if(cost<0||di.length()!=8||expd.length()!=8||q<0||min<0) { JOptionPane.showMessageDialog(null,Please Enter ,Error,JOptionPane.ERROR_MESSAGE); }

the

values

properly

else { try{ Class.forName(com.mysql.jdbc.Driver); Connection connection = DriverManager.getConnection(jdbc:mysql://localhost:3306/datamining,root, root); ResultSet rs1; Statement stmt= connection.createStatement(); Statement statement= connection.createStatement(); Random rand=new Random(); float j,costprice; int k; j = rand.nextFloat(); k=rand.nextInt(10); j=j*10; String t,c,m; int p; t=(String)type.getSelectedItem(); c=(String)company.getSelectedItem(); m=(String)model.getSelectedItem(); p=Integer.parseInt(jTextField1.getText()); int price=Integer.parseInt(cp.getText()); costprice=price/((j/100)+1); String qr1; qr1=select count(model) from product where model=+m+; rs1=statement.executeQuery(qr1); rs1.next(); if(rs1.getInt(1)>=1) { JOptionPane.showMessageDialog(null,Product already ,Error,JOptionPane.ERROR_MESSAGE); }

Present

S.I.M.S INDORE

140

ELECTROMART ANALYSIS USING DATAMINING

else { stmt.executeUpdate(insert into product values(+p+,+t+,+c+,+m+)); //stmt.executeUpdate(insert into prices values (+p+,+costprice+,+price+,+0+,+j+,+(k+price)+)); String name; //name=company.getSelectedItem()+ +model.getSelectedItem(); //statement.executeUpdate(insert into stock values (+p+,+name+,+Integer.parseInt(di)+,+Integer.parseInt(expd) +,+100+,+q+,+100+,+100+,+min+)); JOptionPane.showMessageDialog(null,Product Insreted ,Information,JOptionPane.INFORMATION_MESSAGE); add a = new add(); a.setVisible(true); this.setVisible(false); } } catch(Exception e) { cp.setText(e.toString()); } } } private void jButton3MouseClicked(java.awt.event.MouseEvent evt) { ModuleSelect ms= new ModuleSelect(); ms.setVisible(true); this.setVisible(false); } private void cpMouseExited(java.awt.event.MouseEvent evt) { // TODO add your handling code here: } private void cpFocusLost(java.awt.event.FocusEvent evt) { } private void typeActionPerformed(java.awt.event.ActionEvent evt) { int i; company.removeAllItems();

S.I.M.S INDORE

141

ELECTROMART ANALYSIS USING DATAMINING

company.setSelectedIndex(-1); i=type.getSelectedIndex(); if( i==0) { company.addItem(Panasonic); company.addItem(Cannon); company.addItem(Flip); company.addItem(Nikon); } if( i==1) { company.addItem(Panasonic); company.addItem(Samsung); company.addItem(Viore); company.addItem(Toshiba); company.addItem(LG); company.addItem(Axion); company.addItem(Vizio); } if( i==2) { company.addItem(Panasonic); company.addItem(Sony); company.addItem(LG); company.addItem(Philips); } if( i==3) { company.addItem(Sony); company.addItem(Panasonic); company.addItem(Onkyo); company.addItem(Samsung); } if( i==4) { company.addItem(Apple); company.addItem(HP); company.addItem(Dell); company.addItem(Acer); } if( i==5)

S.I.M.S INDORE

142

ELECTROMART ANALYSIS USING DATAMINING

{ company.addItem(Dell); company.addItem(Sony); company.addItem(Gateway); company.addItem(Acer); } if( i==6) { company.addItem(Cannon); company.addItem(HP); } if( i==7) { company.addItem(Nokia); } if( i==9) { company.addItem(Pinnacle); company.addItem(Aver Media); company.addItem(PCTV); company.addItem(Ext Combo); company.addItem(Dapic Mobile); company.addItem(Compro); company.addItem(Umax); company.addItem(Techcom); company.addItem(Internal TV capture); company.addItem(Lomega); } if( i==10) { company.addItem(Sennheiser); company.addItem(FiiO); company.addItem(Sony); company.addItem(Nokia); company.addItem(Umax); company.addItem(iBall); company.addItem(Logitech); } if( i==11) { company.addItem(EGG); company.addItem(Logitech);

S.I.M.S INDORE

143

ELECTROMART ANALYSIS USING DATAMINING

company.addItem(iBall); company.addItem(Bug Speaker); company.addItem(Jabra); company.addItem(Gear4); company.addItem(X-Mini); company.addItem(Altec); company.addItem(Creative); company.addItem(Philips); } if( i==12) { company.addItem(Kingston); company.addItem(HP); company.addItem(Transcend); company.addItem(SanDisk); } if( i==13) { company.addItem(Segate); company.addItem(iOmega); company.addItem(Western Digital); } if( i==14) { company.addItem(Quantum); company.addItem(Logitech); company.addItem(Creative Vista); company.addItem(Mercury); company.addItem(iBall); company.addItem(Microsoft); company.addItem(Frontech); } if( i==15) { company.addItem(Apple); } // TODO add your handling code here: } /** @param args the command line arguments */ public static void main(String args[]) {

// TODO add your handling code here:

S.I.M.S INDORE

144

ELECTROMART ANALYSIS USING DATAMINING

java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new add().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.border.BevelBorder bevelBorder1; private javax.swing.JComboBox company; private javax.swing.JTextField cp; private javax.swing.JTextField datein; private javax.swing.JTextField expdate; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JTextField jTextField1 private javax.swing.JTextField minimum; private javax.swing.JComboBox model; private javax.swing.JTextField qty; private javax.swing.JComboBox type; // End of variables declaration}

S.I.M.S INDORE

145

ELECTROMART ANALYSIS USING DATAMINING

SCREENSHOTS

11. Screenshots

1 Main Login Page

2. Module select

S.I.M.S INDORE

146

ELECTROMART ANALYSIS USING DATAMINING

3.Add product

S.I.M.S INDORE

147

ELECTROMART ANALYSIS USING DATAMINING

3. Selling Price Determination

S.I.M.S INDORE

148

ELECTROMART ANALYSIS USING DATAMINING

4. Sales trend

S.I.M.S INDORE

149

ELECTROMART ANALYSIS USING DATAMINING

5. Buying Module

S.I.M.S INDORE

150

ELECTROMART ANALYSIS USING DATAMINING

S.I.M.S INDORE

151

ELECTROMART ANALYSIS USING DATAMINING

6. Offer Module

S.I.M.S INDORE

152

ELECTROMART ANALYSIS USING DATAMINING

7. Billing Module

S.I.M.S INDORE

153

ELECTROMART ANALYSIS USING DATAMINING

S.I.M.S INDORE

154

ELECTROMART ANALYSIS USING DATAMINING

S.I.M.S INDORE

155

You might also like