Sie sind auf Seite 1von 62

A PROJECT

entitled
RAILWAY RESERVATION SYSTEM
INFORMATICS PRACTICES (065)
AISSCE(2018-19)

GUIDED BY:- CREATED


BY:-
MR. A.K. PANDEY RISHABH
GARG
(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 Rishabh Garg 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.)

3
ACKNOWLEDGEMENT
undertook 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 help me with valuable suggestions in the
successful completion of this project.
4
CONTENTS

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

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

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

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

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

9
Open Source Software being used in our School:

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)

INTRODUCTION
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
10
language choice of Internet and Intranet applications.
Java plays an important role for the proper functioning
of many software-based devices attached to
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.

11
BYTE CODE
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.

*******

12
MySQL SERVER 5.1
(BACK END SOFTWARE)
INTRODUCTION
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.

13
DATABASE MANAGEMENT SYSTEM
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.
14
 Integrity can be maintained:
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

15
3. System Implementation

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. System Design & Development

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.

16
TABLE STRUCTURE

 LOGIN DETAILS

 SAMPLE DATA

17
 INFO TABLE

 SAMPLE DATA

18
 RECORD TABLE

 SAMPLE DATA

19
(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{

20
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.getString
("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.ActionEvent
evt) {
new manageAcc().setVisible(true);

21
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:

22
(2) START PAGE

CODING:

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

this.dispose();

23
(3) LOADING PAGE

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

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

24
(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:

25
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.ActionEv
ent 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.ActionEvent
evt) {
this.dispose();

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

26
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEvent
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.ActionEvent
evt) {
this.dispose();

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

27
(5) TICKET BOOKING

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);

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

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);

*/

29
}

// TODO add your handling code here:

private void
netAmountBTNActionPerformed(java.awt.event.ActionEvent
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();

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

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

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

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:

31
System.out.println("insert into records
values("+PNR+",'"+name+"',"+age+",'"+sex+"','"+train+"','"+date+"','"+board+"','"+desti
nation+"',"+acType+");");

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){

newRecord = stmt.executeUpdate("insert into records


values("+PNR+",'"+name+"',"+age+",'"+sex+"','"+train+"','"+date+"','"+board+"','"+desti
nation+"',"+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);

32
// 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.ActionEvent
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.ActionEvent
evt) {
this.dispose();

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

private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEvent
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.ActionEvent
evt) {
this.dispose();

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

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

34
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:

35
(6) CANCEL TICKET

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) {

36
PNR=Integer.parseInt(JOptionPane.showInputDialog("ENTER YOUR PNR
NUMBER")); // TODO add your handling code here:

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();

Connection con = (Connection)


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

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery(query);

37
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");

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);

38
}

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

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:

39
private void
CancelTicketMIActionPerformed(java.awt.event.ActionEvent
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.ActionEvent
evt) {
this.dispose();

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


here:

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

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

40
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.ActionEvent
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:

41
(7) DISPLAY RECORD

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) {

42
DefaultTableModel model = (DefaultTableModel) recordTBL.getModel();

int rows = model.getRowCount();

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){

43
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");

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:

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

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

private void
CancelTicketMIActionPerformed(java.awt.event.ActionEvent
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.ActionEvent
evt) {
this.dispose();

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


here:

45
private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEvent
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.ActionEvent
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:

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

47
(8) GET TRAIN INFO

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.ActionEvent
evt) {

48
String tname =(String) trainRB.getSelectedItem();

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 = 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());

49
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.ActionEvent
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.ActionEvent
evt) {
this.dispose();

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


here:

50
}

private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEvent
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.ActionEvent
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:

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

52
(9) ADD TRAIN INFO

IMPORT COMMAND:

import java.sql.*;

import javax.swing.JOptionPane;

CODING:

53
private void
Get_train_infoBTNActionPerformed(java.awt.event.ActionEvent
evt) {
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());

54
}

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

// 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.ActionEvent
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:

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

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


here:

private void
checkTrainInfoMIActionPerformed(java.awt.event.ActionEvent
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.ActionEvent
evt) {
this.dispose();

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

56
}

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:

57
(10) CREATE NEW ID

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());

58
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)

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");

59
if (choice==0)

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: }

60
BIBLIOGRAPHY

 Informatics Practices – XI by Sumita Arora


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

61
RAILWAY
RESERVATION
SYSTEM

THE END

62

Das könnte Ihnen auch gefallen