Documentos de Académico
Documentos de Profesional
Documentos de Cultura
NAINITAL
A Project Report
on
SUBMITTED BY:
Devansh Agarwal
[Roll No…….]
PGT (Comp.Sc)
CERTIFICATE
………………………… ……………………………..
Signature of Student Signature of Teacher/Guide
……….…………………
Signature of Principal
Name: ………………….
Place:…………….
Date:……………..
ACKNOWLEDGEMENT
I
undertook this Project work, as the part of my XII-Informatics
Practices course. I had tried to apply my best of knowledge and
experience, gained during the study and class work experience.
However, developing software system is generally a quite complex
and time-consuming process. It requires a systematic study, insight
vision and professional approach during the design and development.
Moreover, the developer always feels the need, the help and good
wishes of the people near you, who have considerable experience and
idea.
I also feel indebted to my friends Mr. ……….. and Mr……….. for the
valuable suggestions during the project work.
…………….
Class XII
C O N T E N T S
1. Introduction-----------------------------------------------------------------1
3. Theoretical Background------------------------------------------------4
5. System Implementation-----------------------------------------------22
7. User Manual-------------------------------------------------------------150
8. References --------------------------------------------------------------173
1. Introduction
This software project is developed to automate the functionalities of a
reports relevant to the user. An application program is tied with the database
for easy access and interface to the database. Using Application program or
front-end, we can store, retrieve and manage all information in proper way.
This software, being simple in design and working, does not require much of
During coding and design of the software Project, Java NetBeans IDE, a
powerful front-end tool is used for getting Graphical User Interface (GUI)
In its current scope, the software enables user to retrieve and update the information
from centralized database designed with MySQL . This software does not require
much training time of the users due to limited functionality and simplicity.
Despite of the best effort of the developer, the following limitations and functional
boundaries are visible, which limits the scope of this application software.
1. This software can store records and produce reports in pre-designed format in
soft copy. There is no facility yet to produce customized reports. Only specified
reports are covered.
So far as future scope of the project is concerned, firstly it is open to any modular
expansion i.e. other modules or functions can be designed and embedded to handle
the user need in future. Any part of the software and reports can be modified
independently without much effort.
3. Theoretical Background
3.1 What is Database?
Introduction and Concepts:
A database is a collection of information related to a particular subject or purpose, such as
tracking customer orders or maintaining a music collection. Using any RDBMS application
software like MS SQL Server, MySQL, Oracle, Sybase etc, you can manage all your information
from a single database file. Within the file, divide your data into separate storage containers
called tables. You may and retrieve the data using queries.
A table is a collection of data about a specific topic, such as products or suppliers. Using a
separate table for each topic means you can store that data only once, which makes your
database more efficient and reduces data-entry errors. Table organises data into columns (called
fields) and rows (called records).
A Primary key is one or more fields whose value or values uniquely identify each record in a
table. In a relationship, a primary key is used to refer to specific record in one table from another
table. A primary key is called foreign key when it is referred to from another table.
To find and retrieve just the data that meets conditions you specify, including data from multiple
tables, create a query. A query can also update or delete multiple records at the same time, and
perform built-in or custom calculations on your data.
The DBMS interprets and processes users' requests to retrieve information from a database. In
most cases, a query request will have to penetrate several layers of software in the DBMS and
operating system before the physical database can be accessed. The DBMS responds to a query
by invoking the appropriate subprograms, each of which performs its special function to
interpret the query, or to locate the desired data in the database and present it in the desired
order.
NetBeans started as a student project (originally called Xelfi) in the Czech Republic in 1996.
The goal was to write a Delphi-like Java IDE in Java. Xelfi was the first Java IDE (Integrated
Development Environment) written in Java, with its first pre-releases in 1997. Xelfi was a fun
project to work on, especially since Java IDE space was uncharted territory at that time. The
project attracted enough interest that these students, once they graduated, decided that they could
market it as a commercial product. Soliciting resources from friends and relatives for a web
space, they formed a company around it.
Soon after, they were contacted by Roman Stanek, an entrepreneur who had already been
involved in several startups in the Czech Republic. He was looking for a good idea to invest in,
and discovered Xelfi. He met with the founders; they hit it off, and a business was born.
In the spring of 1999, NetBeans DeveloperX2 was released, supporting Swing. The performance
improvements that came in JDK 1.3, released in the fall of 1999, made NetBeans a viable choice
for development tools. By the summer of 1999, the team was hard at work re-architecting
DeveloperX2 into the more modular NetBeans that forms the basis of the software today.
Something else was afoot in the summer of 1999: Sun Microsystems wanted better Java
development tools, and had become interested in NetBeans. It was a dream come true for the
NetBeans team: NetBeans would become the flagship tool set of the maker of Java itself! By the
Fall, with the next generation of NetBeans Developer in beta, a deal was struck. Sun
Microsystems had also acquired another tools company, During the acqusition, the young
developers who had been involved in open-source projects for most of their programming
careers, mentioned the idea of open-sourcing NetBeans. Fast forward to less than six months
later, the decision was made that NetBeans would be open sourced. While Sun had contributed
considerable amounts of code to open source projects over the years, this was Sun's first
sponsored open source project, one in which Sun would be paying for the site and handling the
infrastructure.
Features of NetBeans
A free, open-source Integrated Development Environment for software developers. You get all
the tools you need to create professional desktop, enterprise, web, and mobile applications with
the Java platform, as well as C/C++, PHP, JavaScript, Groovy, and Ruby.
NetBeans IDE 6.9 introduces the JavaFX Composer, support for JavaFX SDK 1.3, OSGi
interoperability, support for the PHP Zend framework and Ruby on Rails 3.0, and more.
4. Problem Definition & Analysis
The hardest part of building a software system is deciding precisely what to build. No other part
of the conceptual work is so difficult as establishing the detailed technical requirement. Defining
and applying good, complete requirements are hard to work, and success in this endeavor has
eluded many of us. Yet, we continue to make progress.
Problem definition describes the What of a system, not How . The quality of a software product
is only as good as the process that creates it. Problem definition is one of the most crucial steps
in this creation process. Without defining a problem, developers do not know what to build,
customers do not know what to expect, and there is no way to validate that the built system
satisfies the requirement.
Problem definition and Analysis is the activity that encompasses learning about the problem to
be solved, understanding the needs of customer and users, trying to find out who the user really
is, and understanding all the constraints on the solution. It includes all activities related to the
following:
Identification and documentation of customer’s or user’s needs.
Creation of a document that describes the external behavior and the association
constraints that will satisfies those needs.
Analysis and validation of the requirements documents to ensure consistency,
completeness, and feasibility
Evolution of needs.
After the analysis of the functioning of a Inventory Managementsystem, the proposed System is
expected to do the following: -
To provide a user friendly, Graphical User Interface (GUI) based integrated and
centralized environment for computerized Inventory Management System.
The proposed system should maintain all the records and transactions, and should
generate the required reports and information when required.
To provide efficient and secured Information storage, flow and retrieval system, ensuring
the integrity and validity of records.
To provide graphical and user-friendly interface to interact with a centralized database
based on client-server architecture.
To identify the critical operation procedure and possibilities of simplification using
modern IT tools and practices.
5. System Implementation
Table Design:
The database of Library System contains 5 tables. The tables are normalized to minimize the
redundancies of data and enforcing the validation rules of the organization. Most of the tables
are designed to store master records. The tables and their structure are given below.
Table: Publisher
Column Name Type Size
Pub_ID (Primary Key) Integer 4
Pub_Name Varchar 30
Pub_Address Varchar 40
Pub_Phone1 Varchar 12
Pub_Phone2 Varchar 12
Status Char 1
Table: Lib
Column Name Type Size
ACC_No (Primary Key) Integer 4
Acq_No Integer 4
BTitle Varchar 30
Author1 Varchar 30
Author2 Varchar 30
Pub_ID (Foreign Key-Reference Publisher) Integer 4
Price Float(8,2) 8
PDate Date
Pages Integer 4
Edition Integer 4
Status Char 1
Table: Member
Column Name Type Size
Memb_No (Primary Key) Integer 4
Memb_Name Varchar 30
Memb_Add Varchar 40
Memb_Phone Varchar 12
MDate Date
MEDate Date
MFee Float(8,2) 4
Mem_Status Char 1
Mem_Issue Char 1
Table: MIssue
Column Name Type Size
ACC_No Integer 4
Acq_No Integer 4
Memb_No Integer 4
IDate Date 10
RDate Date 10
Table: TIssue
Column Name Type Size
ACC_No Integer 4
Memb_No Integer 4
IDate Date 10
RDate Date 10
Frame: Home.java
public Home() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 250,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(40, 40, 40)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton3)
.addContainerGap(66, Short.MAX_VALUE))
);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
Coding of Main.java
public Main() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
jMenu5.setText("File");
customerMNU2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.CTRL_MASK));
customerMNU2.setText("Customer");
customerMNU2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customerMNU2ActionPerformed(evt);
}
});
jMenu5.add(customerMNU2);
supplierMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.CTRL_MASK));
supplierMNU1.setText("Supplier");
supplierMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplierMNU1ActionPerformed(evt);
}
});
jMenu5.add(supplierMNU1);
itemMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.CTRL_MASK));
itemMNU1.setText("Item");
itemMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itemMNU1ActionPerformed(evt);
}
});
jMenu5.add(itemMNU1);
storeMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
storeMNU1.setText("Store");
storeMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
storeMNU1ActionPerformed(evt);
}
});
jMenu5.add(storeMNU1);
modesMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modesMNU1.setText("Mode Of Payment");
modesMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modesMNU1ActionPerformed(evt);
}
});
jMenu5.add(modesMNU1);
unitsMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
unitsMNU1.setText("Units Of Measurement");
unitsMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
unitsMNU1ActionPerformed(evt);
}
});
jMenu5.add(unitsMNU1);
jMenuBar1.add(jMenu5);
jMenu6.setText("Edit");
customer1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.SHIFT_MASK));
customer1MNU1.setText("Customer");
customer1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customer1MNU1ActionPerformed(evt);
}
});
jMenu6.add(customer1MNU1);
supplier1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK));
supplier1MNU1.setText("Supplier");
supplier1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplier1MNU1ActionPerformed(evt);
}
});
jMenu6.add(supplier1MNU1);
item1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.SHIFT_MASK));
item1MNU1.setText("Item");
item1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
item1MNU1ActionPerformed(evt);
}
});
jMenu6.add(item1MNU1);
store1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
store1MNU1.setText("Store");
store1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
store1MNU1ActionPerformed(evt);
}
});
jMenu6.add(store1MNU1);
modes1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modes1MNU1.setText("Mode Of Payment");
modes1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modes1MNU1ActionPerformed(evt);
}
});
jMenu6.add(modes1MNU1);
units1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
units1MNU1.setText("Units Of Measurement");
units1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
units1MNU1ActionPerformed(evt);
}
});
jMenu6.add(units1MNU1);
jMenuBar1.add(jMenu6);
jMenu7.setText("Transactions");
jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem3.setText("Buy");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem3);
jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem4.setText("Sell");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem4);
jMenuBar1.add(jMenu7);
jMenu4.setText("Calculator");
jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem5.setText("Calculator");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem5);
jMenuBar1.add(jMenu4);
setJMenuBar(jMenuBar1);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author A33
*/
public class InsertCustomer extends javax.swing.JFrame {
public InsertCustomer() {
initComponents();
//customersLST.setEnabled(false);
customersLST.setSelectedIndex(0);
try{
customersLST.setModel(dlm);
dlm.removeAllElements();
dbc.rs=dbc.stmt.executeQuery("Select * from customers");
while(dbc.rs.next()){
String name = dbc.rs.getString("name");
dlm.addElement(name);
}
dbc.rs=dbc.stmt.executeQuery("SELECT MAX(code) as code FROM customers");
dbc.rs.first();
int cod=dbc.rs.getInt("code");
code=cod+1;
codeTF.setText(""+code);
dbc.rs=dbc.stmt.executeQuery("SELECT COUNT(name) as name from customers");
dbc.rs.first();
int count=dbc.rs.getInt("name");
countLBL.setText(""+count);
}catch(Exception ex){
ex.printStackTrace();
}
/*
try{
dbc.rs=dbc.stmt.executeQuery("Select name from CUSTOMERS");
while(dbc.rs.next()){
exist=dbc.rs.getString("name");
}
}catch(Exception ex){
ex.printStackTrace();
}
*/
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
codeTF.setEditable(false);
codeTF.setBackground(new java.awt.Color(255, 255, 255));
codeTF.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
codeTF.setDisabledTextColor(new java.awt.Color(0, 0, 0));
codeTF.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
codeTFMouseClicked(evt);
}
});
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(45, 45, 45)
.addComponent(jLabel2))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(nameTF, javax.swing.GroupLayout.DEFAULT_SIZE, 141,
Short.MAX_VALUE)
.addComponent(addressTF)
.addComponent(codeTF))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(submitBTN)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(clearBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(54, 54, 54)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(countLBL, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 184,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(39, 39, 39))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(249, Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(247, 247, 247))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(26, 26, 26)
.addComponent(jLabel1)
.addGap(53, 53, 53)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(nameTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(codeTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(addressTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addGap(35, 35, 35)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(submitBTN)
.addComponent(clearBTN))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(62, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(countLBL, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 263,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(79, 79, 79))
);
jMenu5.setText("File");
customerMNU2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.CTRL_MASK));
customerMNU2.setText("Customer");
customerMNU2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customerMNU2ActionPerformed(evt);
}
});
jMenu5.add(customerMNU2);
supplierMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.CTRL_MASK));
supplierMNU1.setText("Supplier");
supplierMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplierMNU1ActionPerformed(evt);
}
});
jMenu5.add(supplierMNU1);
itemMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.CTRL_MASK));
itemMNU1.setText("Item");
itemMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itemMNU1ActionPerformed(evt);
}
});
jMenu5.add(itemMNU1);
storeMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
storeMNU1.setText("Store");
storeMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
storeMNU1ActionPerformed(evt);
}
});
jMenu5.add(storeMNU1);
modesMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modesMNU1.setText("Mode Of Payment");
modesMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modesMNU1ActionPerformed(evt);
}
});
jMenu5.add(modesMNU1);
unitsMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
unitsMNU1.setText("Units Of Measurement");
unitsMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
unitsMNU1ActionPerformed(evt);
}
});
jMenu5.add(unitsMNU1);
jMenuBar1.add(jMenu5);
jMenu6.setText("Edit");
customer1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.SHIFT_MASK));
customer1MNU1.setText("Customer");
customer1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customer1MNU1ActionPerformed(evt);
}
});
jMenu6.add(customer1MNU1);
supplier1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK));
supplier1MNU1.setText("Supplier");
supplier1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplier1MNU1ActionPerformed(evt);
}
});
jMenu6.add(supplier1MNU1);
item1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.SHIFT_MASK));
item1MNU1.setText("Item");
item1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
item1MNU1ActionPerformed(evt);
}
});
jMenu6.add(item1MNU1);
store1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
store1MNU1.setText("Store");
store1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
store1MNU1ActionPerformed(evt);
}
});
jMenu6.add(store1MNU1);
modes1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modes1MNU1.setText("Mode Of Payment");
modes1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modes1MNU1ActionPerformed(evt);
}
});
jMenu6.add(modes1MNU1);
units1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
units1MNU1.setText("Units Of Measurement");
units1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
units1MNU1ActionPerformed(evt);
}
});
jMenu6.add(units1MNU1);
jMenuBar1.add(jMenu6);
jMenu7.setText("Transactions");
jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem3.setText("Buy");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem3);
jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem4.setText("Sell");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem4);
jMenuBar1.add(jMenu7);
jMenu4.setText("Calculator");
jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem5.setText("Calculator");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem5);
jMenuBar1.add(jMenu4);
setJMenuBar(jMenuBar1);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
String customer=nameTF.getText().toUpperCase();
int code1=Integer.parseInt(codeTF.getText());
String address=addressTF.getText();
String query= "INSERT INTO customers VALUES ('"+customer+"',"+code1+",'"+address+"')";
//JOptionPane.showMessageDialog(null,query);
try{
dbc.stmt1.executeUpdate(query);
JOptionPane.showMessageDialog(null, "CUSTOMER INSERTED");
nameTF.setText("");
codeTF.setText("");
addressTF.setText("");
dlm.removeAllElements();
dbc.rs=dbc.stmt.executeQuery("Select name from CUSTOMERS");
while(dbc.rs.next()){
String name = dbc.rs.getString("name");
dlm.addElement(name);
}
}catch(Exception ex){
JOptionPane.showMessageDialog(null, "Customer Name Already Exists", "Warning",
JOptionPane.WARNING_MESSAGE);
//JOptionPane.showMessageDialog(null, "Customer Name Already Exists");
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(InsertCustomer.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(InsertCustomer.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(InsertCustomer.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(InsertCustomer.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
}
//</editor-fold>
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
public InsertSupplier() {
initComponents();
try{
suppliersLST.setModel(dlm);
dlm.removeAllElements();
dbc.rs=dbc.stmt.executeQuery("Select distinct name from suppliers");
while(dbc.rs.next()){
String name = dbc.rs.getString("name");
dlm.addElement(name);
}
dbc.rs=dbc.stmt.executeQuery("SELECT MAX(code) as code FROM suppliers");
dbc.rs.first();
int cod=dbc.rs.getInt("code");
code=cod+1;
codeTF.setText(""+code);
dbc.rs=dbc.stmt.executeQuery("SELECT COUNT(name) as name from suppliers");
dbc.rs.first();
int count=dbc.rs.getInt("name");
countLBL.setText(""+count);
}catch(Exception ex){
ex.printStackTrace();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jScrollPane2.setViewportView(jEditorPane1);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
codeTF.setEditable(false);
codeTF.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
submitBTN.setText("Submit");
submitBTN.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
submitBTNActionPerformed(evt);
}
});
clearBTN.setText("Clear");
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(45, 45, 45)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4)
.addComponent(jLabel3)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(addressTF, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(codeTF, javax.swing.GroupLayout.PREFERRED_SIZE, 98,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(nameTF, javax.swing.GroupLayout.PREFERRED_SIZE, 98,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(184, 184, 184)
.addComponent(submitBTN)
.addGap(61, 61, 61)
.addComponent(clearBTN)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(countLBL, javax.swing.GroupLayout.PREFERRED_SIZE, 42,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 177,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(42, 42, 42))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(34, 34, 34)
.addComponent(jLabel1)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(45, 45, 45)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(nameTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(codeTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(addressTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(41, 41, 41)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(submitBTN)
.addComponent(clearBTN)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(37, 37, 37)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(countLBL, javax.swing.GroupLayout.PREFERRED_SIZE, 17,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 283,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(43, Short.MAX_VALUE))
);
jMenu5.setText("File");
customerMNU2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.CTRL_MASK));
customerMNU2.setText("Customer");
customerMNU2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customerMNU2ActionPerformed(evt);
}
});
jMenu5.add(customerMNU2);
supplierMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.CTRL_MASK));
supplierMNU1.setText("Supplier");
supplierMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplierMNU1ActionPerformed(evt);
}
});
jMenu5.add(supplierMNU1);
itemMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.CTRL_MASK));
itemMNU1.setText("Item");
itemMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itemMNU1ActionPerformed(evt);
}
});
jMenu5.add(itemMNU1);
storeMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
storeMNU1.setText("Store");
storeMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
storeMNU1ActionPerformed(evt);
}
});
jMenu5.add(storeMNU1);
modesMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modesMNU1.setText("Mode Of Payment");
modesMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modesMNU1ActionPerformed(evt);
}
});
jMenu5.add(modesMNU1);
unitsMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
unitsMNU1.setText("Units Of Measurement");
unitsMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
unitsMNU1ActionPerformed(evt);
}
});
jMenu5.add(unitsMNU1);
jMenuBar1.add(jMenu5);
jMenu6.setText("Edit");
customer1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.SHIFT_MASK));
customer1MNU1.setText("Customer");
customer1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customer1MNU1ActionPerformed(evt);
}
});
jMenu6.add(customer1MNU1);
supplier1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK));
supplier1MNU1.setText("Supplier");
supplier1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplier1MNU1ActionPerformed(evt);
}
});
jMenu6.add(supplier1MNU1);
item1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.SHIFT_MASK));
item1MNU1.setText("Item");
item1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
item1MNU1ActionPerformed(evt);
}
});
jMenu6.add(item1MNU1);
store1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
store1MNU1.setText("Store");
store1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
store1MNU1ActionPerformed(evt);
}
});
jMenu6.add(store1MNU1);
modes1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modes1MNU1.setText("Mode Of Payment");
modes1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modes1MNU1ActionPerformed(evt);
}
});
jMenu6.add(modes1MNU1);
units1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
units1MNU1.setText("Units Of Measurement");
units1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
units1MNU1ActionPerformed(evt);
}
});
jMenu6.add(units1MNU1);
jMenuBar1.add(jMenu6);
jMenu7.setText("Transactions");
jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem3.setText("Buy");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem3);
jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem4.setText("Sell");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem4);
jMenuBar1.add(jMenu7);
jMenu4.setText("Calculator");
jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem5.setText("Calculator");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem5);
jMenuBar1.add(jMenu4);
setJMenuBar(jMenuBar1);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
try{
dlm.removeAllElements();
dbc.rs=dbc.stmt.executeQuery("Select distinct name from suppliers");
while(dbc.rs.next()){
String name = dbc.rs.getString("name");
dlm.addElement(name);
}
dbc.rs=dbc.stmt.executeQuery("SELECT MAX(code) as code FROM suppliers");
dbc.rs.first();
int cod=dbc.rs.getInt("code");
code=cod+1;
codeTF.setText(""+code);
}catch(Exception ex){
JOptionPane.showMessageDialog(null, "Supplier Name Already Exists", "Warning",
JOptionPane.WARNING_MESSAGE);
//JOptionPane.showMessageDialog(null, "Store Name Already Exists");
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(InsertSupplier.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(InsertSupplier.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(InsertSupplier.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(InsertSupplier.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
Coding of InsertItem.java
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author A33
*/
public class InsertItem extends javax.swing.JFrame {
DBConnection dbc=new DBConnection();
DefaultListModel dlm=new DefaultListModel();
String exist;
int code;
/**
* Creates new form InsertItem
*/
public InsertItem() {
initComponents();
try{
itemLST.setModel(dlm);
dlm.removeAllElements();
dbc.rs=dbc.stmt.executeQuery("Select * from items");
while(dbc.rs.next()){
String name = dbc.rs.getString("name");
dlm.addElement(name);
}
dbc.rs=dbc.stmt.executeQuery("SELECT MAX(code) as code FROM items");
dbc.rs.first();
int cod=dbc.rs.getInt("code");
code=cod+1;
codeTF.setText(""+code);
dbc.rs=dbc.stmt.executeQuery("SELECT COUNT(name) as name from items");
dbc.rs.first();
int count=dbc.rs.getInt("name");
countLBL.setText(""+count);
}catch(Exception ex){
ex.printStackTrace();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
itemLST.setBorder(javax.swing.BorderFactory.createTitledBorder("Existing Items"));
jScrollPane1.setViewportView(itemLST);
codeTF.setEditable(false);
codeTF.setBackground(new java.awt.Color(255, 255, 255));
codeTF.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
codeTF.setDisabledTextColor(new java.awt.Color(0, 0, 0));
codeTF.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
codeTFMouseClicked(evt);
}
});
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(87, 87, 87)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 3,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING))))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(nameTF)
.addComponent(priceTF)
.addComponent(codeTF, javax.swing.GroupLayout.PREFERRED_SIZE, 141,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 180,
Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(submitBTN)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(clearBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(74, 74, 74)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(countLBL, javax.swing.GroupLayout.PREFERRED_SIZE, 43,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 179,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(266, 266, 266))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLabel1)
.addGap(52, 52, 52)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(nameTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(codeTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(priceTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addGap(42, 42, 42)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(submitBTN)
.addComponent(clearBTN))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(68, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6)
.addComponent(countLBL, javax.swing.GroupLayout.PREFERRED_SIZE, 19,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 290,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(66, 66, 66))
);
jMenu5.setText("File");
customerMNU2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.CTRL_MASK));
customerMNU2.setText("Customer");
customerMNU2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customerMNU2ActionPerformed(evt);
}
});
jMenu5.add(customerMNU2);
supplierMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.CTRL_MASK));
supplierMNU1.setText("Supplier");
supplierMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplierMNU1ActionPerformed(evt);
}
});
jMenu5.add(supplierMNU1);
itemMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.CTRL_MASK));
itemMNU1.setText("Item");
itemMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itemMNU1ActionPerformed(evt);
}
});
jMenu5.add(itemMNU1);
storeMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
storeMNU1.setText("Store");
storeMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
storeMNU1ActionPerformed(evt);
}
});
jMenu5.add(storeMNU1);
modesMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modesMNU1.setText("Mode Of Payment");
modesMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modesMNU1ActionPerformed(evt);
}
});
jMenu5.add(modesMNU1);
unitsMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
unitsMNU1.setText("Units Of Measurement");
unitsMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
unitsMNU1ActionPerformed(evt);
}
});
jMenu5.add(unitsMNU1);
jMenuBar1.add(jMenu5);
jMenu6.setText("Edit");
customer1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.SHIFT_MASK));
customer1MNU1.setText("Customer");
customer1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customer1MNU1ActionPerformed(evt);
}
});
jMenu6.add(customer1MNU1);
supplier1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK));
supplier1MNU1.setText("Supplier");
supplier1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplier1MNU1ActionPerformed(evt);
}
});
jMenu6.add(supplier1MNU1);
item1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.SHIFT_MASK));
item1MNU1.setText("Item");
item1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
item1MNU1ActionPerformed(evt);
}
});
jMenu6.add(item1MNU1);
store1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
store1MNU1.setText("Store");
store1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
store1MNU1ActionPerformed(evt);
}
});
jMenu6.add(store1MNU1);
modes1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modes1MNU1.setText("Mode Of Payment");
modes1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modes1MNU1ActionPerformed(evt);
}
});
jMenu6.add(modes1MNU1);
units1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
units1MNU1.setText("Units Of Measurement");
units1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
units1MNU1ActionPerformed(evt);
}
});
jMenu6.add(units1MNU1);
jMenuBar1.add(jMenu6);
jMenu7.setText("Transactions");
jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem3.setText("Buy");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem3);
jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem4.setText("Sell");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem4);
jMenuBar1.add(jMenu7);
jMenu2.setText("Calculator");
jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem5.setText("Calculator");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem5);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
String item=nameTF.getText().toUpperCase();
int code1=Integer.parseInt(codeTF.getText());
int price=Integer.parseInt(priceTF.getText());
String query= "INSERT INTO items VALUES ('"+item+"',"+code1+","+price+")";
try{
dbc.stmt1.executeUpdate(query);
JOptionPane.showMessageDialog(null, "ITEM INSERTED");
nameTF.setText("");
codeTF.setText("");
priceTF.setText("");
dlm.removeAllElements();
dbc.rs=dbc.stmt.executeQuery("Select name from items");
while(dbc.rs.next()){
String name = dbc.rs.getString("name");
dlm.addElement(name);
}
}catch(Exception ex){
JOptionPane.showMessageDialog(null, "Item Name Already Exists", "Warning",
JOptionPane.WARNING_MESSAGE);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(InsertItem.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(InsertItem.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(InsertItem.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(InsertItem.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author A33
*/
public class InsertStore extends javax.swing.JFrame {
storesLST.setSelectedIndex(0);
try{
storesLST.setModel(dlm);
dlm.removeAllElements();
dbc.rs=dbc.stmt.executeQuery("Select * from stores");
while(dbc.rs.next()){
String name = dbc.rs.getString("name");
dlm.addElement(name);
}
dbc.rs=dbc.stmt.executeQuery("SELECT MAX(code) as code FROM stores");
dbc.rs.first();
int cod=dbc.rs.getInt("code");
code=cod+1;
codeTF.setText(""+code);
dbc.rs=dbc.stmt.executeQuery("SELECT COUNT(name) as name from stores");
dbc.rs.first();
int count=dbc.rs.getInt("name");
countLBL.setText(""+count);
}catch(Exception ex){
ex.printStackTrace();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
codeTF.setEditable(false);
codeTF.setBackground(new java.awt.Color(255, 255, 255));
codeTF.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
codeTF.setDisabledTextColor(new java.awt.Color(0, 0, 0));
codeTF.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
codeTFMouseClicked(evt);
}
});
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(45, 45, 45)
.addComponent(jLabel2))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(nameTF, javax.swing.GroupLayout.DEFAULT_SIZE, 141,
Short.MAX_VALUE)
.addComponent(addressTF)
.addComponent(codeTF))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(0, 262, Short.MAX_VALUE)
.addComponent(submitBTN)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(clearBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(54, 54, 54)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(countLBL, javax.swing.GroupLayout.PREFERRED_SIZE, 40,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 184,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(39, 39, 39))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(261, 261, 261))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(jLabel1)
.addGap(51, 51, 51)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(nameTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(codeTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(addressTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addGap(35, 35, 35)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(submitBTN)
.addComponent(clearBTN))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(67, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(countLBL, javax.swing.GroupLayout.PREFERRED_SIZE, 22,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6))
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 263,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(79, 79, 79))
);
jMenu5.setText("File");
customerMNU2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.CTRL_MASK));
customerMNU2.setText("Customer");
customerMNU2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customerMNU2ActionPerformed(evt);
}
});
jMenu5.add(customerMNU2);
supplierMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.CTRL_MASK));
supplierMNU1.setText("Supplier");
supplierMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplierMNU1ActionPerformed(evt);
}
});
jMenu5.add(supplierMNU1);
itemMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.CTRL_MASK));
itemMNU1.setText("Item");
itemMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itemMNU1ActionPerformed(evt);
}
});
jMenu5.add(itemMNU1);
storeMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
storeMNU1.setText("Store");
storeMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
storeMNU1ActionPerformed(evt);
}
});
jMenu5.add(storeMNU1);
modesMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modesMNU1.setText("Mode Of Payment");
modesMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modesMNU1ActionPerformed(evt);
}
});
jMenu5.add(modesMNU1);
unitsMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
unitsMNU1.setText("Units Of Measurement");
unitsMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
unitsMNU1ActionPerformed(evt);
}
});
jMenu5.add(unitsMNU1);
jMenuBar1.add(jMenu5);
jMenu6.setText("Edit");
customer1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.SHIFT_MASK));
customer1MNU1.setText("Customer");
customer1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customer1MNU1ActionPerformed(evt);
}
});
jMenu6.add(customer1MNU1);
supplier1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK));
supplier1MNU1.setText("Supplier");
supplier1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplier1MNU1ActionPerformed(evt);
}
});
jMenu6.add(supplier1MNU1);
item1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.SHIFT_MASK));
item1MNU1.setText("Item");
item1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
item1MNU1ActionPerformed(evt);
}
});
jMenu6.add(item1MNU1);
store1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
store1MNU1.setText("Store");
store1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
store1MNU1ActionPerformed(evt);
}
});
jMenu6.add(store1MNU1);
modes1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modes1MNU1.setText("Mode Of Payment");
modes1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modes1MNU1ActionPerformed(evt);
}
});
jMenu6.add(modes1MNU1);
units1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
units1MNU1.setText("Units Of Measurement");
units1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
units1MNU1ActionPerformed(evt);
}
});
jMenu6.add(units1MNU1);
jMenuBar1.add(jMenu6);
jMenu7.setText("Transactions");
jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem3.setText("Buy");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem3);
jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem4.setText("Sell");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem4);
jMenuBar1.add(jMenu7);
jMenu4.setText("Calculator");
jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem5.setText("Calculator");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem5);
jMenuBar1.add(jMenu4);
setJMenuBar(jMenuBar1);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
private void customerMNU2ActionPerformed(java.awt.event.ActionEvent evt) {
InsertCustomer obj1=new InsertCustomer();
this.dispose();
obj1.show();
}
String Store=nameTF.getText().toUpperCase();
int code1=Integer.parseInt(codeTF.getText());
String address=addressTF.getText();
String query= "INSERT INTO Stores VALUES ('"+Store+"',"+code1+",'"+address+"')";
//JOptionPane.showMessageDialog(null,query);
try{
dbc.stmt1.executeUpdate(query);
JOptionPane.showMessageDialog(null, "STORE INSERTED");
nameTF.setText("");
codeTF.setText("");
addressTF.setText("");
dlm.removeAllElements();
dbc.rs=dbc.stmt.executeQuery("Select name from Stores");
while(dbc.rs.next()){
String name = dbc.rs.getString("name");
dlm.addElement(name);
}
}catch(Exception ex){
JOptionPane.showMessageDialog(null, "Store Name Already Exists", "Warning",
JOptionPane.WARNING_MESSAGE);
//JOptionPane.showMessageDialog(null, "Store Name Already Exists");
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(InsertStore.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(InsertStore.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(InsertStore.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(InsertStore.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author A33
*/
public class InsertModeOfPayment extends javax.swing.JFrame {
try{
modesLST.setModel(dlm);
dlm.removeAllElements();
dbc.rs=dbc.stmt.executeQuery("Select * from mode_payment");
while(dbc.rs.next()){
String name = dbc.rs.getString("Mode_Payment");
dlm.addElement(name);
}
try{
dbc.rs=dbc.stmt.executeQuery("Select * from mode_payment");
while(dbc.rs.next()){
exist = dbc.rs.getString("Mode_Payment");
}
}catch(Exception ex){
ex.printStackTrace();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
modesLST.setBorder(javax.swing.BorderFactory.createTitledBorder("Existing Modes"));
jScrollPane1.setViewportView(modesLST);
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(87, 87, 87)
.addComponent(jLabel2)
.addGap(4, 4, 4)
.addComponent(nameTF, javax.swing.GroupLayout.PREFERRED_SIZE, 141,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 172,
Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(submitBTN)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(clearBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(74, 74, 74)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(countLBL, javax.swing.GroupLayout.PREFERRED_SIZE, 43,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 179,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(176, 176, 176))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLabel1)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(52, 52, 52)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(nameTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(100, 100, 100)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(submitBTN)
.addComponent(clearBTN))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6)
.addComponent(countLBL, javax.swing.GroupLayout.PREFERRED_SIZE, 19,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 290,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(66, 66, 66))))
);
jMenu5.setText("File");
customerMNU2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.CTRL_MASK));
customerMNU2.setText("Customer");
customerMNU2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customerMNU2ActionPerformed(evt);
}
});
jMenu5.add(customerMNU2);
supplierMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.CTRL_MASK));
supplierMNU1.setText("Supplier");
supplierMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplierMNU1ActionPerformed(evt);
}
});
jMenu5.add(supplierMNU1);
itemMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.CTRL_MASK));
itemMNU1.setText("Item");
itemMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itemMNU1ActionPerformed(evt);
}
});
jMenu5.add(itemMNU1);
storeMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
storeMNU1.setText("Store");
storeMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
storeMNU1ActionPerformed(evt);
}
});
jMenu5.add(storeMNU1);
modesMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modesMNU1.setText("Mode Of Payment");
modesMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modesMNU1ActionPerformed(evt);
}
});
jMenu5.add(modesMNU1);
unitsMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
unitsMNU1.setText("Units Of Measurement");
unitsMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
unitsMNU1ActionPerformed(evt);
}
});
jMenu5.add(unitsMNU1);
jMenuBar1.add(jMenu5);
jMenu6.setText("Edit");
customer1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.SHIFT_MASK));
customer1MNU1.setText("Customer");
customer1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customer1MNU1ActionPerformed(evt);
}
});
jMenu6.add(customer1MNU1);
supplier1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK));
supplier1MNU1.setText("Supplier");
supplier1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplier1MNU1ActionPerformed(evt);
}
});
jMenu6.add(supplier1MNU1);
item1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.SHIFT_MASK));
item1MNU1.setText("Item");
item1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
item1MNU1ActionPerformed(evt);
}
});
jMenu6.add(item1MNU1);
store1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
store1MNU1.setText("Store");
store1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
store1MNU1ActionPerformed(evt);
}
});
jMenu6.add(store1MNU1);
modes1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modes1MNU1.setText("Mode Of Payment");
modes1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modes1MNU1ActionPerformed(evt);
}
});
jMenu6.add(modes1MNU1);
units1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
units1MNU1.setText("Units Of Measurement");
units1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
units1MNU1ActionPerformed(evt);
}
});
jMenu6.add(units1MNU1);
jMenuBar1.add(jMenu6);
jMenu7.setText("Transactions");
jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem3.setText("Buy");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem3);
jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem4.setText("Sell");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem4);
jMenuBar1.add(jMenu7);
jMenu2.setText("Calculator");
jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem5.setText("Calculator");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem5);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
pack();
}// </editor-fold>
try{
String name=nameTF.getText();
dlm.removeAllElements();
dbc.rs=dbc.stmt.executeQuery("Select * from mode_payment where Mode_Payment like
'"+name+"%'");
while(dbc.rs.next()){
String name1 = dbc.rs.getString("Mode_Payment");
dlm.addElement(name1);
}
}
catch(Exception ex){
System.out.println(ex.getMessage());
}
}
String Mode_Payment=nameTF.getText().toUpperCase();
try{
dbc.stmt1.executeUpdate(query);
JOptionPane.showMessageDialog(null, "Mode Of Payment INSERTED");
nameTF.setText("");
modesLST.setModel(dlm);
dlm.removeAllElements();
dbc.rs=dbc.stmt.executeQuery("Select * from mode_payment");
while(dbc.rs.next()){
String name = dbc.rs.getString("Mode_Payment");
dlm.addElement(name);
}
}catch(Exception ex){
JOptionPane.showMessageDialog(null, "Mode Of Payment Already Exists", "Warning",
JOptionPane.WARNING_MESSAGE);
//JOptionPane.showMessageDialog(null, "Mode Of Payment Already Exists");
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(InsertModeOfPayment.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(InsertModeOfPayment.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(InsertModeOfPayment.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(InsertModeOfPayment.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
}
//</editor-fold>
Coding of InsertUnits.Java
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
public InsertUnits() {
initComponents();
try{
unitsLST.setModel(dlm);
dlm.removeAllElements();
dbc.rs=dbc.stmt.executeQuery("Select * from units");
while(dbc.rs.next()){
String name = dbc.rs.getString("Unit");
dlm.addElement(name);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
unitsLST.setBorder(javax.swing.BorderFactory.createTitledBorder("Existing Units"));
jScrollPane1.setViewportView(unitsLST);
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(87, 87, 87)
.addComponent(jLabel2)
.addGap(4, 4, 4)
.addComponent(nameTF, javax.swing.GroupLayout.PREFERRED_SIZE, 141,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 184,
Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(submitBTN)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(clearBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(74, 74, 74)))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(countLBL, javax.swing.GroupLayout.PREFERRED_SIZE, 43,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 179,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(266, 266, 266))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLabel1)
.addGap(52, 52, 52)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(nameTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(100, 100, 100)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(submitBTN)
.addComponent(clearBTN))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(68, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6)
.addComponent(countLBL, javax.swing.GroupLayout.PREFERRED_SIZE, 19,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 290,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(66, 66, 66))
);
jMenu5.setText("File");
customerMNU2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.CTRL_MASK));
customerMNU2.setText("Customer");
customerMNU2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customerMNU2ActionPerformed(evt);
}
});
jMenu5.add(customerMNU2);
supplierMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.CTRL_MASK));
supplierMNU1.setText("Supplier");
supplierMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplierMNU1ActionPerformed(evt);
}
});
jMenu5.add(supplierMNU1);
itemMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.CTRL_MASK));
itemMNU1.setText("Item");
itemMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itemMNU1ActionPerformed(evt);
}
});
jMenu5.add(itemMNU1);
storeMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
storeMNU1.setText("Store");
storeMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
storeMNU1ActionPerformed(evt);
}
});
jMenu5.add(storeMNU1);
modesMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modesMNU1.setText("Mode Of Payment");
modesMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modesMNU1ActionPerformed(evt);
}
});
jMenu5.add(modesMNU1);
unitsMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
unitsMNU1.setText("Units Of Measurement");
unitsMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
unitsMNU1ActionPerformed(evt);
}
});
jMenu5.add(unitsMNU1);
jMenuBar1.add(jMenu5);
jMenu6.setText("Edit");
customer1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.SHIFT_MASK));
customer1MNU1.setText("Customer");
customer1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customer1MNU1ActionPerformed(evt);
}
});
jMenu6.add(customer1MNU1);
supplier1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK));
supplier1MNU1.setText("Supplier");
supplier1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplier1MNU1ActionPerformed(evt);
}
});
jMenu6.add(supplier1MNU1);
item1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.SHIFT_MASK));
item1MNU1.setText("Item");
item1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
item1MNU1ActionPerformed(evt);
}
});
jMenu6.add(item1MNU1);
store1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
store1MNU1.setText("Store");
store1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
store1MNU1ActionPerformed(evt);
}
});
jMenu6.add(store1MNU1);
modes1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modes1MNU1.setText("Mode Of Payment");
modes1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modes1MNU1ActionPerformed(evt);
}
});
jMenu6.add(modes1MNU1);
units1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
units1MNU1.setText("Units Of Measurement");
units1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
units1MNU1ActionPerformed(evt);
}
});
jMenu6.add(units1MNU1);
jMenuBar1.add(jMenu6);
jMenu7.setText("Transactions");
jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem3.setText("Buy");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem3);
jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem4.setText("Sell");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem4);
jMenuBar1.add(jMenu7);
jMenu4.setText("Calculator");
jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem5.setText("Calculator");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem5);
jMenuBar1.add(jMenu4);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
String unit=nameTF.getText().toUpperCase();
try{
dbc.stmt1.executeUpdate(query);
JOptionPane.showMessageDialog(null, "UNIT INSERTED");
nameTF.setText("");
unitsLST.setModel(dlm);
dlm.removeAllElements();
dbc.rs=dbc.stmt.executeQuery("Select * from units");
while(dbc.rs.next()){
String name = dbc.rs.getString("Unit");
dlm.addElement(name);
}
}catch(Exception ex){
JOptionPane.showMessageDialog(null, "Unit Already Exists", "Warning",
JOptionPane.WARNING_MESSAGE);
//JOptionPane.showMessageDialog(null, "Store Name Already Exists");
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(InsertUnits.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(InsertUnits.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(InsertUnits.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(InsertUnits.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
import java.sql.DriverManager;
import java.util.Objects;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author A33
*/
public class UpdateCustomer extends javax.swing.JFrame {
public UpdateCustomer(){
initComponents();
nameCBO.setModel(dcm);
nameCBO.setModel(dcm);
dcm.removeAllElements();
try{
dbc.rs=dbc.stmt.executeQuery("SELECT * FROM customers");
while(dbc.rs.next()){
dcm.addElement(dbc.rs.getString("name"));
}
}catch(Exception ex){
ex.printStackTrace();
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
submitBTN.setText("Submit");
submitBTN.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
submitBTNActionPerformed(evt);
}
});
codeTF.setEditable(false);
codeTF.setBackground(new java.awt.Color(255, 255, 255));
codeTF.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
codeTFMouseClicked(evt);
}
});
jLabel3.setText("Address:");
jLabel1.setText("Customer Name:");
jLabel2.setText("Customer Code:");
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(nameCBO, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(4, 4, 4)
.addComponent(nameTF, javax.swing.GroupLayout.PREFERRED_SIZE, 121,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(submitBTN)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(addressTF)
.addComponent(codeTF, javax.swing.GroupLayout.PREFERRED_SIZE, 95,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(nameCBO, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(nameTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(codeTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(addressTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(64, 64, 64)
.addComponent(submitBTN)
.addContainerGap(207, Short.MAX_VALUE))
);
jMenu5.setText("File");
customerMNU2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.CTRL_MASK));
customerMNU2.setText("Customer");
customerMNU2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customerMNU2ActionPerformed(evt);
}
});
jMenu5.add(customerMNU2);
supplierMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.CTRL_MASK));
supplierMNU1.setText("Supplier");
supplierMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplierMNU1ActionPerformed(evt);
}
});
jMenu5.add(supplierMNU1);
itemMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.CTRL_MASK));
itemMNU1.setText("Item");
itemMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itemMNU1ActionPerformed(evt);
}
});
jMenu5.add(itemMNU1);
storeMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
storeMNU1.setText("Store");
storeMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
storeMNU1ActionPerformed(evt);
}
});
jMenu5.add(storeMNU1);
modesMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modesMNU1.setText("Mode Of Payment");
modesMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modesMNU1ActionPerformed(evt);
}
});
jMenu5.add(modesMNU1);
unitsMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
unitsMNU1.setText("Units Of Measurement");
unitsMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
unitsMNU1ActionPerformed(evt);
}
});
jMenu5.add(unitsMNU1);
jMenuBar1.add(jMenu5);
jMenu6.setText("Edit");
customer1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.SHIFT_MASK));
customer1MNU1.setText("Customer");
customer1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customer1MNU1ActionPerformed(evt);
}
});
jMenu6.add(customer1MNU1);
supplier1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK));
supplier1MNU1.setText("Supplier");
supplier1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplier1MNU1ActionPerformed(evt);
}
});
jMenu6.add(supplier1MNU1);
item1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.SHIFT_MASK));
item1MNU1.setText("Item");
item1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
item1MNU1ActionPerformed(evt);
}
});
jMenu6.add(item1MNU1);
store1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
store1MNU1.setText("Store");
store1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
store1MNU1ActionPerformed(evt);
}
});
jMenu6.add(store1MNU1);
modes1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modes1MNU1.setText("Mode Of Payment");
modes1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modes1MNU1ActionPerformed(evt);
}
});
jMenu6.add(modes1MNU1);
units1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
units1MNU1.setText("Units Of Measurement");
units1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
units1MNU1ActionPerformed(evt);
}
});
jMenu6.add(units1MNU1);
jMenuBar1.add(jMenu6);
jMenu7.setText("Transactions");
jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem3.setText("Buy");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem3);
jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem4.setText("Sell");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem4);
jMenuBar1.add(jMenu7);
jMenu4.setText("Calculator");
jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem5.setText("Calculator");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem5);
jMenuBar1.add(jMenu4);
setJMenuBar(jMenuBar1);
pack();
setLocationRelativeTo(null);
}// </editor-fold>
nameCBO.setModel(dcm1);
dcm1.removeAllElements();
dbc.rs4=dbc.stmt4.executeQuery("SELECT * FROM customers");
while(dbc.rs4.next()){
dcm1.addElement(dbc.rs4.getString("name"));
UpdateCustomer obj1= new UpdateCustomer();
this.dispose();
obj1.show();
}
}catch(Exception ex){
ex.printStackTrace();
}
}
String name=nameCBO.getSelectedItem().toString();
try{
dbc.rs1=dbc.stmt1.executeQuery("select * from customers where name ='"+name+"'");
while(dbc.rs1.next()){
nameTF.setText(dbc.rs1.getString("name"));
codeTF.setText(""+dbc.rs1.getInt("code"));
addressTF.setText(dbc.rs1.getString("address"));
}
}
catch(Exception ex){
ex.printStackTrace();
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(UpdateCustomer.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(UpdateCustomer.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(UpdateCustomer.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(UpdateCustomer.class.getName()).log(java.util.logging.Level.SEVE
RE, null, ex);
}
//</editor-fold>
import java.sql.DriverManager;
import java.util.Objects;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
public UpdateSupplier() {
initComponents();
nameCBO.setModel(dcm);
nameCBO.setModel(dcm);
dcm.removeAllElements();
try{
dbc.rs=dbc.stmt.executeQuery("SELECT * FROM suppliers");
while(dbc.rs.next()){
dcm.addElement(dbc.rs.getString("name"));
}
}catch(Exception ex){
ex.printStackTrace();
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Supplier Name:");
codeTF.setEditable(false);
codeTF.setBackground(new java.awt.Color(255, 255, 255));
codeTF.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
codeTFMouseClicked(evt);
}
});
jLabel2.setText("Supplier Code:");
submitBTN.setText("Submit");
submitBTN.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
submitBTNActionPerformed(evt);
}
});
jLabel3.setText("Address:");
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(nameCBO, javax.swing.GroupLayout.PREFERRED_SIZE, 109,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(4, 4, 4)
.addComponent(nameTF, javax.swing.GroupLayout.PREFERRED_SIZE, 121,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(submitBTN)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(addressTF)
.addComponent(codeTF, javax.swing.GroupLayout.PREFERRED_SIZE, 95,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(nameCBO, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(nameTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(codeTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(addressTF, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(64, 64, 64)
.addComponent(submitBTN)
.addContainerGap(207, Short.MAX_VALUE))
);
jMenu5.setText("File");
customerMNU2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.CTRL_MASK));
customerMNU2.setText("Customer");
customerMNU2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customerMNU2ActionPerformed(evt);
}
});
jMenu5.add(customerMNU2);
supplierMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.CTRL_MASK));
supplierMNU1.setText("Supplier");
supplierMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplierMNU1ActionPerformed(evt);
}
});
jMenu5.add(supplierMNU1);
itemMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.CTRL_MASK));
itemMNU1.setText("Item");
itemMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
itemMNU1ActionPerformed(evt);
}
});
jMenu5.add(itemMNU1);
storeMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
storeMNU1.setText("Store");
storeMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
storeMNU1ActionPerformed(evt);
}
});
jMenu5.add(storeMNU1);
modesMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modesMNU1.setText("Mode Of Payment");
modesMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modesMNU1ActionPerformed(evt);
}
});
jMenu5.add(modesMNU1);
unitsMNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
unitsMNU1.setText("Units Of Measurement");
unitsMNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
unitsMNU1ActionPerformed(evt);
}
});
jMenu5.add(unitsMNU1);
jMenuBar1.add(jMenu5);
jMenu6.setText("Edit");
customer1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.SHIFT_MASK));
customer1MNU1.setText("Customer");
customer1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
customer1MNU1ActionPerformed(evt);
}
});
jMenu6.add(customer1MNU1);
supplier1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK));
supplier1MNU1.setText("Supplier");
supplier1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplier1MNU1ActionPerformed(evt);
}
});
jMenu6.add(supplier1MNU1);
item1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
java.awt.event.InputEvent.SHIFT_MASK));
item1MNU1.setText("Item");
item1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
item1MNU1ActionPerformed(evt);
}
});
jMenu6.add(item1MNU1);
store1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
store1MNU1.setText("Store");
store1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
store1MNU1ActionPerformed(evt);
}
});
jMenu6.add(store1MNU1);
modes1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
java.awt.event.InputEvent.CTRL_MASK));
modes1MNU1.setText("Mode Of Payment");
modes1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
modes1MNU1ActionPerformed(evt);
}
});
jMenu6.add(modes1MNU1);
units1MNU1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
java.awt.event.InputEvent.CTRL_MASK));
units1MNU1.setText("Units Of Measurement");
units1MNU1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
units1MNU1ActionPerformed(evt);
}
});
jMenu6.add(units1MNU1);
jMenuBar1.add(jMenu6);
jMenu7.setText("Transactions");
jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem3.setText("Buy");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem3);
jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem4.setText("Sell");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem4ActionPerformed(evt);
}
});
jMenu7.add(jMenuItem4);
jMenuBar1.add(jMenu7);
jMenu4.setText("Calculator");
jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
jMenuItem5.setText("Calculator");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem5);
jMenuBar1.add(jMenu4);
setJMenuBar(jMenuBar1);
pack();
}// </editor-fold>
nameCBO.setModel(dcm1);
dcm1.removeAllElements();
dbc.rs4=dbc.stmt4.executeQuery("SELECT * FROM suppliers");
while(dbc.rs4.next()){
dcm1.addElement(dbc.rs4.getString("name"));
UpdateSupplier obj1= new UpdateSupplier();
//this.dispose();
obj1.show();
this.dispose();
}
}catch(Exception ex){
ex.printStackTrace();
}
}
String name=nameCBO.getSelectedItem().toString();
try{
dbc.rs1=dbc.stmt1.executeQuery("select * from suppliers where name ='"+name+"'");
while(dbc.rs1.next()){
nameTF.setText(dbc.rs1.getString("name"));
codeTF.setText(""+dbc.rs1.getInt("code"));
addressTF.setText(dbc.rs1.getString("address"));
}
}
catch(Exception ex){
ex.printStackTrace();
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(UpdateSupplier.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(UpdateSupplier.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(UpdateSupplier.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(UpdateSupplier.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);
}
//</editor-fold>
//</editor-fold>
//</editor-fold>
//</editor-fold>
Frame: MembEditUI.java
Coding for MembEditUI.java
/* * MembEditUI.java **/
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.DefaultListModel;
public class MembEditUI extends javax.swing.JFrame {
/** Creates new form MembEditUI */
public MembEditUI() {
initComponents();
}
Statement stmt = null;
ResultSet rs = null;
String SQL = "SELECT * FROM Member";
private void cmdExitActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
}
private void cmdUpdateActionPerformed(java.awt.event.ActionEvent evt) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
int Mno = Integer.parseInt(txtMNo.getText().trim());
String MName = txtMName.getText();
String MAdd = txtMAdd.getText();
String MPh1 = txtMPh.getText();
String MDate = txtMDate.getText();
String MEDate = txtMDate.getText(); // This is temporarily assigned same as membership date
double MFee = Double.parseDouble(txtMFee.getText());
char MStatus = 'Y'; // Member status is Y
String strSQL = "Update Member set memb_name ='"+(MName)+"', memb_add = '"+(MAdd)+"',
memb_phone = '"+(MPh1)+"', mdate = '"+(MDate)+"', mfee = "+(MFee)+" where memb_no = " +
(Mno);
int rowsEffected = stmt.executeUpdate(strSQL);
if (rowsEffected == 0)
JOptionPane.showMessageDialog(this, "Record does not exists");
else
JOptionPane.showMessageDialog(this,"Record modified");
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
private void jList1MouseClicked(java.awt.event.MouseEvent evt) {
// getSelectedValue() method extracts the current cursor location value into a variable
String MembNo = (String) jList1.getSelectedValue();
// Extract the first 4 characters as Member No into a variable
String Mno =MembNo.trim().substring(0, 3);
String query = "SELECT * FROM Member WHERE memb_no = " + (Mno) + ";";
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
// Create SQL statement and execute query.
stmt = con.createStatement();
rs = stmt.executeQuery(query);
if (rs.next()) {
String MName = rs.getString("memb_name");
String MAdd = rs.getString("memb_add");
String MPh1 = rs.getString("memb_phone");
String MDate = rs.getString("mdate");
String MEDate = rs.getString("medate");
String MFee = rs.getString("mfee");
String MStatus = rs.getString("mem_status");
String MIssue = rs.getString("mem_issue");
// Displaying the contents in respective text boxes.
txtMNo.setText(Mno);
txtMName.setText(MName);
txtMAdd.setText(MAdd);
txtMPh.setText(MPh1);
txtMDate.setText(MDate);
txtMFee.setText(MFee);
txtMStatus.setText(MStatus);
txtMStatus.setEditable(false);
} else {
JOptionPane.showMessageDialog(null, "Record does not found in Member table");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
txtMNo.setEditable(false);
txtMStatus.setEditable(false);
// Creating a ListModel object dModel to perform DefaultListModel
// method operations
DefaultListModel dModel = (DefaultListModel) jList1.getModel();
// Method to add elements into jList1 control
dModel.clear();
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
while (rs.next()) {
String Mno = rs.getString("memb_no");
String MName = rs.getString("memb_name");
// To make the Member no. as 4 digit because we will extract 4 digit from list value
// in mouse click event.
if (Mno.length() < 4)
{
int x = Mno.length();
int nl = 4 - x;
while (nl > 0){
Mno = Mno + " ";
nl--;
}
}
dModel.addElement(Mno + "- " + MName);
}
jList1.setModel(dModel);
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}
/** * @param args the command line arguments */
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MembEditUI().setVisible(true);
}
});
}
}
Frame: MembDelUI.java
Coding for MembDelUI.java
/* * MembDelUI.java * */
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.DefaultListModel;
public class MembDelUI extends javax.swing.JFrame {
/** Creates new form MembDelUI */
public MembDelUI() {
initComponents();
}
Statement stmt = null;
ResultSet rs = null;
String SQL = "SELECT * FROM Member";
private void jList1MouseClicked(java.awt.event.MouseEvent evt) {
// getSelectedValue() method extracts the current cursor location value into a variable
String MembNo = (String) jList1.getSelectedValue();
// Extract the first 4 characters as Member No into a variable
String Mno =MembNo.trim().substring(0, 3);
String query = "SELECT * FROM Member WHERE memb_no = " + (Mno) + ";";
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
// Create SQL statement and execute query.
stmt = con.createStatement();
rs = stmt.executeQuery(query);
if (rs.next()) {
String MName = rs.getString("memb_name");
String MAdd = rs.getString("memb_add");
String MPh1 = rs.getString("memb_phone");
String MDate = rs.getString("mdate");
String MEDate = rs.getString("medate");
String MFee = rs.getString("mfee");
String MStatus = rs.getString("mem_status");
String MIssue = rs.getString("mem_issue");
// Displaying the contents in respective text boxes.
txtMNo.setText(Mno);
txtMName.setText(MName);
txtMAdd.setText(MAdd);
txtMPh.setText(MPh1);
txtMDate.setText(MDate);
txtMFee.setText(MFee);
txtMStatus.setText(MStatus);
txtMStatus.setEditable(false);
} else {
JOptionPane.showMessageDialog(null, "Record does not found in Member table");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
private void cmdExit1ActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
//new MainUI().setVisible(true);
}
private void cmdDeleteActionPerformed(java.awt.event.ActionEvent evt) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
int Mno = Integer.parseInt(txtMNo.getText().trim());
// Steps to confirm deletion
int opt = JOptionPane.showConfirmDialog(null, "Are you sure to delete this record ?");
if (opt == JOptionPane.YES_OPTION) {
try {
char stb = 'N'; // Member table
String strSQL = "Update Member set mem_status ='"+(stb)+"' where memb_no = " + (Mno);
int rowsEffected = stmt.executeUpdate(strSQL);
if (rowsEffected == 0)
JOptionPane.showMessageDialog(this, "Record does not exists");
else {
JOptionPane.showMessageDialog(this,"Record Deleted");
// Text boxes cleared
txtMNo.setText("");
txtMName.setText("");
txtMAdd.setText("");
txtMPh.setText("");
txtMDate.setText("");
txtMFee.setText("");
txtMStatus.setText("");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Unable to delete");
}
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
}
}
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
txtMNo.setEditable(false);
txtMName.setEditable(false);
txtMAdd.setEditable(false);
txtMPh.setEditable(false);
txtMDate.setEditable(false);
txtMFee.setEditable(false);
txtMStatus.setEditable(false);
// Creating a ListModel object dModel to perform DefaultListModel
// method operations
DefaultListModel dModel = (DefaultListModel) jList1.getModel();
// Method to add elements into jList1 control
dModel.clear();
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/Library","root","raj");
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
while (rs.next()) {
String Mno = rs.getString("memb_no");
String MName = rs.getString("memb_name");
// To make the Member no. as 4 digit because we will extract 4 digit from list value
// in mouse click event.
if (Mno.length() < 4)
{
int x = Mno.length();
int nl = 4 - x;
while (nl > 0){
Mno = Mno + " ";
nl--;
}
}
dModel.addElement(Mno + "- " + MName);
}
jList1.setModel(dModel);
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.getMessage());
e.printStackTrace();
}
}
/** * @param args the command line arguments */
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MembDelUI().setVisible(true);
}
});
}
}
Frame: MembNavUI.java
Frame: IBListUI.java
Frame: MListUI.java
Software Requirement-
Windows 2000/XP OS is desirable.
NetBeans Ver 5.1 or higher should be installed with JDK and JVM.
MySQL Ver 6.1 with Library Database must be present at machine.
Database Installation
The software project is distributed with a backup copy of a Database named Library with
required tables. Some dummy records are present in the tables for testing purposes, which can be
deleted before inserting real data. The project is shipped with LIB.SQL file which installs a
database and tables in the computer system.
Note: The PC must have MySQL server with user (root) and password (raj) . If root password is
any other password, it can be changed by running MySQL Server Instance Configure Wizard.
Start Program MySQL MySQL Server MySQL Server Instance Config Wizard
Provide current password of root and new password as “raj” , this will change the root password.
To install a MySQL database from a dump file ( Lib.sql) , simply follow the following steps.
Step 1: Copy the Lib.sql file in C:\Program files\Mysql\MySql server 5.1\Bin folder.
Step 2: Open MySQL and type the following command to create the dabase named Library.
mysql> create database Library;
Step 3: Open Command Window (Start Run cmd)
Step 4: Go to the following folder using CD command of DOS.
C:\Program files\Mysql\MySql server 5.1\Bin>
Step 5: type the following command on above prompt -
C:….\bin> mysql -u root -praj Library < lib.sql
This will create a Library databse with required tables.
7.2 Working with SoftwareProject:
The Library Management Program consists of the following logically organised Menu-structure
for the easy functionality. User may choose the menu options for corresponding works.
Publisher:
This menu item gives options to insert, delete, update and access the Publisher record.
Book:
This menu gives options to Insert, delete, modify and delete the Books record. Also the Books
can be Issued and Received to/from members.
Members:
This menu item gives options to insert, delete, update and access the Member’s record.
Report:
This menu provides option to get reports of Issued books, Available books and Members list.
8. References
In order to work on this project titled -LibSys – Inventory ManagementManagement System,
the following books and literature are refered by me during the various phases of development
of the project.
(4) http://www.netbeans.org/
Other than the above-mentioned books, the suggestions and supervision of my teacher and my
class experience also helped me to develop this software project.