Вы находитесь на странице: 1из 135

Department of Computer Science technology Doaba Institute of Engineering and Technology

ACKNOWLEDGEMENT

I am highly grateful to Doaba Institute of Engineering and technology, for providing this opportunity to carry out the six week industrial training at NICT, Chandigarh. The constant technical guidance and encouragement received from Mr. Lalit Bansal, Head of IT Department, DIET has been of great help in carrying out the project work and is acknowledged with reverential thanks. I would also like to express a deep sense of gratitude and thanks profusely to Ms. Neha Arora, Project Incharge at NICT. Without her wise counsel and able guidance, it would have been impossible to complete the report in this manner. The help rendered by her, for her continuous guidance during experimentation and completion of the report is greatly acknowledged.

I would also like to express a deep sense of gratitude to other faculty members of Computer Science & Engineering department of DIET for their intellectual support throughout the course of this work. I am highly thankful to my friends for their constant help which has been source of great encouragement to me. .

CONTENTS
1. Introduction to Project. 4 Theme of Project. .4 Basic idea of project. ..4 Requirements. .4

2. Introduction to Software development latency. .5

3. Analysis Phase7 Functionality7 Special Feature8 Glimpses of Database9 Software Screenshots19

4. Design Phase.26 Entity Relationship..26 Linking Interface 27

5. Coding Phase29

Concepts used in Coding 211 6. Testing Phase.212

7. Bibliography 218

INTRODUCTION TO PROJECT This Inventory system software is a Client Based Software and not Generic as we have developed this software for New City Driving School and have taken prior permission from Mr. Yuvraj Singh the proud owner of the company which deals in product mangemnt .it has ben particularly designed to satisfy all the demands of our client.

Theme and Basic Idea Of Project


We have made this software keeping all the general problems that might have to be faced by the owner, So the Theme of the software is to make the register work go away and bring Information technology into common mans world.we have taken up a task in this software as to bring comfort and technology to the places where it is yet to reach. The software is mainly focusing on making life of owner very easy and comfortable by making every thing digital and on the click of button.we have put in alarms, reminders and timers for making life a bit easier. COMPETITION:- the competition in the market is cutr throught and in that scenario trying to hold on to data on pages and store them for years is way more hectic then it sounds. REQUIREMENTS:we were asked by our client to provide a set of features that are our softwares main requiremenst and essential for us to provide theya re as follows:1) REMINDERS 2) DATABASE ACCESS 3) AUTOMATIC UPDATE FEATURE 4) DAILY SCHEDULE OF INSTRUCTORS 5) REGULAR RECORD OF INSTRUCTOR

OBJECTIVE:The objective of our software is the complete satisfaction of our client and clear all the requirements that he asks for. And this is for the business prespective but socially we just want to bring ease and comfort to the life of those who are still stuck in the pile of papers and covered in spots of ink. We choose this project with a reason to bring IT in a field where it has not yet reached in India and so we found in case of Driving Schools where as the Business is low scaled the need of portability and technology is not given importance so we decided to change it and this is our Objective for this software ever sisnce just trying to bring change to the world.

INTRODUCTION TO SDLC
Software development life cycle (SDLC) as name suggests is a set of some pre specified steps that are followed while software development and it consists of some phases that are followed and they are as follows:-

Fig. software development phases/steps Steps of SDLC are:1) ANALYSIS:- At this stage we analyze the problem for which we are developing the software and try to see all the requirements that we will have to satisfy in order to reach a to a understanding of the scope of the software that is under production. This gives us the view of what are the things to be kept in mind while programming so that we have a actual idea of what the user desires from the software and what else can be done to make it better and provide it a more comfortable environment for the user. 2) DESIGN:- Now, in this step we design the outlook of the software that how it will appear like the frames that will be seen by the user. We can say that we basically make a interface

between the user and the coding that makes it easier for the user to work using the program without having the burden to face the codes and be scared. This phase is also a step of decision making where we decide the features we will have in our software and make its design to have a idea how the software will work and proceed.
3) IMPLEMENTATION:- In this step we have the base of the software. Here we do the

coding now in this step its very essential to be very logical cover up any exceptions and any error that might come up. By now we have a clear view of what we want the software to do and how it should look so we start with the coding to make that design come together into a single working collection of programs we call software.

Fig. waterfall model (a methodology of software development)


4) TESTING/VERIFICATION:- Now as the name suggests this step is the verification of

whatever we have done yet to see if everything is working fine and for this we do testing where we use test suite to see how our software reacts to situations quite similar to practical scenarios. Test suite is a collection of test cases focusing on different sections of software . Test cases are actually the values or conditions which are used to test the critical areas or break points of software to see if those critical codes or sections cause any error or give expected values. Here we make list of test cases and their theoretical answers that we expect the software to show then we see the actual values and then see what can be done to remove the difference between the expected and actual values.

5) MAINTANENCE:- This is the last step where we actually take care of the installation and

acceptance of the software, this is very important that the software is satisfying all the test cases prerequisite to acceptance of software by customer. So this step basically includes the acceptance by customer and then installation of software to the customers server or system and then any suitable promise or agreement or maintanence for a specific time period that was promised before. So as explained above software development life cycle (SDLC) is a complete life of software from an idea in someones mind to a fully fledged software making lives easier.and it has many forms and methodology like ITERATION MODEL, WA

ANALYSIS PHASE
This phase contain the planning for the software of Billing software for optical showroom in this document we discuss about how we are making the software and what are our requirement. Also see screen shot for our future software that how it looks when software is complete. see below there is figure which shows how our software will start.

FUNCTIONALITY
The given below list is of the set of functionalities that the software is to provide to the client. And some of these are given as a requirement by the client; few have been added as extra features by us. These features have been strictly added by the consent of the client and again this software is client dependent and not generic.

FUNCTIONALITIES REQUESTED BY THE CLIENT


1) SCHEDULING: This feature allows the client to manage the schedule of

the driving classes and maintaining the schedule of drivers so that the drivers can have their schedule from the software every day and keep up with any change that is fed to the software by the owner of the driving school.
2) CUSTOMER PERSONEL INFO: here we have been asked toadd this

feature giving the administrator of the software to store the personal information of the customer like phone no., house address, payment received or not and the number of classes that have been attended and so on.

3) CERTIFICATE DATE: this is a feature where we can check when is the

date of the certificate giving to a customer after the completion of the course.

GLIMPSE OF THE SOFTWARE


DATABASE SCREENSHOTS
1. Customer Detail

` 2. Supplier details

3. SalesRep Master

4. Warehouse Detail

SOFTWARE SCREENSHOTS

1. Main page

2. Coustomer

3. Add new details of coustomer

4. Supplier

5. Warehouse

6. Sales representives

DESIGN PHASE
ENTITY RELATIONSHIP DIAGRAM:
An entity-relationship (ER) diagram is a specialized graphic that illustrates the interrelationships between entities in a database. ER diagrams often use symbols to represent three different types of information. Boxes are commonly used to represent entities. Diamonds are normally used to represent relationships and ovals are used to represent attributes. Also Known As: ER Diagram, E-R Diagram, entity-relationship model Due to the size constraint we have stapled the E-R diagram to the next page as it is in A-3 page size.

LINKING :
Microsoft SQL Server 2008: Microsoft SQL Server 2008 is a full-featured relational database management system (RDBMS) that offers a variety of

administrative tools to ease the burdens of database development, maintenance and administration. In this article, we'll cover six of the more frequently used tools: Enterprise Manager, Query Analyzer, SQL Profiler, Service Manager, Data Transformation Services and Books Online.

2.6.1

Components:

Enterprise Manager: It is the main administrative console for SQL Server installations. It provides you with a graphical "birdseye" view of all of the SQL Server installations on your network. You can perform high-level administrative functions that affect one or more servers, schedule common maintenance tasks or create and modify the structure of individual databases. Query Analyzer: It offers a quick and dirty method for performing queries against any of your SQL Server databases. It's a great way to quickly pull information out of a database in response to a user request, test queries before implementing them in other applications, create/modify stored procedures and execute administrative tasks. SQL Profiler: It provides a window into the inner workings of your database. You can monitor many different event types and observe database performance in real time. SQL Profiler allows you to capture and replay system "traces" that log various activities. It's a great tool for optimizing databases with performance issues or troubleshooting particular problems. Service Manager: It is used to control the MSSQLServer (the main SQL Server process), MSDTC (Microsoft Distributed Transaction Coordinator) and SQLServerAgent processes. An icon for this service normally resides in the system tray of machines running SQL Server. You can use Service Manager to start, stop or pause any one of these services. Data Transformation Services (DTS): provide an extremely flexible method for importing and exporting data between a Microsoft SQL Server installation and a large variety of other formats. The most commonly used DTS application is the "Import and Export Data" wizard found in the SQL Server program group. 2.6.2. Features: User-Defined Functions: SQL Server 2008 introduces the longawaited support for user-defined functions. User-defined functions

can take zero or more input parameters and return a single value either a scalar value like the system-defined functions, or a table result. Table-valued functions can be used anywhere table or view expressions can be used in queries, and they can perform more complex logic than is allowed in a view. 2.6.2.2. Indexed Views: Views are often used to simplify complex queries, and they can contain joins and aggregate functions. In SQL Server 2008 Enterprise or Developer Edition, you can define indexes on views to improve query performance against the view. When creating an index on a view, the result set of the view is stored and indexed in the database. Existing applications can take advantage of the performance improvements without needing to be modified. Indexed views can improve performance for the following types of queries: 1. Joins and aggregations that process many rows 2. Join and aggregation operations that are performed frequently within many queries 2.6.2.3. Distributed Partitioned Views: SQL Server 2008 expands the ability to create partitioned views by allowing you to horizontally partition tables across multiple SQL Servers. The feature helps you scale out one database server to multiple database servers, while making the data appear as if it comes from a single table on a single SQL Server. In addition, partitioned views are now able to be updated. 2.6.2.4. New Data types: SQL Server 2008 introduces three new data types. Two of these can be used as data types for local variables, stored procedure parameters and return values, userdefined function parameters and return values, or table columns: 2.6.2.5. Text in Row Data: SQL Server 2008 provides a new text in row table option that allows small text and image data values to be placed directly in the data row, instead of requiring a separate data page. This can reduce the amount of space required to store small text and image data values, as well as reduce the amount of I/O required to retrieve rows containing small text and image data values. 2.6.2.6. Cascading RI Constraints: SQL Server 2008 provides the ability to specify the action to take when a column referenced by a foreign key constraint is updated or deleted. You can still

abort the update or delete if related foreign key records exist by specifying the NO ACTION option, or you can specify the new CASCADE option, which will cascade the update or delete operation to the related foreign key records. Multiple SQL Server Instances: SQL Server 2008 provides support for running multiple instances of SQL Server on the same system. This allows you to simultaneously run one instance of SQL Server 6.5 or 7.0 along with one or more instances of SQL Server 2008. Each SQL Server instance runs independently of the others and has its own set of system and user databases, security configuration, and so on. Applications can connect to the different instances in the same way they connect to different SQL Servers on different machines.

CODING PHASE
In this phase we will explain the coding part of our software that how we have linked the frame with the database:

Main form:
import import import import import import import import javax.swing.*; javax.swing.plaf.metal.*; javax.swing.border.*; java.awt.*; java.awt.event.*; java.util.*; java.beans.*; java.sql.*;

/* import com.incors.plaf.*; import com.incors.plaf.kunststoff.*; import com.incors.plaf.kunststoff.themes.*; */ public class MainForm extends JFrame implements WindowListener{ /************************ Variable declaration start **********************/ //The form container variable

JPanel Panel1; JDesktopPane Desk1 = new JDesktopPane(); JLabel StatusLabel = new JLabel("Copyright 2004 by Philip V. Naparan. All Rights Reserved. Visit http://www.naparansoft.cjb.net.",JLabel.CENTER); JLabel BusinessTitleLabel = new JLabel(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();

String StrBusinesTitle; String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver"; String DBSource = "jdbc:odbc:NaparansoftInventory"; String DBUserName = "Admin"; String DBPassword = "philip121"; Connection CN; //--Start variable the contains forms FrmCustomer FormCustomer; FrmSupplier FormSupplier; FrmSalesRep FormSalesRep; FrmWarehouse FormWarehouse; FrmProduct FormProduct; FrmInvoice FormInvoice; FrmSplash FormSplash = new FrmSplash(); //--End variable the contains forms Thread ThFormSplash = new Thread(FormSplash); //End the form container variable /********************** End variable declaration start ********************/ /************************ MainForm constructor start **********************/ public MainForm(){ //Set the main form title super("Naparansoft Inventory System version 1.1"); //End set the main form title loadSplashScreen(); //We will dispose now the FormSplash because it is now useless FormSplash.dispose(); //StatusLabel.setBorder(BorderFactory.createTitledBorder("")); StatusLabel.setFont(new Font("Dialog", Font.PLAIN, 12));

StrBusinesTitle = "Your Business Name"; BusinessTitleLabel.setText(StrBusinesTitle); BusinessTitleLabel.setHorizontalAlignment(JLabel.LEFT); BusinessTitleLabel.setForeground(new Color(166,0,0)); //Set the main form properties addWindowListener(this); Desk1.setBackground(Color.gray); Desk1.setBorder(BorderFactory.createEmptyBorder()); //Most fastest drag mode Desk1.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); Panel1 = new JPanel(new BorderLayout()); Panel1.setBackground(Color.gray); Panel1.setBorder(BorderFactory.createLoweredBevelBorder()); Panel1.add(new JScrollPane(Desk1),BorderLayout.CENTER); getContentPane().add(CreateJToolBar(),BorderLayout.PAGE_START); getContentPane().add(Panel1,BorderLayout.CENTER); getContentPane().add(StatusLabel,BorderLayout.PAGE_END); setJMenuBar(CreateJMenuBar()); setExtendedState(this.MAXIMIZED_BOTH); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setIconImage(new ImageIcon("images/appicon.png").getImage()); setLocation(0,0); setSize(screen); setResizable(true); setVisible(true); show(); try{ Class.forName(DBDriver); CN = DriverManager.getConnection(DBSource,DBUserName ,DBPassword); }catch(ClassNotFoundException e) { System.err.println("Failed to load driver"); e.printStackTrace(); System.exit(1); } catch(SQLException e){ System.err.println("Unable to connect"); e.printStackTrace(); System.exit(1); } //End set the main form properties

} /********************** End MainForm constructor start ********************/ /*********************** Custom class creation start **********************/ //Create menu bar protected JMenuBar CreateJMenuBar(){ JMenuBar NewJMenuBar = new JMenuBar(); //Setup file menu JMenu MnuFile = new JMenu("File"); MnuFile.setFont(new Font("Dialog", Font.PLAIN, 12)); MnuFile.setMnemonic('F'); MnuFile.setBackground(new Color(255,255,255)); NewJMenuBar.add(MnuFile); //End setup file menu //Set file sub menu JMenuItem ItmLockApp = new JMenuItem("lock Application"); ItmLockApp.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmLockApp.setMnemonic('L'); ItmLockApp.setIcon(new ImageIcon("images/lockapplication.png")); ItmLockApp.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_L,ActionEvent.CTRL_MASK ) ); ItmLockApp.setActionCommand("lockapp"); ItmLockApp.addActionListener(JMenuActionListener); ItmLockApp.setBackground(new Color(255,255,255)); JMenuItem ItmLoggOff = new JMenuItem("Logg Off"); ItmLoggOff.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmLoggOff.setMnemonic('O'); ItmLoggOff.setIcon(new ImageIcon("images/loggoff.png")); ItmLoggOff.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_O,ActionEvent.CTRL_MASK ) ); ItmLoggOff.setActionCommand("loggoff"); ItmLoggOff.addActionListener(JMenuActionListener); ItmLoggOff.setBackground(new Color(255,255,255)); JMenuItem ItmExit = new JMenuItem("Exit"); ItmExit.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmExit.setMnemonic('E'); ItmExit.setIcon(new ImageIcon("images/exit.png"));

ItmExit.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_E,ActionEvent.CTRL_MASK ) ); ItmExit.setActionCommand("exit"); ItmExit.addActionListener(JMenuActionListener); ItmExit.setBackground(new Color(255,255,255)); MnuFile.add(ItmLockApp); MnuFile.addSeparator(); MnuFile.add(ItmLoggOff); MnuFile.add(ItmExit); //End set file sub menu //Setup records menu JMenu MnuRec = new JMenu("Records"); MnuRec.setFont(new Font("Dialog", Font.PLAIN, 12)); MnuRec.setMnemonic('R'); MnuRec.setBackground(new Color(255,255,255)); NewJMenuBar.add(MnuRec); //End records menu //Set records sub menu //-- For Customer JMenuItem ItmCustomer = new JMenuItem("Customers"); ItmCustomer.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmCustomer.setMnemonic('C'); ItmCustomer.setIcon(new ImageIcon("images/customer.png")); ItmCustomer.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_C,ActionEvent.CTRL_MASK ) ); ItmCustomer.setActionCommand("cus"); ItmCustomer.addActionListener(JMenuActionListener); ItmCustomer.setBackground(new Color(255,255,255)); MnuRec.add(ItmCustomer); //-- For Supplier JMenuItem ItmSupplier = new JMenuItem("Suppliers"); ItmSupplier.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmSupplier.setMnemonic('S'); ItmSupplier.setIcon(new ImageIcon("images/supplier.png")); ItmSupplier.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_S,ActionEvent.CTRL_MASK )

); ItmSupplier.setActionCommand("sup"); ItmSupplier.addActionListener(JMenuActionListener); ItmSupplier.setBackground(new Color(255,255,255)); MnuRec.add(ItmSupplier); //-- For SalesRep JMenuItem ItmSalesRep = new JMenuItem("SalesRep"); ItmSalesRep.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmSalesRep.setMnemonic('R'); ItmSalesRep.setIcon(new ImageIcon("images/SalesRep.png")); ItmSalesRep.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_B,ActionEvent.CTRL_MASK ) ); ItmSalesRep.setActionCommand("bran"); ItmSalesRep.addActionListener(JMenuActionListener); ItmSalesRep.setBackground(new Color(255,255,255)); MnuRec.add(ItmSalesRep); //-- For Warehouse JMenuItem ItmWarehouse = new JMenuItem("Warehouse"); ItmWarehouse.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmWarehouse.setMnemonic('W'); ItmWarehouse.setIcon(new ImageIcon("images/Warehouse.png")); ItmWarehouse.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_B,ActionEvent.CTRL_MASK ) ); ItmWarehouse.setActionCommand("wareh"); ItmWarehouse.addActionListener(JMenuActionListener); ItmWarehouse.setBackground(new Color(255,255,255)); MnuRec.add(ItmWarehouse); MnuRec.addSeparator(); //-- For Products JMenuItem ItmProduct = new JMenuItem("Products"); ItmProduct.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmProduct.setMnemonic('P'); ItmProduct.setIcon(new ImageIcon("images/product.png")); ItmProduct.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_P,ActionEvent.CTRL_MASK )

); ItmProduct.setActionCommand("prod"); ItmProduct.addActionListener(JMenuActionListener); ItmProduct.setBackground(new Color(255,255,255)); MnuRec.add(ItmProduct); //-- For Categories JMenuItem ItmCategory = new JMenuItem("Categories"); ItmCategory.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmCategory.setMnemonic('T'); ItmCategory.setIcon(new ImageIcon("images/categories.png")); ItmCategory.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_T,ActionEvent.CTRL_MASK ) ); ItmCategory.setActionCommand("cat"); ItmCategory.addActionListener(JMenuActionListener); ItmCategory.setBackground(new Color(255,255,255)); MnuRec.add(ItmCategory); //-- For Stock Adjustment JMenuItem ItmStockAdj = new JMenuItem("Stock Adjustment"); ItmStockAdj.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmStockAdj.setMnemonic('A'); ItmStockAdj.setIcon(new ImageIcon("images/adjustment.png")); ItmStockAdj.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_A,ActionEvent.CTRL_MASK ) ); ItmStockAdj.setActionCommand("stockadj"); ItmStockAdj.addActionListener(JMenuActionListener); ItmStockAdj.setBackground(new Color(255,255,255)); MnuRec.add(ItmStockAdj); MnuRec.addSeparator(); //-- For Invoices JMenuItem ItmInv = new JMenuItem("Invoices"); ItmInv.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmInv.setMnemonic('I'); ItmInv.setIcon(new ImageIcon("images/invoice.png")); ItmInv.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_I,ActionEvent.CTRL_MASK ) );

ItmInv.setActionCommand("invoice"); ItmInv.addActionListener(JMenuActionListener); ItmInv.setBackground(new Color(255,255,255)); MnuRec.add(ItmInv); //-- For Purchase Orders JMenuItem ItmPO = new JMenuItem("Purchase Orders"); ItmPO.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmPO.setMnemonic('O'); ItmPO.setIcon(new ImageIcon("images/purchaseorder.png")); ItmPO.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_O,ActionEvent.CTRL_MASK ) ); ItmPO.setActionCommand("PO"); ItmPO.addActionListener(JMenuActionListener); ItmPO.setBackground(new Color(255,255,255)); MnuRec.add(ItmPO); //-- For Purchase Receipt JMenuItem ItmRecieve = new JMenuItem("Purchase Receipt"); ItmRecieve.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmRecieve.setMnemonic('R'); ItmRecieve.setIcon(new ImageIcon("images/recieve.png")); ItmRecieve.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_R,ActionEvent.CTRL_MASK ) ); ItmRecieve.setActionCommand("preceipt"); ItmRecieve.addActionListener(JMenuActionListener); ItmRecieve.setBackground(new Color(255,255,255)); MnuRec.add(ItmRecieve); //-- For Expenses JMenuItem ItmExpense = new JMenuItem("Expenses"); ItmExpense.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmExpense.setMnemonic('E'); ItmExpense.setIcon(new ImageIcon("images/expense.png")); ItmExpense.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_E,ActionEvent.CTRL_MASK ) ); ItmExpense.setActionCommand("expense"); ItmExpense.addActionListener(JMenuActionListener);

ItmExpense.setBackground(new Color(255,255,255)); MnuRec.add(ItmExpense); //End records sub menu //Setup proccess menu JMenu MnuProccess = new JMenu("Proccess"); MnuProccess.setFont(new Font("Dialog", Font.PLAIN, 12)); MnuProccess.setMnemonic('P'); MnuProccess.setBackground(new Color(255,255,255)); NewJMenuBar.add(MnuProccess); //End records menu //Set proccess sub menu //-- For New Invoice JMenuItem ItmNewInv = new JMenuItem("New Invoice"); ItmNewInv.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmNewInv.setMnemonic('I'); ItmNewInv.setIcon(new ImageIcon("images/newinvoice.png")); ItmNewInv.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_F1,ActionEvent.CTRL_MASK ) ); ItmNewInv.setActionCommand("newinv"); ItmNewInv.addActionListener(JMenuActionListener); ItmNewInv.setBackground(new Color(255,255,255)); MnuProccess.add(ItmNewInv); //-- For New PO JMenuItem ItmNewPO = new JMenuItem("New Purchase Order"); ItmNewPO.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmNewPO.setMnemonic('P'); ItmNewPO.setIcon(new ImageIcon("images/newpurchaseorder.png")); ItmNewPO.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_F2,ActionEvent.CTRL_MASK ) ); ItmNewPO.setActionCommand("newPO"); ItmNewPO.addActionListener(JMenuActionListener); ItmNewPO.setBackground(new Color(255,255,255)); MnuProccess.add(ItmNewPO); //-- For New Purchase Receipt

JMenuItem ItmNewRecieve = new JMenuItem("New Purchase Receipt"); ItmNewRecieve.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmNewRecieve.setMnemonic('E'); ItmNewRecieve.setIcon(new ImageIcon("images/newrecieve.png")); ItmNewRecieve.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_F4,ActionEvent.CTRL_MASK ) ); ItmNewRecieve.setActionCommand("newpreceipt"); ItmNewRecieve.addActionListener(JMenuActionListener); ItmNewRecieve.setBackground(new Color(255,255,255)); MnuProccess.add(ItmNewRecieve); //-- For New Expenses JMenuItem ItmNewExpense = new JMenuItem("New Expense"); ItmNewExpense.setFont(new Font("Dialog", Font.PLAIN, 12)); ItmNewExpense.setMnemonic('E'); ItmNewExpense.setIcon(new ImageIcon("images/newexpense.png")); ItmNewExpense.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_F3,ActionEvent.CTRL_MASK ) ); ItmNewExpense.setActionCommand("newexpense"); ItmNewExpense.addActionListener(JMenuActionListener); ItmNewExpense.setBackground(new Color(255,255,255)); MnuProccess.add(ItmNewExpense); //End proccess sub menu //Setup reports menu JMenu MnuRpt = new JMenu("Reports"); MnuRpt.setFont(new Font("Dialog", Font.PLAIN, 12)); MnuRpt.setMnemonic('t'); MnuRpt.setBackground(new Color(255,255,255)); NewJMenuBar.add(MnuRpt); //End records menu //Setup system menu JMenu MnuSys = new JMenu("System"); MnuSys.setFont(new Font("Dialog", Font.PLAIN, 12)); MnuSys.setMnemonic('S'); MnuSys.setBackground(new Color(255,255,255)); NewJMenuBar.add(MnuSys);

//End records menu //Setup window menu JMenu MnuWin = new JMenu("Window"); MnuWin.setFont(new Font("Dialog", Font.PLAIN, 12)); MnuWin.setMnemonic('W'); MnuWin.setBackground(new Color(255,255,255)); NewJMenuBar.add(MnuWin); //End records menu //Setup help menu JMenu MnuHelp = new JMenu("Help"); MnuHelp.setFont(new Font("Dialog", Font.PLAIN, 12)); MnuHelp.setMnemonic('H'); MnuHelp.setBackground(new Color(255,255,255)); NewJMenuBar.add(MnuHelp); //End records menu NewJMenuBar.setBackground(new Color(255,255,255)); return NewJMenuBar; } //End create menu bar //Create a tool bar protected JToolBar CreateJToolBar (){ JToolBar NewJToolBar = new JToolBar("Toolbar"); NewJToolBar.setMargin(new Insets(0,0,0,0)); //Create a toolbar button NewJToolBar.add(CreateJToolbarButton("Customers Record","images/customer.png","toolCus")); NewJToolBar.add(CreateJToolbarButton("Suppliers Record","images/supplier.png","toolSup")); NewJToolBar.add(CreateJToolbarButton("SalesRep Record","images/SalesRep.png","toolSalesrep")); NewJToolBar.add(CreateJToolbarButton("Warehouse Record","images/Warehouse.png","toolWareh")); NewJToolBar.addSeparator(); NewJToolBar.add(CreateJToolbarButton("Products Record","images/product.png","toolProd")); NewJToolBar.add(CreateJToolbarButton("Categories Record","images/categories.png","toolCat")); NewJToolBar.add(CreateJToolbarButton("Stock Adjustment Record","images/adjustment.png","toolStockAdj")); NewJToolBar.addSeparator(); NewJToolBar.add(CreateJToolbarButton("Invoices Record","images/invoice.png","toolInv")); NewJToolBar.add(CreateJToolbarButton("Purchase Orders Record","images/purchaseorder.png","toolPur"));

NewJToolBar.add(CreateJToolbarButton("Purchase Receipt Record","images/recieve.png","toolRecieve")); NewJToolBar.add(CreateJToolbarButton("Expenses Record","images/expense.png","toolExpense")); NewJToolBar.addSeparator(); NewJToolBar.add(CreateJToolbarButton("New Invoice","images/newinvoice.png","toolNewInv")); NewJToolBar.add(CreateJToolbarButton("New Purchase Order","images/newpurchaseorder.png","toolNewPur")); NewJToolBar.add(CreateJToolbarButton("New Purchase Receipt","images/newrecieve.png","toolNewRecieveStock")); NewJToolBar.add(CreateJToolbarButton("New Expense","images/newexpense.png","toolNewExpense")); NewJToolBar.addSeparator(); NewJToolBar.add(CreateJToolbarButton("Business Setup","images/businesssetup.png","toolBussSet")); NewJToolBar.add(CreateJToolbarButton("Security Option","images/security.png","toolSecOpt")); NewJToolBar.add(CreateJToolbarButton("Lock Application","images/lockapplication.png","toolLockApp")); NewJToolBar.addSeparator(); NewJToolBar.add(BusinessTitleLabel); NewJToolBar.addSeparator(); //End create a toolbar button return NewJToolBar; } //End create a tool bar protected JButton CreateJToolbarButton(String srcToolTipText,String srcImageLocation,String srcActionCommand){ JButton NewJButton = new JButton(new ImageIcon(srcImageLocation)); NewJButton.setActionCommand(srcActionCommand); NewJButton.setToolTipText(srcToolTipText); NewJButton.addActionListener(JToolBarActionListener); return NewJButton; } /********************* End custom class creation start ********************/ /********************** Method for loading form start *********************/ //Create customer form protected void loadCustomerForm() throws SQLException{ //Verify if the form is already loaded boolean AlreadyLoaded = isLoaded("Customer Records"); if(AlreadyLoaded==false){

FormCustomer = new FrmCustomer(CN,this); Desk1.add(FormCustomer); //Load the FormCustomer FormCustomer.setVisible(true); FormCustomer.show(); try{ FormCustomer.setIcon(false); FormCustomer.setSelected(true); }catch(PropertyVetoException e){ } //End load the FormCustomer }else{ try{ FormCustomer.setIcon(false); FormCustomer.setSelected(true); }catch(PropertyVetoException e){ } } //End verify if the form is already loaded } //End create customer from //Create supplier form protected void loadSupplierForm() throws SQLException{ //Verify if the form is already loaded boolean AlreadyLoaded = isLoaded("Supplier Records"); if(AlreadyLoaded==false){ FormSupplier = new FrmSupplier(CN,this); Desk1.add(FormSupplier); //Load the FormSupplier FormSupplier.setVisible(true); FormSupplier.show(); try{ FormSupplier.setIcon(false); FormSupplier.setSelected(true); }catch(PropertyVetoException e){ } //End load the FormSupplier }else{ try{ FormSupplier.setIcon(false); FormSupplier.setSelected(true); }catch(PropertyVetoException e){ } } //End verify if the form is already loaded

} //End create supplier form //Create SalesRep form protected void loadSalesRepForm() throws SQLException{ //Verify if the form is already loaded boolean AlreadyLoaded = isLoaded("SalesRep Records"); if(AlreadyLoaded==false){ FormSalesRep = new FrmSalesRep(CN,this); Desk1.add(FormSalesRep); //Load the FormSalesRep FormSalesRep.setVisible(true); FormSalesRep.show(); try{ FormSalesRep.setIcon(false); FormSalesRep.setSelected(true); }catch(PropertyVetoException e){ } //End load the FormSalesRep }else{ try{ FormSalesRep.setIcon(false); FormSalesRep.setSelected(true); }catch(PropertyVetoException e){ } } //End verify if the form is already loaded } //End create SalesRep form //Create Warehouse form protected void loadWarehouseForm() throws SQLException{ //Verify if the form is already loaded boolean AlreadyLoaded = isLoaded("Warehouse Records"); if(AlreadyLoaded==false){ FormWarehouse = new FrmWarehouse(CN,this); Desk1.add(FormWarehouse); //Load the FormWarehouse FormWarehouse.setVisible(true); FormWarehouse.show(); try{ FormWarehouse.setIcon(false); FormWarehouse.setSelected(true); }catch(PropertyVetoException e){ } //End load the FormWarehouse }else{

try{ FormWarehouse.setIcon(false); FormWarehouse.setSelected(true); }catch(PropertyVetoException e){ } } //End verify if the form is already loaded } //End create Warehouse form //Create Product form protected void loadProductForm() throws SQLException{ //Verify if the form is already loaded boolean AlreadyLoaded = isLoaded("Product List"); if(AlreadyLoaded==false){ FormProduct = new FrmProduct(CN,this); Desk1.add(FormProduct); //Load the FormWarehouse FormProduct.setVisible(true); FormProduct.show(); try{ FormProduct.setIcon(false); FormProduct.setSelected(true); }catch(PropertyVetoException e){ } //End load the FormWarehouse }else{ try{ FormProduct.setIcon(false); FormProduct.setSelected(true); }catch(PropertyVetoException e){ } } //End verify if the form is already loaded } //End create Product form //End create Invoice form protected void loadInvoiceForm() throws SQLException{ //Verify if the form is already loaded boolean AlreadyLoaded = isLoaded("Invoice"); if(AlreadyLoaded==false){ FormInvoice = new FrmInvoice(); Desk1.add(FormInvoice); //Load the FormWarehouse FormInvoice.setVisible(true); FormInvoice.show(); try{

FormInvoice.setIcon(false); FormInvoice.setSelected(true); }catch(PropertyVetoException e){ } //End load the FormWarehouse }else{ try{ FormInvoice.setIcon(false); FormInvoice.setSelected(true); }catch(PropertyVetoException e){ } } //End verify if the form is already loaded } //End create Invoice form protected void loadSplashScreen(){ //Start the thread ThFormSplash.start(); while(!FormSplash.isShowing()){ try{ //Display the FormSplash for 10 seconds Thread.sleep(10000); }catch(InterruptedException e){ } } }

/******************** End method for loading form start *******************/ /************************** Event handling start **************************/ //Create action listener for JMenu ActionListener JMenuActionListener = new ActionListener(){ public void actionPerformed(ActionEvent e) { String srcObject = e.getActionCommand(); if(srcObject=="cus"){ try{ loadCustomerForm(); }catch(SQLException sqle){ } }else if(srcObject=="sup"){ try{ loadSupplierForm(); }catch(SQLException sqle){ } }else if(srcObject=="salesrep"){

try{ loadSalesRepForm(); }catch(SQLException sqle){ } }else if(srcObject=="wareh"){ try{ loadWarehouseForm(); }catch(SQLException sqle){ } }else if(srcObject=="loggoff"){ }else if(srcObject=="exit"){ UnloadWindow(); } } }; //End create action listener for JMenu //Create action Listerner for JToolBar Button ActionListener JToolBarActionListener = new ActionListener(){ public void actionPerformed(ActionEvent e) { String srcObject = e.getActionCommand(); if(srcObject=="toolCus"){ try{ loadCustomerForm(); }catch(SQLException sqle){ } }else if(srcObject=="toolSup"){ try{ loadSupplierForm(); }catch(SQLException sqle){ } }else if(srcObject=="toolSalesrep"){ try{ loadSalesRepForm(); }catch(SQLException sqle){ } }else if(srcObject=="toolWareh"){ try{ loadWarehouseForm(); }catch(SQLException sqle){ } }else if(srcObject=="toolProd"){ try{ loadProductForm(); }catch(SQLException sqle){ } } else if(srcObject=="toolInv"){ try{

loadInvoiceForm(); }catch(SQLException sqle){ } } } }; //End create action Listerner for JToolBar Button //Interface event from WindowListener start public void windowOpened(WindowEvent e){ } public void windowClosing(WindowEvent e){ UnloadWindow(); } public void windowClosed(WindowEvent e){ } public void windowIconified(WindowEvent e){ } public void windowDeiconified(WindowEvent e){ } public void windowActivated(WindowEvent e){ } public void windowDeactivated(WindowEvent e){ } //End interface event from WindowListener start /************************ End event handling start ************************/ /************************** Custom method start ***************************/ protected void UnloadWindow(){ String ObjButtons[] = {"Yes","No"}; int PromptResult = JOptionPane.showOptionDialog(null,"Are you sure you want to exit?","Naparansoft Inventory System",JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE,null,ObjBu ttons,ObjButtons[1]); if(PromptResult==0){ System.out.println( "\n\n" + " ------------------------------------------------------------\n\n" + " THANK YOU FOR USING NAPARANSOFT INVENTORY SYSTEM VERSION 1.1\n\n" + " ------------------------------------------------------------\n\n" + " Programmer: Philip V. Naparan\n" + " Address: Apo Sandawa Homes Phase 1 Block 6 Lot 18\n" + " City/Province: Kidapawan\n" + " Zip Code: 9400\n" + " Country: Philippines\n" + " Website: www.naparansoft.cjb.net\n" +

" " " " PINOY!\n" + www.pscode.com!\n" +

Email Address: philipnaparan@yahoo.com\n" + Contact No: 639186443161\n\n" + ------------------------------------------------------------\n" + ITOY 100% GAWANG PINOY! MABUHAY ANG MGA

" PLS. DONT FORGET TO VOTE THIS AT " ------------------------------------------------------------\n" + "\n\n" ); System.exit(0); } } protected boolean isLoaded(String FormTitle) { JInternalFrame Form[] = Desk1.getAllFrames(); for (int i = 0; i < Form.length; i++) { if (Form[i].getTitle().equalsIgnoreCase (FormTitle)) { Form[i].show (); try{ Form[i].setIcon(false); Form[i].setSelected(true); }catch(PropertyVetoException e){ } return true; } } return false; } protected void changeTheme(int sSelectedTheme){ if(sSelectedTheme == 1){ try { javax.swing.UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel"); JFrame.setDefaultLookAndFeelDecorated(true); } catch (Exception e) {} }else if(sSelectedTheme == 2){ //If Failed to load the liquid them then load my own XPStyleTheme MetalTheme myXPStyleTheme = new XPStyleTheme(); MetalLookAndFeel.setCurrentTheme(myXPStyleTheme); try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception err) {

System.out.println("Error loading myXPStyleTheme"); System.out.println(err); } } } /************************* End custom method end **************************/ /**************************** Main method start ***************************/ public static void main(String[] args){ try { javax.swing.UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndF eel"); } catch (Exception e) { System.out.println("Error Loading Theme:" + e.toString()); //If Failed to load the liquid them then load my own XPStyleTheme MetalTheme myXPStyleTheme = new XPStyleTheme(); MetalLookAndFeel.setCurrentTheme(myXPStyleTheme); try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); } catch (Exception err) { System.out.println("Error loading myXPStyleTheme:" + err.toString()); } } new MainForm(); } /************************** End main method start *************************/ }

customer :
import import import import import import import import javax.swing.*; java.awt.*; java.awt.event.*; java.sql.*; javax.swing.table.*; java.awt.PrintJob; java.util.*; java.text.*;

public class FrmCustomer extends JInternalFrame{ /************************ Variable declaration start **********************/ //Start form variables public static JScrollPane CusTableJSP = new JScrollPane();

public static JPanel JPContainer = new JPanel(); public static JTable JTCusTable; JLabel JLPicture1 = new JLabel(new ImageIcon("images/helper.png")); JLabel JLHelpText = new JLabel("To display a certain \n record click the 'search button' and look for the record that you want."); JFrame JFParentFrame; JButton JBAddNew = new JButton("Add New",new ImageIcon("images/new.png")); JButton JBModify = new JButton("Modify",new ImageIcon("images/modify.png")); JButton JBSearch = new JButton("Search",new ImageIcon("images/search.png")); JButton JBPrint = new JButton("Print",new ImageIcon("images/print.png")); JButton JBDelete = new JButton("Delete",new ImageIcon("images/delete.png")); JButton JBReload = new JButton("Reload",new ImageIcon("images/reload.png")); Connection cnCus; public static Statement stCus; public static ResultSet rsCus; public static String strSQL; public static String Content[][]; public static int rowNum = 0; public static int total = 0; boolean goEOF; Dimension screen = //End form variables /********************** End variable declaration start ********************/ /********************* Start FrmCustomer constructor **********************/ public FrmCustomer(Connection srcCN,JFrame getParentFrame) throws SQLException{ //Set the form caption and some properties start super("Customer Records",false,true,false,true); //End set the form caption and some properties //Start initialize variables Toolkit.getDefaultToolkit().getScreenSize();

JPContainer.setLayout(null); JFParentFrame = getParentFrame; cnCus = srcCN; stCus = cnCus.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_RE AD_ONLY); strSQL = "SELECT * FROM tblCustomer WHERE CustomerIndex = 0 ORDER BY CompanyName ASC"; //-- Add the JLPicture1 JLPicture1.setBounds(5,5,48,48); JPContainer.add(JLPicture1); //-- Add the JLHelpText JLHelpText.setBounds(55,5,570,48); JLHelpText.setFont(new Font("Dialog", Font.PLAIN, 12)); JPContainer.add(JLHelpText); //-- Add the CusTable JTCusTable=CreateTable(); CusTableJSP.getViewport().add(JTCusTable); CusTableJSP.setBounds(5,55,727,320); JPContainer.add(CusTableJSP); //-- Add the JBAddNew JBAddNew.setBounds(5,382,105,25); JBAddNew.setFont(new Font("Dialog", Font.PLAIN, 12)); JBAddNew.setMnemonic(KeyEvent.VK_A); JBAddNew.addActionListener(JBActionListener); JBAddNew.setActionCommand("add"); JPContainer.add(JBAddNew); //-- Add the JBModify JBModify.setBounds(112,382,99,25); JBModify.setFont(new Font("Dialog", Font.PLAIN, 12)); JBModify.setMnemonic(KeyEvent.VK_M); JBModify.addActionListener(JBActionListener); JBModify.setActionCommand("modify"); JPContainer.add(JBModify); //-- Add the JBSearch JBSearch.setBounds(212,382,99,25); JBSearch.setFont(new Font("Dialog", Font.PLAIN, 12)); JBSearch.setMnemonic(KeyEvent.VK_S); JBSearch.addActionListener(JBActionListener); JBSearch.setActionCommand("search"); JPContainer.add(JBSearch);

//-- Add the JBPrint JBPrint.setBounds(312,382,99,25); JBPrint.setFont(new Font("Dialog", Font.PLAIN, 12)); JBPrint.setMnemonic(KeyEvent.VK_P); JBPrint.addActionListener(JBActionListener); JBPrint.setActionCommand("print"); JPContainer.add(JBPrint); //-- Add the JBDelete JBDelete.setBounds(413,382,105,25); JBDelete.setFont(new Font("Dialog", Font.PLAIN, 12)); JBDelete.setMnemonic(KeyEvent.VK_D); JBDelete.addActionListener(JBActionListener); JBDelete.setActionCommand("delete"); JPContainer.add(JBDelete); //-- Add the JBReload JBReload.setBounds(627,382,105,25); JBReload.setFont(new Font("Dialog", Font.PLAIN, 12)); JBReload.setMnemonic(KeyEvent.VK_R); JBReload.addActionListener(JBActionListener); JBReload.setActionCommand("reload"); JPContainer.add(JBReload); //End initialize variables //Start set the form properties getContentPane().add(JPContainer); setSize(747,450); setLocation((screen.width - 747)/2,((screen.height-450)/2)-45); setFrameIcon(new ImageIcon("images/customer.png")); //End set the form properties } /********************** FrmCustomer constructor end ***********************/ /************************** Start event handling **************************/ ActionListener JBActionListener = new ActionListener(){ public void actionPerformed(ActionEvent e){ String srcObj = e.getActionCommand(); //Add Record if(srcObj=="add"){ JDialog JDAdd = new frm_add_edit_customer(true,JFParentFrame,cnCus,""); JDAdd.show(); //Modify Record }else if(srcObj=="modify"){ if(total != 0){ try{

if(JTCusTable.getValueAt(JTCusTable.getSelectedRow(),JTCusTable.getSelectedColu mn()) != null){ JDialog JDEdit = new frm_add_edit_customer(false,JFParentFrame,cnCus,"SELECT * FROM tblCustomer WHERE CustomerIndex = " + JTCusTable.getValueAt(JTCusTable.getSelectedRow(),0)); JDEdit.show(); } }catch(Exception sqlE){ if(sqlE.getMessage() != null){ System.out.println(sqlE.getMessage()); }else{ JOptionPane.showMessageDialog(null,"Please select a record in the list to modify.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); } } } //Search Record }else if(srcObj=="search"){ JDialog JDSearchRec = new FrmSearchCustomer(JFParentFrame); JDSearchRec.show(true); //Print Record }else if(srcObj=="print"){ if(total != 0){ try{ if(JTCusTable.getValueAt(JTCusTable.getSelectedRow(),JTCusTable.getSelectedColu mn()) != null){ clsPublicMethods PrintingClass = new clsPublicMethods(); ResultSet rsPrint = stCus.executeQuery("SELECT * FROM tblCustomer WHERE CustomerIndex = " + JTCusTable.getValueAt(JTCusTable.getSelectedRow(),0)); if(rsPrint.next()==true){ String RecordToPrint = ""; java.util.Date CurrentDate = new java.util.Date(); SimpleDateFormat SDFDateFormatter = new SimpleDateFormat("MMM. dd, yyyy",Locale.getDefault()); CUSTOMER RECORD RecordToPrint += " \n";

RecordToPrint += " " + SDFDateFormatter.format(CurrentDate).toString() + "\n\n\n"; RecordToPrint += "___________________________________________________________________________________\ n\n\n"; Customer ID: " + rsPrint.getString("CustomerID") + " rsPrint.getString("CompanyName") + "\n"; RecordToPrint += " Company Name: " +

RecordToPrint += "___________________________________________________________________________________\ n"; RecordToPrint += "___________________________________________________________________________________\ n\n"; RecordToPrint Contact Person: " + rsPrint.getString("ContactName") + "\n"; RecordToPrint Contact Title: " + rsPrint.getString("ContactTitle") + "\n"; RecordToPrint Address: " + rsPrint.getString("Address") + "\n"; RecordToPrint " + rsPrint.getString("CityTown") + "\n"; RecordToPrint State/Province: " + rsPrint.getString("StateProvince") + "\n"; RecordToPrint Code: " + rsPrint.getString("ZipCode") + "\n"; RecordToPrint Country: " + rsPrint.getString("Country") + "\n"; RecordToPrint Phone: " + rsPrint.getString("Phone") + "\n"; RecordToPrint + rsPrint.getString("Fax") + "\n\n"; += " += " += " += " City: += " += " Zip += " += " += " Fax: "

RecordToPrint += "___________________________________________________________________________________\ n\n"; PrintingClass.printRecord(RecordToPrint,JFParentFrame); CurrentDate=null; SDFDateFormatter=null; RecordToPrint=null; }else{

JOptionPane.showMessageDialog(null,"The selected record has been change since last modified. Please click the 'Reload' button and try again!","No record to print",JOptionPane.WARNING_MESSAGE); } //Dispose the variable rsPrint=null; } }catch(Exception sqlE){ if(sqlE.getMessage() != null){ System.out.println(sqlE.getMessage()); }else{ JOptionPane.showMessageDialog(null,"Please select a record in the list to print.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); } } } //Delete Record }else if(srcObj=="delete"){ if(total != 0){ try{ if(JTCusTable.getValueAt(JTCusTable.getSelectedRow(),JTCusTable.getSelectedColu mn()) != null){ String ObjButtons[] = {"Yes","No"}; int PromptResult = JOptionPane.showOptionDialog(null,"Are you sure you want to delete the selected record?","Delete Record",JOptionPane.DEFAULT_OPTION,JOptionPane.ERROR_MESSAGE,null,ObjButto ns,ObjButtons[1]); if(PromptResult==0){ stCus.execute("DELETE * FROM tblCustomer WHERE CustomerIndex = " + JTCusTable.getValueAt(JTCusTable.getSelectedRow(),0)); reloadRecord(); JOptionPane.showMessageDialog(null,"Record has been successfully deleted.","Comfirm Delete",JOptionPane.INFORMATION_MESSAGE); } } }catch(Exception sqlE){ if(sqlE.getMessage()!=null){ JOptionPane.showMessageDialog(null,"You cannot delete this customer because it already have an invoice transaction.\nIn order to delete this customer, delete its invoice first.","Comfirm Delete",JOptionPane.WARNING_MESSAGE); }else{

JOptionPane.showMessageDialog(null,"Please select a record in the list to deleted.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); } } } //Reload Record }else if(srcObj=="reload"){ reloadRecord(); //Close the Form } } }; /*************************** End event handling ***************************/ /************************** Start custom class ***************************/ public static JTable CreateTable(){ String ColumnHeaderName[] = { "Index","Customer ID","Company Name","Contact Name" }; try{ rsCus = stCus.executeQuery(strSQL); total = 0; //Move to the last record rsCus.afterLast(); //Get the current record position if(rsCus.previous())total = rsCus.getRow(); //Move back to the first record; rsCus.beforeFirst(); if(total > 0){ Content = new String[total][4]; while(rsCus.next()){ Content[rowNum][0] = "" + rsCus.getString("CustomerIndex"); Content[rowNum][1] = "" + rsCus.getString("CustomerID"); Content[rowNum][2] = "" + rsCus.getString("CompanyName"); Content[rowNum][3] = "" + rsCus.getString("ContactName"); rowNum++; } }else{ Content = new String[0][4]; Content[0][0] = " "; Content[0][1] = " "; Content[0][2] = " "; Content[0][3] = " "; }

}catch(Exception eE){ } JTable NewTable = new JTable (Content,ColumnHeaderName){ public boolean isCellEditable (int iRows, int iCols) { return false; } }; NewTable.setPreferredScrollableViewportSize(new Dimension(727, 320)); NewTable.setBackground(Color.white); //Start resize the table column NewTable.getColumnModel().getColumn(0).setMaxWidth(0); NewTable.getColumnModel().getColumn(0).setMinWidth(0); NewTable.getColumnModel().getColumn(0).setWidth(0); NewTable.getColumnModel().getColumn(0).setPreferredWidth(0); NewTable.getColumnModel().getColumn(1).setPreferredWidth(100); NewTable.getColumnModel().getColumn(2).setPreferredWidth(300); NewTable.getColumnModel().getColumn(3).setPreferredWidth(200); //End resize the table column //Disposed variables ColumnHeaderName=null; Content=null; rowNum = 0; return NewTable; } /**************************** End custom class ****************************/ /************************** Start Custom method ***************************/ public static void reloadRecord(String srcSQL){ strSQL = srcSQL; CusTableJSP.getViewport().remove(JTCusTable); JTCusTable=CreateTable(); CusTableJSP.getViewport().add(JTCusTable); JPContainer.repaint(); } public static void reloadRecord(){ CusTableJSP.getViewport().remove(JTCusTable); JTCusTable=CreateTable(); CusTableJSP.getViewport().add(JTCusTable); JPContainer.repaint(); } /*************************** End Custom method ****************************/

Edit customer details :


import import import import javax.swing.*; java.sql.*; java.awt.*; java.awt.event.*;

public class frm_add_edit_product extends JDialog{ JButton JBUpdate = new JButton(new ImageIcon("images/save.png")); JButton JBReset = new JButton("Reset",new ImageIcon("images/reset.png")); JButton JBCancel = new JButton("Cancel",new ImageIcon("images/cancel.png")); JLabel JLPic1 = new JLabel(); JLabel JLBanner = new JLabel("Please fill-up all the required fields."); JLabel JLabel JLabel JLabel JLabel JLabel JLabel JLabel JLabel JLabel JLId = new JLabel("Warehouse ID:"); JLName = new JLabel("Warehouse Name:"); JLCPerson = new JLabel("Contact Person:"); JLCTitle = new JLabel("Contact Title:"); JLAddr = new JLabel("Address:"); JLCity = new JLabel("CityTown:"); JLStateProv = new JLabel("State/Province:"); JLZipCode = new JLabel("Zip Code:"); JLPhone = new JLabel("Phone:"); JLFax = new JLabel("Fax:"); JTFId = new JTextField(); JTFName = new JTextField(); JTFCPerson = new JTextField(); JTFCTitle = new JTextField(); JTFAddr = new JTextField(); JTFCity = new JTextField(); JTFStateProv = new JTextField(); JTFZipCode = new JTextField(); JTFPhone = new JTextField(); JTFFax = new JTextField();

JTextField JTextField JTextField JTextField JTextField JTextField JTextField JTextField JTextField JTextField

Connection cnAEW; Statement stAEW; ResultSet rsAEW; Dimension screen = boolean ADDING_STATE; Toolkit.getDefaultToolkit().getScreenSize();

public frm_add_edit_product(boolean ADD_STATE,JFrame OwnerForm,Connection srcCN,String srcSQL){ super(OwnerForm,true); cnAEW = srcCN; ADDING_STATE = ADD_STATE; try{ stAEW = cnAEW.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_U PDATABLE); }catch( SQLException sqlEx){ } if(ADD_STATE==true){ JLPic1.setIcon(new ImageIcon("images/bNew.png")); setTitle("Add New Warehouse"); JBUpdate.setText("Update"); }else{ JLPic1.setIcon(new ImageIcon("images/bModify.png")); setTitle("Modify Warehouse"); JBUpdate.setText("Save"); try{ rsAEW = stAEW.executeQuery(srcSQL); rsAEW.next(); JTFId.setText("" + rsAEW.getString("WarehouseID")); JTFName.setText("" + rsAEW.getString("WarehouseName")); JTFCPerson.setText("" + rsAEW.getString("ContactPerson")); JTFCTitle.setText("" + rsAEW.getString("ContactTitle")); JTFAddr.setText("" + rsAEW.getString("Address")); JTFCity.setText("" + rsAEW.getString("CityTown")); JTFStateProv.setText("" + rsAEW.getString("StateProvince")); JTFZipCode.setText("" + rsAEW.getString("ZipCode")); JTFPhone.setText("" + rsAEW.getString("Phone")); JTFFax.setText("" + rsAEW.getString("Fax")); }catch(SQLException sqlEx){ System.out.println(sqlEx.getMessage()); } } JPanel JPContainer = new JPanel(); JPContainer.setLayout(null); //-- Add the JLPic1 JLPic1.setBounds(5,5,32,32); JPContainer.add(JLPic1); //-- Add the JLBanner

JLBanner.setBounds(55,5,268,48); JLBanner.setFont(new Font("Dialog",Font.PLAIN,12)); JPContainer.add(JLBanner); //******************** Start adding of input field //-- Add Id Input Field JLId.setBounds(5,50,105,20); JLId.setFont(new Font("Dialog",Font.PLAIN,12)); JTFId.setBounds(110,50,200,20); JTFId.setFont(new Font("Dialog",Font.PLAIN,12)); JPContainer.add(JLId); JPContainer.add(JTFId); //-- Add Name Input Field JLName.setBounds(5,72,105,20); JLName.setFont(new Font("Dialog",Font.PLAIN,12)); JTFName.setBounds(110,72,200,20); JTFName.setFont(new Font("Dialog",Font.PLAIN,12)); JPContainer.add(JLName); JPContainer.add(JTFName); //-- Add Contact Person Input Field JLCPerson.setBounds(5,94,105,20); JLCPerson.setFont(new Font("Dialog",Font.PLAIN,12)); JTFCPerson.setBounds(110,94,200,20); JTFCPerson.setFont(new Font("Dialog",Font.PLAIN,12)); JPContainer.add(JLCPerson); JPContainer.add(JTFCPerson); //-- Add Primary Address Input Field JLCTitle.setBounds(5,116,105,20); JLCTitle.setFont(new Font("Dialog",Font.PLAIN,12)); JTFCTitle.setBounds(110,116,200,20); JTFCTitle.setFont(new Font("Dialog",Font.PLAIN,12)); JPContainer.add(JLCTitle); JPContainer.add(JTFCTitle); //-- Add Secondary Address Input Field JLAddr.setBounds(5,138,105,20); JLAddr.setFont(new Font("Dialog",Font.PLAIN,12)); JTFAddr.setBounds(110,138,200,20);

JTFAddr.setFont(new Font("Dialog",Font.PLAIN,12)); JPContainer.add(JLAddr); JPContainer.add(JTFAddr); //-- Add CityTown Input Field JLCity.setBounds(5,160,105,20); JLCity.setFont(new Font("Dialog",Font.PLAIN,12)); JTFCity.setBounds(110,160,200,20); JTFCity.setFont(new Font("Dialog",Font.PLAIN,12)); JPContainer.add(JLCity); JPContainer.add(JTFCity); //-- Add StateProvince Input Field JLStateProv.setBounds(5,182,105,20); JLStateProv.setFont(new Font("Dialog",Font.PLAIN,12)); JTFStateProv.setBounds(110,182,200,20); JTFStateProv.setFont(new Font("Dialog",Font.PLAIN,12)); JPContainer.add(JLStateProv); JPContainer.add(JTFStateProv); //-- Add Zip Code Input Field JLZipCode.setBounds(5,204,105,20); JLZipCode.setFont(new Font("Dialog",Font.PLAIN,12)); JTFZipCode.setBounds(110,204,200,20); JTFZipCode.setFont(new Font("Dialog",Font.PLAIN,12)); JPContainer.add(JLZipCode); JPContainer.add(JTFZipCode); //-- Add Contact Number Input Field JLPhone.setBounds(5,226,105,20); JLPhone.setFont(new Font("Dialog",Font.PLAIN,12)); JTFPhone.setBounds(110,226,200,20); JTFPhone.setFont(new Font("Dialog",Font.PLAIN,12)); JPContainer.add(JLPhone); JPContainer.add(JTFPhone); //-- Add E-mail Address Input Field JLFax.setBounds(5,248,105,20); JLFax.setFont(new Font("Dialog",Font.PLAIN,12)); JTFFax.setBounds(110,248,200,20);

JTFFax.setFont(new Font("Dialog",Font.PLAIN,12)); JPContainer.add(JLFax); JPContainer.add(JTFFax); //******************** End adding of input field //-- Add the JBUpdate JBUpdate.setBounds(5,292,105,25); JBUpdate.setFont(new Font("Dialog", Font.PLAIN, 12)); JBUpdate.setMnemonic(KeyEvent.VK_A); JBUpdate.addActionListener(JBActionListener); JBUpdate.setActionCommand("update"); JPContainer.add(JBUpdate); //-- Add the JBReset JBReset.setBounds(112,292,99,25); JBReset.setFont(new Font("Dialog", Font.PLAIN, 12)); JBReset.setMnemonic(KeyEvent.VK_R); JBReset.addActionListener(JBActionListener); JBReset.setActionCommand("reset"); JPContainer.add(JBReset); //-- Add the JBCancel JBCancel.setBounds(212,292,99,25); JBCancel.setFont(new Font("Dialog", Font.PLAIN, 12)); JBCancel.setMnemonic(KeyEvent.VK_C); JBCancel.addActionListener(JBActionListener); JBCancel.setActionCommand("cancel"); JPContainer.add(JBCancel); getContentPane().add(JPContainer); setSize(325,357); setResizable(false); setLocation((screen.width - 325)/2,((screen.height-357)/2)); } private boolean RequiredFieldEmpty(){ if(JTFId.getText().equals("") || JTFName.getText().equals("") || JTFCPerson.getText().equals("")){ JOptionPane.showMessageDialog(null,"Some required fields is/are empty.\nPlease check it and try again.","Naparansoft Inventory System",JOptionPane.WARNING_MESSAGE); JTFId.requestFocus(); return true; }else{ return false; } } private void clearFields(){ JTFId.setText("");

JTFName.setText(""); JTFCPerson.setText(""); JTFCTitle.setText(""); JTFAddr.setText(""); JTFCity.setText(""); JTFStateProv.setText(""); JTFZipCode.setText(""); JTFPhone.setText(""); JTFFax.setText(""); } ActionListener JBActionListener = new ActionListener(){ public void actionPerformed(ActionEvent e){ String srcObj = e.getActionCommand(); if(srcObj=="update"){ if(RequiredFieldEmpty()==false){ if(ADDING_STATE == true){ try{ stAEW.executeUpdate("INSERT INTO tblWarehouse(WarehouseID,WarehouseName,ContactPerson,ContactTitle,Address,C ityTown,StateProvince,ZipCode,Phone,Fax) " + "VALUES ('" + JTFId.getText() + "', '" + JTFName.getText() + "', '" + JTFCPerson.getText() + "', '" + JTFCTitle.getText() + "', '" + JTFAddr.getText() + "', '" + JTFCity.getText() + "', '" + JTFStateProv.getText() + "', '" + JTFZipCode.getText() + "', '" + JTFPhone.getText() + "', '" + JTFFax.getText() + "')"); // Start Display the new record int total =0; total = clsPublicMethods.getMaxNum("SELECT * FROM tblWarehouse ORDER BY WarehouseIndex ASC",cnAEW,"WarehouseIndex"); if(total != 0){

FrmWarehouse.reloadRecord("SELECT * FROM tblWarehouse WHERE WarehouseIndex = " + total + " ORDER BY WarehouseName ASC"); }else{ FrmWarehouse.reloadRecord("SELECT * FROM tblWarehouse ORDER BY WarehouseName ASC"); } total =0; // End Display the new record JOptionPane.showMessageDialog(null,"New record has been successfully added.","Naparansoft Inventory System",JOptionPane.INFORMATION_MESSAGE); String ObjButtons[] = {"Yes","No"}; int PromptResult = JOptionPane.showOptionDialog(null,"Do you want add another record?","Naparansoft Inventory System",JOptionPane.DEFAULT_OPTION,JOptionPane.QUESTION_MESSAGE,null,ObjB uttons,ObjButtons[0]); if(PromptResult==0){ clearFields(); JTFId.requestFocus(true); }else{ dispose(); } }catch(SQLException sqlEx){ System.out.println(sqlEx.getMessage()); } }else{ try{ String RowIndex; RowIndex = rsAEW.getString("WarehouseIndex"); stAEW.executeUpdate("UPDATE tblWarehouse SET WarehouseID = '" + JTFId.getText() + "', WarehouseName = '" + JTFName.getText() + "', ContactPerson = '" + JTFCPerson.getText() + "', ContactTitle = '" + JTFCTitle.getText() + "', Address = '" + JTFAddr.getText() + "', CityTown = '" + JTFCity.getText() + "', StateProvince = '" + JTFStateProv.getText() + "', ZipCode = '" +

JTFZipCode.getText() + "', Phone = '" + JTFPhone.getText() + "', Fax = '" + JTFFax.getText() + "' WHERE WarehouseIndex = " + RowIndex); FrmWarehouse.reloadRecord("SELECT * FROM tblWarehouse WHERE WarehouseIndex = " + RowIndex + " ORDER BY WarehouseName ASC"); JOptionPane.showMessageDialog(null,"Changes in the record has been successfully save.","Naparansoft Inventory System",JOptionPane.INFORMATION_MESSAGE); dispose(); }catch(SQLException sqlEx){ System.out.println(sqlEx.getMessage()); } } } }else if(srcObj=="reset"){ clearFields(); }else if(srcObj=="cancel"){ dispose(); } } }; }.

warehouse
import import import import import import import import javax.swing.*; java.awt.*; java.awt.event.*; java.sql.*; javax.swing.table.*; java.awt.PrintJob; java.util.*; java.text.*;

public class FrmWarehouse extends JInternalFrame{ /************************ Variable declaration start **********************/ //Start form variables

public static JScrollPane WrhTableJSP = new JScrollPane(); public static JPanel JPContainer = new JPanel(); public static JTable JTWrhTable; JLabel JLPicture1 = new JLabel(new ImageIcon("images/helper.png")); JLabel JLHelpText = new JLabel("To display a certain \n record click the 'search button' and look for the record that you want."); JFrame JFParentFrame; JButton JBAddNew = new JButton("Add New",new ImageIcon("images/new.png")); JButton JBModify = new JButton("Modify",new ImageIcon("images/modify.png")); JButton JBSearch = new JButton("Search",new ImageIcon("images/search.png")); JButton JBPrint = new JButton("Print",new ImageIcon("images/print.png")); JButton JBDelete = new JButton("Delete",new ImageIcon("images/delete.png")); JButton JBReload = new JButton("Reload",new ImageIcon("images/reload.png")); Connection cnWrh; public static Statement stWrh; public static ResultSet rsWrh; public static String strSQL; public static String Content[][]; public static int rowNum = 0; public static int total = 0; boolean goEOF; Dimension screen = //End form variables /********************** End variable declaration start ********************/ /********************* Start FrmWarehouse constructor **********************/ public FrmWarehouse(Connection srcCN,JFrame getParentFrame) throws SQLException{ //Set the form caption and some properties start super("Warehouse Records",false,true,false,true); //End set the form caption and some properties Toolkit.getDefaultToolkit().getScreenSize();

//Start initialize variables JPContainer.setLayout(null); JFParentFrame = getParentFrame; cnWrh = srcCN; stWrh = cnWrh.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_R EAD_ONLY); strSQL = "SELECT * FROM tblWarehouse WHERE WarehouseIndex = 0 ORDER BY WarehouseName ASC"; //-- Add the JLPicture1 JLPicture1.setBounds(5,5,48,48); JPContainer.add(JLPicture1); //-- Add the JLHelpText JLHelpText.setBounds(55,5,570,48); JLHelpText.setFont(new Font("Dialog", Font.PLAIN, 12)); JPContainer.add(JLHelpText); //-- Add the WrhTable JTWrhTable=CreateTable(); WrhTableJSP.getViewport().add(JTWrhTable); WrhTableJSP.setBounds(5,55,727,320); JPContainer.add(WrhTableJSP); //-- Add the JBAddNew JBAddNew.setBounds(5,382,105,25); JBAddNew.setFont(new Font("Dialog", Font.PLAIN, 12)); JBAddNew.setMnemonic(KeyEvent.VK_A); JBAddNew.addActionListener(JBActionListener); JBAddNew.setActionCommand("add"); JPContainer.add(JBAddNew); //-- Add the JBModify JBModify.setBounds(112,382,99,25); JBModify.setFont(new Font("Dialog", Font.PLAIN, 12)); JBModify.setMnemonic(KeyEvent.VK_M); JBModify.addActionListener(JBActionListener); JBModify.setActionCommand("modify"); JPContainer.add(JBModify); //-- Add the JBSearch JBSearch.setBounds(212,382,99,25); JBSearch.setFont(new Font("Dialog", Font.PLAIN, 12)); JBSearch.setMnemonic(KeyEvent.VK_S); JBSearch.addActionListener(JBActionListener); JBSearch.setActionCommand("search");

JPContainer.add(JBSearch); //-- Add the JBPrint JBPrint.setBounds(312,382,99,25); JBPrint.setFont(new Font("Dialog", Font.PLAIN, 12)); JBPrint.setMnemonic(KeyEvent.VK_P); JBPrint.addActionListener(JBActionListener); JBPrint.setActionCommand("print"); JPContainer.add(JBPrint); //-- Add the JBDelete JBDelete.setBounds(413,382,105,25); JBDelete.setFont(new Font("Dialog", Font.PLAIN, 12)); JBDelete.setMnemonic(KeyEvent.VK_D); JBDelete.addActionListener(JBActionListener); JBDelete.setActionCommand("delete"); JPContainer.add(JBDelete); //-- Add the JBReload JBReload.setBounds(627,382,105,25); JBReload.setFont(new Font("Dialog", Font.PLAIN, 12)); JBReload.setMnemonic(KeyEvent.VK_R); JBReload.addActionListener(JBActionListener); JBReload.setActionCommand("reload"); JPContainer.add(JBReload); //End initialize variables //Start set the form properties getContentPane().add(JPContainer); setSize(747,450); setLocation((screen.width - 747)/2,((screen.height-450)/2)-45); setFrameIcon(new ImageIcon("images/Warehouse.png")); //End set the form properties } /********************** FrmWarehouse constructor end ***********************/ /************************** Start event handling **************************/ ActionListener JBActionListener = new ActionListener(){ public void actionPerformed(ActionEvent e){ String srcObj = e.getActionCommand(); //Add Record if(srcObj=="add"){ JDialog JDAdd = new frm_add_edit_warehouse(true,JFParentFrame,cnWrh,""); JDAdd.show(); //Modify Record

}else if(srcObj=="modify"){ if(total != 0){ try{ if(JTWrhTable.getValueAt(JTWrhTable.getSelectedRow(),JTWrhTable.getSelectedColu mn()) != null){ JDialog JDEdit = new frm_add_edit_warehouse(false,JFParentFrame,cnWrh,"SELECT * FROM tblWarehouse WHERE WarehouseIndex = " + JTWrhTable.getValueAt(JTWrhTable.getSelectedRow(),0)); JDEdit.show(); } }catch(Exception sqlE){ if(sqlE.getMessage() != null){ System.out.println(sqlE.getMessage()); }else{ JOptionPane.showMessageDialog(null,"Please select a record in the list to modify.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); } } } //Search Record }else if(srcObj=="search"){ JDialog JDSearchRec = new FrmSearchWarehouse(JFParentFrame); JDSearchRec.show(true); //Print Record }else if(srcObj=="print"){ if(total != 0){ try{ if(JTWrhTable.getValueAt(JTWrhTable.getSelectedRow(),JTWrhTable.getSelectedColu mn()) != null){ clsPublicMethods PrintingClass = new clsPublicMethods(); ResultSet rsPrint = stWrh.executeQuery("SELECT * FROM tblWarehouse WHERE WarehouseIndex = " + JTWrhTable.getValueAt(JTWrhTable.getSelectedRow(),0)); if(rsPrint.next()==true){ String RecordToPrint = ""; java.util.Date CurrentDate = new java.util.Date(); SimpleDateFormat SDFDateFormatter = new SimpleDateFormat("MMM. dd, yyyy",Locale.getDefault());

RecordToPrint += " W A R E H O U S E R E C O R D\n"; RecordToPrint += " " + SDFDateFormatter.format(CurrentDate).toString() + "\n\n\n"; RecordToPrint += "___________________________________________________________________________________\ n\n\n"; Warehouse ID: " + rsPrint.getString("WarehouseID") + " Name: " + rsPrint.getString("WarehouseName") + "\n"; RecordToPrint += " Warehouse

RecordToPrint += "___________________________________________________________________________________\ n"; RecordToPrint += "___________________________________________________________________________________\ n\n"; RecordToPrint += " Contact Person: " + rsPrint.getString("ContactPerson") + "\n"; RecordToPrint += " Contact Title: " + rsPrint.getString("ContactTitle") + "\n"; RecordToPrint += " CityTown: " + rsPrint.getString("CityTown") + "\n"; RecordToPrint += " State/Province: " + rsPrint.getString("StateProvince") + "\n"; RecordToPrint += " Zip Code: " + rsPrint.getString("ZipCode") + "\n"; RecordToPrint += " Phone: " + rsPrint.getString("Phone") + "\n"; RecordToPrint += " Fax: " + rsPrint.getString("Fax") + "\n\n"; RecordToPrint += "___________________________________________________________________________________\ n\n"; PrintingClass.printRecord(RecordToPrint,JFParentFrame); CurrentDate=null; SDFDateFormatter=null; RecordToPrint=null; }else{

JOptionPane.showMessageDialog(null,"The selected record has been change since last modified. Please click the 'Reload' button and try again!","No record to print",JOptionPane.WARNING_MESSAGE); } //Dispose the variable rsPrint=null; } }catch(Exception sqlE){ if(sqlE.getMessage() != null){ System.out.println(sqlE.getMessage()); }else{ JOptionPane.showMessageDialog(null,"Please select a record in the list to print.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); } } } //Delete Record }else if(srcObj=="delete"){ if(total != 0){ try{ if(JTWrhTable.getValueAt(JTWrhTable.getSelectedRow(),JTWrhTable.getSelectedColu mn()) != null){ String ObjButtons[] = {"Yes","No"}; int PromptResult = JOptionPane.showOptionDialog(null,"Are you sure you want to delete the selected record?","Delete Record",JOptionPane.DEFAULT_OPTION,JOptionPane.ERROR_MESSAGE,null,ObjButto ns,ObjButtons[1]); if(PromptResult==0){ stWrh.execute("DELETE * FROM tblWarehouse WHERE WarehouseIndex = " + JTWrhTable.getValueAt(JTWrhTable.getSelectedRow(),0)); reloadRecord(); JOptionPane.showMessageDialog(null,"Record has been successfully deleted.","Comfirm Delete",JOptionPane.INFORMATION_MESSAGE); } } }catch(Exception sqlE){ if(sqlE.getMessage()!=null){ JOptionPane.showMessageDialog(null,"You cannot delete this Warehouse because it already have an invoice transaction.\nIn order to delete this Warehouse, delete its invoice first.","Comfirm Delete",JOptionPane.WARNING_MESSAGE); }else{

JOptionPane.showMessageDialog(null,"Please select a record in the list to deleted.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); } } } //Reload Record }else if(srcObj=="reload"){ reloadRecord(); //Close the Form } } }; /*************************** End event handling ***************************/ /************************** Start Custom class ***************************/ public static JTable CreateTable(){ String ColumnHeaderName[] = { "Index","Warehouse ID","Warehouse Name","Contact Person" }; try{ rsWrh = stWrh.executeQuery(strSQL); total = 0; //Move to the last record rsWrh.afterLast(); //Get the current record position if(rsWrh.previous())total = rsWrh.getRow(); //Move back to the first record; rsWrh.beforeFirst(); if(total != 0){ Content = new String[total][4]; while(rsWrh.next()){ Content[rowNum][0] = "" + rsWrh.getString("WarehouseIndex"); Content[rowNum][1] = "" + rsWrh.getString("WarehouseID"); Content[rowNum][2] = "" + rsWrh.getString("WarehouseName"); Content[rowNum][3] = "" + rsWrh.getString("ContactPerson"); rowNum++; } }else{ Content = new String[0][4]; Content[0][0] = " "; Content[0][1] = " "; Content[0][2] = " "; Content[0][3] = " "; }

}catch(Exception eE){ } JTable NewTable = new JTable (Content,ColumnHeaderName){ public boolean isCellEditable (int iRows, int iCols) { return false; } }; NewTable.setPreferredScrollableViewportSize(new Dimension(727, 320)); NewTable.setBackground(Color.white); //Start resize the table column NewTable.getColumnModel().getColumn(0).setMaxWidth(0); NewTable.getColumnModel().getColumn(0).setMinWidth(0); NewTable.getColumnModel().getColumn(0).setWidth(0); NewTable.getColumnModel().getColumn(0).setPreferredWidth(0); NewTable.getColumnModel().getColumn(1).setPreferredWidth(100); NewTable.getColumnModel().getColumn(2).setPreferredWidth(300); NewTable.getColumnModel().getColumn(3).setPreferredWidth(200); //End resize the table column //Disposed variables ColumnHeaderName=null; Content=null; rowNum = 0; return NewTable; } /**************************** End Custom class ****************************/ /************************** Start Custom method ***************************/ public static void reloadRecord(String srcSQL){ strSQL = srcSQL; WrhTableJSP.getViewport().remove(JTWrhTable); JTWrhTable=CreateTable(); WrhTableJSP.getViewport().add(JTWrhTable); JPContainer.repaint(); } public static void reloadRecord(){ WrhTableJSP.getViewport().remove(JTWrhTable); JTWrhTable=CreateTable(); WrhTableJSP.getViewport().add(JTWrhTable); JPContainer.repaint(); }

/*************************** End Custom method ****************************/ }

supplier
import import import import import import import import javax.swing.*; java.awt.*; java.awt.event.*; java.sql.*; javax.swing.table.*; java.awt.PrintJob; java.util.*; java.text.*;

public class FrmSupplier extends JInternalFrame{ /************************ Variable declaration start **********************/ //Start form variables public static JScrollPane SupTableJSP = new JScrollPane(); public static JPanel JPContainer = new JPanel(); public static JTable JTSupTable; JLabel JLPicture1 = new JLabel(new ImageIcon("images/helper.png")); JLabel JLHelpText = new JLabel("To display a certain \n record click the 'search button' and look for the record that you want."); JFrame JFParentFrame; JButton JBAddNew = new JButton("Add New",new ImageIcon("images/new.png")); JButton JBModify = new JButton("Modify",new ImageIcon("images/modify.png")); JButton JBSearch = new JButton("Search",new ImageIcon("images/search.png")); JButton JBPrint = new JButton("Print",new ImageIcon("images/print.png")); JButton JBDelete = new JButton("Delete",new ImageIcon("images/delete.png")); JButton JBReload = new JButton("Reload",new ImageIcon("images/reload.png")); Connection cnSup; public static Statement stSup;

public static ResultSet rsSup; public static String strSQL; public static String Content[][]; public static int rowNum = 0; public static int total = 0; boolean goEOF; Dimension screen = //End form variables /********************** End variable declaration start ********************/ /********************* Start FrmSupplier constructor **********************/ public FrmSupplier(Connection srcCN,JFrame getParentFrame) throws SQLException{ //Set the form caption and some properties start super("Supplier Records",false,true,false,true); //End set the form caption and some properties //Start initialize variables JPContainer.setLayout(null); JFParentFrame = getParentFrame; cnSup = srcCN; stSup = cnSup.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_RE AD_ONLY); strSQL = "SELECT * FROM tblSupplier WHERE SupplierIndex = 0 ORDER BY CompanyName ASC"; //-- Add the JLPicture1 Toolkit.getDefaultToolkit().getScreenSize();

JLPicture1.setBounds(5,5,48,48); JPContainer.add(JLPicture1); //-- Add the JLHelpText JLHelpText.setBounds(55,5,570,48); JLHelpText.setFont(new Font("Dialog", Font.PLAIN, 12)); JPContainer.add(JLHelpText);

//-- Add the SupTable JTSupTable=CreateTable(); SupTableJSP.getViewport().add(JTSupTable); SupTableJSP.setBounds(5,55,727,320); JPContainer.add(SupTableJSP); //-- Add the JBAddNew JBAddNew.setBounds(5,382,105,25); JBAddNew.setFont(new Font("Dialog", Font.PLAIN, 12)); JBAddNew.setMnemonic(KeyEvent.VK_A); JBAddNew.addActionListener(JBActionListener); JBAddNew.setActionCommand("add"); JPContainer.add(JBAddNew); //-- Add the JBModify JBModify.setBounds(112,382,99,25); JBModify.setFont(new Font("Dialog", Font.PLAIN, 12)); JBModify.setMnemonic(KeyEvent.VK_M); JBModify.addActionListener(JBActionListener); JBModify.setActionCommand("modify"); JPContainer.add(JBModify); //-- Add the JBSearch JBSearch.setBounds(212,382,99,25); JBSearch.setFont(new Font("Dialog", Font.PLAIN, 12)); JBSearch.setMnemonic(KeyEvent.VK_S); JBSearch.addActionListener(JBActionListener); JBSearch.setActionCommand("search"); JPContainer.add(JBSearch); //-- Add the JBPrint JBPrint.setBounds(312,382,99,25); JBPrint.setFont(new Font("Dialog", Font.PLAIN, 12)); JBPrint.setMnemonic(KeyEvent.VK_P); JBPrint.addActionListener(JBActionListener); JBPrint.setActionCommand("print"); JPContainer.add(JBPrint); //-- Add the JBDelete JBDelete.setBounds(413,382,105,25); JBDelete.setFont(new Font("Dialog", Font.PLAIN, 12)); JBDelete.setMnemonic(KeyEvent.VK_D); JBDelete.addActionListener(JBActionListener); JBDelete.setActionCommand("delete"); JPContainer.add(JBDelete); //-- Add the JBReload JBReload.setBounds(627,382,105,25); JBReload.setFont(new Font("Dialog", Font.PLAIN, 12));

JBReload.setMnemonic(KeyEvent.VK_R); JBReload.addActionListener(JBActionListener); JBReload.setActionCommand("reload"); JPContainer.add(JBReload); //End initialize variables //Start set the form properties getContentPane().add(JPContainer); setSize(747,450); setLocation((screen.width - 747)/2,((screen.height-450)/2)-45); setFrameIcon(new ImageIcon("images/Supplier.png")); //End set the form properties } /********************** FrmSupplier constructor end ***********************/ /************************** Start event handling **************************/ ActionListener JBActionListener = new ActionListener(){ public void actionPerformed(ActionEvent e){ String srcObj = e.getActionCommand(); //Add Record if(srcObj=="add"){ JDialog JDAdd = new frm_add_edit_supplier(true,JFParentFrame,cnSup,""); JDAdd.show(); //Modify Record }else if(srcObj=="modify"){ if(total != 0){ try{ if(JTSupTable.getValueAt(JTSupTable.getSelectedRow(),JTSupTable.getSelectedColu mn()) != null){ JDialog JDEdit = new frm_add_edit_supplier(false,JFParentFrame,cnSup,"SELECT * FROM tblSupplier WHERE SupplierIndex = " + JTSupTable.getValueAt(JTSupTable.getSelectedRow(),0)); JDEdit.show(); } }catch(Exception sqlE){ if(sqlE.getMessage() != null){ System.out.println(sqlE.getMessage()); }else{ JOptionPane.showMessageDialog(null,"Please select a record in the list to modify.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); }

} } //Search Record }else if(srcObj=="search"){ JDialog JDSearchRec = new FrmSearchSupplier(JFParentFrame); JDSearchRec.show(true); //Print Record }else if(srcObj=="print"){ if(total != 0){ try{ if(JTSupTable.getValueAt(JTSupTable.getSelectedRow(),JTSupTable.getSelectedColu mn()) != null){ clsPublicMethods PrintingClass = new clsPublicMethods(); ResultSet rsPrint = stSup.executeQuery("SELECT * FROM tblSupplier WHERE SupplierIndex = " + JTSupTable.getValueAt(JTSupTable.getSelectedRow(),0)); if(rsPrint.next()==true){ String RecordToPrint = ""; java.util.Date CurrentDate = new java.util.Date(); SimpleDateFormat SDFDateFormatter = new SimpleDateFormat("MMM. dd, yyyy",Locale.getDefault()); RecordToPrint += " \n"; RecordToPrint += " " + SDFDateFormatter.format(CurrentDate).toString() + "\n\n\n"; SUPPLIER RECORD RecordToPrint += "___________________________________________________________________________________\ n\n\n"; Supplier ID: " + rsPrint.getString("SupplierID") + " rsPrint.getString("CompanyName") + "\n"; RecordToPrint += " Company Name: " +

RecordToPrint += "___________________________________________________________________________________\ n"; RecordToPrint += "___________________________________________________________________________________\ n\n";

RecordToPrint Contact Person: " + rsPrint.getString("ContactName") + "\n"; RecordToPrint Contact Title: " + rsPrint.getString("ContactTitle") + "\n"; RecordToPrint Address: " + rsPrint.getString("Address") + "\n"; RecordToPrint " + rsPrint.getString("CityTown") + "\n"; RecordToPrint State/Province: " + rsPrint.getString("StateProvince") + "\n"; RecordToPrint Code: " + rsPrint.getString("ZipCode") + "\n"; RecordToPrint Country: " + rsPrint.getString("Country") + "\n"; RecordToPrint Phone: " + rsPrint.getString("Phone") + "\n"; RecordToPrint + rsPrint.getString("Fax") + "\n\n"; RecordToPrint Website: " + rsPrint.getString("Website") + "\n\n";

+= " += " += " += " City: += " += " Zip += " += " += " Fax: " += "

RecordToPrint += "___________________________________________________________________________________\ n\n"; PrintingClass.printRecord(RecordToPrint,JFParentFrame); CurrentDate=null; SDFDateFormatter=null; RecordToPrint=null; }else{ JOptionPane.showMessageDialog(null,"The selected record has been change since last modified. Please click the 'Reload' button and try again!","No record to print",JOptionPane.WARNING_MESSAGE); } //Dispose the variable rsPrint=null; } }catch(Exception sqlE){ if(sqlE.getMessage() != null){ System.out.println(sqlE.getMessage()); }else{ JOptionPane.showMessageDialog(null,"Please select a record in the list to print.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); }

} } //Delete Record }else if(srcObj=="delete"){ if(total != 0){ try{ if(JTSupTable.getValueAt(JTSupTable.getSelectedRow(),JTSupTable.getSelectedColu mn()) != null){ String ObjButtons[] = {"Yes","No"}; int PromptResult = JOptionPane.showOptionDialog(null,"Are you sure you want to delete the selected record?","Delete Record",JOptionPane.DEFAULT_OPTION,JOptionPane.ERROR_MESSAGE,null,ObjButto ns,ObjButtons[1]); if(PromptResult==0){ stSup.execute("DELETE * FROM tblSupplier WHERE SupplierIndex = " + JTSupTable.getValueAt(JTSupTable.getSelectedRow(),0)); reloadRecord(); JOptionPane.showMessageDialog(null,"Record has been successfully deleted.","Comfirm Delete",JOptionPane.INFORMATION_MESSAGE); } } }catch(Exception sqlE){ if(sqlE.getMessage()!=null){ JOptionPane.showMessageDialog(null,"You cannot delete this Supplier because it already have an invoice transaction.\nIn order to delete this Supplier, delete its invoice first.","Comfirm Delete",JOptionPane.WARNING_MESSAGE); }else{ JOptionPane.showMessageDialog(null,"Please select a record in the list to deleted.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); } } } //Reload Record }else if(srcObj=="reload"){ reloadRecord(); //Close the Form } } }; /*************************** End event handling ***************************/ /************************** Start Custom class ***************************/

public static JTable CreateTable(){ String ColumnHeaderName[] = { "Index","Supplier ID","Company Name","Contact Name" }; try{ rsSup = stSup.executeQuery(strSQL); total = 0; //Move to the last record rsSup.afterLast(); //Get the current record position if(rsSup.previous())total = rsSup.getRow(); //Move back to the first record; rsSup.beforeFirst(); if(total > 0){ Content = new String[total][4]; while(rsSup.next()){ Content[rowNum][0] = "" + rsSup.getString("SupplierIndex"); Content[rowNum][1] = "" + rsSup.getString("SupplierID"); Content[rowNum][2] = "" + rsSup.getString("CompanyName"); Content[rowNum][3] = "" + rsSup.getString("ContactName"); rowNum++; } }else{ Content = new String[0][4]; Content[0][0] = " "; Content[0][1] = " "; Content[0][2] = " "; Content[0][3] = " "; } }catch(Exception eE){ } JTable NewTable = new JTable (Content,ColumnHeaderName){ public boolean isCellEditable (int iRows, int iCols) { return false; } }; NewTable.setPreferredScrollableViewportSize(new Dimension(727, 320)); NewTable.setBackground(Color.white); //Start resize the table column NewTable.getColumnModel().getColumn(0).setMaxWidth(0); NewTable.getColumnModel().getColumn(0).setMinWidth(0); NewTable.getColumnModel().getColumn(0).setWidth(0); NewTable.getColumnModel().getColumn(0).setPreferredWidth(0); NewTable.getColumnModel().getColumn(1).setPreferredWidth(100); NewTable.getColumnModel().getColumn(2).setPreferredWidth(300);

NewTable.getColumnModel().getColumn(3).setPreferredWidth(200); //End resize the table column //Disposed variables ColumnHeaderName=null; Content=null; rowNum = 0; return NewTable; } /**************************** End Custom class ****************************/ /************************** Start Custom method ***************************/ public static void reloadRecord(String srcSQL){ strSQL = srcSQL; SupTableJSP.getViewport().remove(JTSupTable); JTSupTable=CreateTable(); SupTableJSP.getViewport().add(JTSupTable); JPContainer.repaint(); } public static void reloadRecord(){ SupTableJSP.getViewport().remove(JTSupTable); JTSupTable=CreateTable(); SupTableJSP.getViewport().add(JTSupTable); JPContainer.repaint(); } /*************************** End Custom method ****************************/ }

Sales repersentive import javax.swing.*;


import java.awt.*; import java.awt.event.*; import java.sql.*; import javax.swing.table.*; import java.awt.PrintJob; import java.util.*; import java.text.*;

public class FrmSalesRep extends JInternalFrame{ /************************ Variable declaration start **********************/ //Start form variables public static JScrollPane SlrTableJSP = new JScrollPane();

public static JPanel JPContainer = new JPanel();

public static JTable JTSlrTable;

JLabel JLPicture1 = new JLabel(new ImageIcon("images/helper.png")); JLabel JLHelpText = new JLabel("To display a certain \n record click the 'search button' and look for the record that you want.");

JFrame JFParentFrame;

JButton JBAddNew = new JButton("Add New",new ImageIcon("images/new.png")); JButton JBModify = new JButton("Modify",new ImageIcon("images/modify.png")); JButton JBSearch = new JButton("Search",new ImageIcon("images/search.png")); JButton JBPrint = new JButton("Print",new ImageIcon("images/print.png")); JButton JBDelete = new JButton("Delete",new ImageIcon("images/delete.png")); JButton JBReload = new JButton("Reload",new ImageIcon("images/reload.png"));

Connection cnSlr;

public static Statement stSlr;

public static ResultSet rsSlr;

public static String strSQL; public static String Content[][];

public static int rowNum = 0; public static int total = 0;

boolean goEOF;

Dimension screen =

Toolkit.getDefaultToolkit().getScreenSize();

//End form variables

/********************** End variable declaration start ********************/

/********************* Start FrmSalesRep constructor **********************/ public FrmSalesRep(Connection srcCN,JFrame getParentFrame) throws SQLException{ //Set the form caption and some properties start super("Sales Representative Records",false,true,false,true); //End set the form caption and some properties

//Start initialize variables

JPContainer.setLayout(null);

JFParentFrame = getParentFrame;

cnSlr = srcCN; stSlr = cnSlr.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_RE AD_ONLY); strSQL = "SELECT * FROM tblSalesRep WHERE SalesRepIndex = 0 ORDER BY Name ASC";

//-- Add the JLPicture1 JLPicture1.setBounds(5,5,48,48); JPContainer.add(JLPicture1);

//-- Add the JLHelpText JLHelpText.setBounds(55,5,570,48); JLHelpText.setFont(new Font("Dialog", Font.PLAIN, 12)); JPContainer.add(JLHelpText);

//-- Add the SlrTable JTSlrTable=CreateTable(); SlrTableJSP.getViewport().add(JTSlrTable); SlrTableJSP.setBounds(5,55,727,320); JPContainer.add(SlrTableJSP);

//-- Add the JBAddNew

JBAddNew.setBounds(5,382,105,25); JBAddNew.setFont(new Font("Dialog", Font.PLAIN, 12)); JBAddNew.setMnemonic(KeyEvent.VK_A); JBAddNew.addActionListener(JBActionListener); JBAddNew.setActionCommand("add"); JPContainer.add(JBAddNew);

//-- Add the JBModify JBModify.setBounds(112,382,99,25); JBModify.setFont(new Font("Dialog", Font.PLAIN, 12)); JBModify.setMnemonic(KeyEvent.VK_M); JBModify.addActionListener(JBActionListener); JBModify.setActionCommand("modify"); JPContainer.add(JBModify);

//-- Add the JBSearch JBSearch.setBounds(212,382,99,25); JBSearch.setFont(new Font("Dialog", Font.PLAIN, 12)); JBSearch.setMnemonic(KeyEvent.VK_S); JBSearch.addActionListener(JBActionListener); JBSearch.setActionCommand("search"); JPContainer.add(JBSearch);

//-- Add the JBPrint JBPrint.setBounds(312,382,99,25); JBPrint.setFont(new Font("Dialog", Font.PLAIN, 12));

JBPrint.setMnemonic(KeyEvent.VK_P); JBPrint.addActionListener(JBActionListener); JBPrint.setActionCommand("print"); JPContainer.add(JBPrint); //-- Add the JBDelete JBDelete.setBounds(413,382,105,25); JBDelete.setFont(new Font("Dialog", Font.PLAIN, 12)); JBDelete.setMnemonic(KeyEvent.VK_D); JBDelete.addActionListener(JBActionListener); JBDelete.setActionCommand("delete"); JPContainer.add(JBDelete);

//-- Add the JBReload JBReload.setBounds(627,382,105,25); JBReload.setFont(new Font("Dialog", Font.PLAIN, 12)); JBReload.setMnemonic(KeyEvent.VK_R); JBReload.addActionListener(JBActionListener); JBReload.setActionCommand("reload"); JPContainer.add(JBReload);

//End initialize variables

//Start set the form properties getContentPane().add(JPContainer);

setSize(747,450);

setLocation((screen.width - 747)/2,((screen.height-450)/2)-45); setFrameIcon(new ImageIcon("images/SalesRep.png")); //End set the form properties

} /********************** FrmSalesRep constructor end ***********************/

/************************** Start event handling **************************/

ActionListener JBActionListener = new ActionListener(){ public void actionPerformed(ActionEvent e){ String srcObj = e.getActionCommand(); //Add Record if(srcObj=="add"){ JDialog JDAdd = new frm_add_edit_salesrep(true,JFParentFrame,cnSlr,""); JDAdd.show(); //Modify Record }else if(srcObj=="modify"){ if(total != 0){ try{

if(JTSlrTable.getValueAt(JTSlrTable.getSelectedRow(),JTSlrTable.getSelectedColumn( )) != null){ JDialog JDEdit = new frm_add_edit_salesrep(false,JFParentFrame,cnSlr,"SELECT * FROM tblSalesRep WHERE SalesRepIndex = " + JTSlrTable.getValueAt(JTSlrTable.getSelectedRow(),0)); JDEdit.show();

} }catch(Exception sqlE){ if(sqlE.getMessage() != null){ System.out.println(sqlE.getMessage()); }else{ JOptionPane.showMessageDialog(null,"Please select a record in the list to modify.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); }

} } //Search Record }else if(srcObj=="search"){ JDialog JDSearchRec = new FrmSearchSalesRep(JFParentFrame); JDSearchRec.show(true); //Print Record }else if(srcObj=="print"){ if(total != 0){ try{

if(JTSlrTable.getValueAt(JTSlrTable.getSelectedRow(),JTSlrTable.getSelectedColumn( )) != null){ clsPublicMethods PrintingClass = new clsPublicMethods();

ResultSet rsPrint = stSlr.executeQuery("SELECT * FROM tblSalesRep WHERE SalesRepIndex = " + JTSlrTable.getValueAt(JTSlrTable.getSelectedRow(),0)); if(rsPrint.next()==true){ String RecordToPrint = ""; java.util.Date CurrentDate = new java.util.Date(); SimpleDateFormat SDFDateFormatter = new SimpleDateFormat("MMM. dd, yyyy",Locale.getDefault());

RecordToPrint += " SUPPLIER RECORD \n"; RecordToPrint += " " + SDFDateFormatter.format(CurrentDate).toString() + "\n\n\n";

RecordToPrint += "-----------------------------------------------------------------------------------\n\n";

SalesRep ID: " + rsPrint.getString("SalesRepID") + " rsPrint.getString("SalesRepName") + "\n\n";

RecordToPrint += " SalesRep Name: " +

RecordToPrint += " Primary Address: " + rsPrint.getString("Address1") + "\n"; RecordToPrint += " Secondary Address: " + rsPrint.getString("Address2") + "\n"; RecordToPrint += " City: " + rsPrint.getString("City") + "\n"; RecordToPrint += " State/Province: " + rsPrint.getString("StateProvince") + "\n";

RecordToPrint += " Zip Code: " + rsPrint.getString("ZipCode") + "\n"; RecordToPrint += " Contact No: " + rsPrint.getString("ContactNo") + "\n"; RecordToPrint += " Email Address: " + rsPrint.getString("EmailAddress") + "\n\n";

RecordToPrint += "-----------------------------------------------------------------------------------\n\n\n";

PrintingClass.printRecord(RecordToPrint,JFParentFrame);

CurrentDate=null; SDFDateFormatter=null; RecordToPrint=null;

}else{ JOptionPane.showMessageDialog(null,"The selected record has been change since last modified. Please click the 'Reload' button and try again!","No record to print",JOptionPane.WARNING_MESSAGE); } //Dispose the variable rsPrint=null;

} }catch(Exception sqlE){ if(sqlE.getMessage() != null){

System.out.println(sqlE.getMessage()); }else{ JOptionPane.showMessageDialog(null,"Please select a record in the list to print.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); } } } //Delete Record }else if(srcObj=="delete"){ if(total != 0){ try{

if(JTSlrTable.getValueAt(JTSlrTable.getSelectedRow(),JTSlrTable.getSelectedColumn( )) != null){ String ObjButtons[] = {"Yes","No"}; int PromptResult = JOptionPane.showOptionDialog(null,"Are you sure you want to delete the selected record?","Delete Record",JOptionPane.DEFAULT_OPTION,JOptionPane.ERROR_MESSAGE,null,ObjButto ns,ObjButtons[1]); if(PromptResult==0){ stSlr.execute("DELETE * FROM tblSalesRep WHERE SalesRepIndex = " + JTSlrTable.getValueAt(JTSlrTable.getSelectedRow(),0)); reloadRecord(); JOptionPane.showMessageDialog(null,"Record has been successfully deleted.","Comfirm Delete",JOptionPane.INFORMATION_MESSAGE); }

} }catch(Exception sqlE){ if(sqlE.getMessage()!=null){ JOptionPane.showMessageDialog(null,"You cannot delete this SalesRep because it already used in product table.\nIn order to delete this SalesRep, delete all the product of this SalesRep.","Comfirm Delete",JOptionPane.WARNING_MESSAGE); }else{ JOptionPane.showMessageDialog(null,"Please select a record in the list to deleted.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); } } } //Reload Record }else if(srcObj=="reload"){ reloadRecord(); //Close the Form } } };

/*************************** End event handling ***************************/

/*************************** Start Custom class ***************************/

public static JTable CreateTable(){ String ColumnHeaderName[] = {

"Index","Sales Rep. ID","Name" }; try{ rsSlr = stSlr.executeQuery(strSQL); total = 0; //Move to the last record rsSlr.afterLast(); //Get the current record position if(rsSlr.previous())total = rsSlr.getRow(); //Move back to the first record; rsSlr.beforeFirst(); if(total != 0){ Content = new String[total][3]; while(rsSlr.next()){ Content[rowNum][0] = "" + rsSlr.getString("SalesRepIndex"); Content[rowNum][1] = "" + rsSlr.getString("SalesRepID"); Content[rowNum][2] = "" + rsSlr.getString("Name"); rowNum++; } }else{ Content = new String[0][3]; Content[0][0] = " "; Content[0][1] = " "; Content[0][2] = " ";

} }catch(Exception eE){ } JTable NewTable = new JTable (Content,ColumnHeaderName){ public boolean isCellEditable (int iRows, int iCols) { return false; } };

NewTable.setPreferredScrollableViewportSize(new Dimension(727, 320)); NewTable.setBackground(Color.white);

//Start resize the table column NewTable.getColumnModel().getColumn(0).setMaxWidth(0); NewTable.getColumnModel().getColumn(0).setMinWidth(0); NewTable.getColumnModel().getColumn(0).setWidth(0); NewTable.getColumnModel().getColumn(0).setPreferredWidth(0); NewTable.getColumnModel().getColumn(1).setPreferredWidth(100); NewTable.getColumnModel().getColumn(2).setPreferredWidth(500); //End resize the table column

//Disposed variables ColumnHeaderName=null; Content=null;

rowNum = 0;

return NewTable; }

/**************************** End Custom class ****************************/

/************************** Start Custom method ***************************/

public static void reloadRecord(String srcSQL){ strSQL = srcSQL; SlrTableJSP.getViewport().remove(JTSlrTable); JTSlrTable=CreateTable(); SlrTableJSP.getViewport().add(JTSlrTable); JPContainer.repaint(); }

public static void reloadRecord(){ SlrTableJSP.getViewport().remove(JTSlrTable); JTSlrTable=CreateTable(); SlrTableJSP.getViewport().add(JTSlrTable); JPContainer.repaint(); }

/*************************** End Custom method ****************************/

Edit warehouse

import javax.swing.*; import java.awt.*; import java.awt.event.*;

public class FrmSearchWarehouse extends JDialog{ //Start create variables JButton JBSearch = new JButton("Search",new ImageIcon("images/search.png")); JButton JBCancel = new JButton("Cancel",new ImageIcon("images/cancel.png"));

JLabel JLPic1 = new JLabel(new ImageIcon("images/bSearch.png")); JLabel JLBanner = new JLabel("Enter text and select where to locate."); JPanel JPDialogContainer = new JPanel();

JLabel JLSearchFor = new JLabel("Search For:"); JLabel JLSearchIn = new JLabel("Look In:");

JTextField JTFSearchFor = new JTextField();

JComboBox JCSearchIn;

Dimension screen =

Toolkit.getDefaultToolkit().getScreenSize();

//End create variables

public FrmSearchWarehouse(JFrame OwnerForm){ super(OwnerForm,true); setTitle("Search Warehouse");

//Start Initalize variables String StrListItem[]={"Warehouse ID","Warehouse Name","Contact Person"}; JCSearchIn = new JComboBox(StrListItem); StrListItem = null;

JPDialogContainer.setLayout(null);

//-- Add the JLPic1 JLPic1.setBounds(5,5,32,32); JPDialogContainer.add(JLPic1);

//-- Add the JLBanner JLBanner.setBounds(55,5,280,48); JLBanner.setFont(new Font("Dialog",Font.PLAIN,12)); JPDialogContainer.add(JLBanner); //End initialize variables

//******************** Start adding of input field //-- Add Id Input Field JLSearchFor.setBounds(5,50,105,20); JLSearchFor.setFont(new Font("Dialog",Font.PLAIN,12));

JTFSearchFor.setBounds(110,50,225,20); JTFSearchFor.setFont(new Font("Dialog",Font.PLAIN,12));

JPDialogContainer.add(JLSearchFor); JPDialogContainer.add(JTFSearchFor);

//-- Add Name Input Field JLSearchIn.setBounds(5,72,105,20); JLSearchIn.setFont(new Font("Dialog",Font.PLAIN,12));

JCSearchIn.setBounds(110,72,225,20); JCSearchIn.setFont(new Font("Dialog",Font.PLAIN,12));

JPDialogContainer.add(JLSearchIn); JPDialogContainer.add(JCSearchIn); //******************** End adding of input field

//-- Add the JBSearch JBSearch.setBounds(137,100,99,25); JBSearch.setFont(new Font("Dialog", Font.PLAIN, 12)); JBSearch.setMnemonic(KeyEvent.VK_S); JBSearch.addActionListener(JBActionListener); JBSearch.setActionCommand("search"); JPDialogContainer.add(JBSearch);

//-- Add the JBCancel

JBCancel.setBounds(237,100,99,25); JBCancel.setFont(new Font("Dialog", Font.PLAIN, 12)); JBCancel.setMnemonic(KeyEvent.VK_C); JBCancel.addActionListener(JBActionListener); JBCancel.setActionCommand("cancel"); JPDialogContainer.add(JBCancel);

getContentPane().add(JPDialogContainer); setSize(350,165); setResizable(false); setLocation((screen.width - 350)/2,((screen.height-165)/2));

} ActionListener JBActionListener = new ActionListener(){ public void actionPerformed(ActionEvent e){ String srcObj = e.getActionCommand(); if(srcObj=="search"){ if(JTFSearchFor.getText().equals("")){ JOptionPane.showMessageDialog(null,"Please enter a text to search.","Naparansoft Inventory System",JOptionPane.WARNING_MESSAGE); JTFSearchFor.requestFocus(); }else{ FrmWarehouse.reloadRecord("SELECT * FROM tblWarehouse WHERE " + JCSearchIn.getSelectedItem().toString().replaceAll(" ", "") + " LIKE '%" + JTFSearchFor.getText() + "%' ORDER BY WarehouseName ASC"); dispose(); }

}else{ dispose(); } } }; }

Edit product :\

import javax.swing.*; import java.sql.*; import java.awt.*; import java.awt.event.*; public class frm_add_edit_product extends JDialog{ JButton JBUpdate = new JButton(new ImageIcon("images/save.png")); JButton JBReset = new JButton("Reset",new ImageIcon("images/reset.png")); JButton JBCancel = new JButton("Cancel",new ImageIcon("images/cancel.png"));

JLabel JLPic1 = new JLabel(); JLabel JLBanner = new JLabel("Please fill-up all the required fields.");

JLabel JLId = new JLabel("Warehouse ID:"); JLabel JLName = new JLabel("Warehouse Name:"); JLabel JLCPerson = new JLabel("Contact Person:"); JLabel JLCTitle = new JLabel("Contact Title:"); JLabel JLAddr = new JLabel("Address:"); JLabel JLCity = new JLabel("CityTown:");

JLabel JLStateProv = new JLabel("State/Province:"); JLabel JLZipCode = new JLabel("Zip Code:"); JLabel JLPhone = new JLabel("Phone:"); JLabel JLFax = new JLabel("Fax:");

JTextField JTFId = new JTextField(); JTextField JTFName = new JTextField(); JTextField JTFCPerson = new JTextField(); JTextField JTFCTitle = new JTextField(); JTextField JTFAddr = new JTextField(); JTextField JTFCity = new JTextField(); JTextField JTFStateProv = new JTextField(); JTextField JTFZipCode = new JTextField(); JTextField JTFPhone = new JTextField(); JTextField JTFFax = new JTextField();

Connection cnAEW; Statement stAEW; ResultSet rsAEW;

Dimension screen =

Toolkit.getDefaultToolkit().getScreenSize();

boolean ADDING_STATE;

public frm_add_edit_product(boolean srcCN,String srcSQL){ super(OwnerForm,true);

ADD_STATE,JFrame

OwnerForm,Connection

cnAEW = srcCN; ADDING_STATE = ADD_STATE; try{ stAEW = cnAEW.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABL E); }catch( SQLException sqlEx){

} if(ADD_STATE==true){ JLPic1.setIcon(new ImageIcon("images/bNew.png")); setTitle("Add New Warehouse"); JBUpdate.setText("Update"); }else{ JLPic1.setIcon(new ImageIcon("images/bModify.png")); setTitle("Modify Warehouse"); JBUpdate.setText("Save"); try{ rsAEW = stAEW.executeQuery(srcSQL); rsAEW.next(); JTFId.setText("" + rsAEW.getString("WarehouseID")); JTFName.setText("" + rsAEW.getString("WarehouseName")); JTFCPerson.setText("" + rsAEW.getString("ContactPerson")); JTFCTitle.setText("" + rsAEW.getString("ContactTitle")); JTFAddr.setText("" + rsAEW.getString("Address")); JTFCity.setText("" + rsAEW.getString("CityTown")); JTFStateProv.setText("" + rsAEW.getString("StateProvince")); JTFZipCode.setText("" + rsAEW.getString("ZipCode"));

JTFPhone.setText("" + rsAEW.getString("Phone")); JTFFax.setText("" + rsAEW.getString("Fax")); }catch(SQLException sqlEx){ System.out.println(sqlEx.getMessage()); } } JPanel JPContainer = new JPanel(); JPContainer.setLayout(null); //-- Add the JLPic1 JLPic1.setBounds(5,5,32,32); JPContainer.add(JLPic1);

//-- Add the JLBanner JLBanner.setBounds(55,5,268,48); JLBanner.setFont(new Font("Dialog",Font.PLAIN,12)); JPContainer.add(JLBanner);

//******************** Start adding of input field //-- Add Id Input Field JLId.setBounds(5,50,105,20); JLId.setFont(new Font("Dialog",Font.PLAIN,12));

JTFId.setBounds(110,50,200,20); JTFId.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLId); JPContainer.add(JTFId);

//-- Add Name Input Field JLName.setBounds(5,72,105,20); JLName.setFont(new Font("Dialog",Font.PLAIN,12));

JTFName.setBounds(110,72,200,20); JTFName.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLName); JPContainer.add(JTFName);

//-- Add Contact Person Input Field JLCPerson.setBounds(5,94,105,20); JLCPerson.setFont(new Font("Dialog",Font.PLAIN,12));

JTFCPerson.setBounds(110,94,200,20); JTFCPerson.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLCPerson); JPContainer.add(JTFCPerson);

//-- Add Primary Address Input Field JLCTitle.setBounds(5,116,105,20); JLCTitle.setFont(new Font("Dialog",Font.PLAIN,12));

JTFCTitle.setBounds(110,116,200,20); JTFCTitle.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLCTitle); JPContainer.add(JTFCTitle);

//-- Add Secondary Address Input Field JLAddr.setBounds(5,138,105,20); JLAddr.setFont(new Font("Dialog",Font.PLAIN,12));

JTFAddr.setBounds(110,138,200,20); JTFAddr.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLAddr); JPContainer.add(JTFAddr);

//-- Add CityTown Input Field JLCity.setBounds(5,160,105,20); JLCity.setFont(new Font("Dialog",Font.PLAIN,12));

JTFCity.setBounds(110,160,200,20); JTFCity.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLCity); JPContainer.add(JTFCity);

//-- Add StateProvince Input Field JLStateProv.setBounds(5,182,105,20); JLStateProv.setFont(new Font("Dialog",Font.PLAIN,12));

JTFStateProv.setBounds(110,182,200,20); JTFStateProv.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLStateProv); JPContainer.add(JTFStateProv); //-- Add Zip Code Input Field JLZipCode.setBounds(5,204,105,20); JLZipCode.setFont(new Font("Dialog",Font.PLAIN,12));

JTFZipCode.setBounds(110,204,200,20); JTFZipCode.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLZipCode); JPContainer.add(JTFZipCode);

//-- Add Contact Number Input Field JLPhone.setBounds(5,226,105,20); JLPhone.setFont(new Font("Dialog",Font.PLAIN,12));

JTFPhone.setBounds(110,226,200,20); JTFPhone.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLPhone); JPContainer.add(JTFPhone);

//-- Add E-mail Address Input Field

JLFax.setBounds(5,248,105,20); JLFax.setFont(new Font("Dialog",Font.PLAIN,12));

JTFFax.setBounds(110,248,200,20); JTFFax.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLFax); JPContainer.add(JTFFax);

//******************** End adding of input field

//-- Add the JBUpdate JBUpdate.setBounds(5,292,105,25); JBUpdate.setFont(new Font("Dialog", Font.PLAIN, 12)); JBUpdate.setMnemonic(KeyEvent.VK_A); JBUpdate.addActionListener(JBActionListener); JBUpdate.setActionCommand("update"); JPContainer.add(JBUpdate);

//-- Add the JBReset JBReset.setBounds(112,292,99,25); JBReset.setFont(new Font("Dialog", Font.PLAIN, 12)); JBReset.setMnemonic(KeyEvent.VK_R); JBReset.addActionListener(JBActionListener); JBReset.setActionCommand("reset"); JPContainer.add(JBReset);

//-- Add the JBCancel JBCancel.setBounds(212,292,99,25); JBCancel.setFont(new Font("Dialog", Font.PLAIN, 12)); JBCancel.setMnemonic(KeyEvent.VK_C); JBCancel.addActionListener(JBActionListener); JBCancel.setActionCommand("cancel"); JPContainer.add(JBCancel);

getContentPane().add(JPContainer); setSize(325,357); setResizable(false); setLocation((screen.width - 325)/2,((screen.height-357)/2)); } private boolean RequiredFieldEmpty(){ if(JTFId.getText().equals("") JTFCPerson.getText().equals("")){ || JTFName.getText().equals("") ||

JOptionPane.showMessageDialog(null,"Some required fields is/are empty.\nPlease check it and try again.","Naparansoft Inventory System",JOptionPane.WARNING_MESSAGE); JTFId.requestFocus(); return true; }else{ return false; } } private void clearFields(){ JTFId.setText(""); JTFName.setText("");

JTFCPerson.setText(""); JTFCTitle.setText(""); JTFAddr.setText(""); JTFCity.setText(""); JTFStateProv.setText(""); JTFZipCode.setText(""); JTFPhone.setText(""); JTFFax.setText(""); }

ActionListener JBActionListener = new ActionListener(){ public void actionPerformed(ActionEvent e){ String srcObj = e.getActionCommand(); if(srcObj=="update"){ if(RequiredFieldEmpty()==false){ if(ADDING_STATE == true){ try{

stAEW.executeUpdate("INSERT INTO tblWarehouse(WarehouseID,WarehouseName,ContactPerson,ContactTitle,Address,CityTown,StateProvi nce,ZipCode,Phone,Fax) " + "VALUES ('" + JTFId.getText() + "', '" + JTFName.getText() + "', '" + JTFCPerson.getText() + "', '" +

JTFCTitle.getText() + "', '" + JTFAddr.getText() + "', '" + JTFCity.getText() + "', '" + JTFStateProv.getText() + "', '" + JTFZipCode.getText() + "', '" + JTFPhone.getText() + "', '" + JTFFax.getText() + "')"); // Start Display the new record int total =0; total = clsPublicMethods.getMaxNum("SELECT * FROM tblWarehouse ORDER BY WarehouseIndex ASC",cnAEW,"WarehouseIndex"); if(total != 0){ FrmWarehouse.reloadRecord("SELECT * FROM tblWarehouse WHERE WarehouseIndex = " + total + " ORDER BY WarehouseName ASC"); }else{ FrmWarehouse.reloadRecord("SELECT * FROM tblWarehouse ORDER BY WarehouseName ASC"); } total =0; // End Display the new record record has been successfully System",JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null,"New added.","Naparansoft Inventory String ObjButtons[] = {"Yes","No"};

int PromptResult = JOptionPane.showOptionDialog(null,"Do you want add another record?","Naparansoft Inventory System",JOptionPane.DEFAULT_OPTION,JOptionPane.QUESTION_MESSAGE,null,ObjButtons,Obj Buttons[0]); if(PromptResult==0){ clearFields(); JTFId.requestFocus(true); }else{ dispose(); } }catch(SQLException sqlEx){ System.out.println(sqlEx.getMessage()); } }else{ try{ String RowIndex; RowIndex rsAEW.getString("WarehouseIndex"); stAEW.executeUpdate("UPDATE tblWarehouse SET WarehouseID = '" + JTFId.getText() + "', WarehouseName = '" + JTFName.getText() + "', ContactPerson = '" + JTFCPerson.getText() + "', ContactTitle = '" + JTFCTitle.getText() + "', Address = '" + JTFAddr.getText() + "', CityTown = '" + JTFCity.getText() + "', StateProvince = '" + =

JTFStateProv.getText() + "', ZipCode = '" + JTFZipCode.getText() + "', Phone = '" + JTFPhone.getText() + "', Fax = '" + JTFFax.getText() + "' WHERE WarehouseIndex = " + RowIndex); FrmWarehouse.reloadRecord("SELECT * FROM tblWarehouse WHERE WarehouseIndex = " + RowIndex + " ORDER BY WarehouseName ASC"); JOptionPane.showMessageDialog(null,"Changes in the record has been save.","Naparansoft Inventory System",JOptionPane.INFORMATION_MESSAGE); dispose(); }catch(SQLException sqlEx){ System.out.println(sqlEx.getMessage()); } } } }else if(srcObj=="reset"){ clearFields(); }else if(srcObj=="cancel"){ dispose(); } } }; successfully

Edit supplier
import javax.swing.*; import java.sql.*; import java.awt.*; import java.awt.event.*;

public class frm_add_edit_supplier extends JDialog{ JButton JBUpdate = new JButton(new ImageIcon("images/save.png")); JButton JBReset = new JButton("Reset",new ImageIcon("images/reset.png")); JButton JBCancel = new JButton("Cancel",new ImageIcon("images/cancel.png"));

JLabel JLPic1 = new JLabel(); JLabel JLBanner = new JLabel("Please fill-up all the required fields.");

JLabel JLId = new JLabel("Supplier ID:"); JLabel JLName = new JLabel("Supplier Name:"); JLabel JLContName = new JLabel("Contact Name:"); JLabel JLContTitle = new JLabel("Contact Title:"); JLabel JLAddr = new JLabel("Address:"); JLabel JLCity = new JLabel("City/Town:"); JLabel JLState = new JLabel("State/Province:"); JLabel JLZipCode = new JLabel("Zip Code:"); JLabel JLCountry = new JLabel("Country:"); JLabel JLPhone = new JLabel("Phone:"); JLabel JLFax = new JLabel("Fax:"); JLabel JLWebsite = new JLabel("Website:");

JTextField JTFId = new JTextField(); JTextField JTFName = new JTextField(); JTextField JTFContName = new JTextField(); JTextField JTFContTitle = new JTextField(); JTextField JTFAddr = new JTextField(); JTextField JTFCity = new JTextField(); JTextField JTFState = new JTextField(); JTextField JTFZipCode = new JTextField(); JComboBox JCBCountry; JTextField JTFPhone = new JTextField(); JTextField JTFFax = new JTextField(); JTextField JTFWebsite = new JTextField();

Connection cnAES; Statement stAES; ResultSet rsAES;

Dimension screen = boolean ADDING_STATE;

Toolkit.getDefaultToolkit().getScreenSize();

public frm_add_edit_supplier(boolean srcCN,String srcSQL){ super(OwnerForm,true); cnAES = srcCN; ADDING_STATE = ADD_STATE; try{

ADD_STATE,JFrame

OwnerForm,Connection

stAES = cnAES.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE ); }catch( SQLException sqlEx){ System.out.println("\nERROR frm_add_edit_supplier(frm_add_edit_supplier):" + sqlEx + "\n"); } IN

JCBCountry tblCountry",cnAES,"Name");

clsPublicMethods.fillCombo("SELECT

FROM

if(ADD_STATE==true){ JLPic1.setIcon(new ImageIcon("images/bNew.png")); setTitle("Add New Supplier"); JBUpdate.setText("Update");

}else{ JLPic1.setIcon(new ImageIcon("images/bModify.png")); setTitle("Modify Supplier"); JBUpdate.setText("Save"); try{ rsAES = stAES.executeQuery(srcSQL); rsAES.next(); JTFId.setText("" + rsAES.getString("SupplierID")); JTFName.setText("" + rsAES.getString("CompanyName")); JTFContName.setText("" + rsAES.getString("ContactName")); JTFContTitle.setText("" + rsAES.getString("ContactTitle")); JTFAddr.setText("" + rsAES.getString("Address")); JTFCity.setText("" + rsAES.getString("CityTown"));

JTFState.setText("" + rsAES.getString("StateProvince")); JTFZipCode.setText("" + rsAES.getString("ZipCode")); //searchInComboPos JCBCountry.setSelectedItem("" + rsAES.getString("Country")); JTFPhone.setText("" + rsAES.getString("Phone")); JTFFax.setText("" + rsAES.getString("Fax")); JTFWebsite.setText("" + rsAES.getString("Website")); }catch(SQLException sqlEx){ System.out.println(sqlEx.getMessage()); } } JPanel JPContainer = new JPanel(); JPContainer.setLayout(null); //-- Add the JLPic1 JLPic1.setBounds(5,5,32,32); JPContainer.add(JLPic1);

//-- Add the JLBanner JLBanner.setBounds(55,5,268,48); JLBanner.setFont(new Font("Dialog",Font.PLAIN,12)); JPContainer.add(JLBanner);

//******************** Start adding of input field //-- Add Id Input Field JLId.setBounds(5,50,105,20); JLId.setFont(new Font("Dialog",Font.PLAIN,12));

JTFId.setBounds(110,50,200,20); JTFId.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLId); JPContainer.add(JTFId);

//-- Add Name Input Field JLName.setBounds(5,72,105,20); JLName.setFont(new Font("Dialog",Font.PLAIN,12));

JTFName.setBounds(110,72,200,20); JTFName.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLName); JPContainer.add(JTFName); //-- Add Contact Name Input Field JLContName.setBounds(5,94,105,20); JLContName.setFont(new Font("Dialog",Font.PLAIN,12));

JTFContName.setBounds(110,94,200,20); JTFContName.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLContName); JPContainer.add(JTFContName);

//-- Add Contact Title Input Field JLContTitle.setBounds(5,116,105,20);

JLContTitle.setFont(new Font("Dialog",Font.PLAIN,12));

JTFContTitle.setBounds(110,116,200,20); JTFContTitle.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLContTitle); JPContainer.add(JTFContTitle);

//-- Add Address Input Field JLAddr.setBounds(5,138,105,20); JLAddr.setFont(new Font("Dialog",Font.PLAIN,12));

JTFAddr.setBounds(110,138,200,20); JTFAddr.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLAddr); JPContainer.add(JTFAddr);

//-- Add City Input Field JLCity.setBounds(5,160,105,20); JLCity.setFont(new Font("Dialog",Font.PLAIN,12));

JTFCity.setBounds(110,160,200,20); JTFCity.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLCity); JPContainer.add(JTFCity);

//-- Add State/Province Input Field JLState.setBounds(5,182,105,20); JLState.setFont(new Font("Dialog",Font.PLAIN,12));

JTFState.setBounds(110,182,200,20); JTFState.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLState); JPContainer.add(JTFState);

//-- Add Zip Code Input Field JLZipCode.setBounds(5,204,105,20); JLZipCode.setFont(new Font("Dialog",Font.PLAIN,12));

JTFZipCode.setBounds(110,204,200,20); JTFZipCode.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLZipCode); JPContainer.add(JTFZipCode); //-- Add Country Input Field JLCountry.setBounds(5,226,105,20); JLCountry.setFont(new Font("Dialog",Font.PLAIN,12));

JCBCountry.setBounds(110,226,200,20); JCBCountry.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLCountry); JPContainer.add(JCBCountry);

//-- Add Phone Input Field JLPhone.setBounds(5,248,105,20); JLPhone.setFont(new Font("Dialog",Font.PLAIN,12));

JTFPhone.setBounds(110,248,200,20); JTFPhone.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLPhone); JPContainer.add(JTFPhone);

//-- Add Fax Input Field JLFax.setBounds(5,270,105,20); JLFax.setFont(new Font("Dialog",Font.PLAIN,12));

JTFFax.setBounds(110,270,200,20); JTFFax.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLFax); JPContainer.add(JTFFax);

//-- Add Website Input Field JLWebsite.setBounds(5,292,105,20); JLWebsite.setFont(new Font("Dialog",Font.PLAIN,12));

JTFWebsite.setBounds(110,292,200,20); JTFWebsite.setFont(new Font("Dialog",Font.PLAIN,12));

JPContainer.add(JLWebsite); JPContainer.add(JTFWebsite);

//******************** End adding of input field

//-- Add the JBUpdate JBUpdate.setBounds(5,340,105,25); JBUpdate.setFont(new Font("Dialog", Font.PLAIN, 12)); JBUpdate.setMnemonic(KeyEvent.VK_A); JBUpdate.addActionListener(JBActionListener); JBUpdate.setActionCommand("update"); JPContainer.add(JBUpdate);

//-- Add the JBReset JBReset.setBounds(112,340,99,25); JBReset.setFont(new Font("Dialog", Font.PLAIN, 12)); JBReset.setMnemonic(KeyEvent.VK_R); JBReset.addActionListener(JBActionListener); JBReset.setActionCommand("reset"); JPContainer.add(JBReset);

//-- Add the JBCancel JBCancel.setBounds(212,340,99,25); JBCancel.setFont(new Font("Dialog", Font.PLAIN, 12));

JBCancel.setMnemonic(KeyEvent.VK_C); JBCancel.addActionListener(JBActionListener); JBCancel.setActionCommand("cancel"); JPContainer.add(JBCancel);

getContentPane().add(JPContainer); setSize(325,405); setResizable(false); setLocation((screen.width - 325)/2,((screen.height-405)/2)); } private boolean RequiredFieldEmpty(){ if(JTFId.getText().equals("") || JTFName.getText().equals("")){ JOptionPane.showMessageDialog(null,"Some required fields is/are empty.\nPlease check it and try again.","Naparansoft Inventory System",JOptionPane.WARNING_MESSAGE); JTFId.requestFocus(); return true; }else{ return false; } } private void clearFields(){ JTFId.setText(""); JTFName.setText(""); JTFContName.setText(""); JTFContTitle.setText(""); JTFAddr.setText(""); JTFCity.setText("");

JTFState.setText(""); JTFZipCode.setText(""); JCBCountry.setSelectedIndex(0); JTFPhone.setText(""); JTFFax.setText(""); JTFWebsite.setText(""); }

ActionListener JBActionListener = new ActionListener(){ public void actionPerformed(ActionEvent e){ String srcObj = e.getActionCommand(); if(srcObj=="update"){ if(RequiredFieldEmpty()==false){ if(ADDING_STATE == true){ try{

stAES.executeUpdate("INSERT INTO tblSupplier(SupplierID,CompanyName,ContactName,ContactTitle,Address,CityTown,StateProvince,Zip Code,Country,Phone,Fax,Website) " + "VALUES ('" + JTFId.getText() + "', '" + JTFName.getText() + "', '" + JTFContName.getText() + "', '" + JTFContTitle.getText() + "', '" +

JTFAddr.getText() + "', '" + JTFCity.getText() + "', '" + JTFState.getText() + "', '" + JTFZipCode.getText() + "', '" + JCBCountry.getSelectedItem().toString() + "', '" + JTFPhone.getText() + "', '" + JTFFax.getText() + "', '" + JTFWebsite.getText() + "')"); // Start Display the new record int total =0; clsPublicMethods.getMaxNum("SELECT ASC",cnAES,"SupplierIndex"); * FROM total tblSupplier if(total != 0){ FrmSupplier.reloadRecord("SELECT * FROM tblSupplier WHERE SupplierIndex = " + total + " ORDER BY CompanyName ASC"); }else{ FrmSupplier.reloadRecord("SELECT * FROM tblSupplier ORDER BY CompanyName ASC"); } total =0; // End Display the new record ORDER BY = SupplierIndex

record has been successfully System",JOptionPane.INFORMATION_MESSAGE);

JOptionPane.showMessageDialog(null,"New added.","Naparansoft Inventory String ObjButtons[] = {"Yes","No"};

int PromptResult = JOptionPane.showOptionDialog(null,"Do you want add another record?","Naparansoft Inventory System",JOptionPane.DEFAULT_OPTION,JOptionPane.QUESTION_MESSAGE,null,ObjButtons,Obj Buttons[0]); if(PromptResult==0){ clearFields(); JTFId.requestFocus(true); }else{ dispose(); } }catch(SQLException sqlEx){ System.out.println(sqlEx.getMessage()); } }else{ try{ String RowIndex; RowIndex = rsAES.getString("SupplierIndex"); stAES.executeUpdate("UPDATE SET SupplierID = '" + JTFId.getText() + "', CompanyName = '" + JTFName.getText() + "', ContactName = '" + JTFContName.getText() + "', ContactTitle = '" + JTFContTitle.getText() + "', Address = '" + tblSupplier

JTFAddr.getText() + "', CityTown = '" + JTFCity.getText() + "', StateProvince = '" + JTFState.getText() + "', ZipCode = '" + JTFZipCode.getText() + "', Country = '" + JCBCountry.getSelectedItem().toString() + "', Phone = '" + JTFPhone.getText() + "', Fax = '" + JTFFax.getText() + "', Website = '" + JTFWebsite.getText() + "' WHERE SupplierIndex = " + RowIndex); FrmSupplier.reloadRecord("SELECT * FROM tblSupplier WHERE SupplierIndex = " + RowIndex + " ORDER BY CompanyName ASC"); JOptionPane.showMessageDialog(null,"Changes in the record has been save.","Naparansoft Inventory System",JOptionPane.INFORMATION_MESSAGE); RowIndex=""; dispose(); }catch(SQLException sqlEx){ System.out.println(sqlEx.getMessage()); } } } }else if(srcObj=="reset"){ clearFields(); successfully

}else if(srcObj=="cancel"){ dispose(); } } };

Product
import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.sql.*; import javax.swing.table.*; import java.awt.PrintJob; import java.util.*; import java.text.*;

public class FrmProduct extends JInternalFrame{

/************************ Variable declaration start **********************/

//Start form variables public static JScrollPane CusTableJSP = new JScrollPane();

public static JPanel JPContainer = new JPanel();

public static JTable JTCusTable;

JLabel JLPicture1 = new JLabel(new ImageIcon("images/helper.png")); JLabel JLHelpText = new JLabel("To display a certain \n record click the 'search button' and look for the record that you want.");

JFrame JFParentFrame;

JButton JBAddNew = new JButton("Add New",new ImageIcon("images/new.png")); JButton JBModify = new JButton("Modify",new ImageIcon("images/modify.png")); JButton JBSearch = new JButton("Search",new ImageIcon("images/search.png")); JButton JBPrint = new JButton("Print",new ImageIcon("images/print.png")); JButton JBDelete = new JButton("Delete",new ImageIcon("images/delete.png")); JButton JBReload = new JButton("Reload",new ImageIcon("images/reload.png"));

Connection cnCus;

public static Statement stCus;

public static ResultSet rsCus;

public static String strSQL; public static String Content[][];

public static int rowNum = 0;

public static int total = 0;

boolean goEOF;

Dimension screen =

Toolkit.getDefaultToolkit().getScreenSize();

//End form variables

/********************** End variable declaration start ********************/

/********************* Start FrmProduct constructor **********************/ public FrmProduct(Connection srcCN,JFrame getParentFrame) throws SQLException{ //Set the form caption and some properties start super("Product Records",false,true,false,true); //End set the form caption and some properties

//Start initialize variables JPContainer.setLayout(null);

JFParentFrame = getParentFrame;

cnCus = srcCN; stCus = cnCus.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY) ; strSQL = "SELECT * FROM tblItem WHERE ItemIndex = 0 ORDER BY Description ASC";

//-- Add the JLPicture1 JLPicture1.setBounds(5,5,48,48); JPContainer.add(JLPicture1);

//-- Add the JLHelpText JLHelpText.setBounds(55,5,570,48); JLHelpText.setFont(new Font("Dialog", Font.PLAIN, 12)); JPContainer.add(JLHelpText);

//-- Add the CusTable JTCusTable=CreateTable(); CusTableJSP.getViewport().add(JTCusTable); CusTableJSP.setBounds(5,55,727,320); JPContainer.add(CusTableJSP);

//-- Add the JBAddNew JBAddNew.setBounds(5,382,105,25); JBAddNew.setFont(new Font("Dialog", Font.PLAIN, 12)); JBAddNew.setMnemonic(KeyEvent.VK_A); JBAddNew.addActionListener(JBActionListener); JBAddNew.setActionCommand("add"); JPContainer.add(JBAddNew);

//-- Add the JBModify JBModify.setBounds(112,382,99,25); JBModify.setFont(new Font("Dialog", Font.PLAIN, 12)); JBModify.setMnemonic(KeyEvent.VK_M);

JBModify.addActionListener(JBActionListener); JBModify.setActionCommand("modify"); JPContainer.add(JBModify);

//-- Add the JBSearch JBSearch.setBounds(212,382,99,25); JBSearch.setFont(new Font("Dialog", Font.PLAIN, 12)); JBSearch.setMnemonic(KeyEvent.VK_S); JBSearch.addActionListener(JBActionListener); JBSearch.setActionCommand("search"); JPContainer.add(JBSearch);

//-- Add the JBPrint JBPrint.setBounds(312,382,99,25); JBPrint.setFont(new Font("Dialog", Font.PLAIN, 12)); JBPrint.setMnemonic(KeyEvent.VK_P); JBPrint.addActionListener(JBActionListener); JBPrint.setActionCommand("print"); JPContainer.add(JBPrint);

//-- Add the JBDelete JBDelete.setBounds(413,382,105,25); JBDelete.setFont(new Font("Dialog", Font.PLAIN, 12)); JBDelete.setMnemonic(KeyEvent.VK_D); JBDelete.addActionListener(JBActionListener); JBDelete.setActionCommand("delete"); JPContainer.add(JBDelete);

//-- Add the JBReload JBReload.setBounds(627,382,105,25); JBReload.setFont(new Font("Dialog", Font.PLAIN, 12)); JBReload.setMnemonic(KeyEvent.VK_R); JBReload.addActionListener(JBActionListener); JBReload.setActionCommand("reload"); JPContainer.add(JBReload);

//End initialize variables

//Start set the form properties getContentPane().add(JPContainer); setSize(747,450); setLocation((screen.width - 747)/2,((screen.height-450)/2)-45); setFrameIcon(new ImageIcon("images/customer.png")); //End set the form properties

} /********************** FrmProduct constructor end ***********************/

/************************** Start event handling **************************/

ActionListener JBActionListener = new ActionListener(){ public void actionPerformed(ActionEvent e){ String srcObj = e.getActionCommand(); //Add Record

if(srcObj=="add"){ JDialog frm_add_edit_product(true,JFParentFrame,cnCus,""); JDAdd = new

JDAdd.show();//Modify Record }else if(srcObj=="modify"){ if(total != 0){ try{ if(JTCusTable.getValueAt(JTCusTable.getSelectedRow(),JTCusTable.getSelectedColumn()) null){ JDialog JDEdit = new frm_add_edit_product(false,JFParentFrame,cnCus,"SELECT * FROM tblItem WHERE ItemIndex = " + JTCusTable.getValueAt(JTCusTable.getSelectedRow(),0)); JDEdit.show(); !=

} }catch(Exception sqlE){ if(sqlE.getMessage() != null){ System.out.println(sqlE.getMessage()); }else{ JOptionPane.showMessageDialog(null,"Please select a record in the list to modify.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); }

} } //Search Record }else if(srcObj=="search"){ JDialog JDSearchRec = new FrmSearchProduct(JFParentFrame);

JDSearchRec.show(true); //Print Record }else if(srcObj=="print"){ if(total != 0){ try{ if(JTCusTable.getValueAt(JTCusTable.getSelectedRow(),JTCusTable.getSelectedColumn()) null){ clsPublicMethods PrintingClass = new clsPublicMethods(); stCus.executeQuery("SELECT * FROM tblItem JTCusTable.getValueAt(JTCusTable.getSelectedRow(),0)); ResultSet WHERE rsPrint ItemIndex = " = + !=

if(rsPrint.next()==true){ String RecordToPrint = ""; java.util.Date new java.util.Date(); SimpleDateFormat SDFDateFormatter = new SimpleDateFormat("MMM. dd, yyyy",Locale.getDefault()); CurrentDate =

RecordToPrint CUSTOMER RECORD RecordToPrint " + SDFDateFormatter.format(CurrentDate).toString() + "\n\n\n"; \n";

+= +=

" "

RecordToPrint += "___________________________________________________________________________________\ n\n\n";

" + rsPrint.getString("ProductID") + " + "\n";

RecordToPrint += " Product ID: Company Name: " + rsPrint.getString("CompanyName")

RecordToPrint += "___________________________________________________________________________________\ n"; RecordToPrint += "___________________________________________________________________________________\ n\n";

RecordToPrint += " Contact Person: " + rsPrint.getString("ContactName") + "\n"; RecordToPrint += " Contact Title: " + rsPrint.getString("ContactTitle") + "\n"; RecordToPrint += " Address: " + rsPrint.getString("Address") + "\n"; RecordToPrint += " City: " + rsPrint.getString("CityTown") + "\n"; RecordToPrint State/Province: " + rsPrint.getString("StateProvince") + "\n"; RecordToPrint += " Zip Code: " + rsPrint.getString("ZipCode") + "\n"; RecordToPrint += " Country: " + rsPrint.getString("Country") + "\n"; RecordToPrint += " Phone: " + rsPrint.getString("Phone") + "\n"; RecordToPrint += " Fax: " + rsPrint.getString("Fax") + "\n\n"; += "

RecordToPrint += "___________________________________________________________________________________\ n\n";

PrintingClass.printRecord(RecordToPrint,JFParentFrame);

CurrentDate=null; SDFDateFormatter=null; RecordToPrint=null;

}else{ JOptionPane.showMessageDialog(null,"The selected record has been change since last modified. Please click the 'Reload' button and try again!","No record to print",JOptionPane.WARNING_MESSAGE); } //Dispose the variable rsPrint=null;

} }catch(Exception sqlE){ if(sqlE.getMessage() != null){ System.out.println(sqlE.getMessage()); }else{ JOptionPane.showMessageDialog(null,"Please select a record in the list to print.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); } } } //Delete Record }else if(srcObj=="delete"){ if(total != 0){

try{ if(JTCusTable.getValueAt(JTCusTable.getSelectedRow(),JTCusTable.getSelectedColumn()) null){ String ObjButtons[] = {"Yes","No"}; int PromptResult = JOptionPane.showOptionDialog(null,"Are you sure you want to delete the selected record?","Delete Record",JOptionPane.DEFAULT_OPTION,JOptionPane.ERROR_MESSAGE,null,ObjButtons,ObjButto ns[1]); if(PromptResult==0){ stCus.execute("DELETE * tblItem WHERE ItemIndex = " + JTCusTable.getValueAt(JTCusTable.getSelectedRow(),0)); reloadRecord(); JOptionPane.showMessageDialog(null,"Record Delete",JOptionPane.INFORMATION_MESSAGE); } } }catch(Exception sqlE){ if(sqlE.getMessage()!=null){ JOptionPane.showMessageDialog(null,"You cannot delete this customer because it already have an invoice transaction.\nIn order to delete this customer, delete its invoice first.","Comfirm Delete",JOptionPane.WARNING_MESSAGE); }else{ JOptionPane.showMessageDialog(null,"Please select a record in the list to deleted.","No Record Selected",JOptionPane.INFORMATION_MESSAGE); } } } //Reload Record }else if(srcObj=="reload"){ reloadRecord(); has been successfully deleted.","Comfirm FROM !=

//Close the Form } } }; /*************************** End event handling ***************************/

/************************** Start custom class ***************************/

public static JTable CreateTable(){ String ColumnHeaderName[] = { "Index","Item No","Description","Sales Price","On Hand" ,"On Order" }; try{ rsCus = stCus.executeQuery(strSQL); total = 0; //Move to the last record rsCus.afterLast(); //Get the current record position if(rsCus.previous())total = rsCus.getRow(); //Move back to the first record; rsCus.beforeFirst(); if(total > 0){ Content = new String[total][6]; while(rsCus.next()){ Content[rowNum][0] = "" + rsCus.getString("ItemIndex"); Content[rowNum][1] = "" + rsCus.getString("ItemNo"); Content[rowNum][2] = "" + rsCus.getString("Description");

Content[rowNum][3] = "" + rsCus.getString("SalesPrice"); Content[rowNum][4] = "" + rsCus.getString("QtyOnHand"); Content[rowNum][5] = "" + rsCus.getString("QtyOnOrder"); rowNum++; } }else{ Content = new String[0][6]; Content[0][0] = " "; Content[0][1] = " "; Content[0][2] = " "; Content[0][3] = " "; Content[0][4] = " "; Content[0][5] = " "; } }catch(Exception eE){ } JTable NewTable = new JTable (Content,ColumnHeaderName){ public boolean isCellEditable (int iRows, int iCols) { return false; } };

NewTable.setPreferredScrollableViewportSize(new Dimension(727, 320)); NewTable.setBackground(Color.white);

//Start resize the table column NewTable.getColumnModel().getColumn(0).setMaxWidth(0);

NewTable.getColumnModel().getColumn(0).setMinWidth(0); NewTable.getColumnModel().getColumn(0).setWidth(0); NewTable.getColumnModel().getColumn(0).setPreferredWidth(0); NewTable.getColumnModel().getColumn(1).setPreferredWidth(100); NewTable.getColumnModel().getColumn(2).setPreferredWidth(300); NewTable.getColumnModel().getColumn(3).setPreferredWidth(100); NewTable.getColumnModel().getColumn(4).setPreferredWidth(50); NewTable.getColumnModel().getColumn(5).setPreferredWidth(50); //End resize the table column

//Disposed variables ColumnHeaderName=null; Content=null;

rowNum = 0;

return NewTable; }

/**************************** End custom class ****************************/ /************************** Start Custom method ***************************/

public static void reloadRecord(String srcSQL){ strSQL = srcSQL; CusTableJSP.getViewport().remove(JTCusTable); JTCusTable=CreateTable(); CusTableJSP.getViewport().add(JTCusTable);

JPContainer.repaint(); } public static void reloadRecord(){ CusTableJSP.getViewport().remove(JTCusTable); JTCusTable=CreateTable(); CusTableJSP.getViewport().add(JTCusTable); JPContainer.repaint(); }

/*************************** End Custom method ****************************/

CONCEPT USED WHILE CODING


INTERFACE:

Using the keyword interface, you can fully abstract a class interface from its implementation. That is, using interface, you can specify what a class must do, but not how it does it. Interfaces are syntactically similar to classes, but they lack instance variables, and their methods are declared without any body. By providing the interface keyword, Java allows you to fully utilize the one interface, multiple methods aspect of polymorphism.
APPLET:

An applet is an application designed to be transmitted over the Internet and executed by Java-compatible Web browser. An applet is actually a tiny Java program, dynamically downloaded across the network, just like an image, sound file, or video clip. The important difference is that an applet is an intelligent program, not just an animation or media file. In other words, an applet is a program that can react to user input and dynamically change not just run the same animation or sound over and over.
AWT CLASSES:

The AWT classes are contained in the java.awt package. It is one of Javas largest packages. Fortunately, because it is logically organized in a topdown, hierarchical fashion, it is easier to understand and use than you might at first believe.
EVENT:

an event is an object that describes a state change in a source. It can be generated as a consequence of a person interacting with the elements in a graphical user interface. Some of the activities that cause events to be generated are pressing a button, entering a character via the keyboard, selecting an item in a list, and clicking the mouse. Many other user operations could also be cited as examples. Events may also occur that are not directly caused by interactions with a user interface. For example, an event may be generated when a timer expires, a counter exceeds a value, software or hardware failure occurs, or an operation is completed. You are free to define events that are appropriate for your application.

JDBC: JDBC Java Database Connectivity is a Java feature that lets you connect To almost any relational database system, execute SQL commands, And process the results all from within a Java program. In this chapter, you Set up JDBC and use it to access data in a MySQL database. If you arent familiar with the basics of SQL, read the previous chapter

TESTING PHASE
Software testing is an investigation conducted to provide stakeholders with information about the quality of the product or service under test. Software testing can also be stated as the process of validating and verifying that a software program/application/product: 1. meets the business and technical requirements that guided its design and development; 2. works as expected; and 3. can be implemented with the same characteristics.

Testing levels
Tests are frequently grouped by where they are added in the software development process, or by the level of specificity of the test. 1. Unit testing: Unit testing refers to tests that verify the functionality of a specific section of code, usually at the function level. In an object-oriented environment, this is usually at the class level, and the minimal unit tests include the constructors and destructors. These type of tests are usually written by developers as they work on code (whitebox style), to ensure that the specific function is working as expected. One function might have multiple tests, to catch corner cases or other branches in the code. Unit testing alone cannot verify the functionality of a piece of software, but rather is used to assure that the building blocks the software uses work independently of each other. Unit testing is also called component testing. 2. Integration testing: Integration testing is any type of software testing that seeks to verify the interfaces between components against a software design. Software components may be integrated in an iterative way or all together ("big bang"). Normally the former is considered a better practice since it allows interface issues to be localised more quickly and fixed.

Integration testing works to expose defects in the interfaces and interaction between integrated components (modules). Progressively larger groups of tested software components corresponding to elements of the architectural design are integrated and tested until the software works as a system. 3. System testing: System testing tests a completely integrated system to verify that it meets its requirements. 4. System integration testing: System integration testing verifies that a system is integrated to any external or third party systems defined in the system requirements. 5. Regression testing: Regression testing focuses on finding defects after a major code change has occurred. Specifically, it seeks to uncover software regressions, or old bugs that have come back. Such regressions occur whenever software functionality that was previously working correctly stops working as intended. Typically, regressions occur as an unintended consequence of program changes, when the newly developed part of the software collides with the previously existing code. Common methods of regression testing include re-running previously run tests and checking whether previously fixed faults have re-emerged. The depth of testing depends on the phase in the release process and the risk of the added features. They can either be complete, for changes added late in the release or deemed to be risky, to very shallow, consisting of positive tests on each feature, if the changes are early in the release or deemed to be of low risk. 6. Acceptance testing: Acceptance testing can mean one of two things: 1. A smoke test is used as an acceptance test prior to introducing a new build to the main testing process, i.e. before integration or regression. 2. Acceptance testing performed by the customer, often in their lab environment on their own hardware, is known as user acceptance testing (UAT). Acceptance testing may be performed as part of the hand-off process between any two phases of development. Software testing methods are traditionally divided into white- and black-box testing. These two approaches are used to describe the point of view that a test engineer takes when designing test cases.

White box testing:


White box testing is when the tester has access to the internal data structures and algorithms including the code that implement these.

Types of white box testing The following types of white box testing exist: API testing (application programming interface) - testing of the application using public and private APIs Code coverage - creating tests to satisfy some criteria of code coverage (e.g., the test designer can create tests to cause all statements in the program to be executed at least once) Fault injection methods - improving the coverage of a test by introducing faults to test code paths Mutation testing methods Static testing - White box testing includes all static testing Test coverage White box testing methods can also be used to evaluate the completeness of a test suite that was created with black box testing methods. This allows the software team to examine parts of a system that are rarely tested and ensures that the most important function points have been tested. Two common forms of code coverage are: Function coverage, which reports on functions executed Statement coverage, which reports on the number of lines executed to complete the test They both return code coverage metric, measured as a percentage.

Black box testing:


Black box testing treats the software as a "black box"without any knowledge of internal implementation. Black box testing methods include: equivalence partitioning, boundary value analysis, all-pairs testing, fuzz testing, model-based testing, traceability matrix, exploratory testing and specification-based testing. Specification-based testing: Specification-based testing aims to test the functionality of software according to the applicable requirements.Thus, the tester inputs data into, and only sees the output from, the test object. This level of testing usually requires thorough test cases to be provided to the tester, who then can simply verify that for a given input, the output value (or behavior), either "is" or "is not" the same as the expected value specified in the test case.

Specification-based testing is necessary, but it is insufficient to guard against certain risks. Advantages and disadvantages: The black box tester has no "bonds" with the code, and a tester's perception is very simple: a code must have bugs. Using the principle, "Ask and you shall receive," black box testers find bugs where programmers do not. But, on the other hand, black box testing has been said to be "like a walk in a dark labyrinth without a flashlight," because the tester doesn't know how the software being tested was actually constructed. As a result, there are situations when (1) a tester writes many test cases to check something that could have been tested by only one test case, and/or (2) some parts of the back-end are not tested at all. Therefore, black box testing has the advantage of "an unaffiliated opinion," on the one hand, and the disadvantage of "blind exploring," on the other.

BIBLIOGRAPHY

Herbert Schildt,The Complete Reference java2 fifth edition,Mc Graw-Hill, copyrighted 2002.

Doug lowe, All in one Desk Reference For dummies, Wiley Publishing, 2008.

Alain Trottier, Alain Trottier, paraglyph press 2002.

Вам также может понравиться