Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 55

INFORMATION PRACTICES

A PROJECT ON

“CAR SHOWROOM SYSTEM”

Submitted in partial rollback in fulfillment of the requirement for the

SENIOR SECONDARY EXAMINATION (AISSCE)

Submitted By : Submitted To :

Student Name Name of Faculty


(Roll No : 1234567) (Computer Sci. Teacher)
CERTIFICATE .

This is to certify that the project titled “CAR


SHOWROOM SYSTEM” submitted by Miss / Master
STUDENT NAME having roll no ________ of CLASS XII
has completed this project for partial rollback in full -
fillment of the requirement for the senior secondary
examination (AISSCE) embodies the bonafide work
done by him/her under my supervision.

Internal Supervisor External Supervisor


Signature Signature

Name : Name :

Date : Date :

CAR SHOWROOM SYSTEM | Created by : Student Name


ID – SHEET

Roll No : ………………………….

Name of Student : ………………………….

Address : ………………………….
………………………….

Phone No : ………………………….

Email Address : ………………………….

Supervisor : ………………………….

Project Title : ………………………….

Front End Tool : ………………………….

Back End Tool : ………………………….

CAR SHOWROOM SYSTEM | Created by : Student Name


ACKNOWLEDGEMENT

It would be our outmost pleasure to express


our sincere thanks to our Computer Science
Teacher “Faculty Name” in providing a
helping hand in this project.

His unflagging patience, creativity


and immense knowledge that he shared with
us have proved highly beneficial to us and
have made our Project possible and
successful.

Student Name

CAR SHOWROOM SYSTEM | Created by : Student Name


TABLE OF CONTENTS

 Introduction

 Java Details

 Priliminary Design

 Form Layouts

 Database Design

 Implementation

 Bibliography

 Teacher Remarks

CAR SHOWROOM SYSTEM | Created by : Student Name


INTRODUCTION

This program is designed for the use

of Car Showroom 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.

CAR SHOWROOM SYSTEM | Created by : Student Name


What is java?
Java is a general purpose object oriented programming language . It is the first programming
language that is not tied to any particular hardware or operating system .The language is
based on the concept of an object. Java is highly derived from C++ . Most striking feature of
the language is that it is platform neutral language.

There were five primary goals in the creation of the Java language:

• It should use the object-oriented programming methodology.


• It should allow the same program to be executed on multiple operating systems.
• It should contain built-in support for using computer networks.
• It should be designed to execute code from remote sources securely.
• It should be easy to use and borrow the good parts of older object-oriented languages like
C++.

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
● Compiler and Interpreted
● Platform independent
● Simple
● Secure
● Familiar
● Portable
● Object-Oriented
● Robust
● Multithreaded
● High performance
● Distributed
● Dynamic

Compiler and Interpreted - There is a java compiler , named javac . The java compiler
takes input source code files (these files typically have the ext.java) and converts them into
compiled bytecode files.The java Interpreter known as javac can be used to execute java
application .The interpreter translates bytecode directly into program actions.

Platform independent - Java programs can be easily moved from one computer to
another, anywhere and anytime.Changes and upgrades made in operating systems,
processors and system resources will not force any changes in java programs.

Simple - Java is designed to be easy for programmer to learn and use efficiently.

CAR SHOWROOM SYSTEM | Created by : Student Name


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.

Familiar- It is modeled on C, C++ languages. Java code looks like C++.

Portable- Java compiler generates bytecode instructions that can be implemented on any
machine and also the size of the primitive data types are machine independent.

Object-Oriented - Java is a true object-oriented language. All program code and data
reside within objects and classes.

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.

Multithreaded - Java supports handling multiple tasks simultaneously which greatly


improves the interactive performance of graphical applications.

High performance - Java performance is impressive for an interpreted language , mainly


due to use of immediate bytecode . Use of multithreaded and further its architecture is also
designed to reduce overheads during runtime.

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.

Dynamic - Java is capable of dynamically in new class libraries , methods and objects .It
supports functions written in other languages like C,C++ called as native methods.

Automatic garbage collection - One idea behind Java's automatic memory


management model is that programmers should be spared the burden of having to perform
manual memory management. In some languages the programmer allocates memory to
create any object stored on the heap and is responsible for later manually deallocating that
memory to delete any such objects. If a programmer forgets to de-allocate memory or
writes code that fails to do so in a timely fashion, a memory leak can occur: the program will
consume a potentially arbitrarily large amount of memory. In addition, if a region of
memory is de-allocated twice, the program can become unstable and may crash.

In Java, this potential problem is avoided by automatic garbage collection. The programmer
determines when objects are created and the Java runtime is responsible for managing the
objects' lifecycle. The program or other objects can reference an object by holding a
reference to it (which, from a low-level point of view, is its address on the heap). When no
references to an object remain, the Java garbage collector automatically deletes the
CAR SHOWROOM SYSTEM | Created by : Student Name
unreachable object, freeing memory and preventing a memory leak. Memory leaks may still
occur if a programmer's code holds a reference to an object that is no longer needed—in
other words, they can still occur but at higher conceptual levels.

Comparing Java and C++, it is possible in C++ to implement similar functionality (for
example, a memory management model for specific classes can be designed in C++ to
improve speed and lower memory fragmentation considerably), with the possibly cost of
extra development time and some application complexity. In Java, garbage collection is built
in and virtually invisible to the developer. That is, developers may have no notion of when
garbage collection will take place as it may not necessarily correlate with any actions being
explicitly performed by the code they write. Depending on intended application, this can be
beneficial or disadvantageous: the programmer is freed from performing low-level tasks but
at the same time lose the option of writing lower level code.

Java Magic: The Bytecode

Bytecode is a highly optimized set of instruction designed to be executed by the java


runtime system, which is called Java Virtual Machine and it exists only inside the computer
memory.

Java Program Java Compiler Virtual Machine

Source code Bytecode


Process of Compilation

Bytecode Java Interpreter Machine code


Virtual Machine Real Machine

Process of converting Bytecode into Machine code

Object Oriented Programming

Object Oriented Programming is an approach that provides a way of modularizing programs


by creating partitioned memory area for both data and functions that can be used as
templates for creating copies of such modules on demand.

Objects and Classes - An object is a software bundle of variables and related methods.
Objects are key to understanding object-oriented technology. Real-world 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
behavior Classes can also define class variables. A class variable contains information that is
CAR SHOWROOM SYSTEM | Created by : Student Name
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 - Wrapping of data and methods into a single unit is known as


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.

Inheritance - Inheritance is the process by which objects of one class acquire the property
of objects of another class. Each subclass inherits state .However, subclasses are not limited
to the states and behaviors provided to them by their superclass. Subclasses can add
variables and methods to the ones they inherit from the superclass. It supports the concept
of hierarchical classification it also provides the use of reusability. .

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.

Java SE - Java Database Connectivity (JDBC)

The Java Database Connectivity (JDBC) API is the industry standard for database-
independent connectivity between the Java programming language and a wide range of
databases – SQL databases and other tabular data sources, such as spreadsheets or flat files.
The JDBC API provides a call-level API for SQL-based database access.

JDBC technology allows you to use the Java programming language to exploit "Write Once,
Run Anywhere" capabilities for applications that require access to enterprise data. With a
JDBC technology-enabled driver, you can connect all corporate data even in a
heterogeneous environment.

 
Advantages of JDBC Technology :

Leverage Existing Enterprise Data

Simplified Enterprise Development

Zero Configuration for Network Computers


 

Driver Loads database drivers and manages the

CAR SHOWROOM SYSTEM | Created by : Student Name


manager connections between the application and the
driver
Driver Translates API calls into operations for a
specific data source
Connection A session between an application and a
database
Statement A SQL statement to perform a query or update
operation
Metadata Information about returned data , database
and driver
Resultset Logical set of columns and rows of data
returned by executing a statement

Driver Manager Connection Statemen ResultSet


t

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.

SQL-STRUCTURED QUERY LANGUAGE

CAR SHOWROOM SYSTEM | Created by : Student Name


SQL is not a procedural language. It is not used to define complex processes; we can use
SQL to use commands that define and manipulate data. SQL is different from other
languages.

• SQL is very readable.

• In SQL we always issue commands.

SQL statements fall into two groups:-

● Data Defination Language (DDL) – DDL statements are used to describe the tables
and the data they contain. The subset of SQL statements 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 don’t return a set of results.

Here are some of the quries defined:-

SELECT - SQL statement used to request a selection, projection, join, query, and so on,
from a SQL Server database.

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

CAR SHOWROOM SYSTEM | Created by : Student Name


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 DESCRIPTION
Abstract Button Abstract super class for Swing buttons.
Button Group Encapsulates a mutually exclusive set of
buttons.
Image Icon Encapsulates an icon.
JApplet The SWING version of APPLET.
JButton The SWING push button class.
JCheckBox The SWING check box class.
JComboBox Encapsulates a combo box .
JLabels The SWING version of a label.
JRadioButton The SWING version of a radio button.
JScrollPane Encapsulates a scrollable window.
JTabbedPane Encapsulates a tabbed window.
JTextField The SWING version of Text field.
JTree Encapsulates a tree based-control.

Here are the some of the components used:

● JApplet – Applet that use SWING must be subclass of JApplet.


JApplet is rich with functionality that is not found in Applet.

● Icons – Icons are encapsulated by the Image Icon class, which paints an icon from an
image.

CAR SHOWROOM SYSTEM | Created by : Student Name


● 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.

● JTextFields – Text field is encapsulated by the JTextComponent class which extends


JComponent. JTextField allows you to edit one line of text.

● JButton – JButton class provides the functionality of a push button. JButton allows an
icon of string to be associated with the push button.

● JCheckBox – It is supported by the JCheckBox class. It is a control that is used to turn an


option on or off.

● JTextArea - Text area is encapsulated by the JTextComponent class which extends


JComponent. JTextArea allows you to edit multiline of text.

● JRadioButton – it is supported by the JRadioButton class. It can be configured into a


group of check boxes in which only one check box can be checked at any one time.

● JComboBox – It is provided through the JComboBox class. It normally displays one entry
and can also display a drop down list that allows a user to select a different entry.

● JScrollPane – It is a component that presents a rectangular area in which a component


may be viewed. These are implemented in Swing by JScrollPane class.

● JTree - It is a component that presents a hierarchical view of data. A user has ability to
expand individual subtrees. These are implemented in Swing by JTree class.

ADVANTAGES OF (JAVAX) SWING:

1. It provides more powerful and more flexible components possible in AWT package.
For e.g. JButton can have both image as well as text field associated with it which is
not possible in awt package.

2. Unlike AWT components SWING components are not implemented by platform-


specific code. Instead they are written entirely in java and therefore are platform
independent. Thus term lightweight is used to describe such elements.

3. Further the Swing components can provide pluggable look and feel, which means
that it is easy to substitute another appearance and behavior for an element.

CAR SHOWROOM SYSTEM | Created by : Student Name


PRELIMINARY
DESIGN
(User Interface)

CAR SHOWROOM SYSTEM | Created by : Student Name


FORM
LAYOUTS

CAR SHOWROOM SYSTEM | Created by : Student Name


CAR SHOWROOM SYSTEM | Created by : Student Name
CAR SHOWROOM SYSTEM | Created by : Student Name
CAR SHOWROOM SYSTEM | Created by : Student Name
CAR SHOWROOM SYSTEM | Created by : Student Name
DATABASE
DESIGN

CAR SHOWROOM SYSTEM | Created by : Student Name


CAR SHOWROOM SYSTEM | Created by : Student Name
IMPLEMENTATION

CAR SHOWROOM SYSTEM | Created by : Student Name


***************************************** javax.swing.GroupLayout(jDialog1.getContentPane
());
LOG IN
jDialog1.getContentPane().setLayout(jDialog1Layo
***************************************** ut);
jDialog1Layout.setHorizontalGroup(
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import java.sql.DriverManager; jDialog1Layout.createParallelGroup(javax.swing.Gr
import java.sql.ResultSet; oupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
public class login extends javax.swing.JFrame { );
jDialog1Layout.setVerticalGroup(
/** Creates new form login */
public login() { jDialog1Layout.createParallelGroup(javax.swing.Gr
initComponents(); oupLayout.Alignment.LEADING)
} .addGap(0, 300, Short.MAX_VALUE)
);
/** This method is called from within the
constructor to
* initialize the form. setDefaultCloseOperation(javax.swing.WindowCon
* WARNING: Do NOT modify this code. The stants.EXIT_ON_CLOSE);
content of this method is setTitle("City Sports Shop Management
* always regenerated by the Form Editor. System");
*/ setBounds(new java.awt.Rectangle(200, 70, 0,
@SuppressWarnings("unchecked") 0));
// <editor-fold defaultstate="collapsed"
desc="Generated Code"> jLabel3.setFont(new java.awt.Font("Tahoma",
private void initComponents() { 1, 12)); // NOI18N
jLabel3.setForeground(new java.awt.Color(0,
jPopupMenu1 = new 153, 255));
javax.swing.JPopupMenu(); jLabel3.setText("PASSWORD");
jPopupMenu2 = new
javax.swing.JPopupMenu(); jLabel2.setFont(new java.awt.Font("Tahoma",
jDialog1 = new javax.swing.JDialog(); 1, 12)); // NOI18N
jLabel3 = new javax.swing.JLabel(); jLabel2.setForeground(new java.awt.Color(0,
jLabel2 = new javax.swing.JLabel(); 153, 255));
idtf = new javax.swing.JTextField(); jLabel2.setText("LOGIN ID");
PassWordTF = new
javax.swing.JPasswordField(); idtf.setBackground(new java.awt.Color(204,
jLabel4 = new javax.swing.JLabel(); 255, 204));
jLabel1 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel(); PassWordTF.setBackground(new
LogInB = new javax.swing.JButton(); java.awt.Color(204, 255, 204));
invalidl = new javax.swing.JLabel();
invalid = new javax.swing.JLabel(); jLabel4.setBackground(new
java.awt.Color(204, 204, 255));
javax.swing.GroupLayout jDialog1Layout = jLabel4.setFont(new java.awt.Font("Colonna
new MT", 3, 24)); // NOI18N

CAR SHOWROOM SYSTEM | Created by : Student Name


jLabel4.setForeground(new java.awt.Color(51,
153, 255)); .addGroup(javax.swing.GroupLayout.Alignment.TR
jLabel4.setText("SHOP MANAGEMENT AILING, layout.createSequentialGroup()
SYSTEM");
.addPreferredGap(javax.swing.LayoutStyle.Compo
jLabel1.setIcon(new nentPlacement.RELATED, 115,
javax.swing.ImageIcon(getClass().getResource("/sp javax.swing.GroupLayout.PREFERRED_SIZE)
orts.png"))); // NOI18N .addComponent(jLabel4,
javax.swing.GroupLayout.PREFERRED_SIZE, 370,
jLabel6.setFont(new java.awt.Font("Poor javax.swing.GroupLayout.PREFERRED_SIZE)
Richard", 0, 18)); .addGap(5, 5, 5))
jLabel6.setForeground(new java.awt.Color(0,
153, 255)); .addGroup(javax.swing.GroupLayout.Alignment.TR
jLabel6.setText("LOG IN TO CONTINUE"); AILING, layout.createSequentialGroup()
.addGap(55, 55, 55)
LogInB.setFont(new java.awt.Font("Tahoma",
1, 18)); // NOI18N
.addGroup(layout.createParallelGroup(javax.swing
LogInB.setForeground(new java.awt.Color(51,
.GroupLayout.Alignment.LEADING)
153, 255));
LogInB.setText("Log In");
.addGroup(layout.createSequentialGroup()
LogInB.addActionListener(new
java.awt.event.ActionListener() {
public void .addGroup(layout.createParallelGroup(javax.swing
actionPerformed(java.awt.event.ActionEvent evt) { .GroupLayout.Alignment.LEADING)
LogInBActionPerformed(evt);
} .addGroup(layout.createSequentialGroup()
}); .addGap(147, 147, 147)
.addComponent(jLabel6,
invalidl.setFont(new java.awt.Font("Tahoma", javax.swing.GroupLayout.PREFERRED_SIZE, 210,
1, 12)); javax.swing.GroupLayout.PREFERRED_SIZE))

invalid.setFont(new java.awt.Font("Tahoma", .addGroup(layout.createSequentialGroup()


1, 12)); // NOI18N
invalid.setText(" "); .addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING)
javax.swing.GroupLayout layout = new .addComponent(jLabel3)
javax.swing.GroupLayout(getContentPane()); .addComponent(jLabel2,
getContentPane().setLayout(layout); javax.swing.GroupLayout.PREFERRED_SIZE, 68,
layout.setHorizontalGroup( javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(49, 49, 49)
layout.createParallelGroup(javax.swing.GroupLayo
ut.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing
.addGroup(layout.createSequentialGroup() .GroupLayout.Alignment.LEADING)
.addGap(20, 20, 20) .addComponent(idtf,
javax.swing.GroupLayout.DEFAULT_SIZE, 244,
.addGroup(layout.createParallelGroup(javax.swing Short.MAX_VALUE)
.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1) .addComponent(PassWordTF,

CAR SHOWROOM SYSTEM | Created by : Student Name


javax.swing.GroupLayout.PREFERRED_SIZE, 244,
javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGroup(layout.createParallelGroup(javax.swing
.addGap(50, 50, 50)) .GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addGroup(layout.createSequentialGroup() .addComponent(idtf,
.addComponent(LogInB, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE) javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(49, 49, 49) .addGap(18, 18, 18)
.addComponent(invalid,
javax.swing.GroupLayout.PREFERRED_SIZE, 183, .addGroup(layout.createParallelGroup(javax.swing
javax.swing.GroupLayout.PREFERRED_SIZE))) .GroupLayout.Alignment.BASELINE)
.addGap(20, 20, 20))) .addComponent(PassWordTF,
javax.swing.GroupLayout.PREFERRED_SIZE,
.addPreferredGap(javax.swing.LayoutStyle.Compo javax.swing.GroupLayout.DEFAULT_SIZE,
nentPlacement.RELATED) javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(invalidl) .addComponent(jLabel3))
.addContainerGap(36, .addGap(28, 28, 28)
Short.MAX_VALUE))
); .addGroup(layout.createParallelGroup(javax.swing
layout.setVerticalGroup( .GroupLayout.Alignment.BASELINE)
.addComponent(LogInB,
layout.createParallelGroup(javax.swing.GroupLayo javax.swing.GroupLayout.PREFERRED_SIZE, 33,
ut.Alignment.LEADING) javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(invalid))
.addGroup(javax.swing.GroupLayout.Alignment.TR .addGap(34, 34, 34))
AILING, layout.createSequentialGroup() );
.addContainerGap(372,
Short.MAX_VALUE) java.awt.Dimension screenSize =
.addComponent(invalidl) java.awt.Toolkit.getDefaultToolkit().getScreenSize(
.addGap(33, 33, 33)) );
setBounds((screenSize.width-568)/2,
.addGroup(javax.swing.GroupLayout.Alignment.TR (screenSize.height-443)/2, 568, 443);
AILING, layout.createSequentialGroup() }// </editor-fold>
.addGap(38, 38, 38)
.addComponent(jLabel4, private void
javax.swing.GroupLayout.PREFERRED_SIZE, 31, LogInBActionPerformed(java.awt.event.ActionEve
javax.swing.GroupLayout.PREFERRED_SIZE) nt evt) {
.addGap(26, 26, 26) // TODO add your handling code here:
.addComponent(jLabel1, invalid.setText("");
javax.swing.GroupLayout.PREFERRED_SIZE, 102, String PWord = PassWordTF.getText();
javax.swing.GroupLayout.PREFERRED_SIZE) String ID = idtf.getText();
String str = null;
.addPreferredGap(javax.swing.LayoutStyle.Compo Statement stmt=null;
nentPlacement.RELATED, 23, Short.MAX_VALUE) ResultSet rs = null;
.addComponent(jLabel6) try {

Class.forName("java.sql.Driver");
.addPreferredGap(javax.swing.LayoutStyle.Compo
nentPlacement.UNRELATED)

CAR SHOWROOM SYSTEM | Created by : Student Name


String database = private javax.swing.JLabel jLabel4;
"jdbc:mysql://localhost:3306/CARSHOWROOM"; private javax.swing.JLabel jLabel6;
Connection conn = (Connection) private javax.swing.JPopupMenu jPopupMenu1;
DriverManager.getConnection(database, "root", private javax.swing.JPopupMenu jPopupMenu2;
"root"); // End of variables declaration
stmt = (Statement) conn.createStatement(); }
String sql = "select * from login where
userID = '" + ID + "'";
rs = stmt.executeQuery(sql); *****************************************
rs.next();
str = rs.getString("Password"); MAIN UI
rs.close();
*****************************************
stmt.close();
conn.close(); import java.sql.*;
if(str.equals(PWord)) { public class MainMenuUI extends
MainMenuUI m = new MainMenuUI(); javax.swing.JFrame {
m.setVisible(true);
this.setVisible(false); /** Creates new form MainMenuUI */
} else { public MainMenuUI() {
invalid.setText("Incorrect ID or initComponents();
Password"); }
}
} catch (Exception e) /** This method is called from within the
{ invalid.setText("Incorrect ID or Password");} constructor to
} * initialize the form.
* WARNING: Do NOT modify this code. The
/** content of this method is
* @param args the command line arguments * always regenerated by the Form Editor.
*/ */
public static void main(String args[]) { @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed"
java.awt.EventQueue.invokeLater(new desc="Generated Code">
Runnable() { private void initComponents() {
public void run() {
new login().setVisible(true); jLabel1 = new javax.swing.JLabel();
} jMenuBar1 = new javax.swing.JMenuBar();
}); jMenu1 = new javax.swing.JMenu();
} mnuCustAdd = new javax.swing.JMenuCARS();
mnuCARSAdd = new
// Variables declaration - do not modify javax.swing.JMenuCARS();
private javax.swing.JButton LogInB; mnuOrder = new javax.swing.JMenuCARS();
private javax.swing.JPasswordField PassWordTF; jMenu2 = new javax.swing.JMenu();
private javax.swing.JTextField idtf; ListCust = new javax.swing.JMenuCARS();
private javax.swing.JLabel invalid; ListCARS = new javax.swing.JMenuCARS();
private javax.swing.JLabel invalidl; ListOrder = new javax.swing.JMenuCARS();
private javax.swing.JDialog jDialog1; jMenu3 = new javax.swing.JMenu();
private javax.swing.JLabel jLabel1; jMenuCARS1 = new javax.swing.JMenuCARS();
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;

CAR SHOWROOM SYSTEM | Created by : Student Name


mnuOrder.setText("Order Entry");
setDefaultCloseOperation(javax.swing.WindowCon mnuOrder.addActionListener(new
stants.EXIT_ON_CLOSE); java.awt.event.ActionListener() {
setTitle("Sports Shop Mangement"); public void
actionPerformed(java.awt.event.ActionEvent evt) {
jLabel1.setFont(new java.awt.Font("Elephant", mnuOrderActionPerformed(evt);
1, 48)); // NOI18N }
jLabel1.setText(" SPORTS SHOP !"); });
jMenu1.add(mnuOrder);

jMenu1.setBorder(javax.swing.BorderFactory.creat jMenuBar1.add(jMenu1);
eEtchedBorder());
jMenu1.setText("Sports Club");
jMenu1.setFont(new java.awt.Font("Segoe jMenu2.setBorder(javax.swing.BorderFactory.creat
UI", 1, 18)); // NOI18N eEtchedBorder());
jMenu1.addActionListener(new jMenu2.setText("View");
java.awt.event.ActionListener() { jMenu2.setFont(new java.awt.Font("Segoe
public void UI", 1, 18)); // NOI18N
actionPerformed(java.awt.event.ActionEvent evt) { jMenu2.addActionListener(new
jMenu1ActionPerformed(evt); java.awt.event.ActionListener() {
} public void
}); actionPerformed(java.awt.event.ActionEvent evt) {
jMenu2ActionPerformed(evt);
mnuCustAdd.setFont(new }
java.awt.Font("Segoe UI", 1, 14)); // NOI18N });
mnuCustAdd.setText("Cusomer Entry");
mnuCustAdd.addActionListener(new ListCust.setFont(new java.awt.Font("Segoe
java.awt.event.ActionListener() { UI", 1, 14)); // NOI18N
public void ListCust.setText("Customer List");
actionPerformed(java.awt.event.ActionEvent evt) { ListCust.addActionListener(new
mnuCustAddActionPerformed(evt); java.awt.event.ActionListener() {
} public void
}); actionPerformed(java.awt.event.ActionEvent evt) {
jMenu1.add(mnuCustAdd); ListCustActionPerformed(evt);
}
mnuCARSAdd.setFont(new });
java.awt.Font("Segoe UI", 1, 14)); // NOI18N jMenu2.add(ListCust);
mnuCARSAdd.setText("CARS Entry");
mnuCARSAdd.addActionListener(new ListCARS.setFont(new java.awt.Font("Segoe
java.awt.event.ActionListener() { UI", 1, 14)); // NOI18N
public void ListCARS.setText("CARS List");
actionPerformed(java.awt.event.ActionEvent evt) { ListCARS.addActionListener(new
mnuCARSAddActionPerformed(evt); java.awt.event.ActionListener() {
} public void
}); actionPerformed(java.awt.event.ActionEvent evt) {
jMenu1.add(mnuCARSAdd); ListCARSActionPerformed(evt);
}
mnuOrder.setFont(new java.awt.Font("Segoe });
UI", 1, 14)); // NOI18N jMenu2.add(ListCARS);

CAR SHOWROOM SYSTEM | Created by : Student Name


ListOrder.setFont(new java.awt.Font("Segoe layout.createParallelGroup(javax.swing.GroupLayo
UI", 1, 14)); // NOI18N ut.Alignment.LEADING)
ListOrder.setText("Order List"); .addGroup(layout.createSequentialGroup()
ListOrder.addActionListener(new .addContainerGap()
java.awt.event.ActionListener() { .addComponent(jLabel1)
public void
actionPerformed(java.awt.event.ActionEvent evt) { .addContainerGap(javax.swing.GroupLayout.DEFA
ListOrderActionPerformed(evt); ULT_SIZE, Short.MAX_VALUE))
} );
}); layout.setVerticalGroup(
jMenu2.add(ListOrder);
layout.createParallelGroup(javax.swing.GroupLayo
jMenuBar1.add(jMenu2); ut.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TR
jMenu3.setBorder(javax.swing.BorderFactory.creat AILING, layout.createSequentialGroup()
eEtchedBorder()); .addContainerGap(110,
jMenu3.setText("quit"); Short.MAX_VALUE)
jMenu3.setFont(new java.awt.Font("Segoe .addComponent(jLabel1,
UI", 1, 18)); // NOI18N javax.swing.GroupLayout.PREFERRED_SIZE, 107,
jMenu3.addActionListener(new javax.swing.GroupLayout.PREFERRED_SIZE)
java.awt.event.ActionListener() { .addGap(115, 115, 115))
public void );
actionPerformed(java.awt.event.ActionEvent evt) {
jMenu3ActionPerformed(evt); java.awt.Dimension screenSize =
} java.awt.Toolkit.getDefaultToolkit().getScreenSize(
}); );
setBounds((screenSize.width-527)/2,
jMenuCARS1.setFont(new (screenSize.height-401)/2, 527, 401);
java.awt.Font("Segoe UI", 1, 14)); // NOI18N }// </editor-fold>
jMenuCARS1.setText("Application");
jMenuCARS1.addActionListener(new private void
java.awt.event.ActionListener() { mnuCustAddActionPerformed(java.awt.event.Acti
public void onEvent evt) {
actionPerformed(java.awt.event.ActionEvent evt) { this.setVisible(false);
jMenuCARS1ActionPerformed(evt); new ShopINUI().setVisible(true);
} }
});
jMenu3.add(jMenuCARS1); private void
mnuCARSAddActionPerformed(java.awt.event.Acti
jMenuBar1.add(jMenu3); onEvent evt) {
this.setVisible(false);
setJMenuBar(jMenuBar1); new CARSINUI().setVisible(true);
}
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane()); private void
getContentPane().setLayout(layout); mnuOrderActionPerformed(java.awt.event.Action
layout.setHorizontalGroup( Event evt) {

CAR SHOWROOM SYSTEM | Created by : Student Name


this.setVisible(false); System.exit(0); // TODO add your handling
new OrderINUI().setVisible(true); code here:
} }

private void /**


jMenu1ActionPerformed(java.awt.event.ActionEve * @param args the command line arguments
nt evt) { */
// TODO add your handling code here: public static void main(String args[]) {
} java.awt.EventQueue.invokeLater(new
Runnable() {
private void public void run() {
jMenu2ActionPerformed(java.awt.event.ActionEve new MainMenuUI().setVisible(true);
nt evt) { }
});
} }

private void // Variables declaration - do not modify


ListCustActionPerformed(java.awt.event.ActionEve private javax.swing.JMenuCARS ListCust;
nt evt) { private javax.swing.JMenuCARS ListCARS;
this.setVisible(false); private javax.swing.JMenuCARS ListOrder;
new CustListUI().setVisible(true); private javax.swing.JLabel jLabel1;
} private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private void private javax.swing.JMenu jMenu3;
ListCARSActionPerformed(java.awt.event.ActionEv private javax.swing.JMenuBar jMenuBar1;
ent evt) { private javax.swing.JMenuCARS jMenuCARS1;
this.setVisible(false); private javax.swing.JMenuCARS mnuCustAdd;
new CARSListUI().setVisible(true); private javax.swing.JMenuCARS mnuCARSAdd;
private javax.swing.JMenuCARS mnuOrder;
} // End of variables declaration

private void }
ListOrderActionPerformed(java.awt.event.ActionE
vent evt) {
this.setVisible(false); *****************************************
new OrdListUI().setVisible(true); CUSTOMER DETAILS
*****************************************
}
import java.sql.*;
private void import javax.swing.JOptionPane;
jMenu3ActionPerformed(java.awt.event.ActionEve
nt evt) { public class ShopINUI extends javax.swing.JFrame {
// TODO add your handling code here:
/** Creates new form ShopINUI */
} public ShopINUI() {
initComponents();
private void }
jMenuCARS1ActionPerformed(java.awt.event.Acti
onEvent evt) {

CAR SHOWROOM SYSTEM | Created by : Student Name


/** This method is called from within the
constructor to txtSHAddress.setFont(new
* initialize the form. java.awt.Font("Tahoma", 1, 12));
* WARNING: Do NOT modify this code. The
content of this method is btnBack.setFont(new
* always regenerated by the Form Editor. java.awt.Font("Tahoma", 1, 12));
*/ btnBack.setText("Back to Main");
@SuppressWarnings("unchecked") btnBack.addActionListener(new
// <editor-fold defaultstate="collapsed" java.awt.event.ActionListener() {
desc="Generated Code"> public void
private void initComponents() { actionPerformed(java.awt.event.ActionEvent evt) {
btnBackActionPerformed(evt);
txtSHPhone = new javax.swing.JTextField(); }
jLabel6 = new javax.swing.JLabel(); });
jLabel1 = new javax.swing.JLabel();
txtSHName = new javax.swing.JTextField(); btnSave.setFont(new
txtSHAddress = new javax.swing.JTextField(); java.awt.Font("Tahoma", 1, 12));
btnBack = new javax.swing.JButton(); btnSave.setText("Save");
btnSave = new javax.swing.JButton(); btnSave.addActionListener(new
txtSHCity = new javax.swing.JTextField(); java.awt.event.ActionListener() {
btnClear = new javax.swing.JButton(); public void
jLabel3 = new javax.swing.JLabel(); actionPerformed(java.awt.event.ActionEvent evt) {
jLabel4 = new javax.swing.JLabel(); btnSaveActionPerformed(evt);
jLabel2 = new javax.swing.JLabel(); }
txtSHno = new javax.swing.JTextField(); });
jLabel5 = new javax.swing.JLabel();
txtSHCity.setFont(new
java.awt.Font("Tahoma", 1, 12));
setDefaultCloseOperation(javax.swing.WindowCon
stants.EXIT_ON_CLOSE); btnClear.setFont(new
setTitle("CARSHOWROOM Data Entry Form"); java.awt.Font("Tahoma", 1, 12));
setCursor(new btnClear.setText("Clear");
java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSO btnClear.addActionListener(new
R)); java.awt.event.ActionListener() {
public void
txtSHPhone.setFont(new actionPerformed(java.awt.event.ActionEvent evt) {
java.awt.Font("Tahoma", 1, 12)); btnClearActionPerformed(evt);
}
jLabel6.setFont(new java.awt.Font("Tahoma", });
1, 24));
jLabel6.setText("CARSHOWROOM Data Entry jLabel3.setFont(new java.awt.Font("Tahoma",
Form"); 1, 12));
jLabel3.setText("Address:");
jLabel1.setFont(new java.awt.Font("Tahoma",
1, 12)); jLabel4.setFont(new java.awt.Font("Tahoma",
jLabel1.setText("CARSHOWROOM's ID.:"); 1, 12));
jLabel4.setText("City:");
txtSHName.setFont(new
java.awt.Font("Tahoma", 1, 12));

CAR SHOWROOM SYSTEM | Created by : Student Name


jLabel2.setFont(new java.awt.Font("Tahoma", .addComponent(txtSHno,
1, 12)); javax.swing.GroupLayout.PREFERRED_SIZE, 62,
jLabel2.setText("Name:"); javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtSHName,
txtSHno.setFont(new javax.swing.GroupLayout.PREFERRED_SIZE, 228,
java.awt.Font("Tahoma", 1, 12)); javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtSHAddress,
jLabel5.setFont(new java.awt.Font("Tahoma", javax.swing.GroupLayout.PREFERRED_SIZE, 321,
1, 12)); javax.swing.GroupLayout.PREFERRED_SIZE)))
jLabel5.setText("Phone No.:");
.addGroup(layout.createSequentialGroup()
javax.swing.GroupLayout layout = new .addGap(42, 42, 42)
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); .addGroup(layout.createParallelGroup(javax.swing
layout.setHorizontalGroup( .GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4)
layout.createParallelGroup(javax.swing.GroupLayo .addComponent(jLabel5))
ut.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.Compo
nentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addComponent(txtSHPhone,
.addGap(86, 86, 86) javax.swing.GroupLayout.PREFERRED_SIZE, 126,
.addComponent(jLabel6)) javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtSHCity,
.addGroup(layout.createSequentialGroup() javax.swing.GroupLayout.PREFERRED_SIZE, 145,
.addGap(37, 37, 37) javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addContainerGap(40,
.addGroup(layout.createParallelGroup(javax.swing Short.MAX_VALUE))
.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TR
.addGroup(layout.createSequentialGroup() AILING, layout.createSequentialGroup()
.addContainerGap(78, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing .addComponent(btnSave)
.GroupLayout.Alignment.TRAILING) .addGap(43, 43, 43)
.addComponent(jLabel2) .addComponent(btnBack)
.addComponent(jLabel1) .addGap(56, 56, 56)
.addComponent(jLabel3)) .addComponent(btnClear)
.addGap(98, 98, 98))
.addPreferredGap(javax.swing.LayoutStyle.Compo );
nentPlacement.RELATED) layout.setVerticalGroup(

.addGroup(layout.createParallelGroup(javax.swing layout.createParallelGroup(javax.swing.GroupLayo
.GroupLayout.Alignment.LEADING) ut.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(jLabel6)

CAR SHOWROOM SYSTEM | Created by : Student Name


.addGap(39, 39, 39) javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing .addGap(43, 43, 43)
.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1) .addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup() .addComponent(btnClear,
.addComponent(txtSHno, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnBack,
javax.swing.GroupLayout.DEFAULT_SIZE, 35,
.addPreferredGap(javax.swing.LayoutStyle.Compo Short.MAX_VALUE)
nentPlacement.RELATED) .addComponent(btnSave,
javax.swing.GroupLayout.DEFAULT_SIZE, 35,
.addGroup(layout.createParallelGroup(javax.swing Short.MAX_VALUE))
.GroupLayout.Alignment.BASELINE) .addGap(24, 24, 24))
.addComponent(txtSHName, );
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, java.awt.Dimension screenSize =
javax.swing.GroupLayout.PREFERRED_SIZE) java.awt.Toolkit.getDefaultToolkit().getScreenSize(
.addComponent(jLabel2)) );
.addGap(16, 16, 16) setBounds((screenSize.width-526)/2,
(screenSize.height-388)/2, 526, 388);
}// </editor-fold>
.addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.BASELINE)
private void
.addComponent(txtSHAddress,
btnBackActionPerformed(java.awt.event.ActionEv
javax.swing.GroupLayout.PREFERRED_SIZE,
ent evt) {
javax.swing.GroupLayout.DEFAULT_SIZE,
this.setVisible(false);
javax.swing.GroupLayout.PREFERRED_SIZE)
new MainMenuUI().setVisible(true);
.addComponent(jLabel3))))
}
.addGap(18, 18, 18)

private void
.addGroup(layout.createParallelGroup(javax.swing
btnSaveActionPerformed(java.awt.event.ActionEv
.GroupLayout.Alignment.BASELINE)
ent evt) {
.addComponent(jLabel4)
try {
.addComponent(txtSHCity,
Class.forName("com.mysql.jdbc.Driver");
javax.swing.GroupLayout.PREFERRED_SIZE,
Connection con = (Connection)
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
DriverManager.getConnection("jdbc:mysql://local
host:3306/CARSHOWROOM","root","root");
.addPreferredGap(javax.swing.LayoutStyle.Compo
Statement stmt = null;
nentPlacement.UNRELATED)
ResultSet rs = null; // ResultSet for
CARSHOWROOM table.
.addGroup(layout.createParallelGroup(javax.swing String SQL = "SELECT * FROM
.GroupLayout.Alignment.BASELINE) CARSHOWROOM";
.addComponent(jLabel5) stmt = con.createStatement(); //
.addComponent(txtSHPhone, Connection string for ResultSet - rs.
javax.swing.GroupLayout.PREFERRED_SIZE,

CAR SHOWROOM SYSTEM | Created by : Student Name


rs = stmt.executeQuery(SQL); public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new
// Data transfer from JTextField control to Runnable() {
variables public void run() {
String shno = txtSHno.getText().trim(); new ShopINUI().setVisible(true);
String shname = txtSHName.getText(); }
String shadd = txtSHAddress.getText(); });
String shcity = txtSHCity.getText(); }
double shphone =
Double.parseDouble(txtSHPhone.getText()); // Variables declaration - do not modify
if (shno.length() <= 4) { private javax.swing.JButton btnBack;
String strSQL = "INSERT INTO private javax.swing.JButton btnClear;
CARSHOWROOM(Shopper_id, Name, Address, private javax.swing.JButton btnSave;
City, Phone) VALUES ('"+(shno)+"','"+(shname) private javax.swing.JLabel jLabel1;
+"','"+(shadd)+"','"+(shcity)+"',"+(shphone)+")"; private javax.swing.JLabel jLabel2;
JOptionPane.showMessageDialog(this, private javax.swing.JLabel jLabel3;
"Record successfully inserted"); private javax.swing.JLabel jLabel4;
int rowsEffected = private javax.swing.JLabel jLabel5;
stmt.executeUpdate(strSQL); private javax.swing.JLabel jLabel6;
System.out.println(rowsEffected + " rows private javax.swing.JTextField txtSHAddress;
effected"); private javax.swing.JTextField txtSHCity;
} private javax.swing.JTextField txtSHName;
else { private javax.swing.JTextField txtSHPhone;
JOptionPane.showMessageDialog(this, private javax.swing.JTextField txtSHno;
"Customer ID should not more than 4 character."); // End of variables declaration
}
con.close(); }
} catch (Exception e) {

JOptionPane.showMessageDialog(this,e.getMessa
*****************************************
ge());
e.printStackTrace(); CAR DETAILS
} *****************************************
}
import java.sql.*;
private void import javax.swing.JOptionPane;
btnClearActionPerformed(java.awt.event.ActionEv
ent evt) { public class CARSINUI extends javax.swing.JFrame {
// TODO add your handling code here:
txtSHno.setText(""); /** Creates new form CARSINUI */
txtSHName.setText(""); public CARSINUI() {
txtSHAddress.setText(""); initComponents();
txtSHCity.setText(""); }
txtSHPhone.setText("");
} /** This method is called from within the
constructor to
/** * initialize the form.
* @param args the command line arguments * WARNING: Do NOT modify this code. The
*/ content of this method is
* always regenerated by the Form Editor.

CAR SHOWROOM SYSTEM | Created by : Student Name


*/ btnClearActionPerformed(evt);
@SuppressWarnings("unchecked") }
// <editor-fold defaultstate="collapsed" });
desc="Generated Code">
private void initComponents() { txtCARSPrice.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel3 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel(); btnSave.setFont(new
txtCARSno = new javax.swing.JTextField(); java.awt.Font("Tahoma", 1, 12));
txtCARSName = new javax.swing.JTextField(); btnSave.setText("Save");
jLabel13 = new javax.swing.JLabel(); btnSave.addActionListener(new
btnClear = new javax.swing.JButton(); java.awt.event.ActionListener() {
txtCARSPrice = new javax.swing.JTextField(); public void
btnSave = new javax.swing.JButton(); actionPerformed(java.awt.event.ActionEvent evt) {
btnBack = new javax.swing.JButton(); btnSaveActionPerformed(evt);
txtCARSDesc = new javax.swing.JTextField(); }
jLabel15 = new javax.swing.JLabel(); });
jLabel14 = new javax.swing.JLabel();
btnBack.setFont(new
java.awt.Font("Tahoma", 1, 12));
setDefaultCloseOperation(javax.swing.WindowCon btnBack.setText("Back to Main");
stants.EXIT_ON_CLOSE); btnBack.addActionListener(new
setTitle("Sports CARS Entry Form"); java.awt.event.ActionListener() {
public void
jLabel3.setFont(new java.awt.Font("Tahoma", actionPerformed(java.awt.event.ActionEvent evt) {
1, 12)); btnBackActionPerformed(evt);
jLabel3.setText("CARS Id.:"); }
});
jLabel1.setFont(new java.awt.Font("Tahoma",
1, 24)); txtCARSDesc.setFont(new
jLabel1.setText("Sports CARS Entry Form"); java.awt.Font("Tahoma", 1, 12));

txtCARSno.setFont(new jLabel15.setFont(new
java.awt.Font("Tahoma", 1, 12)); java.awt.Font("Tahoma", 1, 12));
jLabel15.setText("Description:");
txtCARSName.setFont(new
java.awt.Font("Tahoma", 1, 12)); jLabel14.setFont(new
java.awt.Font("Tahoma", 1, 12));
jLabel13.setFont(new jLabel14.setText("CARS Name:");
java.awt.Font("Tahoma", 1, 12));
jLabel13.setText("Price:"); javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
btnClear.setFont(new getContentPane().setLayout(layout);
java.awt.Font("Tahoma", 1, 12)); layout.setHorizontalGroup(
btnClear.setText("Clear");
btnClear.addActionListener(new layout.createParallelGroup(javax.swing.GroupLayo
java.awt.event.ActionListener() { ut.Alignment.LEADING)
public void .addGroup(layout.createSequentialGroup()
actionPerformed(java.awt.event.ActionEvent evt) { .addGap(59, 59, 59)

CAR SHOWROOM SYSTEM | Created by : Student Name


.addContainerGap(109,
.addGroup(layout.createParallelGroup(javax.swing Short.MAX_VALUE)
.GroupLayout.Alignment.TRAILING) .addComponent(jLabel1)
.addComponent(jLabel15, .addGap(80, 80, 80))
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, .addGroup(javax.swing.GroupLayout.Alignment.TR
Short.MAX_VALUE) AILING, layout.createSequentialGroup()
.addComponent(jLabel14, .addContainerGap(78, Short.MAX_VALUE)
javax.swing.GroupLayout.Alignment.LEADING, .addComponent(btnSave)
javax.swing.GroupLayout.DEFAULT_SIZE, 73, .addGap(47, 47, 47)
Short.MAX_VALUE) .addComponent(btnBack)
.addGap(48, 48, 48)
.addGroup(layout.createSequentialGroup() .addComponent(btnClear)
.addGap(19, 19, 19) .addGap(64, 64, 64))
.addComponent(jLabel3, );
javax.swing.GroupLayout.DEFAULT_SIZE, layout.setVerticalGroup(
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)) layout.createParallelGroup(javax.swing.GroupLayo
ut.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(27, 27, 27) .addGap(27, 27, 27)
.addComponent(jLabel13, .addComponent(jLabel1)
javax.swing.GroupLayout.DEFAULT_SIZE, 46, .addGap(35, 35, 35)
Short.MAX_VALUE)))
.addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.BASELINE)
.addGroup(layout.createParallelGroup(javax.swing .addComponent(jLabel3,
.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.PREFERRED_SIZE, 29,
.addComponent(txtCARSDesc, javax.swing.GroupLayout.PREFERRED_SIZE)
javax.swing.GroupLayout.PREFERRED_SIZE, 204, .addComponent(txtCARSno))
javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18)

.addGroup(javax.swing.GroupLayout.Alignment.TR .addGroup(layout.createParallelGroup(javax.swing
AILING, layout.createSequentialGroup() .GroupLayout.Alignment.BASELINE)
.addComponent(txtCARSName, .addComponent(jLabel14)
javax.swing.GroupLayout.DEFAULT_SIZE, 123, .addComponent(txtCARSName))
Short.MAX_VALUE) .addGap(21, 21, 21)
.addGap(81, 81, 81))
.addComponent(txtCARSPrice, .addGroup(layout.createParallelGroup(javax.swing
javax.swing.GroupLayout.PREFERRED_SIZE, 92, .GroupLayout.Alignment.BASELINE)
javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel15)
.addComponent(txtCARSno, .addComponent(txtCARSDesc,
javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)) javax.swing.GroupLayout.DEFAULT_SIZE,
.addGap(118, 118, 118)) javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33)
.addGroup(javax.swing.GroupLayout.Alignment.TR
AILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.BASELINE)

CAR SHOWROOM SYSTEM | Created by : Student Name


.addComponent(jLabel13) String SQL = "SELECT * FROM CARS";
.addComponent(txtCARSPrice)) stmt = con.createStatement(); //
.addGap(47, 47, 47) Connection string for ResultSet - rs.
rs = stmt.executeQuery(SQL);
.addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING, false) // Data transfer from JTextField control to
.addComponent(btnClear, variables
javax.swing.GroupLayout.DEFAULT_SIZE, String CARSno = txtCARSno.getText();
javax.swing.GroupLayout.DEFAULT_SIZE, String CARSname = txtCARSName.getText();
Short.MAX_VALUE) String desc = txtCARSDesc.getText();
.addComponent(btnBack, double CARSprice =
javax.swing.GroupLayout.DEFAULT_SIZE, Double.parseDouble(txtCARSPrice.getText());
javax.swing.GroupLayout.DEFAULT_SIZE, String strSQL = "INSERT INTO CARS(CARS_Id,
Short.MAX_VALUE) CARS_Name, Description, Price) VALUES ('"+
.addComponent(btnSave, (CARSno)+"','"+(CARSname)+"','"+(desc)+"',"+
javax.swing.GroupLayout.PREFERRED_SIZE, 33, (CARSprice)+")";
javax.swing.GroupLayout.PREFERRED_SIZE)) JOptionPane.showMessageDialog(this,
.addGap(30, 30, 30)) "Record successfully inserted");
); int rowsEffected =
stmt.executeUpdate(strSQL);
java.awt.Dimension screenSize = System.out.println(rowsEffected + " rows
java.awt.Toolkit.getDefaultToolkit().getScreenSize( effected");
); con.close();
setBounds((screenSize.width-482)/2, } catch (Exception e) {
(screenSize.height-403)/2, 482, 403);
}// </editor-fold> JOptionPane.showMessageDialog(this,e.getMessa
ge());
private void e.printStackTrace();
btnClearActionPerformed(java.awt.event.ActionEv }
ent evt) { }
// TODO add your handling code here:
txtCARSno.setText(""); private void
txtCARSName.setText(""); btnBackActionPerformed(java.awt.event.ActionEv
txtCARSDesc.setText(""); ent evt) {
txtCARSPrice.setText(""); this.setVisible(false);
} new MainMenuUI().setVisible(true);
}
private void
btnSaveActionPerformed(java.awt.event.ActionEv /**
ent evt) { * @param args the command line arguments
try { */
Class.forName("com.mysql.jdbc.Driver"); public static void main(String args[]) {
Connection con = (Connection) java.awt.EventQueue.invokeLater(new
Runnable() {
DriverManager.getConnection("jdbc:mysql://local public void run() {
host:3306/CARSHOWROOM","root","root"); new CARSINUI().setVisible(true);
Statement stmt = null; }
ResultSet rs = null; // ResultSet for });
CARSHOWROOM table. }

CAR SHOWROOM SYSTEM | Created by : Student Name


jLabel9 = new javax.swing.JLabel();
// Variables declaration - do not modify txtOrdno = new javax.swing.JTextField();
private javax.swing.JButton btnBack; jLabel2 = new javax.swing.JLabel();
private javax.swing.JButton btnClear; jLabel3 = new javax.swing.JLabel();
private javax.swing.JButton btnSave; jLabel4 = new javax.swing.JLabel();
private javax.swing.JLabel jLabel1; btnClear = new javax.swing.JButton();
private javax.swing.JLabel jLabel13; txtOrdDate = new javax.swing.JTextField();
private javax.swing.JLabel jLabel14; txtOrdQty = new javax.swing.JTextField();
private javax.swing.JLabel jLabel15; btnBack = new javax.swing.JButton();
private javax.swing.JLabel jLabel3; jLabel10 = new javax.swing.JLabel();
private javax.swing.JTextField txtCARSDesc; btnSave = new javax.swing.JButton();
private javax.swing.JTextField txtCARSName; jLabel1 = new javax.swing.JLabel();
private javax.swing.JTextField txtCARSPrice; jLabel8 = new javax.swing.JLabel();
private javax.swing.JTextField txtCARSno; txtCARSPrice = new javax.swing.JTextField();
// End of variables declaration jLabel5 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
} txtSID = new javax.swing.JTextField();
txtSName = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
***************************************** txtCARSID = new javax.swing.JTextField();
ORDER DETAILS UI jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
*****************************************
jScrollPane2 = new javax.swing.JScrollPane();
jList2 = new javax.swing.JList();
import java.sql.*;
jPanel1 = new javax.swing.JPanel();
import javax.swing.DefaultListModel;
rdYes = new javax.swing.JRadioButton();
import javax.swing.JOptionPane;
rdNo = new javax.swing.JRadioButton();
jLabel11 = new javax.swing.JLabel();
public class OrderINUI extends javax.swing.JFrame
txtDisc = new javax.swing.JTextField();
{

/** Creates new form OrderINUI */


public OrderINUI() { setDefaultCloseOperation(javax.swing.WindowCon
initComponents(); stants.EXIT_ON_CLOSE);
} setTitle("Order Form");
addWindowFocusListener(new
/** This method is called from within the java.awt.event.WindowFocusListener() {
constructor to public void
* initialize the form. windowGainedFocus(java.awt.event.WindowEvent
* WARNING: Do NOT modify this code. The evt) {
content of this method is formWindowGainedFocus(evt);
* always regenerated by the Form Editor. }
*/ public void
@SuppressWarnings("unchecked") windowLostFocus(java.awt.event.WindowEvent
// <editor-fold defaultstate="collapsed" evt) {
desc="Generated Code"> }
private void initComponents() { });

buttonGroup1 = new jLabel9.setFont(new java.awt.Font("Tahoma",


javax.swing.ButtonGroup(); 1, 12));

CAR SHOWROOM SYSTEM | Created by : Student Name


jLabel9.setText("Order Quantity:"); btnBackActionPerformed(evt);
}
txtOrdno.setFont(new });
java.awt.Font("Tahoma", 1, 12));
jLabel10.setFont(new
jLabel2.setFont(new java.awt.Font("Tahoma", java.awt.Font("Tahoma", 1, 24)); // NOI18N
1, 12)); jLabel10.setText("Sports CARS Order Form");
jLabel2.setText("Date:");
btnSave.setFont(new
jLabel3.setFont(new java.awt.Font("Tahoma", java.awt.Font("Tahoma", 1, 12)); // NOI18N
1, 12)); // NOI18N btnSave.setText("Save Order");
jLabel3.setText("CARSHOWROOM Id and btnSave.addActionListener(new
Name"); java.awt.event.ActionListener() {
public void
jLabel4.setFont(new java.awt.Font("Tahoma", actionPerformed(java.awt.event.ActionEvent evt) {
1, 12)); btnSaveActionPerformed(evt);
jLabel4.setText("CARS Id and Name"); }
});
btnClear.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N jLabel1.setFont(new java.awt.Font("Tahoma",
btnClear.setText("Clear"); 1, 12));
btnClear.addActionListener(new jLabel1.setText("Order No.:");
java.awt.event.ActionListener() {
public void jLabel8.setFont(new java.awt.Font("Tahoma",
actionPerformed(java.awt.event.ActionEvent evt) { 1, 12)); // NOI18N
btnClearActionPerformed(evt); jLabel8.setText("CARS price:");
}
}); txtCARSPrice.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
txtOrdDate.setFont(new
java.awt.Font("Tahoma", 1, 12)); jLabel5.setText("ID.:");
txtOrdDate.addActionListener(new
java.awt.event.ActionListener() { jLabel7.setText("Name:");
public void
actionPerformed(java.awt.event.ActionEvent evt) { jLabel6.setText("CARS ID.:");
txtOrdDateActionPerformed(evt);
} jList1.setModel(new DefaultListModel());
}); jList1.addMouseListener(new
java.awt.event.MouseAdapter() {
txtOrdQty.setFont(new public void
java.awt.Font("Tahoma", 1, 12)); // NOI18N mouseClicked(java.awt.event.MouseEvent evt) {
jList1MouseClicked(evt);
btnBack.setFont(new }
java.awt.Font("Tahoma", 1, 12)); // NOI18N });
btnBack.setText("Back to Main"); jScrollPane1.setViewportView(jList1);
btnBack.addActionListener(new
java.awt.event.ActionListener() { jList2.setModel(new DefaultListModel());
public void jList2.addMouseListener(new
actionPerformed(java.awt.event.ActionEvent evt) { java.awt.event.MouseAdapter() {

CAR SHOWROOM SYSTEM | Created by : Student Name


public void
mouseClicked(java.awt.event.MouseEvent evt) { .addContainerGap(javax.swing.GroupLayout.DEFA
jList2MouseClicked(evt); ULT_SIZE, Short.MAX_VALUE))
} );
});
jScrollPane2.setViewportView(jList2); jLabel11.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel11.setText("Discount (%):");
jPanel1.setBorder(javax.swing.BorderFactory.creat
eTitledBorder("Discount")); txtDisc.setFont(new java.awt.Font("Tahoma",
1, 12)); // NOI18N
buttonGroup1.add(rdYes);
rdYes.setFont(new java.awt.Font("Tahoma", javax.swing.GroupLayout layout = new
1, 10)); javax.swing.GroupLayout(getContentPane());
rdYes.setText("Yes"); getContentPane().setLayout(layout);
layout.setHorizontalGroup(
buttonGroup1.add(rdNo);
rdNo.setFont(new java.awt.Font("Tahoma", 1, layout.createParallelGroup(javax.swing.GroupLayo
10)); ut.Alignment.LEADING)
rdNo.setText("No");
.addGroup(javax.swing.GroupLayout.Alignment.TR
javax.swing.GroupLayout jPanel1Layout = new AILING, layout.createSequentialGroup()
javax.swing.GroupLayout(jPanel1); .addGap(37, 37, 37)
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( .addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING)
jPanel1Layout.createParallelGroup(javax.swing.Gr
oupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TR
AILING,
.addGroup(jPanel1Layout.createSequentialGroup() layout.createParallelGroup(javax.swing.GroupLayo
.addContainerGap() ut.Alignment.LEADING)
.addComponent(rdYes)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.Compo
nentPlacement.RELATED, 26, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing
.addComponent(rdNo) .GroupLayout.Alignment.LEADING)
.addGap(20, 20, 20)) .addComponent(jLabel7)
); .addComponent(jLabel5))
jPanel1Layout.setVerticalGroup( .addGap(6, 6, 6)

jPanel1Layout.createParallelGroup(javax.swing.Gr .addGroup(layout.createParallelGroup(javax.swing
oupLayout.Alignment.LEADING) .GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(13, 13, 13)
.addGroup(jPanel1Layout.createParallelGroup(java .addComponent(txtSID,
x.swing.GroupLayout.Alignment.BASELINE) javax.swing.GroupLayout.PREFERRED_SIZE, 88,
.addComponent(rdYes) javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(rdNo))

CAR SHOWROOM SYSTEM | Created by : Student Name


.addComponent(jLabel4)
.addGroup(layout.createSequentialGroup() .addComponent(jScrollPane2,
.addGap(12, 12, 12) javax.swing.GroupLayout.PREFERRED_SIZE, 231,
.addComponent(txtSName, javax.swing.GroupLayout.PREFERRED_SIZE)
javax.swing.GroupLayout.PREFERRED_SIZE, 167,
javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup()
.addGap(25, 25, 25))
.addGroup(layout.createParallelGroup(javax.swing
.addGroup(javax.swing.GroupLayout.Alignment.TR .GroupLayout.Alignment.LEADING)
AILING, layout.createSequentialGroup() .addComponent(jLabel8)
.addComponent(jLabel9, .addComponent(jLabel6))
javax.swing.GroupLayout.DEFAULT_SIZE, 110, .addGap(39, 39, 39)
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing
.addPreferredGap(javax.swing.LayoutStyle.Compo .GroupLayout.Alignment.LEADING)
nentPlacement.RELATED) .addComponent(txtCARSID,
.addComponent(txtOrdQty, javax.swing.GroupLayout.PREFERRED_SIZE, 116,
javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtCARSPrice,
.addGap(337, 337, 337))) javax.swing.GroupLayout.PREFERRED_SIZE, 89,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup() .addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(layout.createParallelGroup(javax.swing javax.swing.GroupLayout.DEFAULT_SIZE,
.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.PREFERRED_SIZE)

.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(jLabel1) .addComponent(jLabel11)
.addGap(18, 18, 18)
.addPreferredGap(javax.swing.LayoutStyle.Compo .addComponent(txtDisc,
nentPlacement.UNRELATED) javax.swing.GroupLayout.PREFERRED_SIZE, 76,
.addComponent(txtOrdno, javax.swing.GroupLayout.PREFERRED_SIZE))))
javax.swing.GroupLayout.PREFERRED_SIZE, 62, .addComponent(jLabel3))
javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(27, 27, 27))
.addComponent(jScrollPane1, .addGroup(layout.createSequentialGroup()
javax.swing.GroupLayout.PREFERRED_SIZE, 203, .addGap(156, 156, 156)
javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel10)
.addGap(119, 119, 119) .addContainerGap(175,
Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing
.addGap(68, 68, 68)
.GroupLayout.Alignment.LEADING)
.addComponent(btnSave)
.addGap(30, 30, 30)
.addGroup(layout.createSequentialGroup()
.addComponent(btnBack,
.addComponent(jLabel2)
javax.swing.GroupLayout.PREFERRED_SIZE, 163,
.addGap(18, 18, 18)
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtOrdDate,
.addGap(26, 26, 26)
javax.swing.GroupLayout.PREFERRED_SIZE, 112,
javax.swing.GroupLayout.PREFERRED_SIZE))

CAR SHOWROOM SYSTEM | Created by : Student Name


.addComponent(btnClear,
javax.swing.GroupLayout.PREFERRED_SIZE, 87, .addPreferredGap(javax.swing.LayoutStyle.Compo
javax.swing.GroupLayout.PREFERRED_SIZE) nentPlacement.RELATED)
.addContainerGap(144,
Short.MAX_VALUE)) .addGroup(layout.createParallelGroup(javax.swing
); .GroupLayout.Alignment.LEADING)
layout.setVerticalGroup(
.addGroup(layout.createSequentialGroup()
layout.createParallelGroup(javax.swing.GroupLayo
ut.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing
.addGroup(layout.createSequentialGroup() .GroupLayout.Alignment.BASELINE)
.addGap(11, 11, 11) .addComponent(jLabel5)
.addComponent(jLabel10) .addComponent(txtSID,
.addGap(18, 18, 18) javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
.addGroup(layout.createParallelGroup(javax.swing javax.swing.GroupLayout.PREFERRED_SIZE))
.GroupLayout.Alignment.BASELINE) .addGap(18, 18, 18)
.addComponent(jLabel2)
.addComponent(jLabel1) .addGroup(layout.createParallelGroup(javax.swing
.addComponent(txtOrdno, .GroupLayout.Alignment.BASELINE)
javax.swing.GroupLayout.PREFERRED_SIZE, .addComponent(jLabel7)
javax.swing.GroupLayout.DEFAULT_SIZE, .addComponent(txtSName,
javax.swing.GroupLayout.PREFERRED_SIZE) javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(txtOrdDate, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
javax.swing.GroupLayout.DEFAULT_SIZE, .addGap(30, 30, 30)
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23)
.addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.BASELINE)
.addGroup(layout.createParallelGroup(javax.swing .addComponent(jLabel9)
.GroupLayout.Alignment.BASELINE) .addComponent(txtOrdQty,
.addComponent(jLabel3) javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(jLabel4)) javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.Compo
nentPlacement.RELATED) .addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing .addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING) .GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE,
.addGroup(layout.createSequentialGroup()
javax.swing.GroupLayout.DEFAULT_SIZE,
.addComponent(txtCARSID,
javax.swing.GroupLayout.PREFERRED_SIZE)
javax.swing.GroupLayout.PREFERRED_SIZE,
.addComponent(jScrollPane2,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
javax.swing.GroupLayout.DEFAULT_SIZE,
.addGap(18, 18, 18)
javax.swing.GroupLayout.PREFERRED_SIZE))

CAR SHOWROOM SYSTEM | Created by : Student Name


setBounds((screenSize.width-633)/2,
.addGroup(layout.createParallelGroup(javax.swing (screenSize.height-529)/2, 633, 529);
.GroupLayout.Alignment.BASELINE) }// </editor-fold>
.addComponent(jLabel8)
.addComponent(txtCARSPrice, private void
javax.swing.GroupLayout.PREFERRED_SIZE, btnClearActionPerformed(java.awt.event.ActionEv
javax.swing.GroupLayout.DEFAULT_SIZE, ent evt) {
javax.swing.GroupLayout.PREFERRED_SIZE))) // TODO add your handling code here:
.addComponent(jLabel6)) txtOrdno.setText("");
txtOrdDate.setText("");
.addPreferredGap(javax.swing.LayoutStyle.Compo txtSID.setText("");
nentPlacement.UNRELATED) txtCARSID.setText("");
.addComponent(jPanel1, txtSName.setText("");
javax.swing.GroupLayout.PREFERRED_SIZE, 43, txtCARSPrice.setText("");
javax.swing.GroupLayout.PREFERRED_SIZE))) txtOrdQty.setText("");
.addGap(18, 18, 18) }

.addGroup(layout.createParallelGroup(javax.swing private void


.GroupLayout.Alignment.BASELINE) btnBackActionPerformed(java.awt.event.ActionEv
.addComponent(jLabel11) ent evt) {
.addComponent(txtDisc, this.setVisible(false);
javax.swing.GroupLayout.PREFERRED_SIZE, new MainMenuUI().setVisible(true);
javax.swing.GroupLayout.DEFAULT_SIZE, }
javax.swing.GroupLayout.PREFERRED_SIZE))
private void
btnSaveActionPerformed(java.awt.event.ActionEv
.addPreferredGap(javax.swing.LayoutStyle.Compo
ent evt) {
nentPlacement.RELATED, 26, Short.MAX_VALUE)
try {
Class.forName("com.mysql.jdbc.Driver");
.addGroup(layout.createParallelGroup(javax.swing
Connection con = (Connection)
.GroupLayout.Alignment.LEADING, false)
.addComponent(btnClear,
DriverManager.getConnection("jdbc:mysql://local
javax.swing.GroupLayout.DEFAULT_SIZE,
host:3306/CARSHOWROOM","root","root");
javax.swing.GroupLayout.DEFAULT_SIZE,
Statement stmt = null;
Short.MAX_VALUE)
ResultSet rs = null; // ResultSet for
CARSHOWROOM table.
.addGroup(layout.createParallelGroup(javax.swing
String SQL = "SELECT * FROM orderCARS";
.GroupLayout.Alignment.BASELINE)
stmt = con.createStatement(); //
.addComponent(btnSave,
Connection string for ResultSet - rs.
javax.swing.GroupLayout.DEFAULT_SIZE, 35,
rs = stmt.executeQuery(SQL);
Short.MAX_VALUE)
.addComponent(btnBack,
float discP = 0; // Discount
javax.swing.GroupLayout.DEFAULT_SIZE, 34,
// Data transfer from JTextField control to
Short.MAX_VALUE)))
variables
.addGap(19, 19, 19))
String Ordno = txtOrdno.getText();
);
String OrdDate = txtOrdDate.getText();
String CARSID = txtCARSID.getText();
java.awt.Dimension screenSize =
String ShopID = txtSID.getText();
java.awt.Toolkit.getDefaultToolkit().getScreenSize(
String CARSPrice = txtCARSPrice.getText();
);

CAR SHOWROOM SYSTEM | Created by : Student Name


double iPrice = // Creating a ListModel object iModel to
Double.parseDouble(txtCARSPrice.getText()); perform DefaultComboBoxModel
String ordQty = txtOrdQty.getText(); // method operations for CARS list
DefaultListModel iModel = (DefaultListModel)
if (rdYes.isSelected()) { jList2.getModel();
discP = Float.parseFloat(txtDisc.getText());
} sModel.clear();
else { iModel.clear();
discP=0; try {
} Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
double amt =
(Integer.parseInt(txtOrdQty.getText()) * DriverManager.getConnection("jdbc:mysql://local
Double.parseDouble(txtCARSPrice.getText())) - host:3306/CARSHOWROOM","root","root");
(Integer.parseInt(txtOrdQty.getText()) * Statement stmt = null;
Double.parseDouble(txtCARSPrice.getText()))*(disc ResultSet rs = null;
P*0.01); ResultSet rs1 = null;
String strSQL = "INSERT INTO
orderCARS(orderno, OrderDate, CARS_Id, String SQL = "SELECT * FROM
Shopper_Id, Quantity, price, discount, Amount ) CARSHOWROOM";
VALUES ('"+(Ordno)+"','"+(OrdDate)+"','"+(CARSID) String SQL1 = "SELECT * FROM CARS";
+"','"+(ShopID)+"',"+(ordQty)+","+iPrice+","+ stmt = con.createStatement();
discP+","+(amt)+")";
JOptionPane.showMessageDialog(this, // Steps to extract CARSHOWROOMs id and
"Order successfully placed"); name
int rowsEffected = rs = stmt.executeQuery(SQL);
stmt.executeUpdate(strSQL); while (rs.next()) {
System.out.println(rowsEffected + " rows String sID = rs.getString("Shopper_id");
effected"); String Sname = rs.getString("Name");
con.close(); sModel.addElement(sID + " - " + Sname);
}
} catch (Exception e) { jList1.setModel(sModel);

JOptionPane.showMessageDialog(this,e.getMessa // Steps to extract CARS id and name


ge()); rs1 = stmt.executeQuery(SQL1);
e.printStackTrace(); while (rs1.next()) {
} String iID = rs1.getString("CARS_Id");
} String Iname =
rs1.getString("CARS_Name");
private void iModel.addElement(iID + " - " + Iname);
formWindowGainedFocus(java.awt.event.Window }
Event evt) { jList2.setModel(iModel);
// Creating a ListModel object sModel to con.close();
perform DefaultListModel
// method operations for CARSHOWROOM list } catch (Exception e) {
DefaultListModel sModel = (DefaultListModel)
jList1.getModel(); JOptionPane.showMessageDialog(this,e.getMessa
ge());
e.printStackTrace();

CAR SHOWROOM SYSTEM | Created by : Student Name


} con.close();
} catch (Exception e) {
}
JOptionPane.showMessageDialog(this,e.getMessa
private void ge());
jList1MouseClicked(java.awt.event.MouseEvent e.printStackTrace();
evt) { }
// Extracting supplier id and name into a
variable SidName }
String SidName = (String)
jList1.getSelectedValue(); private void
String Sid = SidName.substring(0, 3); txtOrdDateActionPerformed(java.awt.event.Action
String Sname= SidName.substring(6); Event evt) {
// TODO add your handling code here:
// Displays ID and name from ComboBox1 }
txtSID.setText(Sid);
txtSName.setText(Sname); /**
} * @param args the command line arguments
*/
private void public static void main(String args[]) {
jList2MouseClicked(java.awt.event.MouseEvent java.awt.EventQueue.invokeLater(new
evt) { Runnable() {
try { public void run() {
Class.forName("com.mysql.jdbc.Driver"); new OrderINUI().setVisible(true);
Connection con = (Connection) }
});
DriverManager.getConnection("jdbc:mysql://local }
host:3306/CARSHOWROOM","root","root");
Statement stmt = null; // Variables declaration - do not modify
ResultSet rs = null; private javax.swing.JButton btnBack;
private javax.swing.JButton btnClear;
// Extracting CARS id and CARS name into a private javax.swing.JButton btnSave;
variable CARSIDName private javax.swing.ButtonGroup buttonGroup1;
String CARSIDName = (String) private javax.swing.JLabel jLabel1;
jList2.getSelectedValue(); private javax.swing.JLabel jLabel10;
String CARSID = CARSIDName.substring(0, private javax.swing.JLabel jLabel11;
3); private javax.swing.JLabel jLabel2;
String Iame= CARSIDName.substring(7); private javax.swing.JLabel jLabel3;
txtCARSID.setText(CARSID); private javax.swing.JLabel jLabel4;
String SQL = "SELECT * FROM CARS where private javax.swing.JLabel jLabel5;
CARS_Id = '"+(CARSID)+"'"; private javax.swing.JLabel jLabel6;
stmt = con.createStatement(); private javax.swing.JLabel jLabel7;
rs = stmt.executeQuery(SQL); private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
while (rs.next()) { private javax.swing.JList jList1;
double iprice = rs.getDouble("Price"); private javax.swing.JList jList2;
private javax.swing.JPanel jPanel1;
txtCARSPrice.setText(Double.toString(iprice)); private javax.swing.JScrollPane jScrollPane1;
} private javax.swing.JScrollPane jScrollPane2;

CAR SHOWROOM SYSTEM | Created by : Student Name


private javax.swing.JRadioButton rdNo;
private javax.swing.JRadioButton rdYes;
private javax.swing.JTextField txtDisc; setDefaultCloseOperation(javax.swing.WindowCon
private javax.swing.JTextField txtCARSID; stants.EXIT_ON_CLOSE);
private javax.swing.JTextField txtCARSPrice; setTitle("Customers list");
private javax.swing.JTextField txtOrdDate;
private javax.swing.JTextField txtOrdQty; jButton1.setFont(new
private javax.swing.JTextField txtOrdno; java.awt.Font("Tahoma", 1, 12)); // NOI18N
private javax.swing.JTextField txtSID; jButton1.setText("Display/Query");
private javax.swing.JTextField txtSName; jButton1.addActionListener(new
// End of variables declaration java.awt.event.ActionListener() {
public void
} actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
*****************************************
CUSTOMER LIST jButton2.setFont(new
***************************************** java.awt.Font("Tahoma", 1, 12)); // NOI18N
jButton2.setText("Back to Menu");
import java.sql.*; jButton2.addActionListener(new
import javax.swing.table.*; java.awt.event.ActionListener() {
import javax.swing.JOptionPane; public void
actionPerformed(java.awt.event.ActionEvent evt) {
public class CustListUI extends javax.swing.JFrame jButton2ActionPerformed(evt);
{ }
});
/** Creates new form CustListUI */
public CustListUI() { jTable1.setModel(new
initComponents(); javax.swing.table.DefaultTableModel(
} new Object [][] {
{null, null, null, null, null},
/** This method is called from within the {null, null, null, null, null},
constructor to {null, null, null, null, null},
* initialize the form. {null, null, null, null, null},
* WARNING: Do NOT modify this code. The {null, null, null, null, null},
content of this method is {null, null, null, null, null},
* always regenerated by the Form Editor. {null, null, null, null, null},
*/ {null, null, null, null, null},
@SuppressWarnings("unchecked") {null, null, null, null, null},
// <editor-fold defaultstate="collapsed" {null, null, null, null, null}
desc="Generated Code"> },
private void initComponents() { new String [] {
"Customer ID", "Name", "Address", "City",
jButton1 = new javax.swing.JButton(); "Phone"
jButton2 = new javax.swing.JButton(); }
jScrollPane1 = new javax.swing.JScrollPane(); ));
jTable1 = new javax.swing.JTable(); jScrollPane1.setViewportView(jTable1);
jLabel1 = new javax.swing.JLabel();

CAR SHOWROOM SYSTEM | Created by : Student Name


jLabel1.setFont(new java.awt.Font("Tahoma",
1, 24)); // NOI18N .addGroup(layout.createParallelGroup(javax.swing
jLabel1.setText("Customer List"); .GroupLayout.Alignment.LEADING, false)
.addComponent(jButton2,
javax.swing.GroupLayout layout = new javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout.DEFAULT_SIZE,
getContentPane().setLayout(layout); Short.MAX_VALUE)
layout.setHorizontalGroup( .addComponent(jButton1,
javax.swing.GroupLayout.DEFAULT_SIZE, 32,
layout.createParallelGroup(javax.swing.GroupLayo Short.MAX_VALUE))
ut.Alignment.LEADING) .addContainerGap(13,
.addGroup(layout.createSequentialGroup() Short.MAX_VALUE))
);
.addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING) java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScreenSize(
.addGroup(layout.createSequentialGroup() );
.addGap(203, 203, 203) setBounds((screenSize.width-623)/2,
.addComponent(jLabel1)) (screenSize.height-357)/2, 623, 357);
}// </editor-fold>
.addGroup(layout.createSequentialGroup()
.addContainerGap() private void
jButton1ActionPerformed(java.awt.event.ActionEv
ent evt) {
.addGroup(layout.createParallelGroup(javax.swing
// Before writting the followng line, you
.GroupLayout.Alignment.LEADING)
should import the line:
.addComponent(jScrollPane1,
// import javax.swing.table.*; at the top of
javax.swing.GroupLayout.DEFAULT_SIZE, 587,
your application
Short.MAX_VALUE)

DefaultTableModel model =
.addGroup(layout.createSequentialGroup()
(DefaultTableModel) jTable1.getModel();
.addGap(161, 161, 161)
// Clear the existing table
.addComponent(jButton1)
int rows = model.getRowCount();
.addGap(39, 39, 39)
if (rows > 0) {
.addComponent(jButton2)))))
for (int i = 0; i < rows; i++) {
.addContainerGap())
model.removeRow(0);
);
}
layout.setVerticalGroup(
}
// SQL Query
layout.createParallelGroup(javax.swing.GroupLayo String query = "SELECT * FROM
ut.Alignment.LEADING) CARSHOWROOM";
.addGroup(layout.createSequentialGroup() try {
.addGap(20, 20, 20) // Connect to MySQL database
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(jScrollPane1,
Class.forName("com.mysql.jdbc.Driver").newInsta
javax.swing.GroupLayout.PREFERRED_SIZE, 172,
nce();
javax.swing.GroupLayout.PREFERRED_SIZE)
Connection con = (Connection)
.addGap(35, 35, 35)
DriverManager.getConnection("jdbc:mysql://local

CAR SHOWROOM SYSTEM | Created by : Student Name


host:3306/CARSHOWROOM","root","root");
// Create SQL statement and execute query. private javax.swing.JScrollPane jScrollPane1;
Statement stmt = con.createStatement(); private javax.swing.JTable jTable1;
// End of variables declaration
ResultSet rs = stmt.executeQuery(query);
}
// Iterate through the result and display on
screen
while (rs.next()) { *****************************************
String Sid = rs.getString("Shopper_id"); CAR LIST
String SName = rs.getString("Name");
****************************************
String SAddress = rs.getString("Address");
String SCity = rs.getString("City"); import java;
String SPhone = rs.getString("Phone"); import javax.swing.table.*;
System.out.println(Sid + "|" + SName + import java.sql.*;
"|" + SAddress + "|" + SCity + "|" + SPhone); import javax.swing.JOptionPane;
model.addRow(new Object[] {Sid, SName,
SAddress, SCity, SPhone}); public class CARSListUI extends javax.swing.JFrame
} {
} catch (Exception e) {
JOptionPane.showMessageDialog(this, /** Creates new form CARSListUI */
e.getMessage()); public CARSListUI() {
} initComponents();
} }

private void /** This method is called from within the


jButton2ActionPerformed(java.awt.event.ActionEv constructor to
ent evt) { * initialize the form.
this.setVisible(false); * WARNING: Do NOT modify this code. The
new MainMenuUI().setVisible(true); content of this method is
} * always regenerated by the Form Editor.
*/
/** @SuppressWarnings("unchecked")
* @param args the command line arguments // <editor-fold defaultstate="collapsed"
*/ desc="Generated Code">
public static void main(String args[]) { private void initComponents() {
java.awt.EventQueue.invokeLater(new
Runnable() { jButton2 = new javax.swing.JButton();
public void run() { jButton1 = new javax.swing.JButton();
new CustListUI().setVisible(true); jScrollPane1 = new javax.swing.JScrollPane();
} jTable1 = new javax.swing.JTable();
}); jLabel1 = new javax.swing.JLabel();
}

// Variables declaration - do not modify setDefaultCloseOperation(javax.swing.WindowCon


private javax.swing.JButton jButton1; stants.EXIT_ON_CLOSE);
setTitle("List of CARSs in shop");
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;

CAR SHOWROOM SYSTEM | Created by : Student Name


jButton2.setFont(new layout.setHorizontalGroup(
java.awt.Font("Tahoma", 1, 11)); // NOI18N
jButton2.setText("Back to Menu"); layout.createParallelGroup(javax.swing.GroupLayo
jButton2.addActionListener(new ut.Alignment.LEADING)
java.awt.event.ActionListener() { .addGroup(layout.createSequentialGroup()
public void
actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(layout.createParallelGroup(javax.swing
jButton2ActionPerformed(evt); .GroupLayout.Alignment.LEADING)
}
}); .addGroup(layout.createSequentialGroup()
.addGap(219, 219, 219)
jButton1.setFont(new .addComponent(jLabel1))
java.awt.Font("Tahoma", 1, 12)); // NOI18N
jButton1.setText("Display/Query");
.addGroup(javax.swing.GroupLayout.Alignment.TR
jButton1.addActionListener(new
AILING, layout.createSequentialGroup()
java.awt.event.ActionListener() {
.addContainerGap()
public void
actionPerformed(java.awt.event.ActionEvent evt) {
.addGroup(layout.createParallelGroup(javax.swing
jButton1ActionPerformed(evt);
.GroupLayout.Alignment.LEADING)
}
.addComponent(jScrollPane1,
});
javax.swing.GroupLayout.DEFAULT_SIZE, 564,
Short.MAX_VALUE)
jTable1.setModel(new
javax.swing.table.DefaultTableModel(
new Object [][] { .addGroup(layout.createSequentialGroup()
{null, null, null, null}, .addGap(137, 137, 137)
{null, null, null, null}, .addComponent(jButton1)
{null, null, null, null}, .addGap(62, 62, 62)
{null, null, null, null}, .addComponent(jButton2)))))
{null, null, null, null}, .addContainerGap())
{null, null, null, null}, );
{null, null, null, null}, layout.setVerticalGroup(
{null, null, null, null},
{null, null, null, null}, layout.createParallelGroup(javax.swing.GroupLayo
{null, null, null, null} ut.Alignment.LEADING)
}, .addGroup(layout.createSequentialGroup()
new String [] { .addContainerGap()
"CARS ID", "Name", "Description", "Price" .addComponent(jLabel1)
} .addGap(27, 27, 27)
)); .addComponent(jScrollPane1,
jScrollPane1.setViewportView(jTable1); javax.swing.GroupLayout.PREFERRED_SIZE, 172,
javax.swing.GroupLayout.PREFERRED_SIZE)
jLabel1.setFont(new java.awt.Font("Tahoma", .addGap(35, 35, 35)
1, 24)); // NOI18N
jLabel1.setText("CARS List"); .addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING, false)
javax.swing.GroupLayout layout = new .addComponent(jButton2,
javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout.DEFAULT_SIZE,
getContentPane().setLayout(layout); javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)

CAR SHOWROOM SYSTEM | Created by : Student Name


.addComponent(jButton1, ResultSet rs = stmt.executeQuery(query);
javax.swing.GroupLayout.DEFAULT_SIZE, 32,
Short.MAX_VALUE)) // Iterate through the result and display on
.addContainerGap(22, screen
Short.MAX_VALUE)) while (rs.next()) {
); String ITid = rs.getString("CARS_id");
String IName =
java.awt.Dimension screenSize = rs.getString("CARS_Name");
java.awt.Toolkit.getDefaultToolkit().getScreenSize( String IDesc = rs.getString("Description");
); String IPrice = rs.getString("Price");
setBounds((screenSize.width-600)/2, System.out.println(ITid + "|" + IName +
(screenSize.height-366)/2, 600, 366); "|" + IDesc + "|" + IPrice);
}// </editor-fold> model.addRow(new Object[] {ITid, IName,
IDesc, IPrice});
private void }
jButton2ActionPerformed(java.awt.event.ActionEv } catch (Exception e) {
ent evt) { JOptionPane.showMessageDialog(this,
this.setVisible(false); e.getMessage());
new MainMenuUI().setVisible(true); }
} }

private void /**


jButton1ActionPerformed(java.awt.event.ActionEv * @param args the command line arguments
ent evt) { */
// Before writting the followng line, you public static void main(String args[]) {
should import the line: java.awt.EventQueue.invokeLater(new
// import javax.swing.table.*; at the top of Runnable() {
your application public void run() {
DefaultTableModel model = new CARSListUI().setVisible(true);
(DefaultTableModel) jTable1.getModel(); }
// Clear the existing table });
int rows = model.getRowCount(); }
if (rows > 0) {
for (int i = 0; i < rows; i++) { // Variables declaration - do not modify
model.removeRow(0); private javax.swing.JButton jButton1;
} private javax.swing.JButton jButton2;
} private javax.swing.JLabel jLabel1;
// SQL Query private javax.swing.JScrollPane jScrollPane1;
String query = "SELECT * FROM CARS"; private javax.swing.JTable jTable1;
try { // End of variables declaration
// Connect to MySQL database
}
Class.forName("com.mysql.jdbc.Driver").newInsta
nce();
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://local
host:3306/CARSHOWROOM","root","root");
// Create SQL statement and execute query.
Statement stmt = con.createStatement();

CAR SHOWROOM SYSTEM | Created by : Student Name


*****************************************
ORDER LIST setDefaultCloseOperation(javax.swing.WindowCon
stants.EXIT_ON_CLOSE);
*****************************************
setTitle("List of orders");
import java;
import javax.swing.table.*;

import java.sql.*; jButton2.setFont(new


java.awt.Font("Tahoma", 1, 11)); // NOI18N
import javax.swing.JOptionPane;
jButton2.setText("Back to Menu");
public class OrdListUI extends javax.swing.JFrame {
jButton2.addActionListener(new
java.awt.event.ActionListener() {

/** Creates new form OrdListUI */ public void


actionPerformed(java.awt.event.ActionEvent evt) {
public OrdListUI() {
jButton2ActionPerformed(evt);
initComponents();
}
}
});

/** This method is called from within the


constructor to jButton1.setFont(new
java.awt.Font("Tahoma", 1, 12)); // NOI18N
* initialize the form.
jButton1.setText("Display/Query");
* WARNING: Do NOT modify this code. The
content of this method is jButton1.addActionListener(new
java.awt.event.ActionListener() {
* always regenerated by the Form Editor.
public void
*/ actionPerformed(java.awt.event.ActionEvent evt) {
@SuppressWarnings("unchecked") jButton1ActionPerformed(evt);
// <editor-fold defaultstate="collapsed" }
desc="Generated Code">
});
private void initComponents() {

jTable1.setModel(new
jButton2 = new javax.swing.JButton(); javax.swing.table.DefaultTableModel(
jButton1 = new javax.swing.JButton(); new Object [][] {
jScrollPane1 = new javax.swing.JScrollPane(); {null, null, null, null, null, null, null, null},
jTable1 = new javax.swing.JTable(); {null, null, null, null, null, null, null, null},
jLabel1 = new javax.swing.JLabel(); {null, null, null, null, null, null, null, null},

{null, null, null, null, null, null, null, null},

{null, null, null, null, null, null, null, null},

CAR SHOWROOM SYSTEM | Created by : Student Name


{null, null, null, null, null, null, null, null}, .addComponent(jButton1)

{null, null, null, null, null, null, null, null}, .addGap(70, 70, 70)

{null, null, null, null, null, null, null, null}, .addComponent(jButton2))

{null, null, null, null, null, null, null, null},


.addGroup(javax.swing.GroupLayout.Alignment.TR
{null, null, null, null, null, null, null, null} AILING, layout.createSequentialGroup()
}, .addComponent(jLabel1)
new String [] { .addGap(234, 234, 234)))
"Order No.", "Order Date", "CARS Id", .addContainerGap())
"Customer Id", "Quantity", "Price", "Discount(%)",
"Amount" );

}
layout.createParallelGroup(javax.swing.GroupLayo
));
ut.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 .addGap(35, 35, 35)

jLabel1.setText("Order List");
.addGroup(layout.createParallelGroup(javax.swing
.GroupLayout.Alignment.LEADING)

javax.swing.GroupLayout layout = new .addComponent(jButton1,


javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout.PREFERRED_SIZE, 37,
javax.swing.GroupLayout.PREFERRED_SIZE)
getContentPane().setLayout(layout);
.addComponent(jButton2,
layout.setHorizontalGroup( javax.swing.GroupLayout.DEFAULT_SIZE, 37,
Short.MAX_VALUE))

layout.createParallelGroup(javax.swing.GroupLayo .addGap(27, 27, 27))


ut.Alignment.LEADING)
);
.addGroup(layout.createSequentialGroup()

.addContainerGap()
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScreenSize(
.addGroup(layout.createParallelGroup(javax.swing );
.GroupLayout.Alignment.LEADING)
setBounds((screenSize.width-624)/2,
.addComponent(jScrollPane1, (screenSize.height-393)/2, 624, 393);
javax.swing.GroupLayout.DEFAULT_SIZE, 588,
Short.MAX_VALUE) }// </editor-fold>

.addGroup(layout.createSequentialGroup() private void


jButton2ActionPerformed(java.awt.event.ActionEv
.addGap(161, 161, 161)
ent evt) {

CAR SHOWROOM SYSTEM | Created by : Student Name


this.setVisible(false); while (rs.next()) {

new MainMenuUI().setVisible(true); String Ordno = rs.getString("Orderno");

} String Ordd = rs.getString("OrderDate");

String OCARSid = rs.getString("CARS_Id");

private void String OSid = rs.getString("Shopper_Id");


jButton1ActionPerformed(java.awt.event.ActionEv
ent evt) { String OQty = rs.getString("Quantity");

// Before writting the followng line, you String IPrice = rs.getString("price");


should import the line:
String Disc = rs.getString("discount");
// import javax.swing.table.*; at the top of
your application String OAmount = rs.getString("Amount");

DefaultTableModel model = System.out.println(Ordno + "|" + Ordd +


(DefaultTableModel) jTable1.getModel(); "|" +OCARSid + "|" + OSid + "|" + OQty + "|" +
IPrice + "|" + Disc + "|" + OAmount);
// Clear the existing table
model.addRow(new Object[] {Ordno,
int rows = model.getRowCount(); Ordd, OCARSid, OSid, OQty, IPrice, Disc,
OAmount});
if (rows > 0) {
}
for (int i = 0; i < rows; i++) {
} catch (Exception e) {
model.removeRow(0);
JOptionPane.showMessageDialog(this,
} e.getMessage());

} public static void main(String args[]) {

// SQL Query java.awt.EventQueue.invokeLater(new


Runnable() {
String query = "SELECT * FROM orderCARS";
public void run() {
try {
new OrdListUI().setVisible(true);
// Connect to MySQL database
}

Class.forName("com.mysql.jdbc.Driver").newInsta });
nce();
}
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://local private javax.swing.JLabel jLabel1;
host:3306/CARSHOWROOM","root","root");
private javax.swing.JScrollPane jScrollPane1;
// Create SQL statement and execute query.
private javax.swing.JTable jTable1;
Statement stmt = con.createStatement();
// End of variables declaration
ResultSet rs = stmt.executeQuery(query);

}
// Iterate through the result and display on
screen

CAR SHOWROOM SYSTEM | Created by : Student Name


BIBILOGRAPHY

Book : INFORMATICS PRACTICES


Writtten by:

1. Sumita Arora 12th IP

2. Oxford 12th IP

CAR SHOWROOM SYSTEM | Created by : Student Name


TEACHER REMARKS

CAR SHOWROOM SYSTEM | Created by : Student Name

You might also like