Académique Documents
Professionnel Documents
Culture Documents
A PROJECT ON
POST OFFICE COURIER SYSTEM
Submitted in partial rollback in fulfillment of the requirement for the
SENIOR SECONDARY EXAMINATION (AISSCE)
Submitted By :
Tarun varma
Gagan
balaji
Submitted To :
Thanuja mam
(Computer Sci.
Teacher)
CERTIFICATE
Internal Supervisor
External Supervisor
Signature
Signature
Name :
Name :
Date :
Date :
ID SHEET
Roll No :
.
Name of Student :
.
Address :
.
.
Phone No :
.
Email Address :
.
Supervisor :
.
Project Title :
.
ACKNOWLEDGEMENT
It would be our outmost pleasure to
express our sincere thanks to our
Computer Science Teacher Mrs.Thanuja
providing a helping hand in this
project.
Her unflagging patience, creativity and
immense knowledge that she shared
with us have proved highly beneficial
to us and had made our Project
possible and successful.
TABLE OF CONTENTS
Introduction
Java Details
Priliminary Design
Form Layouts
Database Design
Implementation
Bibliography
Teacher Remarks
INTRODUCTION
This program is designed for the use of
Post Office Courier System and its
functioning Main Objective of this
project to facilitate the transactions
through use of electronic medium. We
use java netbeans 6.5 software and
Mysql to programming our project.
What is java?
Java tools
In order to write java application or applets ,one need more than a language .
The tools that lets one to write , test , debug programs.
Java features
Secure- When we use a java compatible web browser, we can safely download
java applets without fear of virus infection. Java achieves this protection by
confining a java program to java execution environment and not allowing it
access to other parts of the computer.
implemented on any machine and also the size of the primitive data types are
machine independent.
Robust -It provides many safeguards to ensure reliable code. It has strict
compile time and run time checking for data types. Designed as a garbage-
collected language relieving the programmers and also incorpates the concept
of exception handling which captures series errors.
Distributed- It has ability to share both data and programs. Java applications
can open and access remote objects on internet which enables multiple
programmers at multiple remote locations to collaborate and work together on
single project.
Java Program
Java Compiler
Source code
Virtual Machine
Process of Compilation
Bytecode
Java Interpreter
Bytecode
Machine code
Virtual Machine
Machine
Real
Objects and Classes -An object is a software bundle of variables and related
methods. Objects are key to understanding object-oriented technology. Realworld objects share two characteristics: They all have state and behavior.
Software objects are modeled after real-world objects in that they too have
state and behaviorClasses can also define class variables. A class variable
contains information that is shared by all instances of the class .A class can
also declare class methods. You can invoke a class method directly from the
class, whereas you must invoke instance methods on a particular instance.
encapsulation. It is the most striking feature of class. The data is not accessible
to outside world and only those methods which are wrapped in the class can
access it. The insulation of the data from direct access by the program is called
data hiding.
Polymorphism - This means the ability to take more than one form. An
operation may exhibit different behaviour in different instances. The behaviour
depends upon the types of data used in the operation. It plays an important
role in allowing objects having different internal structures to share external
interface.
Driver
manager
Driver
Connection
Statement
Metadata
Resultset
Driver Manager
update operation
Information about returned data ,
database and driver
Logical set of columns and rows of data
returned by executing a statement
Connection
Statement
ResultSet
Driver
Database
Database
The JDBC architecture is based on a collection of java interfaces and classes that
together enable you to connect to data sources , to create and execute SQL
statements and to retrieve and modify data in a database.
The JDBC-ODBC Bridge sun.jdbc.odbc.jdbcodbcDriver-is included with JDK and it
enables Java applications to access data through drivers written to the ODBC standard.
The driver bridge is useful for accessing data in data sources for which no pure JDBC
drivers exist. The bridge works by translating the JDBC methods into ODBC function
calls.
used for modeling the structure (rather than the contents) of a database or
cube. The DDL gives you the ability to create, modify, and remove databases
and database objects.
Data Manipulation Language (DML) DML statements that are used to
operate on data in the database. These are statements that allow you to create
or alter objects (such as tables, indexes, views, and so on) in the database. The
subset of SQL statements used to retrieve and manipulate data. DML can be
further divided into 2 groups: Select Statements Statements that return a set of results.
Everything else Statements that dont return a set of results.
Here are some of the quries defined:-
Primary key Primary key constraints identify the column or set of columns
whose values uniquely identify a row in a table. No two rows in a table can
have the same primary key value. You cannot enter a NULL value for any
column in a primary key.
Insert- The Insert logical operator inserts each row from its input into the
object specified in the Argument column. To insert the data into a relation we
either specify a tuple to be inserted or write a query.
Delete- The Delete logical operator deletes from an object rows that satisfy
the optional predicate in the Argument column. We can delete only whole
tuples; we cannot delete values on only particular attributes.
Update- The Update logical operator updates each row from its input in the
object specified in the Argument column. It provides a way of modifying
existing data in a table.
SWING
SWING is a set of classes that provides powerful and flexible functionality. In
addition with several components provided by AWT, swing supplies several
exciting additions, including tabbed panes, scroll panes, trees and tables. It
also changes the images as the state of any component changes. Swing is built
upon the foundation of the AWT. Swing components are written entirely in Java
and therefore are Platform-independent .Swing is also termed also light-weight
and provide pluggable look and feel.
There are 2 Swing classes that are quite important:
Jframe and Component Jframe extends the AWT class Frame. It contains
additional features that enable it to support Swing components. JComponent
extends the AWT component and Container classes. It is the top level class for
all Swing components and provides Swing pluggable look and feel.
Here are some of the Swing component classes:
CLASS
Abstract
Button
Button Group
Image Icon
JApplet
JButton
JCheckBox
JComboBox
JLabels
JRadioButton
JScrollPane
JTabbedPane
JTextField
JTree
DESCRIPTION
Abstract super class for Swing
buttons.
Encapsulates a mutually exclusive
set of buttons.
Encapsulates an icon.
The SWING version of APPLET.
The SWING push button class.
The SWING check box class.
Encapsulates a combo box .
The SWING version of a label.
The SWING version of a radio button.
Encapsulates a scrollable window.
Encapsulates a tabbed window.
The SWING version of Text field.
Encapsulates a tree based-control.
Icons Icons are encapsulated by the Image Icon class, which paints an
icon from an image.
JLabel Labels are the instances of the JLabel class which extends
JComponent. It can display text or icon. These are passive controls that do not
support any interaction with the user.
PRELIMINA
RY DESIGN
(User Interface)
FORM
LAYOUT
S
DATABA
SE
DESIGN
IMPLEMENTATI
ON
*****************************************
LOGIN
*****************************************
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import java.sql.DriverManager;
import java.sql.ResultSet;
public class login extends
javax.swing.JFrame {
/** Creates new form login */
public login() {
initComponents();
}
/** 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() {
jPopupMenu1 = new
javax.swing.JPopupMenu();
jPopupMenu2 = new
javax.swing.JPopupMenu();
jDialog1 = new javax.swing.JDialog();
jLabel3 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
idtf = new javax.swing.JTextField();
PassWordTF = new
javax.swing.JPasswordField();
jLabel4 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
LogInB = new javax.swing.JButton();
invalidl = new javax.swing.JLabel();
invalid = new javax.swing.JLabel();
javax.swing.GroupLayout
jDialog1Layout = new
javax.swing.GroupLayout(jDialog1.getConte
ntPane());
jDialog1.getContentPane().setLayout(jDialo
g1Layout);
jDialog1Layout.setHorizontalGroup(
jDialog1Layout.createParallelGroup(javax.s
wing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jDialog1Layout.setVerticalGroup(
jDialog1Layout.createParallelGroup(javax.s
wing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
setDefaultCloseOperation(javax.swing.Wind
owConstants.EXIT_ON_CLOSE);
setTitle("City Sports Shop Management
System");
setBounds(new
java.awt.Rectangle(200, 70, 0, 0));
jLabel3.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel3.setForeground(new
java.awt.Color(0, 153, 255));
jLabel3.setText("PASSWORD");
jLabel2.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel2.setForeground(new
java.awt.Color(0, 153, 255));
jLabel2.setText("LOGIN ID");
idtf.setBackground(new
java.awt.Color(204, 255, 204));
PassWordTF.setBackground(new
java.awt.Color(204, 255, 204));
jLabel4.setBackground(new
java.awt.Color(204, 204, 255));
jLabel4.setFont(new
java.awt.Font("Colonna MT", 3, 24)); //
NOI18N
jLabel4.setForeground(new
java.awt.Color(51, 153, 255));
jLabel4.setText("SHOP MANAGEMENT
SYSTEM");
jLabel1.setIcon(new
javax.swing.ImageIcon(getClass().getResour
ce("/sports.png"))); // NOI18N
jLabel6.setFont(new
java.awt.Font("Poor Richard", 0, 18));
jLabel6.setForeground(new
java.awt.Color(0, 153, 255));
jLabel6.setText("LOG IN TO
CONTINUE");
LogInB.setFont(new
java.awt.Font("Tahoma", 1, 18)); // NOI18N
LogInB.setForeground(new
java.awt.Color(51, 153, 255));
LogInB.setText("Log In");
LogInB.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
LogInBActionPerformed(evt);
}
});
invalidl.setFont(new
java.awt.Font("Tahoma", 1, 12));
invalid.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
invalid.setText(" ");
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane())
;
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.Grou
pLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING,
layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.
ComponentPlacement.RELATED, 115,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4,
javax.swing.GroupLayout.PREFERRED_SIZE,
370,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(5, 5, 5))
.addGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING,
layout.createSequentialGroup()
.addGap(55, 55, 55)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(147, 147,
147)
.addComponent(jLabel6,
javax.swing.GroupLayout.PREFERRED_SIZE,
210,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel2,
javax.swing.GroupLayout.PREFERRED_SIZE,
68,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addGap(49, 49,
49)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addComponent(idtf,
javax.swing.GroupLayout.DEFAULT_SIZE,
244, Short.MAX_VALUE)
.addComponent(PassWordTF,
javax.swing.GroupLayout.PREFERRED_SIZE,
244,
javax.swing.GroupLayout.PREFERRED_SIZE)
)))
.addPreferredGap(javax.swing.LayoutStyle.
ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(idtf,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(PassWordTF,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(LogInB,
javax.swing.GroupLayout.PREFERRED_SIZE,
33,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(invalid))
.addGap(34, 34, 34))
);
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScree
nSize();
setBounds((screenSize.width-568)/2,
(screenSize.height-443)/2, 568, 443);
}// </editor-fold>
private void
LogInBActionPerformed(java.awt.event.Actio
nEvent evt) {
// TODO add your handling code here:
invalid.setText("");
String PWord = PassWordTF.getText();
String ID = idtf.getText();
String str = null;
Statement stmt=null;
ResultSet rs = null;
try {
Class.forName("java.sql.Driver");
String database =
"jdbc:mysql://localhost:3306/shopkeeper";
Connection conn = (Connection)
DriverManager.getConnection(database,
"root", "root");
stmt = (Statement)
conn.createStatement();
String sql = "select * from login
where userID = '" + ID + "'";
rs = stmt.executeQuery(sql);
rs.next();
str = rs.getString("Password");
rs.close();
stmt.close();
conn.close();
if(str.equals(PWord)) {
MainMenuUI m = new
MainMenuUI();
m.setVisible(true);
this.setVisible(false);
} else {
invalid.setText("Incorrect ID or
Password");
}
} catch (Exception e)
{ invalid.setText("Incorrect ID or
Password");}
}
/**
* @param args the command line
arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new
Runnable() {
public void run() {
new login().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton LogInB;
private javax.swing.JPasswordField
PassWordTF;
private javax.swing.JTextField idtf;
private javax.swing.JLabel invalid;
private javax.swing.JLabel invalidl;
private javax.swing.JDialog jDialog1;
private javax.swing.JLabel jLabel1;
*****************************************
MAIN UI
*****************************************
import java.sql.*;
public class MainMenuUI extends
javax.swing.JFrame {
/** Creates new form MainMenuUI */
public MainMenuUI() {
initComponents();
}
/** 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() {
jLabel1 = new javax.swing.JLabel();
jMenuBar1 = new
javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
mnuCustAdd = new
javax.swing.JMenuItem();
mnuItemAdd = new
javax.swing.JMenuItem();
mnuOrder = new
javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
ListCust = new
javax.swing.JMenuItem();
ListItem = new
javax.swing.JMenuItem();
ListOrder = new
javax.swing.JMenuItem();
jMenu3 = new javax.swing.JMenu();
jMenuItem1 = new
javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.Wind
owConstants.EXIT_ON_CLOSE);
setTitle("Sports Shop Mangement");
jLabel1.setFont(new
java.awt.Font("Elephant", 1, 48)); // NOI18N
jLabel1.setText(" SPORTS SHOP !");
jMenu1.setBorder(javax.swing.BorderFactory
.createEtchedBorder());
jMenu1.setText("Sports Club");
jMenu1.setFont(new
java.awt.Font("Segoe UI", 1, 18)); // NOI18N
jMenu1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
jMenu1ActionPerformed(evt);
}
});
mnuCustAdd.setFont(new
java.awt.Font("Segoe UI", 1, 14)); // NOI18N
mnuCustAdd.setText("Cusomer Entry");
mnuCustAdd.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
mnuCustAddActionPerformed(evt);
}
});
jMenu1.add(mnuCustAdd);
mnuItemAdd.setFont(new
java.awt.Font("Segoe UI", 1, 14)); // NOI18N
mnuItemAdd.setText("Item Entry");
mnuItemAdd.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
mnuItemAddActionPerformed(evt);
}
});
jMenu1.add(mnuItemAdd);
mnuOrder.setFont(new
java.awt.Font("Segoe UI", 1, 14)); // NOI18N
mnuOrder.setText("Order Entry");
mnuOrder.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
mnuOrderActionPerformed(evt);
}
});
jMenu1.add(mnuOrder);
jMenuBar1.add(jMenu1);
jMenu2.setBorder(javax.swing.BorderFactory
.createEtchedBorder());
jMenu2.setText("View");
jMenu2.setFont(new
java.awt.Font("Segoe UI", 1, 18)); // NOI18N
jMenu2.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
jMenu2ActionPerformed(evt);
}
});
ListCust.setFont(new
java.awt.Font("Segoe UI", 1, 14)); // NOI18N
ListCust.setText("Customer List");
ListCust.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
ListCustActionPerformed(evt);
}
});
jMenu2.add(ListCust);
ListItem.setFont(new
java.awt.Font("Segoe UI", 1, 14)); // NOI18N
ListItem.setText("Item List");
ListItem.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
ListItemActionPerformed(evt);
}
});
jMenu2.add(ListItem);
ListOrder.setFont(new
java.awt.Font("Segoe UI", 1, 14)); // NOI18N
ListOrder.setText("Order List");
ListOrder.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
ListOrderActionPerformed(evt);
}
});
jMenu2.add(ListOrder);
jMenuBar1.add(jMenu2);
jMenu3.setBorder(javax.swing.BorderFactory
.createEtchedBorder());
jMenu3.setText("quit");
jMenu3.setFont(new
java.awt.Font("Segoe UI", 1, 18)); // NOI18N
jMenu3.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
jMenu3ActionPerformed(evt);
}
});
jMenuItem1.setFont(new
java.awt.Font("Segoe UI", 1, 14)); // NOI18N
jMenuItem1.setText("Application");
jMenuItem1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu3.add(jMenuItem1);
jMenuBar1.add(jMenu3);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane())
;
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.Grou
pLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addContainerGap(javax.swing.GroupLayout
.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.Grou
pLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING,
layout.createSequentialGroup()
.addContainerGap(110,
Short.MAX_VALUE)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
107,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(115, 115, 115))
);
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScree
nSize();
setBounds((screenSize.width-527)/2,
(screenSize.height-401)/2, 527, 401);
}// </editor-fold>
private void
mnuCustAddActionPerformed(java.awt.even
t.ActionEvent evt) {
this.setVisible(false);
new ShopINUI().setVisible(true);
}
private void
mnuItemAddActionPerformed(java.awt.even
t.ActionEvent evt) {
this.setVisible(false);
new ItemINUI().setVisible(true);
}
private void
mnuOrderActionPerformed(java.awt.event.A
ctionEvent evt) {
this.setVisible(false);
new OrderINUI().setVisible(true);
}
private void
jMenu1ActionPerformed(java.awt.event.Acti
onEvent evt) {
// TODO add your handling code here:
}
private void
jMenu2ActionPerformed(java.awt.event.Acti
onEvent evt) {
}
private void
ListCustActionPerformed(java.awt.event.Acti
onEvent evt) {
this.setVisible(false);
new CustListUI().setVisible(true);
}
private void
ListItemActionPerformed(java.awt.event.Acti
onEvent evt) {
this.setVisible(false);
new ItemListUI().setVisible(true);
}
private void
ListOrderActionPerformed(java.awt.event.Ac
tionEvent evt) {
this.setVisible(false);
new OrdListUI().setVisible(true);
}
private void
jMenuItem1ActionPerformed(java.awt.event
.ActionEvent evt) {
System.exit(0);
// TODO add your
handling code here:
}
/**
* @param args the command line
arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new
Runnable() {
public void run() {
new
MainMenuUI().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JMenuItem ListCust;
private javax.swing.JMenuItem ListItem;
private javax.swing.JMenuItem ListOrder;
private javax.swing.JLabel jLabel1;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem
jMenuItem1;
private javax.swing.JMenuItem
mnuCustAdd;
private javax.swing.JMenuItem
mnuItemAdd;
private javax.swing.JMenuItem
mnuOrder;
// End of variables declaration
}
*****************************************
}
private void
jMenu3ActionPerformed(java.awt.event.Acti
onEvent evt) {
// TODO add your handling code here:
RECIEVER DETAILS
*****************************************
import java.sql.*;
import javax.swing.JOptionPane;
jLabel6.setFont(new
java.awt.Font("Tahoma", 1, 24));
jLabel6.setText("Shopkeeper Data
Entry Form");
jLabel1.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel1.setText("Shopkeeper's ID.:");
txtSHName.setFont(new
java.awt.Font("Tahoma", 1, 12));
txtSHAddress.setFont(new
java.awt.Font("Tahoma", 1, 12));
btnBack.setFont(new
java.awt.Font("Tahoma", 1, 12));
btnBack.setText("Back to Main");
btnBack.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
btnBackActionPerformed(evt);
}
});
btnSave.setFont(new
java.awt.Font("Tahoma", 1, 12));
btnSave.setText("Save");
btnSave.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
btnSaveActionPerformed(evt);
}
});
txtSHCity.setFont(new
java.awt.Font("Tahoma", 1, 12));
setDefaultCloseOperation(javax.swing.Wind
owConstants.EXIT_ON_CLOSE);
setTitle("Shopkeeper Data Entry
Form");
setCursor(new
java.awt.Cursor(java.awt.Cursor.DEFAULT_C
URSOR));
txtSHPhone.setFont(new
java.awt.Font("Tahoma", 1, 12));
btnClear.setFont(new
java.awt.Font("Tahoma", 1, 12));
btnClear.setText("Clear");
btnClear.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
btnClearActionPerformed(evt);
}
});
jLabel3.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel3.setText("Address:");
jLabel4.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel4.setText("City:");
jLabel2.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel2.setText("Name:");
txtSHno.setFont(new
java.awt.Font("Tahoma", 1, 12));
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.
ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addComponent(txtSHno,
javax.swing.GroupLayout.PREFERRED_SIZE,
62,
javax.swing.GroupLayout.PREFERRED_SIZE)
jLabel5.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel5.setText("Phone No.:");
.addComponent(txtSHName,
javax.swing.GroupLayout.PREFERRED_SIZE,
228,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtSHAddress,
javax.swing.GroupLayout.PREFERRED_SIZE,
321,
javax.swing.GroupLayout.PREFERRED_SIZE)
))
layout.createParallelGroup(javax.swing.Grou
pLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(42, 42, 42)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(86, 86, 86)
.addComponent(jLabel6))
.addGroup(layout.createSequentialGroup()
.addGap(37, 37, 37)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(jLabel1)
.addComponent(jLabel4)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.
ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addComponent(txtSHPhone,
javax.swing.GroupLayout.PREFERRED_SIZE,
126,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtSHCity,
javax.swing.GroupLayout.PREFERRED_SIZE,
145,
javax.swing.GroupLayout.PREFERRED_SIZE)
)))))
.addContainerGap(40,
Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING,
layout.createSequentialGroup()
.addContainerGap(78,
Short.MAX_VALUE)
.addComponent(btnSave)
.addGap(43, 43, 43)
.addComponent(btnBack)
.addGap(56, 56, 56)
.addComponent(btnClear)
.addGap(98, 98, 98))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.Grou
pLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(jLabel6)
.addGap(39, 39, 39)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addGroup(layout.createSequentialGroup()
.addComponent(txtSHno,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.
ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtSHName,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGap(16, 16, 16)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtSHAddress,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtSHCity,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addPreferredGap(javax.swing.LayoutStyle.
ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtSHPhone,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addGap(43, 43, 43)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(btnClear,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(btnBack,
javax.swing.GroupLayout.DEFAULT_SIZE, 35,
Short.MAX_VALUE)
.addComponent(btnSave,
javax.swing.GroupLayout.DEFAULT_SIZE, 35,
Short.MAX_VALUE))
.addGap(24, 24, 24))
);
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScree
nSize();
setBounds((screenSize.width-526)/2,
(screenSize.height-388)/2, 526, 388);
}// </editor-fold>
private void
btnBackActionPerformed(java.awt.event.Act
ionEvent evt) {
this.setVisible(false);
new MainMenuUI().setVisible(true);
}
private void
btnSaveActionPerformed(java.awt.event.Act
ionEvent evt) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://
localhost:3306/shopkeeper","root","root");
Statement stmt = null;
ResultSet rs = null;
// ResultSet
for SHOPKEEPER table.
String SQL = "SELECT * FROM
shopkeeper";
stmt = con.createStatement(); //
Connection string for ResultSet - rs.
rs = stmt.executeQuery(SQL);
// Data transfer from JTextField
control to variables
String shno =
txtSHno.getText().trim();
String shname =
txtSHName.getText();
String shadd =
txtSHAddress.getText();
String shcity = txtSHCity.getText();
double shphone =
Double.parseDouble(txtSHPhone.getText());
if (shno.length() <= 4) {
String strSQL = "INSERT INTO
shopkeeper(Shopper_id, Name, Address,
City, Phone) VALUES ('"+(shno)+"','"+
(shname)+"','"+(shadd)+"','"+(shcity)
+"',"+(shphone)+")";
JOptionPane.showMessageDialog(this,
"Record successfully inserted");
int rowsEffected =
stmt.executeUpdate(strSQL);
System.out.println(rowsEffected
+ " rows effected");
}
else {
JOptionPane.showMessageDialog(this,
"Customer ID should not more than 4
character.");
}
con.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.get
Message());
e.printStackTrace();
}
}
private void
btnClearActionPerformed(java.awt.event.Act
ionEvent evt) {
// TODO add your handling code here:
txtSHno.setText("");
txtSHName.setText("");
txtSHAddress.setText("");
txtSHCity.setText("");
txtSHPhone.setText("");
}
/**
* @param args the command line
arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new
Runnable() {
public void run() {
new ShopINUI().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnBack;
private javax.swing.JButton btnClear;
private javax.swing.JButton btnSave;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JTextField
txtSHAddress;
private javax.swing.JTextField txtSHCity;
private javax.swing.JTextField txtSHName;
private javax.swing.JTextField
txtSHPhone;
private javax.swing.JTextField txtSHno;
// End of variables declaration
}
*****************************************
SENDER
DETAILS*******************************
**********
import java.sql.*;
import javax.swing.JOptionPane;
public class ItemINUI extends
javax.swing.JFrame {
/** Creates new form ItemINUI */
public ItemINUI() {
initComponents();
}
setDefaultCloseOperation(javax.swing.Wind
owConstants.EXIT_ON_CLOSE);
setTitle("Sports Item Entry Form");
jLabel3.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel3.setText("Item Id.:");
jLabel1.setFont(new
java.awt.Font("Tahoma", 1, 24));
jLabel1.setText("Sports Item Entry
Form");
txtItemno.setFont(new
java.awt.Font("Tahoma", 1, 12));
txtItemName.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel13.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel13.setText("Price:");
btnClear.setFont(new
java.awt.Font("Tahoma", 1, 12));
btnClear.setText("Clear");
btnClear.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
btnClearActionPerformed(evt);
}
});
txtItemPrice.setFont(new
java.awt.Font("Tahoma", 1, 12));
btnSave.setFont(new
java.awt.Font("Tahoma", 1, 12));
btnSave.setText("Save");
btnSave.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
btnSaveActionPerformed(evt);
}
});
btnBack.setFont(new
java.awt.Font("Tahoma", 1, 12));
btnBack.setText("Back to Main");
btnBack.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
btnBackActionPerformed(evt);
}
});
txtItemDesc.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel15.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel15.setText("Description:");
jLabel14.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel14.setText("Item Name:");
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane())
;
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.Grou
pLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(59, 59, 59)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel15,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jLabel14,
javax.swing.GroupLayout.Alignment.LEADIN
G, javax.swing.GroupLayout.DEFAULT_SIZE,
73, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLabel3,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(27, 27, 27)
.addComponent(jLabel13,
javax.swing.GroupLayout.DEFAULT_SIZE, 46,
Short.MAX_VALUE)))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addComponent(txtItemDesc,
javax.swing.GroupLayout.PREFERRED_SIZE,
204,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING,
layout.createSequentialGroup()
.addComponent(txtItemName,
javax.swing.GroupLayout.DEFAULT_SIZE,
123, Short.MAX_VALUE)
.addGap(81, 81, 81))
.addComponent(txtItemPrice,
javax.swing.GroupLayout.PREFERRED_SIZE,
92,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtItemno,
javax.swing.GroupLayout.PREFERRED_SIZE,
90,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addGap(118, 118, 118))
.addGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING,
layout.createSequentialGroup()
.addContainerGap(109,
Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(80, 80, 80))
.addGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING,
layout.createSequentialGroup()
.addContainerGap(78,
Short.MAX_VALUE)
.addComponent(btnSave)
.addGap(47, 47, 47)
.addComponent(btnBack)
.addGap(48, 48, 48)
.addComponent(btnClear)
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(btnSave,
javax.swing.GroupLayout.PREFERRED_SIZE,
33,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addGap(30, 30, 30))
);
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScree
nSize();
setBounds((screenSize.width-482)/2,
(screenSize.height-403)/2, 482, 403);
}// </editor-fold>
private void
btnClearActionPerformed(java.awt.event.Act
ionEvent evt) {
// TODO add your handling code here:
txtItemno.setText("");
txtItemName.setText("");
txtItemDesc.setText("");
txtItemPrice.setText("");
}
private void
btnSaveActionPerformed(java.awt.event.Act
ionEvent evt) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://
localhost:3306/shopkeeper","root","root");
Statement stmt = null;
ResultSet rs = null;
// ResultSet
for SHOPKEEPER table.
String SQL = "SELECT * FROM item";
stmt = con.createStatement(); //
Connection string for ResultSet - rs.
rs = stmt.executeQuery(SQL);
// Data transfer from JTextField
control to variables
String itemno = txtItemno.getText();
String itemname =
txtItemName.getText();
String desc = txtItemDesc.getText();
double itemprice =
Double.parseDouble(txtItemPrice.getText());
private javax.swing.JTextField
txtItemName;
private javax.swing.JTextField
txtItemPrice;
private javax.swing.JTextField txtItemno;
// End of variables declaration
}
*****************************************
BOOKING
DETAILS*******************************
**********
import java.sql.*;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
public class OrderINUI extends
javax.swing.JFrame {
/** Creates new form OrderINUI */
public OrderINUI() {
initComponents();
}
/** 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() {
buttonGroup1 = new
javax.swing.ButtonGroup();
jLabel9 = new javax.swing.JLabel();
txtOrdno = new
javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
btnClear = new javax.swing.JButton();
txtOrdDate = new
javax.swing.JTextField();
txtOrdQty = new
javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.Wind
owConstants.EXIT_ON_CLOSE);
setTitle("Order Form");
addWindowFocusListener(new
java.awt.event.WindowFocusListener() {
public void
windowGainedFocus(java.awt.event.Window
Event evt) {
formWindowGainedFocus(evt);
}
public void
windowLostFocus(java.awt.event.WindowEv
ent evt) {
}
});
jLabel9.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel9.setText("Order Quantity:");
txtOrdno.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel2.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel2.setText("Date:");
jLabel3.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel3.setText("Shopkeeper Id and
Name");
jLabel4.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel4.setText("Item Id and Name");
btnClear.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
btnClear.setText("Clear");
btnClear.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
btnClearActionPerformed(evt);
}
});
txtOrdDate.setFont(new
java.awt.Font("Tahoma", 1, 12));
txtOrdDate.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
txtOrdDateActionPerformed(evt);
}
});
txtOrdQty.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
btnBack.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
btnBack.setText("Back to Main");
btnBack.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
btnBackActionPerformed(evt);
}
});
jLabel10.setFont(new
java.awt.Font("Tahoma", 1, 24)); // NOI18N
});
jScrollPane2.setViewportView(jList2);
jPanel1.setBorder(javax.swing.BorderFactory
.createTitledBorder("Discount"));
buttonGroup1.add(rdYes);
rdYes.setFont(new
java.awt.Font("Tahoma", 1, 10));
rdYes.setText("Yes");
buttonGroup1.add(rdNo);
rdNo.setFont(new
java.awt.Font("Tahoma", 1, 10));
rdNo.setText("No");
jLabel8.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel8.setText("Item price:");
javax.swing.GroupLayout
jPanel1Layout = new
javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
txtItemPrice.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
jPanel1Layout.createParallelGroup(javax.swi
ng.GroupLayout.Alignment.LEADING)
jLabel5.setText("ID.:");
jLabel7.setText("Name:");
jLabel6.setText("Item ID.:");
jList1.setModel(new
DefaultListModel());
jList1.addMouseListener(new
java.awt.event.MouseAdapter() {
public void
mouseClicked(java.awt.event.MouseEvent
evt) {
jList1MouseClicked(evt);
}
});
jScrollPane1.setViewportView(jList1);
jList2.setModel(new
DefaultListModel());
jList2.addMouseListener(new
java.awt.event.MouseAdapter() {
public void
mouseClicked(java.awt.event.MouseEvent
evt) {
jList2MouseClicked(evt);
}
.addGroup(jPanel1Layout.createSequentialG
roup()
.addContainerGap()
.addComponent(rdYes)
.addPreferredGap(javax.swing.LayoutStyle.
ComponentPlacement.RELATED, 26,
Short.MAX_VALUE)
.addComponent(rdNo)
.addGap(20, 20, 20))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swi
ng.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialG
roup()
.addGroup(jPanel1Layout.createParallelGrou
p(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(rdYes)
.addComponent(rdNo))
.addContainerGap(javax.swing.GroupLayout
.DEFAULT_SIZE, Short.MAX_VALUE))
);
jLabel11.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel11.setText("Discount (%):");
txtDisc.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane())
;
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.Grou
pLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING,
layout.createSequentialGroup()
.addGap(37, 37, 37)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING,
layout.createParallelGroup(javax.swing.Grou
pLayout.Alignment.LEADING)
javax.swing.GroupLayout.PREFERRED_SIZE,
88,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addGroup(layout.createSequentialGroup()
.addGap(12, 12, 12)
.addComponent(txtSName,
javax.swing.GroupLayout.PREFERRED_SIZE,
167,
javax.swing.GroupLayout.PREFERRED_SIZE)
))
.addGap(25, 25, 25))
.addGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING,
layout.createSequentialGroup()
.addComponent(jLabel9,
javax.swing.GroupLayout.DEFAULT_SIZE,
110, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.
ComponentPlacement.RELATED)
.addComponent(txtOrdQty,
javax.swing.GroupLayout.PREFERRED_SIZE,
102,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(337, 337, 337)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel7)
.addComponent(jLabel5))
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(13, 13, 13)
.addComponent(txtSID,
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.
ComponentPlacement.UNRELATED)
.addComponent(txtOrdno,
javax.swing.GroupLayout.PREFERRED_SIZE,
62,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
203,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addGap(119, 119, 119)
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel11)
.addGap(18, 18, 18)
.addGroup(layout.createSequentialGroup()
.addComponent(txtDisc,
javax.swing.GroupLayout.PREFERRED_SIZE,
76,
javax.swing.GroupLayout.PREFERRED_SIZE)
)))
.addComponent(jLabel3))
.addGap(27, 27, 27))
.addComponent(jLabel2)
.addGap(18, 18, 18)
.addComponent(txtOrdDate,
javax.swing.GroupLayout.PREFERRED_SIZE,
112,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addComponent(jLabel4)
.addComponent(jScrollPane2,
javax.swing.GroupLayout.PREFERRED_SIZE,
231,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8)
.addComponent(jLabel6))
.addGap(39, 39, 39)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addComponent(txtItemID,
javax.swing.GroupLayout.PREFERRED_SIZE,
116,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtItemPrice,
javax.swing.GroupLayout.PREFERRED_SIZE,
89,
javax.swing.GroupLayout.PREFERRED_SIZE)
))
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createSequentialGroup()
.addGap(156, 156, 156)
.addComponent(jLabel10)
.addContainerGap(175,
Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(68, 68, 68)
.addComponent(btnSave)
.addGap(30, 30, 30)
.addComponent(btnBack,
javax.swing.GroupLayout.PREFERRED_SIZE,
163,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)
.addComponent(btnClear,
javax.swing.GroupLayout.PREFERRED_SIZE,
87,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(144,
Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.Grou
pLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(jLabel10)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jLabel1)
.addComponent(txtOrdno,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtOrdDate,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addGap(23, 23, 23)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.
ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane2,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addPreferredGap(javax.swing.LayoutStyle.
ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(txtSID,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(txtSName,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addGap(30, 30, 30)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(txtOrdQty,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(txtItemID,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(txtItemPrice,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
))
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.
ComponentPlacement.UNRELATED)
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
43,
javax.swing.GroupLayout.PREFERRED_SIZE)
))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(txtDisc,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
)
.addPreferredGap(javax.swing.LayoutStyle.
ComponentPlacement.RELATED, 26,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(btnClear,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnSave,
javax.swing.GroupLayout.DEFAULT_SIZE, 35,
Short.MAX_VALUE)
.addComponent(btnBack,
javax.swing.GroupLayout.DEFAULT_SIZE, 34,
Short.MAX_VALUE)))
.addGap(19, 19, 19))
);
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScree
nSize();
setBounds((screenSize.width-633)/2,
(screenSize.height-529)/2, 633, 529);
}// </editor-fold>
private void
btnClearActionPerformed(java.awt.event.Act
ionEvent evt) {
// TODO add your handling code here:
txtOrdno.setText("");
txtOrdDate.setText("");
txtSID.setText("");
txtItemID.setText("");
txtSName.setText("");
txtItemPrice.setText("");
txtOrdQty.setText("");
}
private void
btnBackActionPerformed(java.awt.event.Act
ionEvent evt) {
this.setVisible(false);
new MainMenuUI().setVisible(true);
}
private void
btnSaveActionPerformed(java.awt.event.Act
ionEvent evt) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://
localhost:3306/shopkeeper","root","root");
Statement stmt = null;
ResultSet rs = null;
// ResultSet
for SHOPKEEPER table.
String SQL = "SELECT * FROM
orderitem";
stmt = con.createStatement(); //
Connection string for ResultSet - rs.
rs = stmt.executeQuery(SQL);
float discP = 0; // Discount
// Data transfer from JTextField
control to variables
String Ordno = txtOrdno.getText();
String OrdDate =
txtOrdDate.getText();
String ItemID = txtItemID.getText();
String ShopID = txtSID.getText();
String ItemPrice =
txtItemPrice.getText();
double iPrice =
Double.parseDouble(txtItemPrice.getText());
String ordQty = txtOrdQty.getText();
if (rdYes.isSelected()) {
discP =
Float.parseFloat(txtDisc.getText());
}
else {
discP=0;
}
double amt =
(Integer.parseInt(txtOrdQty.getText()) *
Double.parseDouble(txtItemPrice.getText()))
- (Integer.parseInt(txtOrdQty.getText()) *
Double.parseDouble(txtItemPrice.getText()))
*(discP*0.01);
String strSQL = "INSERT INTO
orderitem(orderno, OrderDate, Item_Id,
Shopper_Id, Quantity, price, discount,
Amount ) VALUES ('"+(Ordno)+"','"+
(OrdDate)+"','"+(ItemID)+"','"+(ShopID)
+"',"+(ordQty)+","+iPrice+","+ discP+","+
(amt)+")";
JOptionPane.showMessageDialog(this,
"Order successfully placed");
int rowsEffected =
stmt.executeUpdate(strSQL);
System.out.println(rowsEffected + "
rows effected");
con.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.get
Message());
e.printStackTrace();
}
}
private void
formWindowGainedFocus(java.awt.event.Wi
ndowEvent evt) {
// Creating a ListModel object sModel
to perform DefaultListModel
// method operations for Shopkeeper
list
DefaultListModel sModel =
(DefaultListModel) jList1.getModel();
// Creating a ListModel object iModel to
perform DefaultComboBoxModel
// method operations for Item list
DefaultListModel iModel =
(DefaultListModel) jList2.getModel();
sModel.clear();
iModel.clear();
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://
localhost:3306/shopkeeper","root","root");
Statement stmt = null;
ResultSet rs = null;
ResultSet rs1 = null;
String SQL = "SELECT * FROM
shopkeeper";
String SQL1 = "SELECT * FROM
item";
stmt = con.createStatement();
// Steps to extract shopkeepers id
and name
rs = stmt.executeQuery(SQL);
while (rs.next()) {
String sID =
rs.getString("Shopper_id");
String Sname =
rs.getString("Name");
sModel.addElement(sID + " - " +
Sname);
}
jList1.setModel(sModel);
// Steps to extract item id and name
rs1 = stmt.executeQuery(SQL1);
while (rs1.next()) {
String iID =
rs1.getString("Item_Id");
String Iname =
rs1.getString("Item_Name");
iModel.addElement(iID + " - " +
Iname);
}
jList2.setModel(iModel);
con.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.get
Message());
e.printStackTrace();
}
}
private void
jList1MouseClicked(java.awt.event.MouseEv
ent evt) {
// Extracting supplier id and name into
a variable SidName
String SidName = (String)
jList1.getSelectedValue();
String Sid = SidName.substring(0,
3);
String Sname=
SidName.substring(6);
// Displays ID and name from
ComboBox1
txtSID.setText(Sid);
txtSName.setText(Sname);
}
private void
jList2MouseClicked(java.awt.event.MouseEv
ent evt) {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://
localhost:3306/shopkeeper","root","root");
Statement stmt = null;
ResultSet rs = null;
// Extracting item id and item name
into a variable ItemIDName
String ItemIDName = (String)
jList2.getSelectedValue();
String ItemID =
ItemIDName.substring(0, 3);
String Iame=
ItemIDName.substring(7);
txtItemID.setText(ItemID);
String SQL = "SELECT * FROM item
where Item_Id = '"+(ItemID)+"'";
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
while (rs.next()) {
double iprice =
rs.getDouble("Price");
txtItemPrice.setText(Double.toString(iprice))
;
}
con.close();
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e.get
Message());
e.printStackTrace();
}
}
private void
txtOrdDateActionPerformed(java.awt.event.
ActionEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line
arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new
Runnable() {
public void run() {
new OrderINUI().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnBack;
private javax.swing.JButton btnClear;
private javax.swing.JButton btnSave;
private javax.swing.ButtonGroup
buttonGroup1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JList jList1;
private javax.swing.JList jList2;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane
jScrollPane1;
private javax.swing.JScrollPane
jScrollPane2;
private javax.swing.JRadioButton rdNo;
private javax.swing.JRadioButton rdYes;
private javax.swing.JTextField txtDisc;
private javax.swing.JTextField txtItemID;
private javax.swing.JTextField
txtItemPrice;
private javax.swing.JTextField txtOrdDate;
private javax.swing.JTextField txtOrdQty;
private javax.swing.JTextField txtOrdno;
*****************************************R
ECIEVER
LIST*************************************
****
import java.sql.*;
import javax.swing.table.*;
import javax.swing.JOptionPane;
public class CustListUI extends
javax.swing.JFrame {
/** Creates new form CustListUI */
public CustListUI() {
initComponents();
}
/** 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() {
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jScrollPane1 = new
javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.Wind
owConstants.EXIT_ON_CLOSE);
setTitle("Customers list");
jButton1.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
jButton1.setText("Display/Query");
jButton1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
jButton2.setText("Back to Menu");
jButton2.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
jButton2ActionPerformed(evt);
}
});
jTable1.setModel(new
javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null}
},
new String [] {
"Customer ID", "Name",
"Address", "City", "Phone"
}
));
jScrollPane1.setViewportView(jTable1);
jLabel1.setFont(new
java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel1.setText("Customer List");
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane())
;
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.Grou
pLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(203, 203, 203)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.DEFAULT_SIZE,
587, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(161, 161, 161)
.addComponent(jButton1)
.addGap(39, 39, 39)
.addComponent(jButton2)))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.Grou
pLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
172,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jButton2,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jButton1,
javax.swing.GroupLayout.DEFAULT_SIZE, 32,
Short.MAX_VALUE))
.addContainerGap(13,
Short.MAX_VALUE))
);
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScree
nSize();
setBounds((screenSize.width-623)/2,
(screenSize.height-357)/2, 623, 357);
}// </editor-fold>
private void
jButton1ActionPerformed(java.awt.event.Act
ionEvent evt) {
// Before writting the followng line, you
should import the line:
// import javax.swing.table.*; at the top
of your application
DefaultTableModel model =
(DefaultTableModel) jTable1.getModel();
// Clear the existing table
int rows = model.getRowCount();
if (rows > 0) {
for (int i = 0; i < rows; i++) {
model.removeRow(0);
}
}
// SQL Query
String query = "SELECT * FROM
shopkeeper";
try {
// Connect to MySQL database
Class.forName("com.mysql.jdbc.Driver").ne
wInsta
nce();
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://
local
host:3306/shopkeeper","root","root");
// Create SQL statement and
execute query.
Statement stmt =
con.createStatement();
private javax.swing.JScrollPane
jScrollPane1;
private javax.swing.JTable jTable1;
// End of variables declaration
}
*****************************************S
ENDER
LIST*************************************
***
import
import
import
import
java;
javax.swing.table.*;
java.sql.*;
javax.swing.JOptionPane;
setDefaultCloseOperation(javax.swing.Wind
owConstants.EXIT_ON_CLOSE);
setTitle("List of items in shop");
jButton2.setFont(new
java.awt.Font("Tahoma", 1, 11)); // NOI18N
jButton2.setText("Back to Menu");
jButton2.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
jButton2ActionPerformed(evt);
}
});
jButton1.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
jButton1.setText("Display/Query");
jButton1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
jButton1ActionPerformed(evt);
}
});
jTable1.setModel(new
javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Item ID", "Name", "Description",
"Price"
}
));
jScrollPane1.setViewportView(jTable1);
jLabel1.setFont(new
java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel1.setText("Item List");
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane())
;
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.Grou
pLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(219, 219, 219)
.addComponent(jLabel1))
.addGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.DEFAULT_SIZE,
564, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(137, 137, 137)
.addComponent(jButton1)
.addGap(62, 62, 62)
.addComponent(jButton2)))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.Grou
pLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(27, 27, 27)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
172,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jButton2,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(jButton1,
javax.swing.GroupLayout.DEFAULT_SIZE, 32,
Short.MAX_VALUE))
.addContainerGap(22,
Short.MAX_VALUE))
);
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScree
nSize();
setBounds((screenSize.width-600)/2,
(screenSize.height-366)/2, 600, 366);
}// </editor-fold>
private void
jButton2ActionPerformed(java.awt.event.Act
ionEvent evt) {
this.setVisible(false);
new MainMenuUI().setVisible(true);
}
private void
jButton1ActionPerformed(java.awt.event.Act
ionEvent evt) {
// Before writting the followng line, you
should import the line:
// import javax.swing.table.*; at the top
of your application
DefaultTableModel model =
(DefaultTableModel) jTable1.getModel();
// Clear the existing table
int rows = model.getRowCount();
if (rows > 0) {
for (int i = 0; i < rows; i++) {
model.removeRow(0);
}
}
// SQL Query
String query = "SELECT * FROM Item";
try {
// Connect to MySQL database
Class.forName("com.mysql.jdbc.Driver").ne
wInstance();
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://
localhost:3306/shopkeeper","root","root");
*****************************************B
OOKING
LIST*************************************
****
import java;
import javax.swing.table.*;
import java.sql.*;
import javax.swing.JOptionPane;
setDefaultCloseOperation(javax.swing.Wind
owConstants.EXIT_ON_CLOSE);
setTitle("List of orders");
jButton2.setFont(new
java.awt.Font("Tahoma", 1, 11)); // NOI18N
jButton2.setText("Back to Menu");
jButton2.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
jButton2ActionPerformed(evt);
}
});
}
jButton1.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
/** 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.
jButton1.setText("Display/Query");
jButton1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEven
t evt) {
jButton1ActionPerformed(evt);
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed"
desc="Generated Code">
private void initComponents() {
}
});
jTable1.setModel(new
javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null,
null, null},
{null, null, null, null, null, null,
null, null},
{null, null, null, null, null, null,
null, null},
.addComponent(jScrollPane1,
javax.swing.GroupLayout.DEFAULT_SIZE,
588, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(161, 161, 161)
.addComponent(jButton1)
.addGap(70, 70, 70)
.addComponent(jButton2))
.addGroup(javax.swing.GroupLayout.Alignm
ent.TRAILING,
layout.createSequentialGroup()
.addComponent(jLabel1)
},
new String [] {
"Order No.", "Order Date", "Item
Id", "Customer Id", "Quantity", "Price",
"Discount(%)", "Amount"
}
.addContainerGap())
);
layout.createParallelGroup(javax.swing.Grou
pLayout.Alignment.LEADING)
));
jScrollPane1.setViewportView(jTable1);
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
172,
javax.swing.GroupLayout.PREFERRED_SIZE)
jLabel1.setFont(new
java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel1.setText("Order List");
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.
swing.GroupLayout.Alignment.LEADING)
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScree
nSize();
setBounds((screenSize.width-624)/2,
(screenSize.height-393)/2, 624, 393);
}// </editor-fold>
private void
jButton2ActionPerformed(java.awt.event.Act
ionEvent evt) {
this.setVisible(false);
new MainMenuUI().setVisible(true);
String Ordno =
rs.getString("Orderno");
private void
jButton1ActionPerformed(java.awt.event.Act
ionEvent evt) {
// Before writting the followng line, you
should import the line:
// import javax.swing.table.*; at the top
of your application
DefaultTableModel model =
(DefaultTableModel) jTable1.getModel();
// Clear the existing table
int rows = model.getRowCount();
if (rows > 0) {
for (int i = 0; i < rows; i++) {
model.removeRow(0);
}
}
// SQL Query
String query = "SELECT * FROM
orderitem";
String Ordd =
rs.getString("OrderDate");
String OItemid =
rs.getString("Item_Id");
String OSid =
rs.getString("Shopper_Id");
String OQty =
rs.getString("Quantity");
String IPrice =
rs.getString("price");
String Disc =
rs.getString("discount");
String OAmount =
rs.getString("Amount");
System.out.println(Ordno + "|" +
Ordd + "|" +OItemid + "|" + OSid + "|" +
OQty + "|" + IPrice + "|" + Disc + "|" +
OAmount);
model.addRow(new Object[]
{Ordno, Ordd, OItemid, OSid, OQty, IPrice,
Disc, OAmount});
}
try {
} catch (Exception e) {
JOptionPane.showMessageDialog(this,
e.getMessage());
}
}
/**
*/
new OrdListUI().setVisible(true);
}
});
BIBILOGRAPHY
Book: INFORMATICS PRACTICES
Writtten by:
1.
2.
Oxford 12th IP
TEACHER
REMARKS