You are on page 1of 56

DLF Public School

(Managed by Darbari Lal Foundation)

INFORMATICS
PRACTICES
INVESTIGATORY
PROJECT
ON

BUS RESERVATION
SYSTEM
BY-ANKIT ROY and SHAMBO BASU

CERTIFICATE
This is to certify that SHAMBO BASU,
student of Class XII, DLF PUBLIC
SCHOOL has completed the project titled
Bus reservation system during the
academic year 2015-2016 towards partial
fulfillment of credit for the Chemistry
practical evaluation of CBSE 2016, and
submitted satisfactory report, as compiled
in the following pages, Under the
supervision of Mrs. ANSARA BANU,
Department of Chemistry, DLF PUBLIC
SCHOOL
SUBJECT TEACHER

EXTERNAL EXAMINER

___________________

_____________________

ACKNOWLEDGMENT
I would like to express my sincere gratitude to my
physics teacher Mrs. Ansara Banu for her vital
support, guidance and encouragement, without
which this project could not have been completed.
Then I would like to thank my parents and friends
for their constant support and valuable suggestions
which have helped me through various phases of the
project.

INDEX
Sr. No.
1
2
3
4
5
6
7
8
9
10
11
12

CONTENT
CERTIFICATE
ACKNOWLEDGEMENT
MAIN FORM
TICKET BOOKING
ENQUIRY FORM
ENQUIRY TICKET
ENQUIRY CUSTOMER
CANCELLATION
PREACAUTIONS
MYSQL SCREENSHOTS
CONCLUSION
BIBLIOBGRAPHY AND
WEBSITES

PAGE
2
4
6-8
9-18
19-21
22-25
26-29
30-32
13
33-39
40-41
42

Conclusion
The topic chosen by us was BUS RESERVATION
SYSTEM and the first approach to start building up
this project was analysing about the requirements
that a bus reservation would possess and
accordingly what should be layout of our forms. After
this the chief concern was the coding of several
components in order to get the desired result.
Process of analysing and having a complete layout
of our project in our hands was really necessary and
helped a lot. Coding of components wasnt very
difficult but setting connectivity of two forms and
between front and back end was a great task for our

team. There were some errors in our coding and we


were not at all able to detect the problem like errors
related to jdbc driver etc. Despite of difficulties faced
we were able to successfully complete our project
on time only because of our teamwork and great
support of our teacher Mrs. Ansara Banu. She was
always there for us to guide and point out our
mistakes. We also referred to reference books and
our text book. The project we have designed can be
used by any company to make bus reservation very
easy. Each one of us has actually learned a lot, not
just the learning about the subject but moral learning
also. During this process all of us learnt the
important values of team work, time management,
coping with stress and pressure etc . Although it was a
study related task but still both of us have enjoyed it
thoroughly.

Bibliography
INFORMATICS PRACTICES BY CBSE
INFORMATICS PRACTICES BY DHANPAT
RAI PUBLICATIONS

WEBSITES
Lionblogger.com
Stackoverflow.com

FORMS

MAIN FORM
Description
The main form consists the main
interface of this bus reservation
system which gives mainly 3
options to the user to book ticket,
cancel ticket and to enquire about
any kind of information. The user
can select any one of the above 3
options to go to the other form.

INTERFACE

CODE

private void
jButton2ActionPerformed(java.awt.event.ActionEventevt) {
cancellation m=new cancellation();
m.setVisible(true);
}

private void
jButton1ActionPerformed(java.awt.event.ActionEventevt) {

ticket_booking s= new ticket_booking();


s.setVisible(true);

private void
jButton3ActionPerformed(java.awt.event.ActionEventevt) {
enquiry a=new enquiry();
a.setVisible(true);

TICKET BOOKING
DESCRIPTION
Ticket booking form consists of the
form where user can book their
tickets by giving all the necessary
details asked.

INTERFACE

CODE

packageinvestigatoryproject;
importjavax.swing.*;
importjava.sql.DriverManager;
importcom.mysql.jdbc.Connection;

importcom.mysql.jdbc.Statement;
private void jComboBox1ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here
}
private void jButton2ActionPerformed(java.awt.event.ActionEventevt) {

double n=Double.parseDouble(jTextField2.getText()),c=0,cost;
String a;
if (jComboBox1.getSelectedIndex()==0)//delhi-mumbai
c=n*900;
{
if(jComboBox2.getSelectedIndex()==0)//non ac
{cost=c; a="DL CK 4901";}
else if (jComboBox2.getSelectedIndex()==1)//ac
{cost=c+0.1*c;a="DL 12 DE 1433";}
else if (jComboBox2.getSelectedIndex()==2)//volvo
{ cost=c+0.2*c;a="DL 11 CK 0001";}
}
if (jComboBox1.getSelectedIndex()==1)//delhi to kolkata
c=n*800;

if(jComboBox2.getSelectedIndex()==0)//NON AC
{ cost=c;a="DL 8 CE 5432"; }
else if (jComboBox2.getSelectedIndex()==1)//AC
{cost=c+0.1*c;a="DL 06 C 5977";}
else if (jComboBox2.getSelectedIndex()==2)//VOLVO
{cost=c+0.2*c;a="DL 7 CE 2737";}
}

if (jComboBox1.getSelectedIndex()==2)//mumbai-kolkata
c=n*950;
{
if(jComboBox2.getSelectedIndex()==0)//non ac
{cost=c;a="MH 65 ET 2134";}
else if (jComboBox2.getSelectedIndex()==1)//ac
{cost=c+0.1*c;a="MH 56 DF 2333";}

{
if(jComboBox2.getSelectedIndex()==0)// non ac
{cost=c;a="MH 04 CN 5413";}
else if (jComboBox2.getSelectedIndex()==1)//ac
{cost=c+0.1*c;a="MH 01 VU 2200";}
else if (jComboBox2.getSelectedIndex()==2)//volvo
{cost=c+0.2*c;a="MH 02 BG 2413";}
}
if (jComboBox1.getSelectedIndex()==4)//kolkata-mumbai
c=n*950;
{
if(jComboBox2.getSelectedIndex()==0)//non ac

{cost=c;a="WB 44 TT 6781";}
else if (jComboBox2.getSelectedIndex()==1)//ac
{cost=c+0.1*c;a="WB QW 00 6661";}
else if (jComboBox2.getSelectedIndex()==2)//volvo
{cost=c+0.2*c;a="WB 03 AQ 3333";}
}
if (jComboBox1.getSelectedIndex()==5)//kolkata-delhi
c=n*800;
{
if(jComboBox2.getSelectedIndex()==0)//NON AC
{ cost=c;a="WB EW 23 2331";}
else if (jComboBox2.getSelectedIndex()==1)//AC
{cost=c+0.1*c;a="WB 07 YU 2331";}
else if (jComboBox2.getSelectedIndex()==2)//VOLVO
{cost=c+0.2*c;a="WB RT 34 2221";}
}
jTextField9.setText(Double.toString(c));
}

private void jButton3ActionPerformed(java.awt.event.ActionEventevt) {


String ticket_id=(jTextField1.getText());
String route=(String)jComboBox1.getSelectedItem(); //ROUTE TAKEN
String Bus=(String) jComboBox2.getSelectedItem(); //BUS TYPE
String people=jTextField2.getText(); //no. of people
String Date=jTextField3.getText();//DATE OF TRAVEL
String customer_id=jTextField4.getText(); //CUSTOMER ID
String name=jTextField5.getText();// CUSTOMER NAME
String sex=jTextField6.getText();// CUSTOMER SEX
String Phone_no=jTextField7.getText();//CUSTOMER PHONE NO

String Address=jTextField8.getText();//CUSTOMER ADDRESS


String cost=(String)jTextField9.getText();// COST OF TICKET
String a = null;
if (jComboBox1.getSelectedIndex()==0)//delhi-mumbai
{
if(jComboBox2.getSelectedIndex()==0)//non ac
{ a="DL CK 4901";}
else if (jComboBox2.getSelectedIndex()==1)//ac
{a="DL 12 DE 1433";}
else if (jComboBox2.getSelectedIndex()==2)//volvo
{ a="DL 11 CK 0001";}
}
if (jComboBox1.getSelectedIndex()==1)//delhi to kolkata
{
if(jComboBox2.getSelectedIndex()==0)//NON AC
{a="DL 8 CE 5432";}

else if (jComboBox2.getSelectedIndex()==1)//AC
{a="DL 06 C 5977";}
else if (jComboBox2.getSelectedIndex()==2)//VOLVO
{a="DL 7 CE 2737";}
}

if (jComboBox1.getSelectedIndex()==2)//mumbai-kolkata
{
if(jComboBox2.getSelectedIndex()==0)//non ac
{a="MH 65 ET 2134";}
else if (jComboBox2.getSelectedIndex()==1)//ac
{a="MH 56 DF 2333";}
else if (jComboBox2.getSelectedIndex()==2)//volvo
{a="MH 65 EK 3343";}
}
if (jComboBox1.getSelectedIndex()==3)//mumbai-delhi
{
if(jComboBox2.getSelectedIndex()==0)// non ac
{a="MH 04 CN 5413";}
else if (jComboBox2.getSelectedIndex()==1)//ac
{a="MH 01 VU 2200";}
else if (jComboBox2.getSelectedIndex()==2)//volvo
{a="MH 02 BG 2413";}
}

if (jComboBox1.getSelectedIndex()==4)//kolkata-mumbai

{
if(jComboBox2.getSelectedIndex()==0)//non ac
{a="WB 44 TT 6781";}
else if (jComboBox2.getSelectedIndex()==1)//ac
{a="WB QW 00 6661";}
else if (jComboBox2.getSelectedIndex()==2)//volvo
{a="WB 03 AQ 3333";}
}
if (jComboBox1.getSelectedIndex()==5)//kolkata-delhi
{
if(jComboBox2.getSelectedIndex()==0)//NON AC
{ a="WB EW 23 2331";}
else if (jComboBox2.getSelectedIndex()==1)//AC
{a="WB 07 YU 2331";}
else if (jComboBox2.getSelectedIndex()==2)//VOLVO
{a="WB RT 34 2221";}
}

if (ticket_id.isEmpty())
JOptionPane.showMessageDialog(this,"Name not
Entered");//ticket id
else if (route.isEmpty())
JOptionPane.showMessageDialog(this,"Custome ID not
Entered");//route
else if (Bus.isEmpty())
JOptionPane.showMessageDialog(this,"Sex not Entered");//bus
else if (people.isEmpty())
JOptionPane.showMessageDialog(this,"Phone number not
Entered");//total no people
else if (Date.isEmpty())
JOptionPane.showMessageDialog(this,"Adress not
Entered");//Date
else if (customer_id.isEmpty())
JOptionPane.showMessageDialog(this,"Pin code not
Entered");//customer_id
else if (name.isEmpty())
JOptionPane.showMessageDialog(this,"Pin code not
Entered");//name of customer
else if (sex.isEmpty())
JOptionPane.showMessageDialog(this,"Pin code not
Entered");//sex of customer
else if (Phone_no.isEmpty())
JOptionPane.showMessageDialog(this,"Pin code not
Entered");//phone no of customer
else if (Address.isEmpty())
JOptionPane.showMessageDialog(this,"Pin code not
Entered");//address of customer
else {

try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/busresv","root",
"tiger");
Statement stmt=(Statement) con.createStatement();
String query="INSERT INTO customer
VALUES("+customer_id+",'"+name+"','"+Address+"','"+sex+"','"+Phone_no+
"');";
stmt.executeUpdate(query);
String query1="INSERT INTO
ticket_infoVALUES("+ticket_id+",'"+name+"','"+a+"','"+Bus+"','"+route+"','"+p
eople+"','"+cost+"');";
stmt.executeUpdate(query1);
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage());
} }
}

ENQUIRY FORM
DESCRIPTION

Enquiry from allows the user to get


information on either customer or
ticket,this form particularly allows
to choose what he wants to enquire
about..

INTERFACE

CODE

private void
jButton2ActionPerformed(java.awt.event.ActionEventevt) {
enquiry e=new enquiry();
e.setVisible(true);

ENQUIRY TICKET
DESCRIPTION

Enquiry ticket form allows the user


to enquire about any ticket by
entering its ticket id.

INTERFACE

CODE
packageinvestigatoryproject;
importjavax.swing.*;
importjava.sql.DriverManager;
importcom.mysql.jdbc.Connection;
importcom.mysql.jdbc.Statement
private void jButton2ActionPerformed(java.awt.event.ActionEventevt) {
String ticket_id=jTextField1.getText();
if (ticket_id.isEmpty())
JOptionPane.showMessageDialog(this,"Enter your Ticket ID");
else
{
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)

DriverManager.getConnection("jdbc:mysql://local3306//busresv","root","tige
r" );
Statement stmt=(Statement) con.createStatement();
String query="SELECT
ticket_id,Name,Bus_no,type,Route_name,totalpeople,"+
" from TICKE_INFO WHERE ticket_id="+ticket_id+";";

ResultSetrs = (ResultSet) stmt.executeQuery(query);


int Found=0;
while(rs.next())
{String Name=rs.getString("name");
String Bus_no =rs.getString("Bus_no");
String type=rs.getString("type");
String Route_name=rs.getString("Route_name");
String totalpeople=rs.getString("totalpeople");
String cost=rs.getString("cost");
jTextField2.setText(Name);
jTextField3.setText(Bus_no);
jTextField4.setText(type);
jTextField5.setText(Route_name);
jTextField6.setText(totalpeople);
jTextField2.setText(cost);

JOptionPane.showMessageDialog(null,"Click OK to continue!!!");
Found++;
}
if(Found==0)
JOptionPane.showMessageDialog(this,"Sorry! No such Name in
Contact List");
}
catch(Exception e)
{ JOptionPane.showMessageDialog(this,e.getMessage());

CUSTOMER ENQUIRY

DESCRIPTION
Ticket booking form consists of the
form where user can book their
tickets by giving all the necessary
details asked.

INTERFACE

CODE
packageinvestigatoryproject;
importjavax.swing.*;
importjava.sql.DriverManager;
importcom.mysql.jdbc.Connection;
importcom.mysql.jdbc.Statement;/*
private void jButton1ActionPerformed(java.awt.event.ActionEventevt)
{
String ticket_id=jTextField1.getText();
if (ticket_id.isEmpty())
JOptionPane.showMessageDialog(this,"Enter your Ticket ID");
else
{
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://local3306//busesv","root","
tiger" );
Statement stmt=(Statement) con.createStatement();
String query="SELECT Name,Adress,sex,Contact_no from
TICKE_INFO WHERE ticket_id="+ticket_id+";";

ResultSetrs = stmt.executeQuery(query);
int Found=0;
while(rs.next())
{String Name=rs.getString("name");
String Adress=rs.getString("Adress");
String sex=rs.getString("sex");
String contact_no=rs.getString("Contact_no");
jTextField2.setText(Name);
jTextField3.setText(Adress);
jTextField4.setText(sex);
jTextField5.setText(contact_no);
JOptionPane.showMessageDialog
(null,"Click OK to continue!!!");
Found++;
}

if(Found==0)
JOptionPane.showMessageDialog
(this,"Sorry! No such ticket in our database");
}
catch(Exception e)
{ JOptionPane.showMessageDialog(this,e.getMessage());
}
}
}

CANCELLATION
DESCRIPTION
Cancellation form helps a customer
to cancel any ticket he so desires.

INTERFACE

CODE
packageinvestigatoryproject;
importjavax.swing.*;
importjava.sql.DriverManager;
importcom.mysql.jdbc.Connection;
importcom.mysql.jdbc.Statement
private void jButton1ActionPerformed(java.awt.event.ActionEventevt) {
String ticket_id=jTextField2.getText();
if (ticket_id.isEmpty())
JOptionPane.showMessageDialog(this,"Enter Ticket ID which has to
be cancelled");
else
{
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://local3306//busesv","root","tiger
" );
Statement stmt=(Statement) con.createStatement();
String query="DELETE FROM TICKET_INFO WHERE
ticket_id='"+ticket_id+"';";
stmt.executeUpdate(query);
}

catch(Exception e)
{ JOptionPane.showMessageDialog(this,e.getMessage());}}}

MYSQL
SCREENSHO
TS

THANK
YOU

You might also like