Vous êtes sur la page 1sur 64

A PROJECT

entitled
RAILWAY RESERVATION SYSTEM

INFORMATICS PRACTICES (065)


AISSCE(2018-19)
GUIDED BY:- CREATED BY:-
MR. A.K. PANDEY VIKRAM SAHA
(H.O.D., COMPUTER DEPT.) ROLLNO:-
CLASS - XII

Lal Bahadur Shastri SR. SEC. School


Sector-3, R. K. Puram, New Delhi-110022
CERTIFICATE

This is to certify that the Project / Dissertation entitled

RAILWAY RESERVATION SYSTEM is a bonafide work

done by VIKRAM SAHA of class XII Session 2018-19 in

partial fulfillment of CBSE’s AISSCE Examination 2018-19

and has been carried out under my direct supervision and

guidance. This report or a similar report on the topic has

not been submitted for any other examination and does not

form a part of any other course undergone by the

candidate.

ROLL NO:

GUIDED BY
Mr. A.K. Pandey
(Head of Computer
Dept.)

2
3
u
ACKNOWLEDGEMENT
ndertook this Project work, as the part of
my XII-Informatics Practices course.We
had tried to apply my best of knowledge
and experience, gained during the study
and class work experience. However, developing software
system is generally a quite complex and time-consuming
process. It requires a systematic study, insight vision and
professional approach during the design and development.
Moreover, the developer always feels the need, the help and
good wishes of the people near you, who have considerable
experience and idea.

It gives immense pleasure in expressing a deep sense


of gratitude, appreciation and thanks to my respected
teacher
Mr.ARVIND KUMAR PANDEY
for his inspiration throughout the preparation of this
project.
I am thankful to other member of computer department
and school authorities for providing necessary equipment. I
would also like to thank all my friends and classmates who

4
help me with valuable suggestions in the successful
completion of this project.

5
C O N T E N T S

1. Introduction------------------------------------------5

2. Theoretical Background-----------------------------6

3. System Implementation-------------------------15

3.1 The Hardware used:--------------------

3.2 The Softwares used:---------------------

4. System Design & Development---------------16

4.1 I/O Forms Design & Event Coding:-------

5.Bibliography ----------------------------------------61

6
1. Introduction
This software project is developed to automate the functionalities of

a spots shop.The purpose of the software project is to develop the

Management Information System (MIS) to automate the record

keeping of customer entry,order entry and item entry with a view to

enhance the decision making of the functionaries.

A MIS mainly consists of a computerized database, a collection of

inter-related tables for a particular subject or purpose, capable to

produce different reports relevant to the user. An application

program is tied with the database for easy access and interface to

the database. Using Application program or front-end, we can store,

retrieve and manage all information in proper way.

This software, being simple in design and working, does not require

much of training to users, and can be used as a powerful tool for

automating a RAILWAY RESERVATION SYSTEM System.

7
2. Theoretical Background
3.1 What is Database?
Introduction and Concepts:
A database is a collection of information related to a
particular subject or purpose, such as tracking customer
orders or maintaining a music collection. Using any RDBMS
application software like MS SQL Server, MySQL, Oracle,
Sybase etc, you can manage all your information from a
single database file. Within the file, divide your data into
separate storage containers called tables. You may and
retrieve the data using queries.
A table is a collection of data about a specific topic, such as
products or suppliers. Using a separate table for each topic
means you can store that data only once, which makes your
database more efficient and reduces data-entry errors. Table
organises data into columns (called fields) and rows (called
records).
A Primary key is one or more fields whose value or values
uniquely identify each record in a table. In a relationship, a
primary key is used to refer to specific record in one table
from another table. A primary key is called foreign key when
it is referred to from another table.

8
To find and retrieve just the data that meets conditions you
specify, including data from multiple tables, create a query. A
query can also update or delete multiple records at the same
time, and perform built-in or custom calculations on your
data.

NETWORK TOPOLOGY
It is the arrangement of the various elements (links, nodes,
etc.) of a computer network. Essentially, it is the
topological structure of a network and may be depicted
physically or logically.
There are a number of different types of network
topologies, including point-to-point, bus, star, ring, mesh,
tree and hybrid.

Topology being used in LBS School Computer Lab:


STAR TOPLOGY :-
This topology consists of a central node to which all other nodes are
connected by a single path. It is the topology used in most existing
information networks involving data processing or voice
communications. The following figure shows the Star topology pattern.

9
Advantages:
o Ease of Service.
o One device per connection.
o Centralized control.

Disadvantages:
o Long cable length.
o Difficult to expand.
o Central node dependency.

Open Source Software:

Open source software is software whose source code is


available for modification or enhancement by anyone.
"Source code" is the part ofsoftware that most computer users
don't ever see; it's the code computer programmers can
manipulate to change how a piece of software—a "program" or
"application"—works.

Open Source Software being used in our School:


10
Netbeans 6.5.1 (can be downloaded from https://netbeans.org)
MySQL Server 5.1 (Can be downloaded from https://dev.mysql.com)

JAVA NetBeans IDE 6.5.1


(FRONT END SOFTWARE)

INT RODUCTION
Java is a popular third-generation programming
language, which can be used to perform any of the
thousands of things that computer software can do.
With the features it offers, Java has become the
language choice of Internet and Intranet applications.
Java plays an important role for the proper functioning
of many software-based devices attached to
11
network.The kind of functionality the Java offers, has
contributed a lot towards the popularity of Java.

Java is both, a programming language and a platform.


Like any other programming language, you can use
java to write or create various types of computer
applications. Java is also a platform for application
development. The word platform generally is used to
refer to some combination of hardware and system
software. For example:Operating System Windows
Vista or Intel Pentium V etc.
COMPILATION PROCESS
In ordinary compilation, the source code is converted
to machine code, which is dependent upon the
machine or the platform. This resultant machine code
is called native executable code.
Contrary to ordinary compilers, the Java compiler does
not produce native executable code for particular
machine. Instead it produces a special format called
byte code. The Java byte code looks a lot like machine
language, but unlike machine language Java byte code
is exactly the same on every platform.

BYTE CODE

12
Whenever a program written in the Java Programming
Language is compiled, the compiler converts the
human readable source file into platform independent
code that JVM(Java Virtual Machine) can understand.
This platform independent code is called byte code.

RAPID APPLICATION DEVELOPMENT


The rapid application development describes a
method of developing software through the use of pre-
programmed tools or wizards. The pre-programmed
or controls are simply dropped on a screen to visually
design the interface of the application.

*******

13
MySQL SERVER 5.1
(BACK END SOFTWARE)
INT RODUCTION
A database is basically a computer-based record
keeping system. The collection of data, usually referred
to as a database, contains information about one
particular enterprise. It maintains any information
that may be necessary to the decision-making process
involved in the management of that organization. A
database may also be defined as collection of
interrelated data stored together to several multiple
applications; the data is such stored so that it is
independent of the program which uses the data; a
common and controlled approach is used in adding
new data and modifying and retrieving data within the
database. The data is structured so as to provide a
foundation for future application development. The
intention of a database is that the same collection of
data should serve as many applications as possible.

DATABASE MANAGEMENT SYSTEM


14
A Database Management System (DBMS) refers to
software that is responsible for storing, maintaining
and
utilizing databases. A database along with a DBMS is
referred as Database System.
ADVANTAGES
 Reduce the data redundancy to a larger extent:
Data redundancy means the duplication of data.
Non-database systems maintain separate copies of
data for each application.
 Can control data inconsistency to a large extent:
When the redundancy is not controlled there may
be occasions on which the two entries do not
agree. At such time database is said to be
inconsistent.
 Facilitate sharing of data:
Sharing of data means that the individual pieces of
data in the database may be shared among several
different users, in the sense that each may have
access to the same piece of data and each of them
may use it for different purposes.
 Enforce standards:
The database management system can ensure that
all data follow the application standards.
 Integrity can be maintained:

15
Integrated database means unification of servers
otherwise distinct files, with any redundancy
among those files partially or wholly eliminated.
 Can ensures data security:
COMMANDS
 Data Definition Language (DDL) Commands:
o Commands that allow us to perform task
related to data definition. For example:
 creating, altering and dropping
 maintenance commands
 Data Manipulation Language (DML) Commands:
o Commands that allow us to perform data
manipulation. For example:
 retrieval insertion
 deletion
 modification
 Transaction Control Language (TCL) Commands:
o Commands that allow us to manage and
control the transactions (one complete unit of
work involving many steps). For example:
 making changes to database, permanent
 undoing changes to database, permanent
 creating save points

16
 3. System Im pl eme nt at io n

5.1 The Hardware used:

While developing the system, the used hardware are:


PC with I3 core processor (2.7 GHz) processor having
4GB RAM, HD and other required devices.

5.2 The Softwares used:


 Microsoft Windows 7 as Operating System.

 Java NetBeans 8.1 as Front-end Development


environment.

 MySQL as Back-end Sever with Database for Testing.

 MS-Word 2007 for documentation.

6. Syste m Design & Develo pm ent

6.3 I/O Forms Design & Event Coding:


The software project for RAILWAY RESERVATION SYSTEM
contains various forms along with programming codes.
Forms (JFrames) and their event coding are given below.

17
TABLE STRUCTURE

 LOGIN DETAILS

 SAMPLE DATA

18
 INFO TABLE

 SAMPLE DATA

19
 RECORD TABLE

 SAMPLE DATA

20
(1) LOGIN PAGE

IMPORT COMMANDS
import java.sql.*;

import java.lang.*;

import javax.swing.JOptionPane;

CODING:
private void
loginBTNActionPerformed(java.awt.event.ActionEvent evt)
{

String uname=nameTF.getText();

String pass=new String(passTF.getPassword());

try{

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

Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","ad
min");

Statement stmt=con.createStatement();

ResultSet rs;

rs = stmt.executeQuery("select * from login where uname = '"+uname+"' and


pass = '"+pass+"';");

while(rs.next()) {

if
(pass.equalsIgnoreCase(rs.getString("pass"))&&uname.equalsIgnoreCase(rs.getStrin
g("uname")))

{new intro().setVisible(true);

this.dispose();}

else

System.out.print("wrong"); }

con.close();

}catch(Exception e){ JOptionPane.showMessageDialog(this,"error!"+ e);}

// TODO add your handling code here:

private void
manageAccBTNActionPerformed(java.awt.event.ActionEve
nt evt) {
new manageAcc().setVisible(true);

22
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {

System.exit(0); // TODO add your handling code here:

private void
jMenuItem3ActionPerformed(java.awt.event.ActionEvent
evt) {
System.exit(0); // TODO add your handling code here:

23
(2) START PAGE

CODING:

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

new loading().setVisible(true); // TODO add your handling code here:

this.dispose();

24
(3) LOADING PAGE

CODING:
private void
goBTNActionPerformed(java.awt.event.ActionEvent evt) {
new homescreen().setVisible(true);

this.dispose(); // TODO add your handling code here:

25
(4) HOME SCREEN

CODING:

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

System.exit(0); // TODO add your handling code here:

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

System.exit(0); // TODO add your handling code here:

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

26
this.dispose();

new bookticket().setVisible(true); // TODO add your handling code here:

private void
CancelTicketMIActionPerformed(java.awt.event.Act
ionEvent evt) {
this.dispose();

new cancelTicket().setVisible(true); // TODO add your handling code here:

private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionE
vent evt) {
this.dispose();

new records().setVisible(true); // TODO add your handling code here:

private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new addTrainInfo().setVisible(true); // TODO add your handling code here:

27
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEv
ent evt) {
this.dispose();

new Train_info().setVisible(true); // TODO add your handling code here:

private void
SignOutMIActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:

this.dispose();

new login().setVisible(true); // TODO add your handling code here:

private void
homeScreenMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new homescreen().setVisible(true); // TODO add your handling code here:

(5) TICKET BOOKING

28
IMPORT COMMAND:
import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

import javax.swing.JOptionPane;

CODING:

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

int random = (int) (Math.random()*100);

System.out.println(random);

if (boardRB.getSelectedIndex()==destinationRB.getSelectedIndex() ||
(monthRB.getSelectedIndex()==0)||yearRB.getSelectedIndex()==0||
dayRB.getSelectedIndex()==0)

29
JOptionPane.showMessageDialog(null,"PLEASE CHOOSE DESTINATION or DATE
CORRECTLY");

else {

if(random%5==0){

JOptionPane.showMessageDialog(null,"SORRY NO TRAINS AVAILABLE");

trainRB.removeItem(trainRB.getSelectedItem());}

else {

netAmountBTN.setEnabled(true);

JOptionPane.showMessageDialog(null,"TRAINS AVAILABLE");

/*String year =(String) yearRB.getSelectedItem();

int month = monthRB.getSelectedIndex();

int day = dayRB.getSelectedIndex();

String date=("'"+year+"-"+month+"-"+day+"'");

String train=(String) trainRB.getSelectedItem();

double seats=seatRB.getSelectedIndex()+1;

double Trate=trainRB.getSelectedIndex();

double ac=acRB.getSelectedIndex()+1;

double single_amnt=(2000+(2000*(4.5*Trate/100)));

double ac_amnt=single_amnt+single_amnt+750*ac;

double net_amnt=Math.abs(ac_amnt*seats);

System.out.println(net_amnt);

proceedBTN.setText(""+net_amnt);

*/

30
// TODO add your handling code here:

private void
netAmountBTNActionPerformed(java.awt.event.ActionEve
nt evt) {
String year =(String) yearRB.getSelectedItem();

String month = (String) monthRB.getSelectedItem();

String day = (String) dayRB.getSelectedItem();

String date=(""+year+"-"+month+"-"+day+"");

String train=(String) trainRB.getSelectedItem();

double seats=seatRB.getSelectedIndex()+1;

double Trate=trainRB.getSelectedIndex();

double ac=acRB.getSelectedIndex()+1;

double single_amnt=(2000+(2000*(4.5*Trate/100)));

double ac_amnt=single_amnt+single_amnt+750*ac;

double net_amnt=Math.abs(ac_amnt*seats);

netLBL.setText(""+net_amnt);

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

double seats=seatRB.getSelectedIndex();int newRecord=0;long PNR=0;

String year =(String) yearRB.getSelectedItem();

String month = (String) monthRB.getSelectedItem();

String day = (String) dayRB.getSelectedItem();

String date=(""+year+"-"+month+"-"+day+"");

31
String train=(String) trainRB.getSelectedItem();

String board=(String) boardRB.getSelectedItem();

double acType=acRB.getSelectedIndex()+1;

String destination=(String) destinationRB.getSelectedItem();

// code to get pnr number

try{

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

Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","ad
min");

Statement stmt=con.createStatement();

ResultSet rs=stmt.executeQuery("select * from records");

rs.last();

PNR=rs.getInt("PNR")+123;

con.close();

}catch(Exception e){ JOptionPane.showMessageDialog(this,"error!"+ e);}

for(int i=0;i<=seats;i++){

// CODE TO BOOK TICKETS

String name=JOptionPane.showInputDialog("ENTER PASSANGER`S NAME"); //


TODO add your handling code here:

String age=JOptionPane.showInputDialog("ENTER PASSANGER`S AGE"); // TODO


add your handling code here:

String sex=JOptionPane.showInputDialog("ENTER PASSANGER`S SEX (m OR f)");


// TODO add your handling code here:

System.out.println("insert into records


values("+PNR+",'"+name+"',"+age+",'"+sex+"','"+train+"','"+date+"','"+board+"'
,'"+destination+"',"+acType+");");

try{

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

Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","ad
min");

Statement stmt=con.createStatement();

ResultSet rs=null;

int choice = JOptionPane.showConfirmDialog(null,"ARE YOU SURE");

if(choice==0){

newRecord = stmt.executeUpdate("insert into records


values("+PNR+",'"+name+"',"+age+",'"+sex+"','"+train+"','"+date+"','"+board+"'
,'"+destination+"',"+acType+");");

JOptionPane.showMessageDialog(this,"TICKET BOOKED SUCCESSFULLY YOUR


PNR NO. IS "+PNR+" KINDLY NOTE IT DOWN .");

}con.close();

}catch(Exception e){ JOptionPane.showMessageDialog(this,"error!"+ e);}

private void
jCheckBox1ActionPerformed(java.awt.event.ActionEvent
evt) {
if (jCheckBox1.isSelected())

bookBTN.setEnabled(true);

if (jCheckBox1.isSelected()==false)

bookBTN.setEnabled(false);

// TODO add your handling code here:

33
private void
bookTicketMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();

new bookticket().setVisible(true); // TODO add your handling code here:

private void
CancelTicketMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new cancelTicket().setVisible(true); // TODO add your handling code here:

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

this.dispose();

new records().setVisible(true); // TODO add your handling code here:

private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new addTrainInfo().setVisible(true); // TODO add your handling code here:

34
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEv
ent evt) {
this.dispose();

new Train_info().setVisible(true); // TODO add your handling code here:

private void
SignOutMIActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:

this.dispose();

new login().setVisible(true); // TODO add your handling code here:

private void
homeScreenMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new homescreen().setVisible(true); // TODO add your handling code here:

private void
exitMIActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:

35
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {

System.exit(0); // TODO add your handling code here:

(6) CANCEL TICKET

36
IMPORT COMMAND:
import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

CODING:
int PNR;

private void
formWindowOpened(java.awt.event.WindowEvent evt) {
PNR=Integer.parseInt(JOptionPane.showInputDialog("ENTER YOUR PNR
NUMBER")); // TODO add your handling code here:

String query = "SELECT * FROM records where pnr ="+PNR+";";

37
boolean exist=false;

try {

Class.forName("com.mysql.jdbc.Driver").newInstance();

Connection con = (Connection)


DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","admin");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {

if (rs.getInt("pnr")==PNR)

exist=true;

break;}

} catch (Exception e) {

JOptionPane.showMessageDialog(this, e.getMessage());

if (exist==true){

try {

Class.forName("com.mysql.jdbc.Driver").newInstance();

Connection con = (Connection)


DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","admin");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {

String pmrmo = rs.getString("PNR");

String pname = rs.getString("Pname");

String page = rs.getString("Page");

38
String psex = rs.getString("Psex");

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

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

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

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

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

PNRTF.setText(""+PNR);

PNAME.setText(pname);

PSEX.setText(psex);

TNAME.setText(tname);

DATETF.setText(date);

FROMTF.setText(board);

TOTF.setText(destination);

ACTYPETF.setText(acType);

} catch (Exception e) {

JOptionPane.showMessageDialog(this, e.getMessage());

}}

else{

JOptionPane.showMessageDialog(this, "PLEASE ENTER A VALID VALUE");

new cancelTicket().setVisible(true);

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

39
int choice = JOptionPane.showConfirmDialog(null,"ARE YOU SURE THAT YOU WANT
TO CANCEL THE TICKET");

if(choice==0) {

try{

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

Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","ad
min");

Statement stmt=con.createStatement();

ResultSet rs=null;

int delRecord = stmt.executeUpdate("delete from records where PNR


="+PNR+";");

con.close();

}catch(Exception e){ JOptionPane.showMessageDialog(this,"error!"+ e);}}

// TODO add your handling code here:

private void
bookTicketMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();

new bookticket().setVisible(true); // TODO add your handling code here:

private void
CancelTicketMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

40
new cancelTicket().setVisible(true); // TODO add your handling code here:

private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionE
vent evt) {
this.dispose();

new records().setVisible(true); // TODO add your handling code here:

private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new addTrainInfo().setVisible(true); // TODO add your handling code here:

private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEv
ent evt) {
this.dispose();

new Train_info().setVisible(true); // TODO add your handling code here:

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

41
// TODO add your handling code here:

this.dispose();

new login().setVisible(true); // TODO add your handling code here:

private void
homeScreenMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new homescreen().setVisible(true); // TODO add your handling code here:

private void
exitMIActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:

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

System.exit(0); // TODO add your handling code here:

(7) DISPLAY RECORD

42
IMPORT COMMAND:

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

CODING;

private void
displayBTNActionPerformed(java.awt.event.ActionEvent
evt) {
DefaultTableModel model = (DefaultTableModel) recordTBL.getModel();

int rows = model.getRowCount();

43
if (rows > 0) {

for (int i = 0; i < rows; i++) {

model.removeRow(0);

int PNR=Integer.parseInt(JOptionPane.showInputDialog("ENTER YOUR PNR


NUMBER"));

String query = "SELECT * FROM records where pnr ="+PNR+";";

boolean exist=false;

try {

Class.forName("com.mysql.jdbc.Driver").newInstance();

Connection con = (Connection)


DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","admin");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {

if (rs.getInt("pnr")==PNR)

exist=true;

break;}

} catch (Exception e) {

JOptionPane.showMessageDialog(this, e.getMessage());

if (exist==true){

try {

Class.forName("com.mysql.jdbc.Driver").newInstance();

44
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","admin");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {

String pmrmo = rs.getString("PNR");

String pname = rs.getString("Pname");

String page = rs.getString("Page");

String psex = rs.getString("Psex");

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

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

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

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

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

model.addRow(new Object[] {pmrmo, pname, page,


psex,tname,date,board,destination,acType});

} catch (Exception e) {

JOptionPane.showMessageDialog(this, e.getMessage());

} } else

JOptionPane.showMessageDialog(this, "PLEASE ENTER A VALID VALUE"); //


TODO add your handling code here:

private void
bookTicketMI5ActionPerformed(java.awt.event.ActionEven
t evt) {
this.dispose();

45
new bookticket().setVisible(true); // TODO add your handling code here:

private void
CancelTicketMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new cancelTicket().setVisible(true); // TODO add your handling code here:

private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionE
vent evt) {
this.dispose();

new records().setVisible(true); // TODO add your handling code here:

private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new addTrainInfo().setVisible(true); // TODO add your handling code here:

private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEv
ent evt) {

46
this.dispose();

new Train_info().setVisible(true); // TODO add your handling code here:

private void
SignOutMIActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:

this.dispose();

new login().setVisible(true); // TODO add your handling code here:

private void
homeScreenMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new homescreen().setVisible(true); // TODO add your handling code here:

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

System.exit(0); // TODO add your handling code here:

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

47
System.exit(0); // TODO add your handling code here:

(8) GET TRAIN INFO

48
IMPORT COMMAND:
import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

import javax.swing.JOptionPane;

CODING:

private void
Get_train_infoBTNActionPerformed(java.awt.event.ActionE
vent evt) {
String tname =(String) trainRB.getSelectedItem();

try {

49
// Connect to MySQL database

Class.forName("com.mysql.jdbc.Driver").newInstance();

Connection con = (Connection)


DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","admin");

// Create SQL statement and execute query.

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("select * from tinfo where tname =


'"+tname+"';");

// Iterate through the result and display on screen

while (rs.next()) {

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

String pno = rs.getString("PLATFORM_NO");

String BOARDING = rs.getString("BoardTime");

String Journey = rs.getString("journeyTime");

TnoTF.setText(tno);

PnoTF.setText(pno);

BoardTF.setText(BOARDING);

JtimeTF.setText(Journey);

} catch (Exception e) {

JOptionPane.showMessageDialog(this, e.getMessage());

50
private void
bookTicketMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();

new bookticket().setVisible(true); // TODO add your handling code here:

private void
CancelTicketMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new cancelTicket().setVisible(true); // TODO add your handling code here:

private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionE
vent evt) {
this.dispose();

new records().setVisible(true); // TODO add your handling code here:

private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new addTrainInfo().setVisible(true); // TODO add your handling code here:

51
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEv
ent evt) {
this.dispose();

new Train_info().setVisible(true); // TODO add your handling code here:

private void
SignOutMIActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:

this.dispose();

new login().setVisible(true); // TODO add your handling code here:

private void
homeScreenMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new homescreen().setVisible(true); // TODO add your handling code here:

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

System.exit(0); // TODO add your handling code here:

52
private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:

53
(9) ADD TRAIN INFO

IMPORT COMMAND:

import java.sql.*;

import javax.swing.JOptionPane;

CODING:

private void
Get_train_infoBTNActionPerformed(java.awt.event.ActionE
vent evt) {

54
String tname =Tname.getText();

String Tno = TnoTF.getText();

String Pno = PnoTF.getText();

String Board = BoardTF.getText();

String Jtime = JtimeTF.getText();

try {

// Connect to MySQL database

Class.forName("com.mysql.jdbc.Driver").newInstance();

Connection con = (Connection)


DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","admin");

// Create SQL statement and execute query.

Statement stmt = con.createStatement();

ResultSet rs =null;

int choice = JOptionPane.showConfirmDialog(null,"ARE YOU SURE");

int newRecord;

if(choice==0){

newRecord = stmt.executeUpdate("insert into tinfo


values('"+tname+"',"+Tno+","+Pno+",'"+Board+"','"+Jtime+"');");

JOptionPane.showMessageDialog(null, "ADDED SUCCESSFULLY");

} }catch (Exception e) {

JOptionPane.showMessageDialog(this, e.getMessage());

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

// TODO add your handling code here:

55
}

private void
bookTicketMIActionPerformed(java.awt.event.ActionEvent
evt) {
this.dispose();

new bookticket().setVisible(true); // TODO add your handling code here:

private void
CancelTicketMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new cancelTicket().setVisible(true); // TODO add your handling code here:

private void
DisplayRecordsMIActionPerformed(java.awt.event.ActionE
vent evt) {
this.dispose();

new records().setVisible(true); // TODO add your handling code here:

private void
addTrianInfoMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

56
new addTrainInfo().setVisible(true); // TODO add your handling code here:

private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEv
ent evt) {
this.dispose();

new Train_info().setVisible(true); // TODO add your handling code here:

private void
SignOutMIActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:

this.dispose();

new login().setVisible(true); // TODO add your handling code here:

private void
homeScreenMIActionPerformed(java.awt.event.ActionEve
nt evt) {
this.dispose();

new homescreen().setVisible(true); // TODO add your handling code here:

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

57
System.exit(0); // TODO add your handling code here:

private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:

(10) CREATE NEW ID

58
IMPORT:
import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

import javax.swing.JOptionPane;

CODING:
private void
createBTNActionPerformed(java.awt.event.ActionEvent
evt) {
String uname=nameTF.getText();int newAcc;

String pass=new String(passTF.getPassword());

try{

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

59
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","ad
min");

Statement stmt=con.createStatement();

ResultSet rs=null;

int choice = JOptionPane.showConfirmDialog(null,"ARE YOU SURE");

if(choice==0)

newAcc = stmt.executeUpdate("insert into login


values( '"+uname+"','"+pass+"');");

con.close();

}catch(Exception e){ JOptionPane.showMessageDialog(this,"error!"+ e);}


// TODO add your handling code here:

private void
deleteBTNActionPerformed(java.awt.event.ActionEvent
evt) {
String uname=nameTF.getText();int delAcc;

String pass=new String(passTF.getPassword());

try{

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

Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/railway","root","ad
min");

Statement stmt=con.createStatement();

ResultSet rs=null;

int choice = JOptionPane.showConfirmDialog(null,"ARE YOU SURE");

if (choice==0)

60
delAcc = stmt.executeUpdate("delete from login where uname
='"+uname+"' and pass ='"+pass+"';");

con.close();

}catch(Exception e){ JOptionPane.showMessageDialog(this,"error!"+ e);} //


TODO add your handling code here:

private void
jMenu4ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:

private void
jMenuItem2ActionPerformed(java.awt.event.ActionEvent
evt) {
new login().setVisible(true); // TODO add your handling code here:

this.dispose();

private void
jMenuItem3ActionPerformed(java.awt.event.ActionEvent
evt) {
System.exit(0); // TODO add your handling code here: }

61
BIBLIOGRAPHY

 Informatics Practices – XI by Sumita


Arora
 Informatics Practices – XII by Sumita
Arora
 http://www.irctc.in
 Google Images

62
RAILWAY
RESERVATION
SYSTEM

THE END
63
64

Vous aimerez peut-être aussi