Android Online Local Train Reservation
Android Online Local Train Reservation
Objective:-
Through this system, a practical approach has been taken under study to understand how Android Online
Local Train Reservation system works. This system will include all the necessary fields which are required
during online reservation system. This system will be easy to use and can be used by any person. The basic
idea behind this project is to save data in a central database which can be accessed by any authorize
person to get information and saves time and burden which are being faced by their customers.
Existing System:-
Even though the online reservation system is available but the passengers have to fill all their necessary
details using pen and paper which involves manual working. It’s the main counter is not open due to late
arrival or due to some reasons then in this case, passengers have to wait and in certain cases they have to
wait in line, waiting for their chance to come. After wasting so much time, customers able to get their
answers and sometimes they did not positive response.
Proposed System:-
Through this system customers do not have to wait in line and they will able to get their answers in just a
click. Through this system online form will be available by which passengers will able to fill their details
along with their journey details. To book their seats, users will have to first search their trains as per their
requirements and after getting correct train they will have to provide Train number. After pressing next
button, it will show its status, whether it has been activated or in process. Online cancellation form will
also be available and to cancel their reservation, they will have to provide their PNR number again to carry
the next task.
Number of Modules:-
1. Login Form.
2. Reservation Form.
3. Cancellation Form.
4. PNR Enquiry.
5. Exit.
Description of Modules:-
Login Form –To access this system, each user should have a valid login id and password. After providing
the correct login id and password, users will able to access the main system.
Reservation System –Under reservation form users will have to fill the necessary details such as their
basic details, train number, train name will automatically come in the box, class type, date of journey, from
(place) to destination and after that, users will have to press insert button.
Cancellation Form –If passengers want to cancel their tickets then they have to provide their PNR
number and after submitting it, this will display the entire information related to that particular PNR
number. If users want to confirm their cancellation, in this case they have to press OK button .
Software Requirements:
1. Operating System : Windows XP/2003 or Higher Version of Windows OS.
2. User Interface : Java Swing.
3. Programming Language : Java.
4. Database : Oracle
Hardware Requirements:
7. Processor : Pentium IV or above.
8. Hard Disk : 50GB
9. RAM : 512 MB or more
Table of content
1. Introduction
1.1 Purpose
1.2 Document Conventions
1.3 Intended Audience
and Reading
Suggestions
1.4 Definitions, Acronyms and
Abbreviations
1.5 Scope
2.Overall description
2.1 Product Perspective
2.2 Product Function
2.3 Guest Interface
2.4 Train Management Interface
2.5 Operating Environment
2.6 Memory Constrains
2.7 Operations
2.8 User Interface
2.9 Hardware Interface
2.10Software Interfaces
2.11Assumptions, Dependencies
&Limitations
3.System Features
3.1 Description &Priority
3.2 Functional Requirements
3.1.1 View Train Details
3.1.2 Search Train
3.1.3 Create Account
3.1.4 Customer Login
3.1.5 Purchase Ticket
3.1.6 Purchase History
3.1.7 Login Function
3.1.8 Staff Module
3.1.9 Reservation Module
3.1.10 Ticket Module
3.1.11 Membership
Module
3.1.12 Train Module
3.1.13 Pricing Module
3.1.14 Availability Module
3.1.15 Branch Module
3.1.16 Report Module
3.1.17 Access Type
5.Non-functional Requirements
5.1 Performance Requirements
5.2 Safety Requirements
5.3 Security Requirements
5.4 Design Constraint
1. INTRODUCTION
1.1 PURPOSE
The purpose of this source is to describe the railway reservation system which provides the train
timing details, reservation, billing, cancelation on various types of reservation namely.
Confirm Reservation for confirm Seat.
Reservation against Cancellation
Waiting list Reservation.
Online Reservation.
Tatkal Reservation
1.2 DOCUMENTCONVENTIONS:
2.1 PRODUCTPERSPECTIVE
It enables us to maintain the railway train details like their timings, number of seat available
and reservation billing and cancelling the tickets.
2.2 PRODUCTFUNCTIONS:
OMBS will have two users interface layers, first one is guest interface and the second
one is Train Management Interface.
2.3 GUESTINTERFACE:
View Train Details
Search Train
Create Account
Customer Login
Purchase Ticket
Purchase History
2.5 OPERATINGENVIRONMENT
OS
Windows NT
Linux
Windows XP
Windows 98
2.6 MEMORYCONSTRAINTS
A maximum of 42 laces hits per day have been recorded.
2.7 OPERATIONS:
(1) To allow a user post various query about ticket information available at present. User can
use any combination available
(2) To show the user the resulting list of query. This should allow users to further sort the list by
subfields of the ticket information (e.g. price). The view should be friendly and flexible.
(3) To allow a user place a reservation
(4) To detect the conflict if a user placed two incompatible reservations.
(5) To allow a user view his/her reservation
(6) To allow user modify his/her reservation
(7) To allow user to manage his/her account in RRS
2.11 ASSUMPTIONS,DEPENDENCIES ANDLIMITATIONS
AS-1: Users of RRS are assumed to have a computer with internet access.
AS-2: Credit and debit card authorization services are assumed to be
available.
DE-1: RRS has collaboration with every airline’s databases thus it must be able to communicate
with these systems. Also it has to obey airline’s business rules.
3. SYSTEMFEATURES
3.2 FUNCTIONALREQUIREMENTS
REQ-S6 The standard train search method will allow the user to [Priority = Low]
specify a preferred rail line. This is optional, i.e. the
user may or may not specify the rail line of preference.
REQ-S7 The user will have the option to express a preference of [Priority = Low]
non-stop train; otherwise both non-stop trains and
trains with stopovers will be treated equally.
REQ-S8 User can only search for a train in the future and within [Priority = High]
one year of the current date. (The cutoff time can be
applied, i.e. user cannot make the reservation for the
train which will take off in 2 hours.)
REQ-S9 The user to select any hour on the hour (i.e. trains at [Priority = High]
12am, 11am, 2pm etc.).
REQ-S10 When the user is searching for a train he may select [Priority = Medium]
one of the following preset time ranges: Morning,
Evening, Night, or Anytime.
REQ-S11 User should be able to search by Train number and rail [Priority = Low]
line. This will allow him to see the particular train for
the particular rail line.
REQ-S12 The user may specify anywhere from 1 (one) to 6 [Priority = High]
(six)passengers. Passengers will not be treated
separately as minors or seniors.
REQ-S13 Any error in entry of the system will stop the system [Priority = High]
from processing the search. An error message will be
presented to the user.
GUEST INTERFACE:
View Train Details
The system shall enable customer or visitor to view list of trains.
Search Train
The system shall have search function. Customer can search train based on source and
destination station details with date and time.
Create Account
The system shall function to create an account. The system shall record all the
following data from the customer.
a. Username
b. Password
c. Password confirmation
d. First name
e. Last name
f. Identify card number
g. Address
h. Zip code
i. City
j. State
k. Country
l. Mobile no.
Customer Login
The system shall have customer login functions, once activated, customer can login using
username and password.
The system shall have username and password recovery function.
Purchase Ticket
The system shall enable customer to purchase the train ticket from guest
interface. The system shall display all the train details.
The system shall display the date time and price of the ticket.
The system shall have book now button. When book now button is pressed, the
system shall prompt customer to login or register account.
The system shall allow customer who have login only to continue to purchase ticket. If
customer haven’t login, prompt customer to login and create account.
Purchase History
The customer can watch all the purchase history from this module.
The system shall allow system administration only to access the module. System
administration shall login first to access this module.
The system shall allow the system administration to add staff, update staff and delete
staff. The system shall record all the following details:
a. Staff Username
b. password
c. Account
d. First Name
e. Last Name
f. Address
g. City
h. State
Reservation Module
The system shall allow counter clerk, station manager and station supervisor of the particular
station to access this module. They should login first.
The system shall limit the access to branch level only.
The system shall display the seating arrangements for customers. The system shall display the
total amount of ticket. The system shall allow station manager or clerk to check the details.
Ticket cancellation:
The Ticket Canceling is also user (Employee of Railway Dept.) side module. The user can
cancel the ticket using this module. The user should follow the steps for the ticket Cancel.
a) Enter the PNR Number in the Textbox and Click Find.
b) It will show the details like Train No., Train Name, Booked Date, Travel Date, Source,
Destination, Class, Quota, Total Fare, Kms in the Frame.
c) It also shows the passenger names, Age, Sex, Berth, Class, Fare and status in the flex grid.
d) Click the Name in the flex grid which you want to cancel and where the status is “Booked”.
e) Click the “Cancel” Button to cancel the ticket.
Access to the modules is determined by staff account type and branch office
location. Types of account are as follow:
Counter Clerk
Station Master
Station supervisor
Head office
Personnel Ticket
Checker System
Administrator
4. EXTERNAL INTERFACEREQUIREMENT
4.1 USERINTERFACES
Keyboard, Mouse, Printer
4.2 HARDWAREINTERFACES
SERVER SIDE
Operating System: Windows7
Processor:Inteli5
Memory: 4GB
Hard Drive Capacity:750GB
CLIENT SIDE
Operating System: Windows XP, Windows Vista orWindows7
Browser: Internet Explorer and above. Mozilla or Google Chrome.
Memory:512MB
4.3 SOFTWAREINTERFACES
Database
Oracle
Web Server
Apache server version 2.2.6
Programming Languages
Java
4.4 COMMUNICATIONINTERFACES
Dial Up Modem
Broadband Internet
5. NON FUNCTIONALREQUIREMENTS
5.1 PERFORMANCEREQUIREMENTS
PE-1: The system shall accommodate 400 users during the peak usage time window of 8:00am to
10:00am local time, with estimated average session duration of 45 minutes.
PE-2: All Web pages generated by the system shall be fully downloadable in no more than 10 seconds
over a 40KBps modem connection.
PE-3: Responses to queries shall take no longer than 10 seconds to load onto the screen after the user
submits the query.
PE-4: The system shall display confirmation messages to users within 4 seconds after the user submits
information to the system.
Variety of compartments based on comfort:
1. AC first-class
2. A sleeper
3. First class
4. AC three tier
5. sleeper class
6. Ordinary chair car
Types of concerns and complexities:
1. 44 types of quotas
2. 8 types of trains
3. 9 types of classes
4. 162 types of concessions
5. 127 types of bogies
5.2 SAFETYREQUIREMENTS
No safety requirements have been identified.
5.3 SECURITYREQUIREMENTS
SE-1: Users shall be required to log in to the RRS for their own reservation information and
modification with e-mail address and password.
SE-2: The system shall permit only authorized members who are on the list of authorized Menu
Managers to do administrator’s task.
SE-3: The system shall permit customers to view only their own previously placed orders, not orders
placed by other customers.
5.4 DESIGNCONSTRAINT
The system shall be web based system that runs on different type of browsers such as Internet
Explorer, Mozilla, and Google chrome.
There are a number of factors in the client’s environment that may restrict the choices of a designer.
Such factors include standards that must be followed, resource limits, operating environment,
reliability and security requirements and policies that may have an impact on the design of the
system. An SRS (Software Requirements Analysis and Specification) should identify and specify all
such constraints.
Standard Compliance: - This specifies the requirements for the standards the system must follow.
The standards may include the report format and accounting properties.
Hardware Limitations: -The software may have to operate on some existing or predetermined
hardware, thus imposing restrictions on the design. Hardware limitations can include the types of
machines to be used, operating system available on the system, languages supported and limits on
primary and secondary storage.
Reliability and Fault Tolerance: - Fault tolerance requirements can place a major constraint on
how the system is to be designed. Fault tolerance requirements often make the system more complex
and expensive. Requirements about system behavior in the face of certain kinds of faults are
specified. Recovery requirements are often an integral part here, detailing what the system should do
I some failure occurs to ensure certain properties. Reliability requirements are very important for
critical applications.
Security: - Security requirements are particularly significant in defense systems and database
systems. They place restrictions on the use of certain commands, control access to data, provide
different kinds of access requirements for different people, require the use of passwords and
cryptography techniques and maintain a log of activities in the system.
SOURCE CODES
Welcome Screen:
import java.awt.*;
import javax.swing.*;
JFrame f;
JLabel l1,l2,l3;
Thread t;
Login l;
ImageIcon img;
Welcome()
img=new ImageIcon("indian-rail.jpg");
t=new Thread(this);
f=new JFrame("Welcome");
f.getContentPane().setLayout(null);
f.getContentPane().setBackground(Color.yellow);
l1.setBounds(250,300,900,50);
l1.setForeground(Color.red);
l2.setBounds(350,380,800,40);
l2.setForeground(Color.red);
l3=new JLabel(img);
l3.setBounds(0,0,1300,1000);
f.getContentPane().add(l1);
f.getContentPane().add(l2);
f.getContentPane().add(l3);
f.setSize(1300,1000);
f.setVisible(true);
t.start();
int x=1;
while(x<=5)
try
Thread.sleep(1000);
}
catch(Exception e)
{}
x++;
f.setVisible(false);
l=new Login();
Login Screen
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
JFrame f;
JLabel l1,l2;
JTextField t1;
JPasswordField t2;
JButton b1,b2;
Main M;
Login()
f=new JFrame("Login");
f.getContentPane().setLayout(null);
f.getContentPane().setBackground(Color.pink);
l1.setForeground(Color.yellow);
l1.setBounds(50,50,100,30);
l2=new JLabel("Password");
l2.setForeground(Color.yellow);
l2.setBounds(50,80,100,30);
t1=new JTextField(10);
t1.setForeground(Color.blue);
t1.addActionListener(this);
t1.setBounds(150,50,100,30);
t2=new JPasswordField(10);
t2.setForeground(Color.blue);
t2.setEchoChar('*');
t2.addActionListener(this);
t2.setBounds(150,80,100,30);
b1=new JButton("Ok");
b1.setForeground(Color.blue);
b1.addActionListener(this);
b1.setBounds(50,120,100,30);
b2=new JButton("Cancel");
b2.setForeground(Color.blue);
b2.addActionListener(this);
b2.setBounds(180,120,100,30);
b1.setMnemonic('O');
b2.setMnemonic('C');
f.getContentPane().add(l1);
f.getContentPane().add(l2);
f.getContentPane().add(t1);
f.getContentPane().add(t2);
f.getContentPane().add(b1);
f.getContentPane().add(b2);
f.setBounds(300,300,300,200);
f.setResizable(false);
f.setVisible(true);
if(e.getSource()==b1)
if(t1.getText().length()==0||t2.getText().length()==0)
f.setVisible(false);
M=new Main();
else
}
if(e.getSource()==b2)
f.setVisible(false);
System.exit(0);
Main Screen:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
JFrame f;
JButton b1,b2,b3,b4;
Reservation r;
Enquiry q;
Cancellation c;
JLabel imgL;
ImageIcon img;
Main()
img=new ImageIcon("Indian-Railway-Network.jpg");
imgL=new JLabel(img);
imgL.setBounds(0,0,1300,1000);
f=new JFrame("Main");
f.getContentPane().setLayout(null);
f.getContentPane().setBackground(Color.green);
b1.addActionListener(this);
b1.setBounds(150,390,210,60);
b2=new JButton("PNR-enquiry");
b2.addActionListener(this);
b2.setBounds(150,490,210,60);
b3.addActionListener(this);
b3.setBounds(580,390,210,60);
b4=new JButton("Exit");
b4.addActionListener(this);
b4.setBounds(580,490,210,60);
b1.setBackground(new Color(100,200,0));
b1.setForeground(new Color(255,255,255));
b2.setBackground(new Color(100,200,0));
b2.setForeground(new Color(255,255,255));
b3.setBackground(new Color(100,200,0));
b3.setForeground(new Color(255,255,255));
b4.setBackground(new Color(100,200,0));
b4.setForeground(new Color(255,255,255));
b1.setMnemonic('R');
b2.setMnemonic('P');
b3.setMnemonic('C');
b4.setMnemonic('E');
f.getContentPane().add(b1);
f.getContentPane().add(b2);
f.getContentPane().add(b3);
f.getContentPane().add(b4);
f.getContentPane().add(imgL);
f.setSize(1300,1000);
f.setVisible(true);
if(e.getSource()==b1)
f.setVisible(false);
r=new Reservation();
if(e.getSource()==b2)
f.setVisible(false);
q=new Enquiry();
if(e.getSource()==b3)
f.setVisible(false);
c=new Cancellation();
if(e.getSource()==b4)
{
f.setVisible(false);
System.exit(0);
new Main();
Reservation Screen:
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
JFrame f;
JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13;
JTextField t1,t2,t3,t4,t5,t6,t7;
Choice h;
JTextArea ta;
JButton b1,b2,b3;
PreparedStatement ps;
Statement st;
ResultSet rs;
int x;
JLabel imgL;
ImageIcon img;
void disable()
t1.setEnabled(false);
t2.setEnabled(false);
t3.setEnabled(false);
t4.setEnabled(false);
t5.setEnabled(false);
t6.setEnabled(false);
t7.setEnabled(false);
h.setEnabled(false);
b2.setEnabled(false);
void enable()
t1.setEnabled(true);
t2.setEnabled(true);
t3.setEnabled(true);
t4.setEnabled(true);
t5.setEnabled(true);
t6.setEnabled(true);
t7.setEnabled(true);
h.setEnabled(true);
b2.setEnabled(true);
}
Reservation()
img=new ImageIcon("LOGO1.jpg");
imgL=new JLabel(img);
imgL.setBounds(0,320,500,250);
f=new JFrame("Reservation");
f.getContentPane().setLayout(null);
f.getContentPane().setBackground(Color.green);
l1.setBounds(130,50,100,30);
l2.setBounds(50,80,100,30);
l3.setBounds(50,110,100,30);
l4=new JLabel("Class");
l4.setBounds(50,140,100,30);
l5.setBounds(50,170,100,30);
l6=new JLabel("From");
l6.setBounds(50,200,100,30);
l7=new JLabel("To");
l7.setBounds(250,200,50,30);
l8.setBounds(50,230,100,30);
t1=new JTextField(10);
t1.setBounds(230,50,120,30);
t2=new JTextField(10);
t2.addFocusListener(this);
t2.setBounds(150,80,100,30);
t3=new JTextField(10);
t3.setBounds(150,110,100,30);
t4=new JTextField(10);
t4.setBounds(150,170,100,30);
t5=new JTextField(10);
t5.setBounds(150,200,100,30);
t6=new JTextField(10);
t6.setBounds(300,200,100,30);
t7=new JTextField(10);
t7.setBounds(150,230,100,30);
h=new Choice();
h.setBounds(150,140,100,30);
h.add("AC");
h.add("SL");
b1=new JButton("Insert");
b1.setBackground(Color.yellow);
b1.setBounds(50,270,100,30);
b1.addActionListener(this);
b2=new JButton("Next");
b2.setBackground(Color.yellow);
b2.setBounds(160,270,100,30);
b2.addActionListener(this);
b3=new JButton("Main");
b3.setBackground(Color.yellow);
b3.setBounds(270,270,100,30);
b3.addActionListener(this);
b1.setMnemonic('I');
b2.setMnemonic('N');
b3.setMnemonic('M');
f.getContentPane().add(l1);
f.getContentPane().add(l2);
f.getContentPane().add(l3);
f.getContentPane().add(l4);
f.getContentPane().add(l5);
f.getContentPane().add(l6);
f.getContentPane().add(l7);
f.getContentPane().add(l8);
f.getContentPane().add(t1);
f.getContentPane().add(t2);
f.getContentPane().add(t3);
f.getContentPane().add(t4);
f.getContentPane().add(t5);
f.getContentPane().add(t6);
f.getContentPane().add(t7);
f.getContentPane().add(h);
f.getContentPane().add(b1);
f.getContentPane().add(b2);
f.getContentPane().add(b3);
f.getContentPane().add(imgL);
f.setSize(1300,1000);
f.setVisible(true);
disable();
}
public void focusLost(FocusEvent e)
if(t2.getText().length()!=0)
try
ps.setString(1,t2.getText());
rs=ps.executeQuery();
if(rs.next())
t3.setText(rs.getString(1));
catch(Exception e1)
System.out.println("Connection failed:"+e1);
{}
if(e.getSource()==b1)
enable();
b1.setEnabled(false);
try
st=con.createStatement();
rs.next();
x=rs.getInt(1);
t1.setText(String.valueOf(x));
catch(Exception e1)
System.out.println("Connection failed:"+e1);
if(e.getSource()==b2)
try
ps.setString(1,t1.getText());
ps.setString(2,t2.getText());
ps.setString(3,t3.getText());
ps.setString(4,h.getSelectedItem());
ps.setString(5,t4.getText());
ps.setString(6,t5.getText());
ps.setString(7,t6.getText());
ps.setString(8,t7.getText());
ps.executeUpdate();
//update PNR no.
ps.setInt(1,(x+1));
ps.setInt(2,x);
ps.executeUpdate();
b1.setEnabled(true);
b2.setEnabled(false);
f.setVisible(false);
catch(Exception e1)
System.out.println("Connection failed:"+e1);
try
st=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs.last();
x=rs.getInt(1);
st=con.createStatement();
rs.next();
x=rs.getInt(1);
P.t1.setText(String.valueOf(x));
ps.setInt(1,(x+1));
ps.setInt(2,x);
ps.executeUpdate();
catch(Exception e1)
System.out.println("Connection failed:"+e1);
if(e.getSource()==b3)
f.setVisible(false);
new Main();
new Reservation();
Passenger.java
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
JFrame f;
JLabel l1,l2,l3,l4,l5,l6;
JTextField t1,t2,t3;
JButton b1,b2,b3;
Checkbox c1,c2,c3,c4,c5;
CheckboxGroup cbg;
JTextArea ta;
PreparedStatement ps;
Statement st;
ResultSet rs;
int pno;
JLabel imgL;
ImageIcon img;
Passenger(int p)
pno=p;
img=new ImageIcon("LOGO2.jpg");
imgL=new JLabel(img);
imgL.setBounds(0,400,400,200);
f=new JFrame("Passenger");
f.getContentPane().setLayout(null);
f.getContentPane().setBackground(Color.green);
l1=new JLabel("PId");
l1.setBounds(50,50,100,30);
t1=new JTextField(10);
t1.setBounds(170,50,100,30);
l2.setBounds(50,80,120,30);
t2=new JTextField(10);
t2.setBounds(170,80,100,30);
l3=new JLabel("Age");
l3.setBounds(50,130,100,30);
t3=new JTextField(10);
t3.setBounds(150,130,50,30);
l4=new JLabel("Gender");
l4.setBounds(250,130,50,30);
ta=new JTextArea(5,10);
ta.setBounds(150,170,130,70);
l5=new JLabel("Address");
l5.setBounds(50,170,100,30);
l6=new JLabel("Catagory");
l6.setBounds(50,240,100,30);
b1=new JButton("More");
b1.setBackground(Color.yellow);
b1.addActionListener(this);
b1.setBounds(50,330,100,30);
b2=new JButton("Save");
b2.setBackground(Color.yellow);
b2.addActionListener(this);
b2.setBounds(170,330,100,30);
b3=new JButton("Back");
b3.setBackground(Color.yellow);
b3.addActionListener(this);
b3.setBounds(290,330,100,30);
b1.setMnemonic('M');
b2.setMnemonic('S');
b3.setMnemonic('B');
cbg=new CheckboxGroup();
c1=new Checkbox("Male",cbg,true);
c1.setBounds(300,130,100,30);
c2=new Checkbox("Female",cbg,false);
c2.setBounds(300,160,100,30);
c3=new Checkbox("General");
c3.setBounds(150,240,100,30);
c4.setBounds(150,270,100,30);
c5=new Checkbox("Ex-serviceman");
c5.setBounds(150,300,100,30);
f.getContentPane().add(l1);
f.getContentPane().add(l2);
f.getContentPane().add(l3);
f.getContentPane().add(l4);
f.getContentPane().add(l5);
f.getContentPane().add(l6);
f.getContentPane().add(t1);
f.getContentPane().add(t2);
f.getContentPane().add(t3);
f.getContentPane().add(ta);
f.getContentPane().add(b1);
f.getContentPane().add(b2);
f.getContentPane().add(b3);
f.getContentPane().add(c1);
f.getContentPane().add(c2);
f.getContentPane().add(c3);
f.getContentPane().add(c4);
f.getContentPane().add(c5);
f.getContentPane().add(imgL);
f.setSize(1300,1000);
f.setVisible(true);
if(e.getSource()==b1)
try
String cat="";
ps.setString(1,t1.getText());
ps.setString(2,t2.getText());
ps.setString(3,t3.getText());
ps.setString(4,cbg.getSelectedCheckbox().getLabel());
ps.setString(5,ta.getText());
if(c3.getState())
cat+=c3.getLabel()+",";
if(c4.getState())
cat+=c4.getLabel()+",";
if(c5.getState())
cat+=c5.getLabel()+",";
ps.setString(6,cat);
ps.setInt(7,pno);
ps.executeUpdate();
ps.close();
st=con.createStatement();
rs.next();
int x=rs.getInt(1);
P.t1.setText(String.valueOf(x));
st.close();
//update passenger id
ps.setInt(1,(x+1));
ps.setInt(2,x);
ps.executeUpdate();
ps.close();
catch(Exception e1)
System.out.println("Connection failed:"+e1);
}
if(e.getSource()==b2)
try
String cat="";
ps.setString(1,t1.getText());
ps.setString(2,t2.getText());
ps.setString(3,t3.getText());
ps.setString(4,cbg.getSelectedCheckbox().getLabel());
ps.setString(5,ta.getText());
if(c3.getState())
cat+=c3.getLabel()+",";
if(c4.getState())
cat+=c4.getLabel()+",";
if(c5.getState())
cat+=c5.getLabel()+",";
ps.setString(6,cat);
ps.setInt(7,pno);
ps.executeUpdate();
ps.close();
st=con.createStatement();
while(rs.next())
{
ps.setString(1,rs.getString(1));
ps.setString(2,rs.getString(2));
ps.setString(3,rs.getString(3));
ps.setString(4,rs.getString(4));
ps.setString(5,rs.getString(5));
ps.setString(6,rs.getString(6));
ps.setString(7,rs.getString(7));
ps.executeUpdate();
ps.close();
st=con.createStatement();
JOptionPane.showMessageDialog(null,"Record Saved");
b2.setEnabled(false);
b1.setEnabled(false);
st.close();
catch(Exception e1)
System.out.println("Connection failed:"+e1);
if(e.getSource()==b3)
f.setVisible(false);
new Reservation();
new Passenger(0);
Enquiry. Java:
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
JFrame f;
JLabel l1,l2;
JTextField t;
List li;
JButton b1,b2;
PreparedStatement ps;
ResultSet rs;
JLabel imgL;
ImageIcon img;
Enquiry()
{
img=new ImageIcon("LOGO1.jpg");
imgL=new JLabel(img);
imgL.setBounds(0,340,500,200);
f=new JFrame("PNR-Enquiry");
f.getContentPane().setLayout(null);
f.getContentPane().setBackground(Color.green);
l1.setBounds(50,50,60,30);
l2.setBounds(50,80,100,30);
t=new JTextField(10);
t.addActionListener(this);
t.setBounds(110,50,150,30);
li=new List();
li.setBounds(50,110,390,180);
b1=new JButton("Check");
b1.setBackground(Color.yellow);
b1.addActionListener(this);
b1.setBounds(70,300,100,30);
b2=new JButton("Back");
b2.setBackground(Color.yellow);
b2.addActionListener(this);
b2.setBounds(210,300,100,30);
b1.setMnemonic('C');
b2.setMnemonic('B');
f.getContentPane().add(l1);
f.getContentPane().add(l2);
f.getContentPane().add(t);
f.getContentPane().add(li);
f.getContentPane().add(b1);
f.getContentPane().add(b2);
f.getContentPane().add(imgL);
f.setSize(1300,1000);
f.setVisible(true);
if(e.getSource()==b1)
try
//reservation information
ps.setString(1,t.getText());
rs=ps.executeQuery();
rs.next();
li.clear();
li.add("Class: "+rs.getString(4));
li.add("From: "+rs.getString(6));
li.add("To: "+rs.getString(7));
li.add("Boarding at: "+rs.getString(8));
//passeneger information
ps.setString(1,t.getText());
rs=ps.executeQuery();
while(rs.next())
li.add("Age: "+rs.getString(3));
li.add("Gender: "+rs.getString(4));
catch(Exception e1)
System.out.println("connection failed:"+e1);
if(e.getSource()==b2)
f.setVisible(false);
new Main();
new Enquiry();
}
}
Cancellation Form:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
JFrame f;
JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11;
JTextField t1,t2,t3,t4,t5,t6,t7;
JButton b1,b2;
Choice h;
List li;
PreparedStatement ps;
ResultSet rs;
Statement st;
Cancellation()
f=new JFrame("Cancellation");
f.getContentPane().setLayout(null);
f.getContentPane().setBackground(Color.green);
l1.setBounds(130,50,50,30);
l2=new JLabel("Train No");
l2.setBounds(50,90,100,30);
l3.setBounds(50,120,100,30);
l4=new JLabel("Class");
l4.setBounds(50,150,100,30);
l5.setBounds(50,180,100,30);
l6=new JLabel("From");
l6.setBounds(50,210,100,30);
l7=new JLabel("To");
l7.setBounds(250,210,50,30);
l8.setBounds(50,240,100,30);
l9.setBounds(90,290,120,30);
l10=new JLabel("Age");
l10.setBounds(240,290,30,30);
l11=new JLabel("Gender");
l11.setBounds(290,290,100,30);
b1=new JButton("Ok");
b1.setBackground(Color.yellow);
b1.addActionListener(this);
b1.setBounds(50,480,100,30);
b2=new JButton("Back");
b2.setBackground(Color.yellow);
b2.addActionListener(this);
b2.setBounds(200,480,100,30);
b1.setMnemonic('O');
b2.setMnemonic('B');
h=new Choice();
h.setBounds(230,50,140,30);
h.addItemListener(this);
t1=new JTextField(10);
t1.addActionListener(this);
t1.setBounds(150,90,100,30);
t2=new JTextField(10);
t2.addActionListener(this);
t2.setBounds(150,120,100,30);
t3=new JTextField(10);
t3.addActionListener(this);
t3.setBounds(150,150,100,30);
t4=new JTextField(10);
t4.addActionListener(this);
t4.setBounds(150,180,100,30);
t5=new JTextField(10);
t5.addActionListener(this);
t5.setBounds(150,210,100,30);
t6=new JTextField(10);
t6.addActionListener(this);
t6.setBounds(300,210,100,30);
t7=new JTextField(10);
t7.addActionListener(this);
t7.setBounds(150,240,100,30);
li=new List(5,true);
li.setBounds(80,320,320,100);
f.getContentPane().add(l1);
f.getContentPane().add(l2);
f.getContentPane().add(l3);
f.getContentPane().add(l4);
f.getContentPane().add(l5);
f.getContentPane().add(l6);
f.getContentPane().add(l7);
f.getContentPane().add(l8);
f.getContentPane().add(l9);
f.getContentPane().add(l10);
f.getContentPane().add(l11);
f.getContentPane().add(b1);
f.getContentPane().add(b2);
f.getContentPane().add(h);
f.getContentPane().add(t1);
f.getContentPane().add(t2);
f.getContentPane().add(t3);
f.getContentPane().add(t4);
f.getContentPane().add(t5);
f.getContentPane().add(t6);
f.getContentPane().add(t7);
f.getContentPane().add(li);
f.setSize(1300,1000);
f.setVisible(true);
start();
}
public void start()
try
st=con.createStatement();
while(rs.next())
h.add(rs.getString(1));
catch(Exception e)
System.out.println("Connection failed:"+e);
System.out.println((String)h.getSelectedItem());
try
li.removeAll();
ps.setString(1,h.getSelectedItem());
rs=ps.executeQuery();
rs.next();
t1.setText(rs.getString(2));
t2.setText(rs.getString(3));
t3.setText(rs.getString(4));
t4.setText(rs.getString(5));
t5.setText(rs.getString(6));
t6.setText(rs.getString(7));
t7.setText(rs.getString(8));
ps.setString(1,h.getSelectedItem());
rs=ps.executeQuery();
while(rs.next())
catch(Exception e1)
System.out.println("Connection failed"+e1);
if(e.getSource()==b1)
try
ps.setString(1,h.getSelectedItem());
ps.executeUpdate();
ps=con.prepareStatement("delete from Passenger where PNR_No=?");
ps.setString(1,h.getSelectedItem());
ps.executeUpdate();
JOptionPane.showMessageDialog(null,"Reservation Cancelled");
f.setVisible(false);
catch(Exception e1)
System.out.println("Connection failed:"+e1);
if(e.getSource()==b2)
f.setVisible(false);
new Main();
new Cancellation();
Connect.java
import java.sql.*;
public class Connect
public Connect()
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
catch(Exception e1)
System.out.println("Connection failed:"+e1);