You are on page 1of 51

2/8/2019

INFORMATICS
PRACTICES

Airline Reservation System

Kendriya Vidyalaya
INS Mandovi
INDEX
• About the project ………………………………………..….. 2
• Acknowledgements ……………………………………..….. 3
• Certificate………………………………………………………… 4
• System requirements……………………………………..… 5
• Introduction………………………………………………..…… 6
• Flowchart…………………………………………….…….……. 8
• Design and coding……….…………………………………...13
• Homepage form……………….……………………………...14
• Login form…………………..……………………………..…...16
• Signup form………………………………………………….....18
• Booking flights form…………………………………………22
• Flight details form…………………………………………….24
• Seat booking form……..…………………………….……...28
• Payment form………………..…………………………...…..34
• Reservation form……………………………………………..36
• Check Flight Status……………………………………….….39
• Admin login form……………………………………..….….41
• Records form…………..…………………………..…….……43
• Alter Records form…………………………………..………44
• Conclusion……………………………………………..……….48
• Bibliography………………..………………………..……….49
Page 1 of 50
ABOUT THE PROJECT
The GUI application is based upon the simple
and basic idea of how online flight ticket
booking system works . The main objective of this
project is to reduce the time wasted in standing
in lines and booking tickets as well as reduce
the chances that are made in the manual works
done at the booking ports , but this project is an
initiative to ignore any chance of error as well
as save time and promote the simplicity of
online works today. It is a lot much time saving
as such systems responds to users quick enough
making things much easier. This is a user
friendly GUI and can be used to book a flight
ranging any distance in less than a while. The
system keeps the check on user inputs and every
other detail he/she gives thereby suppressing
chances of irrelevancy as well.

The project has been coded and designed in


NetBeans™ IDE 8.0.2 and many photo editors
have also been used such as Adobe Photoshop CS-
6 and many more suiting the situation and
backgrounds have been downloaded from www.
Shutterstock.com

Page 2 of 50
ACKNOWLEDGEMENT
I would like to express my greatest gratitude to
the people who have helped and supported me
throughout my project . I am grateful to my teacher
, Mr Deep Prakash Chaudhary, for his continuous
support for the project , from initial advice and
contacts in the early stages conceptual inception
and through ongoing advice and encouragement
to this day.

I wish to thank my parents for their individual


support and interest, who inspired me and
encouraged me to go my own way , without whom
I would not have been able to complete the
project.

At last but not the least , a special thanks of


mine goes to my friends who helped me in
completing the project through their thoughts
and made this project easy and accurate. I
would also like to thanks my friends who
appreciated me for my work and motivated me
and finally to God who made all things
possible.

Page 3 of 50
CERTIFICATE

This is to certify that Archit Pareek and Utkarsh


Tiwari of Class XII B of Kendriya Vidyalaya I.N.S
Mandovi School has completed his project file
under my supervision. He has taken proper care
and shown utmost sincerity in completion of this
project. I certify that this project is up to my
expectation and as per the guidelines issued by
CBSE.

TEACHER’S SIGNATURE PRINICPAL

Page 4 of 50
SYSTEM REQUIREMENTS
Minimum Hardware Requirements

Microsoft Windows XP/Vista Sp1/ Windows 7 Professional:


Processor: 600MHZ Intel Pentium IV or equivalent
Memory: 512 MB
Disk Space : 300 MB of free

Ubuntu 9.10:
Processor: 600 MHZ Intel Pentium IV or equivalent
Memory : 512 MB
Disk Space: 250MB of free disk space

Solaris OS v ersion 11 Express (x86/x64 Platform Edition)


Processor: AMD Opteron 1200 series 1.8 GHZ
Memory : 512 MB
Disk Space: 275 MB

Macintosh OS X 10.6 Intel:


Processor : Dual-Core Intel(32 or 64-bit)
Memory : 1 GB

Page 5 of 50
INTRODUCTION
Many people are travelling with airplanes, either on
means of daily to and from work or on some vacation ,
to mention a few. To much reservations for such travels,
airline companies hold for a user to book a travel
himself. A functionality which these websites lacks out
on, is the option for the user to set up specific
requirements for the travel such as , minimal travel
time and distance .

Based on the methods provided by Object Oriented


Programming the report will present a result to such
problems. Another aspect of the will be to have an easy to use
Interface which makes it easier for less computer experienced
users to use as well. The functionalities given to users can be
judged through this Figure :

Page 6 of 50
Whereas the Administrator has functionalities as shown:

To form the overview of what the system should interact


with, a rich picture has been made and described.

Page 7 of 50
FLOWCHARTS

Page 8 of 50
0

START

Accept
YES choice

If choice No If choice No If choice


= login = signup =admin

OPEN OPEN OPEN


USER LOGIN Signup ADMIN LOGIN
FORM form FORM

No No No

Accept Accept Accept


login Information login
details details

(If correct) (If correct)

A Stores Information OPEN


Validation
form

Store Data

Page 9 of 50
A

OPEN BOOKING
SYSTEM FORM

ACCEPT
FLIGHT
DETAILS

If choice = If choice =
Domestic International

VIEW FLIGHTS DETAILS VIEW FLIGHTS DETAILS


ACCORDINGLY ACCORDINGLY
DESIRED DESIRED

ACCEPT ACCEPT
FLIGHT FLIGHT

OPEN SEAT SELECTION


FORM

B
Page 10 of 50
C

ACCEPT
CHOICE

If choice = If choice If choice =


VisaCard = Paypal MasterCard

OPEN FINAL DETAILS

RESERVE FLIGHT

STOP

Page 11 of 50
C

ACCEPT
CHOICE

If choice = If choice If choice =


VisaCard = Paypal MasterCard

OPEN FINAL DETAILS

RESERVE FLIGHT

STOP

Page 12 of 50
DESIGN AND CODING

There are 11 forms in total :-

1. Home Page Form

2. Login Form

3. Signup Form

4. Book Flights Form

5. Flights Details Form

6. Seat Booking Form

7. Payment Form

8. Reservation Form

9. Check Flight Status

10. Admin Login Form

11. Records Form

12. Alter Records Form

Page 13 of 50
Home Page

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


new SignUp().setVisible(true);
dispose();

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

new Login().setVisible(true);
dispose();
}

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {


new Admin().setVisible(true);
dispose();
}

FORM SUMMARY :-

The above form is the main window of the application


which provides every user with three choices.

Page 14 of 50
The person can login into the system by

registering himself by clicking “SIGNUP” and then LOGIN

anytime from anywhere he/she desires.

NOTE :- The idea of “ADMIN” is to refer to the regular validation


of the flights and other required information that needs to be
kept fresh that can be done by administrators . It is not meant
for normal users.

Page 15 of 50
Login Form

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


new HomePage().setVisible(true);
dispose();
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


int c=0;
String sql="Select * from airline_users";
try{
class.forName("com.mysql.cj.jdbc.Driver");
Connection con= (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");
Statement stmt = (Statement) con.createStatement();
Statement stmt1 = (Statement) con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
String user=jTextField1.getText();
String pwd= new String (jPasswordField1.getPassword());
while(rs.next()) {
String uname=rs.getString("username");
String password=rs.getString("password");
if ((user.equals(uname)) && (pwd.equals(password)))
{ c=1;
ResultSet rs1 = stmt1.executeQuery("select * from airline_users where username='"+user+"' ");
while(rs1.next()){

Page 16 of 50
String name;
name = rs1.getString("fullname");
String mob;
mob = rs1.getString("mobile");
}
new BookFlights().setVisible(true);
dispose();
}
}
if(c==0)
{JOptionPane.showMessageDialog(null,"Username or Password is Incorrrect");}
}
catch (HeadlessException | ClassNotFoundException | SQLException e){
JOptionPane.showMessageDialog(this, e.getMessage());
}
}

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {


System.exit(0);
}

FORM SUMMARY :-

This is the window that opens when the user clicks on


“login” button . the user is prompted to enter his/her

„username‟ and „password‟ which on being correct

prompts the user to further window which is the

Booking Form.

Page 17 of 50
SignUp Form

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

new HomePage().setVisible(true);

dispose();

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

String name=jTextField1.getText();

String email=jTextField2.getText();

String mobile=jTextField3.getText();

String date=jTextField6.getText()+"/"+jTextField5.getText()+"/"+jTextField4.getText();

String username=jTextField7.getText();

char[] pass=jPasswordField1.getPassword();

Page 18 of 50
String password=new String(pass);

int d = Integer.parseInt(jTextField4.getText());

int m = Integer.parseInt(jTextField5.getText());

int y = Integer.parseInt(jTextField6.getText());

int c = 0 ;

if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)

if(d<=0||d>31)

c=1;

else if(m==4||m==6||m==9||m==11)

if(d<=0||d>30)

c=1;

else if(m==2)

if(y%4==0 && d<=0||d>29)

c=1;

else if(y%4!=0 && d<=0||d>28)

c=1;

if(Integer.toString(y).length()!=4)

{ c=1;}

if(m>12)

{c=1;}

if (c==1)

JOptionPane.showMessageDialog(this,"INVALID DATE");

else

Page 19 of 50
if(name.isEmpty()||email.isEmpty()||mobile.isEmpty()||username.isEmpty())

JOptionPane.showMessageDialog(this,"Information incomplete");

else if(mobile.length()!=10)

JOptionPane.showMessageDialog(this,"wrong mobile no.");

else if(jRadioButton1.isSelected()!= true)

JOptionPane.showMessageDialog(this,"Please agree to our terms and conditions ");

else

try {

Class.forName("java.sql.DriverManager");

} catch (ClassNotFoundException ex) {

Logger.getLogger(SignUp.class.getName()).log(Level.SEVERE, null, ex);

Connection con = null;

try {

con = (Connection)

DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");

} catch (SQLException ex) {

Logger.getLogger(SignUp.class.getName()).log(Level.SEVERE, null, ex);

Statement stmt = null;

try {

stmt = (Statement) con.createStatement();

} catch (SQLException ex) {

Page 20 of 50
Logger.getLogger(SignUp.class.getName()).log(Level.SEVERE, null, ex);

try {

Statement st = (Statement) con.createStatement();

} catch (SQLException ex) {

Logger.getLogger(SignUp.class.getName()).log(Level.SEVERE, null, ex);

String query="INSERT INTO airline_users


VALUES('"+name+"','"+email+"','"+mobile+"','"+date+"','"+username+"','"+password+"');";

try {

stmt.executeUpdate(query);

} catch (SQLException ex) {

Logger.getLogger(SignUp.class.getName()).log(Level.SEVERE, null, ex);

private void QuitActionPerformed(java.awt.event.ActionEvent evt) {

System.exit(0);

Form Summary:-
This is the form/window which opens when the user clicks on

the SIGNUP window on the main form. This form accepts all

essential information from the user and stores them in the

database thereby registering the user in the system.

After Signing up the information gets stored in database

Page 21 of 50
Book Flights Form

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


String field1 = "";
String field2 = "";
String field3 = "";

if(jRadioButton1.isSelected()==true || jRadioButton2.isSelected()==true){
if(jRadioButton1.isSelected()==true)
{

field1=(String) jComboBox1.getSelectedItem();
field2=(String) jComboBox2.getSelectedItem();
field3=("INTERNATIONAL");
}
else if(jRadioButton2.isSelected()==true)
{
field1=(String) jComboBox3.getSelectedItem();
field2=(String) jComboBox4.getSelectedItem();
field3=("DOMESTIC");
}
try {
Class.forName("java.sql.DriverManager");

Page 22 of 50
} catch (ClassNotFoundException ex) {
Logger.getLogger(BookFlights.class.getName()).log(Level.SEVERE, null, ex);
}
Connection con = null;
try {
con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/airline",
"root","rootabc");
} catch (SQLException ex) {
Logger.getLogger(BookFlights.class.getName()).log(Level.SEVERE, null, ex);
}
Statement stmt = null;
try {
stmt = (Statement) con.createStatement();
} catch (SQLException ex) {
Logger.getLogger(BookFlights.class.getName()).log(Level.SEVERE, null, ex);
}
try {
Statement st = (Statement) con.createStatement();
} catch (SQLException ex) {
Logger.getLogger(BookFlights.class.getName()).log(Level.SEVERE, null, ex);
}
String query="INSERT INTO temporary VALUES('"+field1+"','"+field2+"');";
try {
stmt.executeUpdate(query);
} catch (SQLException ex) {
Logger.getLogger(BookFlights.class.getName()).log(Level.SEVERE, null, ex);
}

String info[]=new String[1]; //creates an array to store variable values. You can increase the size
when needed
info[0]=field3; //put jTextField1's value in the array.
FlightDetails.main(info); // call Frame2. Here we create an object of a Frame2. We are passing info
as arguments to main function.

this.setVisible(false); // hiding this form


}
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

new Login().setVisible(true);

dispose();

Page 23 of 50
Form Summary:-

This form on the click of “ next ” accepts the regions the

person wants to travel between and further after sorting

suitable flights view all the flights in a table under

“FLIGHT DETAILS “ form as can be seen in the preview

below.

Page 24 of 50
Flight Details Form

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

int row = jTable1.getSelectedRow();

int column = jTable1.getSelectedColumn();

final String val=(String)jTable1.getValueAt(row,8);

String query="Delete from temporary;";

try {

stmt.executeUpdate(query);

} catch (SQLException ex) {

Logger.getLogger(FlightDetails.class.getName()).log(Level.SEVERE, null, ex);

String sql="Insert into temporary_a values( "+val+") ;";

try {

Page 25 of 50
stmt.execute(sql);

} catch (SQLException ex) {

Logger.getLogger(FlightDetails.class.getName()).log(Level.SEVERE, null, ex);

new SeatBooking().setVisible(true);

dispose();

private void formWindowOpened(java.awt.event.WindowEvent evt) {

try{

Class.forName("java.sql.Driver");

con=DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");

stmt =con.createStatement();

String query="Select * from temporary ;";

rs =stmt.executeQuery(query);

if (rs.next()){

String start=rs.getString("start");

String end=rs.getString("end");

jTextField3.setText(""+start);

jTextField2.setText(""+end);

else

} catch (ClassNotFoundException | SQLException ex) {

Logger.getLogger(FlightDetails.class.getName()).log(Level.SEVERE, null, ex);

String f2=jTextField2.getText();

String f3=jTextField3.getText();

try{

Class.forName("java.sql.Driver");

Page 26 of 50
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");

stmt =con.createStatement();

String query="select * from flights Where src='"+f3+"' and destination= '"+f2+"' ;" ;

rs =stmt.executeQuery(query);

jTable1.setModel(DbUtils.resultSetToTableModel(rs));

}catch (ClassNotFoundException | SQLException ex) {

Logger.getLogger(FlightDetails.class.getName()).log(Level.SEVERE, null, ex);

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

new BookFlights().setVisible(true);

dispose();

Form Summary:-

This form represented above receives command from the previous

“selection” that the user did i.e. selecting the origin and end of the

journey. The action promotes the database to be searched through

and thereby displaying all the flights following the tour. The user

can easily select the flight by simply clicking on the flight suiting

him/her.

Some Flights already saved in the database :-

Page 27 of 50
Seat Booking Form

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


new FlightDetails().setVisible(true);

dispose();

}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
int n,l;

int z = jTextField4.getText().length();

int z1 = Integer.parseInt(jTextField4.getText());

n = Integer.parseInt(jTextField4.getText());

if(jRadioButton1.isSelected()==true)

{
l = l1.getSelectedIndices().length;

if(l>n)

Page 28 of 50
{
JOptionPane.showMessageDialog(this,"PLEASE DONT SELECT EXTRA SEATS");

}
else if(l<n)

{
JOptionPane.showMessageDialog(this,"PLEASE SELECT MORE SEATS");

}
}
if(jRadioButton2.isSelected()==true)

{
l = l2.getSelectedIndices().length;

if(l>n)

{
JOptionPane.showMessageDialog(this,"PLEASE DONT SELECT EXTRA SEATS");

}
else if(l<n)

{
JOptionPane.showMessageDialog(this,"PLEASE SELECT MORE SEATS");

}
}
if(jRadioButton1.isSelected()==false && jRadioButton2.isSelected()==false )

{
JOptionPane.showMessageDialog(this,"SELECT CLASS");

}
else

{
}
if(jRadioButton1.isSelected()==true){

Page 29 of 50
Object[] o=l1.getSelectedValues();

int price=Integer.parseInt(jTextField5.getText());

int tprice=z1*price;

System.out.println(""+Arrays.toString(o)+"\n"+tprice);

try{

Class.forName("java.sql.Driver");

con=DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");

stmt =con.createStatement();

String query="Insert into seatbook values ('"+Arrays.toString(o)+"',"+tprice+",'Economy');";

stmt.executeUpdate(query);

}catch( ClassNotFoundException | SQLException e){

}
}
else if(jRadioButton2.isSelected()==true){

Object[] p=l2.getSelectedValues();

int price=Integer.parseInt(jTextField5.getText());

int tprice=z1*price;

try{

Class.forName("java.sql.Driver");

con=DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");

stmt =con.createStatement();

String query="Insert into seatbook values ('"+Arrays.toString(p)+"',"+tprice+",'First');";

stmt.executeUpdate(query);

}catch(ClassNotFoundException | SQLException e){


}
}

Page 30 of 50
else{

JOptionPane.showMessageDialog(null,"Error in logic");
}
new PaymentForm().setVisible(true);

dispose();

private void formWindowActivated(java.awt.event.WindowEvent evt) {


String f="";

try{

Class.forName("java.sql.Driver");

con=DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");

stmt =con.createStatement();

String query="Select fno from temporary_a ;";

rs=stmt.executeQuery(query);

if (rs.next()){

f=rs.getString("fno");}

else{

}
String a=f;

String sql="Select date,departure,airline,terminal,price from flights where fno= "+a+";";

rs =stmt.executeQuery(sql);

if (rs.next()){

String date=rs.getString("date");

String departure=rs.getString("departure");

String airline=rs.getString("airline");

String terminal=rs.getString("terminal");

String pric=rs.getString("price");

String price=pric.substring(3,pric.length());

Page 31 of 50
jTextField1.setText(""+date);

jTextField2.setText(""+departure);

jTextField6.setText(""+airline);

jTextField3.setText(""+terminal);

jTextField5.setText(""+price);

}else

JOptionPane.showMessageDialog(null,"No such record found");

}catch(HeadlessException | ClassNotFoundException | SQLException e){


JOptionPane.showMessageDialog(this,con);

}
}

Form Summary:-

This form accepts number of passengers from user and

prompts him to the payment portal.

Page 32 of 50
Payment Form

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


String name=jTextField3.getText();
String contactnumber=jTextField4.getText();
String card="";
if(jRadioButton2.isSelected()==true){
card="Paypal";}
else if(jRadioButton1.isSelected()==true){
card="Visa";
}
else if(jRadioButton3.isSelected()==true){
card="MasterCard";
}
else
JOptionPane.showMessageDialog(null,"Select a payment method");
try{
Class.forName("java.sql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");
stmt =con.createStatement();
String query="Insert into pay values ('"+name+"',"+contactnumber+",'"+card+"');";
stmt.executeUpdate(query);

Page 33 of 50
}catch(ClassNotFoundException | SQLException e){
}
new ReservationForm().setVisible(true);
dispose();
}

private void formWindowActivated(java.awt.event.WindowEvent evt) {


try{
Class.forName("java.sql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");
stmt =con.createStatement();
String query="Select * from seatbook;";
rs=stmt.executeQuery(query);
if (rs.next()){
String list=rs.getString("jlist");
String price=rs.getString("price");
String fclass=rs.getString("fclass");
jTextField5.setText(""+list);
jTextField2.setText(""+price);
jTextField1.setText(""+fclass);
}
else{
}
}catch(ClassNotFoundException | SQLException e){
}
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


new SeatBooking().setVisible(true);
dispose();
}
FORM SUMMARY :-
This form receives the essential information from the

previous inputs and results and asks for the payment

through the three ways possible shown i.e.

“VisaCard”, “Paypal”, “MasterCard”.

Page 34 of 50
Reservation Form

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


try
{
String Name = jTextField1.getText();
String contact = jTextField2.getText();
String seatnumber = jTextField3.getText();
String departure = jTextField4.getText();
String date = jTextField5.getText();
String origin = jTextField6.getText();
String end = jTextField7.getText();
String payment = jTextField8.getText();
String uni = jTextField9.getText();

Class.forName("java.sql.DriverManager");
con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/airline", "root","rootabc");
stmt = (Statement) con.createStatement();
String query="INSERT INTO reserved_records
VALUES('"+Name+"','"+contact+"','"+seatnumber+"','"+departure+"','"+date+"','"+origin+"','"+end
+"','"+payment+"','"+uni+"');";
stmt.executeUpdate(query);
String sql="delete from pay;";

Page 35 of 50
stmt.executeUpdate(sql);
String sqla="delete from seatbook;";
stmt.executeUpdate(sqla);
String sqlb="delete from temporary;";
stmt.executeUpdate(sqlb);
String sqlc="delete from temporary_a;";
stmt.executeUpdate(sqlc);
JOptionPane.showMessageDialog(null,"Reservation Successful");
}
catch (ClassNotFoundException | SQLException e)
{
JOptionPane.showMessageDialog (this, e.getMessage());
}
}

private void formWindowActivated(java.awt.event.WindowEvent evt) {


try{
Class.forName("java.sql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");
stmt =con.createStatement();
String query="Select * from pay;";
rs=stmt.executeQuery(query);
if (rs.next()){
String name=rs.getString("name");
String cn=rs.getString("contactnumber");
String card=rs.getString("card");
jTextField1.setText(""+name);
jTextField2.setText(""+cn);
jTextField8.setText(""+card);
}
else{

}
}catch(ClassNotFoundException | SQLException e){

}
try{
Class.forName("java.sql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");
stmt =con.createStatement();

Page 36 of 50
String query="Select * from temporary ;";
rs =stmt.executeQuery(query);
if (rs.next()){
String start=rs.getString("start");
String end=rs.getString("end");
jTextField6.setText(""+start);
jTextField7.setText(""+end);
}
else
;
} catch (ClassNotFoundException | SQLException ex) {
Logger.getLogger(FlightDetails.class.getName()).log(Level.SEVERE, null, ex);
}
String f2=jTextField6.getText();
String f3=jTextField7.getText();

try{
Class.forName("java.sql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");
stmt =con.createStatement();
String query="select * from flights Where src='"+f3+"' and destination= '"+f2+"' ;" ;
rs =stmt.executeQuery(query);
if (rs.next()){
String date=rs.getString("date");
String departure=rs.getString("departure");
String ucode=rs.getString("fno");
jTextField5.setText(""+date);
jTextField4.setText(""+departure);
jTextField9.setText(""+ucode);
}
else
;
}catch (ClassNotFoundException | SQLException ex) {
Logger.getLogger(FlightDetails.class.getName()).log(Level.SEVERE, null, ex);
}

try{
Class.forName("java.sql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");
stmt =con.createStatement();
String query="Select * from seatbook;";
rs=stmt.executeQuery(query);

Page 37 of 50
if (rs.next()){
String list=rs.getString("jlist");
jTextField3.setText(""+list);
}
else{
}
}catch(ClassNotFoundException | SQLException e){
}
String a=jTextField9.getText();
String b=jTextField1.getText();
String b1=b.substring(3,b.length());
String c=jTextField2.getText();
String c1=c.substring(3,c.length()-3);
jTextField9.setText(""+a+b1+c1);
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


new HomePage().setVisible(true);
dispose();
}

This form finally shows the details essential for

reservation and after the user have confirmed these

he/she presses reserve which stores the flight record in

the database that Can be tracked later using the

“UNIQUE CODE” provided.

Page 38 of 50
CHECK FLIGHT STATUS

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


new HomePage().setVisible(true);

dispose();

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


System.exit(0);

}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

fetch_Data();

jTable1.setVisible(true);

Page 39 of 50
private void formWindowActivated(java.awt.event.WindowEvent evt) {
jTable1.setVisible(false);

NOTE

The reservation form provides a UNIQUE CODE to every costumers who


tries to reserve the flight and this unique code can help the customer
to see the record of his flight easily by clicking on the CHECK FLIGHT
STATUS on the main form which will retrieve the particular record
from the database showing his/her flight details.

Page 40 of 50
Admin Form

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {


new HomePage().setVisible(true);
dispose();
}

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {


int c=0;String sql=" Select * from admin ";
try
{
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con;
con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");
Statement stmt = (Statement) con.createStatement();
Statement stmt1 = (Statement) con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
String user=jTextField1.getText();
String pwd= new String (jPasswordField1.getPassword());
while(rs.next())
{
String uname=rs.getString("adminid");
String password=rs.getString("adminpassword");
if ((user.equals(uname)) && (pwd.equals(password)))

Page 41 of 50
{
c=1;
}
}
if(c==1)
{
new UpdateRecords().setVisible(true);
dispose();
}
if(c==0)
{
System.exit(0);
}
}
catch (ClassNotFoundException e)
{
JOptionPane.showMessageDialog(this, e.getMessage());
} catch (SQLException ex) {
Logger.getLogger(Admin.class.getName()).log(Level.SEVERE, null, ex);
}
}

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {


System.exit(0);
}

FORM SUMMARY:-

This form is administration based form which allow the

administrators to modify the flight as well as seat details from

wherever they desire thereby saving time . This form asks the

admin for the password the administration uses and hence it

further opens a modifying window which can help to add ,

delete the flights from the record database.

Page 42 of 50
Records Form

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


System.exit(0);
}

private void jTable1FocusGained(java.awt.event.FocusEvent evt) {


fetch_Data();
}

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {


new Update_Delete().setVisible(true);
dispose();
}
FORM SUMMARY:-

This form shows all the records of flight details and

gives a option to alter the table records

Page 43 of 50
Alter Records Form

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


try{
Class.forName("java.sql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");
stmt =con.createStatement();
int f=Integer.parseInt(jTextField12.getText());
String query="Select * from flights where fno= "+f+";";
rs =stmt.executeQuery(query);
if (rs.next()){
String date=rs.getString("date");
String departure=rs.getString("departure");
String airline=rs.getString("airline");
String terminal=rs.getString("terminal");
String price=rs.getString("price");

Page 44 of 50
String area=rs.getString("area");
String begin =rs.getString("src");
String end=rs.getString("destination");
String fno=rs.getString("fno");
jTextField4.setText(""+date);
jTextField5.setText(""+departure);
jTextField6.setText(""+airline);
jTextField7.setText(""+terminal);
jTextField8.setText(""+price);
jTextField9.setText(""+area);
jTextField10.setText(""+begin);
jTextField11.setText(""+end);
}else
JOptionPane.showMessageDialog(null,"No such record found");

}catch(HeadlessException | ClassNotFoundException | SQLException e){


JOptionPane.showMessageDialog(this,con);

}
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


int ans=JOptionPane.showConfirmDialog(null,"Surely do you wanna update the record");
if(ans ==JOptionPane.YES_OPTION){
String date =jTextField4.getText();
String departure =jTextField5.getText();
String airline =jTextField6.getText();
String terminal =jTextField7.getText();
String price =jTextField8.getText();
String area =jTextField9.getText();
String begin =jTextField10.getText();
String end =jTextField11.getText();
String fno =jTextField12.getText();

try{
stmt =con.createStatement();
String query = "UPDATE flights SET date= '"+date+"' where fno="+fno+";";
stmt.executeUpdate(query);
String querya = "UPDATE flights SET departure= '"+departure+"' where fno="+fno+";";
stmt.executeUpdate(querya);
String queryb = "UPDATE flights SET airline= '"+airline+"' where fno="+fno+";";
stmt.executeUpdate(queryb);

Page 45 of 50
String queryc = "UPDATE flights SET terminal= '"+terminal+"' where fno="+fno+";";
stmt.executeUpdate(queryc);
String queryd = "UPDATE flights SET price= '"+price+"' where fno="+fno+";";
stmt.executeUpdate(queryd);
String querye = "UPDATE flights SET area= '"+area+"' where fno="+fno+";";
stmt.executeUpdate(querye);
String queryf = "UPDATE flights SET src= '"+begin+"' where fno="+fno+";";
stmt.executeUpdate(queryf);
String queryg = "UPDATE flights SET destination= '"+end+"' where fno="+fno+";";
stmt.executeUpdate(queryg);
String queryh = "UPDATE flights SET fno= '"+fno+"' where fno="+fno+";";
stmt.executeUpdate(queryh);

JOptionPane.showMessageDialog(null,"Record Updated!");
}catch(SQLException e){
System.out.println(""+e);

}
}
}

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {


int ans=JOptionPane.showConfirmDialog(null,"Surely do you wanna delete the record");
if(ans == JOptionPane.YES_OPTION){
try{
stmt =con.createStatement();
String query="Delete from flights Where fno ="+jTextField12.getText()+";";
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(null,"Record Deleted!");
}catch(HeadlessException | SQLException e){
JOptionPane.showMessageDialog(null,"Error in Deletion!"); }

}
}

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {

try{
Class.forName("java.sql.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/airline","root","rootabc");
stmt =con.createStatement();

if (rs.next()){
String date =jTextField4.getText();
String departure =jTextField5.getText();

Page 46 of 50
String airline =jTextField6.getText();
String terminal =jTextField7.getText();
String price =jTextField8.getText();
String area =jTextField9.getText();
String begin =jTextField10.getText();
String end =jTextField11.getText();
String fno =jTextField12.getText();
String query = "INSERT INTO flights
VALUES('"+date+"','"+departure+"','"+airline+"','"+terminal+"','"+price+"','"+area+"','"+begin+"','"
+end+"','"+fno+"');";
stmt.executeUpdate(query);

}else
JOptionPane.showMessageDialog(null,"No such entry possible");

}catch(HeadlessException | ClassNotFoundException | SQLException e){


JOptionPane.showMessageDialog(this,con);

}
}

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {


jTextField4.setText("");
jTextField5.setText("");
jTextField6.setText("");
jTextField7.setText("");
jTextField8.setText("");
jTextField9.setText("");
jTextField10.setText("");
jTextField11.setText("");
jTextField12.setText("");

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {


new UpdateRecords().setVisible(true);
dispose();
}

FORM SUMMARY:-
This form can easily modify the flight schedule with the help of

buttons INSERT, DELETE which can add as well as delete a

particular desired row from the database.

Page 47 of 50
CONCLUSION
Airline Reservation System has been prepared to
reduce the manual work and with the help of this
project the users will be able to save their time.

The project is capable of storing information about


the customer and flight details.

It allows deleting ,modifying , adding of new records by


the admin .

It allows searching, selecting , booking of flights by the


user.

Page 48 of 50
BIBLOGRAPHY
The sources that proved out to be very useful

during the making of the project are listed below.

www.wikipedia.org

www.NetBeans.org

www.MySQl.org

www.Shutterstock.com

www.youtube.com

CBSE CLASS 11/12 Informatics Practices.

Page 49 of 50
Page 50 of 50

You might also like