0% found this document useful (0 votes)
128 views51 pages

Railway Akhil Aditya 2013

This document summarizes a project report submitted by Akhil Goel and Aditya Joshi for their All India Senior School Certificate Examination. The report details the development of a Railway Reservation System project, including its objectives to computerize railway reservations and maintain train, fare, and PNR number details. It describes the hardware, software, input screen designs, source code, and data dictionary used to develop the system according to requirements.

Uploaded by

Aditya Joshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views51 pages

Railway Akhil Aditya 2013

This document summarizes a project report submitted by Akhil Goel and Aditya Joshi for their All India Senior School Certificate Examination. The report details the development of a Railway Reservation System project, including its objectives to computerize railway reservations and maintain train, fare, and PNR number details. It describes the hardware, software, input screen designs, source code, and data dictionary used to develop the system according to requirements.

Uploaded by

Aditya Joshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 51

Project Report on

submitted to
Step by Step High School
3, Chitrakoot Scheme
JAIPUR
in partial fulfillment
of the requirements for

All India Senior School


Certificate Examination 2013
of

Central Board of Secondary Education


Submitted by:

Akhil Goel

(Roll No.: ___________)

Aditya Joshi (Roll No.: ___________)

Acknowledgement
We would like to thank everyone who helped me to accomplish this project.

Our sincere thanks to our family members and respected teachers, who have
helped us with their valuable suggestions and support throughout the
development of the project.

We are highly thankful to our project guide Ms. Shakuntala for providing
guidance and support at every stage of the project.

We are extremely grateful to Mrs. Jayshree Periwal, Director and Mrs.


Madhu Maini, Principal of STEP BY STEP HIGH SCHOOL, JAIPUR, for
providing us a very good computer lab, due to which this project became
possible.

Akhil Goel
&
Aditya Joshi

CERTIFICATE OF ORIGINALITY
This is to certify that the project report entitled Railway Project submitted to
STEP

BY

STEP HIGH SCHOOL in partial fulfillment of the requirement for All

India Senior School Certificate Examination (AISSCE) 2013 of


CBSE, is original work carried out by Akhil Goel & Aditya Joshi under my
guidance.

The matter embodied in this project is genuine work done by the


students and has not been submitted of any course of study.

.....
Signature of the Guide
Date:
Name: Ms. Shakuntala
HOD - Computer
STEP BY STEP HIGH SCHOOL
Jaipur

Project Report on Railway Project

Contents

S#

Topic

Page#

Objective & Scope of the Project

Problem Definition

Life Cycle of the Project - ERD

Details of Hardware & Software used

Input Screen Design

Source Code of the Project

20

Data Dictionary

43

Submitted by Akhil Goel & Aditya Joshi

Project Report on Railway Project

Objective & Scope of the Project


Objective
The main objective of the project is to computerize the processing of Railway
Reservations.
This package is useful in maintaining Train information, Fare information and
PNR number Details.

Scope
This is a mini project on Railway Reservation System.
Further, it can be easily customized for the use of any other travel agency etc.
This project will help them to create a working system into the latest concept of
paperless office.

Submitted by Akhil Goel & Aditya Joshi

Project Report on Railway Project

Problem Definition
The following case study is to be adopted for the development of project.
The project should provide facility to add/modify the following records:
Train related information
Fare related information
PNR number entries
The project should facilitate the following details on screen:
Ticket Status
Fare Information All and a particular Train both
Train Information
As a developer you are required to design the project and develop it as per
customer needs.
Suitable assumptions can be made during implementation. A proper normalized
database is to be maintained in the RDBMS and the front end is to be developed
using advanced interface controls. User-friendly interface is to be generated.

Submitted by Akhil Goel & Aditya Joshi

Project Report on Railway Project

Life Cycle of the Project


System Development Life Cycle (SDLC)
The System Development Life Cycle (SDLC) is a set of activities that analysts,
designers and users carry out to develop and implement an Information System.
The SDLC consists of the following activities.
Feasibility Study
Requirement Definition (Analysis)
Design (Database & Program)
Development of Software
Unit Testing
System Testing
Implementation
Evaluation
Maintenance

Submitted by Akhil Goel & Aditya Joshi

Project Report on Railway Project

Details of Hardware & Software used


Platform

Windows 7

Tools

Java Netbeans 6.7

RDBMS

MySQL

Hardware Specifications
Microprocessor(CPU)

Dual Core

Memory (RAM)

4 GB

Virtual Memory

32-bit

Hard Disk

500 GB

VDU

SVGA

Keyboard

Standard 104 Keys

Mouse

Standard 2-buttons Mouse (Scroll)

Printer

Inkjet / Laser

Operating System

Windows 7

Front-End Design

Java NetBeans 6.7

Back-End

MySQL

Documentation

Microsoft Word 2007

Software Specifications

Submitted by Akhil Goel & Aditya Joshi

Project Report on Railway Project

INPUT
FORMS

Submitted by Akhil Goel & Aditya Joshi

Project Report on Railway Project

On Pressing the Administrator Button, we get the


following screen:

Submitted by Akhil Goel & Aditya Joshi

Project Report on Railway Project

By entering the Password (which is railway) and


pressing the enter button, the following screen is
displayed:

Submitted by Akhil Goel & Aditya Joshi

Project Report on Railway Project

Submitted by Akhil Goel & Aditya Joshi

Project Report on Railway Project

On Pressing the Passenger Button, we get the following


screen:

Submitted by Akhil Goel & Aditya Joshi

10

Project Report on Railway Project

On clicking on the TRAIN INFORMATION menu, the


following items are displayed:

On Selecting the Train Information menu item, we get


the information of all the trains

Submitted by Akhil Goel & Aditya Joshi

11

Project Report on Railway Project

On selecting the Particular Train Information, we get the


following screen:

Submitted by Akhil Goel & Aditya Joshi

12

Project Report on Railway Project

On clicking the Ticket Menu Item, we get the following


option and on selecting the New Ticket option,

And we get an auto generated PNR Number

Submitted by Akhil Goel & Aditya Joshi

13

Project Report on Railway Project

On clicking the Ticket Status menu item, we get the


following screen:

On clicking the Get Status Button a new screen with all


the details appears:

Submitted by Akhil Goel & Aditya Joshi

14

Project Report on Railway Project

Submitted by Akhil Goel & Aditya Joshi

15

Project Report on Railway Project

On selecting the Cancel Ticket Menu Item, the following


screen appears:

On clicking the Cancel Ticket Button the ticket with this


PNR Number will get cancelled.

Submitted by Akhil Goel & Aditya Joshi

16

Project Report on Railway Project

On selecting the Edit Ticket option from the Ticket


Menu, the following screen appears:

Submitted by Akhil Goel & Aditya Joshi

17

Project Report on Railway Project

On selecting the NEW Menu, the following Menu is


displayed:

On selecting the Train Entry option:

Submitted by Akhil Goel & Aditya Joshi

18

Project Report on Railway Project

On selecting the EDIT Menu, the following Menu is


displayed:

On selecting the Train Information Item we can edit the


information of trains in our system

Submitted by Akhil Goel & Aditya Joshi

19

Project Report on Railway Project

On selecting the Delete Train option, we get the


following screens so that we can delete a train entry.

Submitted by Akhil Goel & Aditya Joshi

20

Project Report on Railway Project

Submitted by Akhil Goel & Aditya Joshi

21

Project Report on Railway Project

On selecting the ABOUT Menu, we get the information


of the Railway Reservation System Project.

Submitted by Akhil Goel & Aditya Joshi

22

Project Report on Railway Project

Source
Code

Submitted by Akhil Goel & Aditya Joshi

23

Project Report on Railway Project

Source Code of the Initial Check Form:-

private void
passengerActionPerformed(java.awt.event.ActionEvent evt) {
new main().setVisible(true);
}
private void
adminActionPerformed(java.awt.event.ActionEvent evt) {
new password().setVisible(true);
}

Source Code of the Password Form:-

import javax.swing.JOptionPane;
private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
}

Submitted by Akhil Goel & Aditya Joshi

24

Project Report on Railway Project


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String pass = textPass.getText();
if(pass.equals("railway"))
{
new Admin_main().setVisible(true);
}
else
{
password");
}
}

JOptionPane.showMessageDialog(this,"please enter the correct

Source Code of the Admin_Main Form:-

private void jMenu5MouseClicked(java.awt.event.MouseEvent evt)


{
//Code for exit button
System.exit(0);
}
private void
jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
new train_information().setVisible(true);
}
private void
jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {
new trainentry().setVisible(true);
}

Submitted by Akhil Goel & Aditya Joshi

25

Project Report on Railway Project


private void
jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new parttrain().setVisible(true);
}
private void
jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new TcketStatus().setVisible(true);
}
private void
jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new CancelTicket().setVisible(true);
}
private void
jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new trainedit().setVisible(true);
}
private void
jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new pnrentry().setVisible(true);
}
private void
jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new deletetrain().setVisible(true);
}
private void
jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new pnredit().setVisible(true);
}

Submitted by Akhil Goel & Aditya Joshi

26

Project Report on Railway Project

Source Code of the main form:-

private void
jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new train_information().setVisible(true);
}
private void
jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new parttrain().setVisible(true);
}
private void jMenu2MouseClicked(java.awt.event.MouseEvent
evt) {
// TODO add your handling code here:
new TcketStatus().setVisible(true);
}
private void jMenu5MouseClicked(java.awt.event.MouseEvent
evt) {
//Code for exit button
System.exit(0);
}
private void jMenu4MouseClicked(java.awt.event.MouseEvent
evt) {
// TODO add your handling code here:
new about().setVisible(true);
}

Submitted by Akhil Goel & Aditya Joshi

27

Project Report on Railway Project

Source Code of Train_Information form:-

import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public train_information() {
initComponents();
try
{
Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/infor
mation","root","");
Statement st = con.createStatement();
String sql = "SELECT * FROM RAILWAY";
ResultSet rs = st.executeQuery(sql);
DefaultTableModel model = (DefaultTableModel)
jTable1.getModel();
int rows = model.getRowCount();
if(rows>0)
{
for(int i = 0; i<rows;i++)
model.removeRow(0);
}
while(rs.next())
{
model.addRow(new Object[]
{rs.getString(1),rs.getString(2),

Submitted by Akhil Goel & Aditya Joshi

28

Project Report on Railway Project


rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6
),rs.getString(7)});
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this,e.getMessage());
}
}

Source Code for parttrain form:-

import
import
import
public

java.sql.*;
javax.swing.DefaultComboBoxModel;
javax.swing.JOptionPane;
parttrain() {
initComponents();
try
{
Class.forName("java.sql.DriverManager");

Submitted by Akhil Goel & Aditya Joshi

29

Project Report on Railway Project


Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/infor
mation","root","");
Statement st = con.createStatement();
String sql = "SELECT TR_NAME FROM RAILWAY";
ResultSet rs = st.executeQuery(sql);
DefaultComboBoxModel model =
(DefaultComboBoxModel) jComboBox1.getModel();
while(rs.next())
model.addElement(rs.getString(1));
jComboBox1.setModel(model);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this,e.getMessage());
}
}
private void
jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
}
private void
jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
String a = (String) jComboBox1.getSelectedItem();
try
{
Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/infor
mation","root","");
Statement st = con.createStatement();
String sql = "SELECT * FROM RAILWAY WHERE TR_NAME
= '"+a+"'";
ResultSet rs = st.executeQuery(sql);
while(rs.next())
{
trno.setText(rs.getString(1));
trname.setText(rs.getString(2));
startcode.setText(rs.getString(3));
depttime.setText(rs.getString(4));
dest.setText(rs.getString(5));
arrtime.setText(rs.getString(6));
days.setText(rs.getString(7));
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this,e.getMessage());
}
}
Submitted by Akhil Goel & Aditya Joshi

30

Project Report on Railway Project

Source Code for TcketStatus form:-

public static double a;


private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
pnrno.setText("");
}
private void
getstatActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
a =
Double.parseDouble( pnrno.getText());
new pnrstat().setVisible(true);

}
private void
jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.dispose();
}

Submitted by Akhil Goel & Aditya Joshi

31

Project Report on Railway Project

Source Code for pnrstat form:-

import
import
double
public

javax.swing.JOptionPane;
java.sql.*;
b = TcketStatus.a;
pnrstat() {
initComponents();
txtpnr.setText(""+b);
try
{
Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/infor
mation","root","");
Statement st = con.createStatement();
String pnrno1 = txtpnr.getText();
String sql = "SELECT * FROM PNR WHERE
PNR_NO="+pnrno1;
ResultSet rs = st.executeQuery(sql);
rs.next();
String a,b,c,d,e,f,g;
a=rs.getString(3);
b=rs.getString(1);
c=rs.getString(2);
d=rs.getString(13);
e=rs.getString(14);
f=rs.getString(15);
g=rs.getString(4);
txtpnr.setText(a);
txttrno.setText(b);
txttrname.setText(c);
Submitted by Akhil Goel & Aditya Joshi

32

Project Report on Railway Project


txtclass.setText(d);
txtstart.setText(e);
txtend.setText(f);
txtposition.setText(g);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this,e.getMessage());
}
}
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
TcketStatus.jButton3.doClick();
}

Source Code for pnrentry form:-

import javax.swing.JOptionPane;
import java.sql.*;
import java.util.Random;
private String Trname;
private String origin;
private String dept;
private long l;
public pnrentry() {
initComponents();
txtage1.setVisible(false);
combogen1.setVisible(false);
txtage2.setVisible(false);
combogen2.setVisible(false);
Submitted by Akhil Goel & Aditya Joshi

33

Project Report on Railway Project


txtage3.setVisible(false);
combogen3.setVisible(false);
txtage4.setVisible(false);
combogen4.setVisible(false);
p1age.setVisible(false);
p1gen.setVisible(false);
p2age.setVisible(false);
p2gen.setVisible(false);
p3age.setVisible(false);
p3gen.setVisible(false);
p4age.setVisible(false);
p4gen.setVisible(false);
combogen1.setSelectedIndex(0);
combogen2.setSelectedIndex(0);
combogen3.setSelectedIndex(0);
combogen4.setSelectedIndex(0);
l = generateRandom(10);
System.out.print(l);
}
public static long generateRandom(int length) {
Random random = new Random();
char[] digits = new char[length];
digits[0] = (char) (random.nextInt(9) + '1');
for (int i = 1; i < length; i++) {
digits[i] = (char) (random.nextInt(10) + '0');
}
return Long.parseLong(new String(digits));
}
private void addActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
if(txtage1.isVisible())
{
if(txtage2.isVisible())
{
if(txtage3.isVisible())
{
if(txtage4.isVisible())
JOptionPane.showMessageDialog(this,"Sorry No More Passenger
are allowed");
else
{
txtage4.setVisible(true);
txtage4.setText("");
combogen4.setVisible(true);
p4age.setVisible(true);
Submitted by Akhil Goel & Aditya Joshi

34

Project Report on Railway Project


p4gen.setVisible(true);
}
}
else
{
txtage3.setVisible(true);
txtage3.setText("");
combogen3.setVisible(true);
p3age.setVisible(true);
p3gen.setVisible(true);
}
}
else
{
txtage2.setVisible(true);
txtage2.setText("");
combogen2.setVisible(true);
p2age.setVisible(true);
p2gen.setVisible(true);
}
}
else
{
txtage1.setVisible(true);
txtage1.setText("");
combogen1.setVisible(true);
p1age.setVisible(true);
p1gen.setVisible(true);
}
}
private void txttrnoFocusGained(java.awt.event.FocusEvent
evt) {
// TODO add your handling code here:
add.setEnabled(true);
}
private void txttrnoFocusLost(java.awt.event.FocusEvent
evt) {
// TODO add your handling code here:
if(txttrno.getText().isEmpty())
{
JOptionPane.showMessageDialog(this,"Please Enter
the Train Number") ;
add.setEnabled(false);
txtage1.setVisible(false);
combogen1.setVisible(false);
txtage2.setVisible(false);
combogen2.setVisible(false);
txtage3.setVisible(false);
combogen3.setVisible(false);
Submitted by Akhil Goel & Aditya Joshi

35

Project Report on Railway Project


txtage4.setVisible(false);
combogen4.setVisible(false);
p1age.setVisible(false);
p1gen.setVisible(false);
p2age.setVisible(false);
p2gen.setVisible(false);
p3age.setVisible(false);
p3gen.setVisible(false);
p4age.setVisible(false);
p4gen.setVisible(false);
txtage1.setText("");
combogen1.setSelectedIndex(0);
txtage2.setText("");
combogen2.setSelectedIndex(0);
txtage3.setText("");
combogen3.setSelectedIndex(0);
txtage4.setText("");
combogen4.setSelectedIndex(0);
}
else
{
add.setVisible(true);
}
}
private void
add1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try
{
Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/infor
mation","root","");
Statement st = con.createStatement();
Statement st1 = con.createStatement();
String trname = "Select
tr_name,origincode,destinationcode from railway where
trainno="+txttrno.getText();
ResultSet rs = st1.executeQuery(trname);
rs.next();
String Trname = rs.getString(1);
String origin = rs.getString(2);
String dept = rs.getString(3);
System.out.print(Trname);
System.out.print(origin);
Submitted by Akhil Goel & Aditya Joshi

36

Project Report on Railway Project


System.out.print(dept);
String sql="INSERT INTO PNR
VALUES("+txttrno.getText()
+",'"+Trname+"',"+l+",'WAITING','"+txtage1.getText()
+"','"+combogen1.getSelectedItem()+"','"+txtage2.getText()
+"','"+combogen2.getSelectedItem()+"','"+txtage3.getText()
+"','"+combogen3.getSelectedItem()+"','"+txtage4.getText()
+"','"+combogen4.getSelectedItem()
+"','"+comboclass.getSelectedItem()
+"','"+origin+"','"+dept+"')";
st.executeUpdate(sql);
JOptionPane.showMessageDialog(this,"Ticket
Entered");
JOptionPane.showMessageDialog(this,"PNR Number
= "+l);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this,e.getMessage());
}
}

Source code for CancelTicket form:-

import javax.swing.JOptionPane;
import java.sql.*;
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try
{
Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/infor
mation","root","");
Statement st = con.createStatement();
Submitted by Akhil Goel & Aditya Joshi

37

Project Report on Railway Project


String pnrno1 = pnrno.getText();
String sql = "DELETE FROM PNR WHERE
PNR_NO="+pnrno1;
JOptionPane.showConfirmDialog(this,"Do You
Really Want to Cancel this Ticket?");
if(JOptionPane.YES_OPTION==0)
{
st.executeUpdate(sql);
JOptionPane.showMessageDialog(this,"Ticket
Cancelled");
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this,e.getMessage());
}
}
private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.dispose();
}

Source code for pnredit form:-

Submitted by Akhil Goel & Aditya Joshi

38

Project Report on Railway Project


import javax.swing.JOptionPane;
import java.sql.*;
Double pnrno;
String clas =
null,p1age,p1gen,p2age,p2gen,p3age,p3gen,p4age,p4gen,pos;
private void findActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
pnrno = Double.parseDouble(txtpnrno.getText());
txtpnrno.setEditable(false);
txtage1.setText("");
combogen1.setSelectedIndex(0);
txtage2.setText("");
combogen2.setSelectedIndex(0);
txtage3.setText("");
combogen3.setSelectedIndex(0);
txtage4.setText("");
combogen4.setSelectedIndex(0);
txtpos.setText("");
txtage1.setEditable(true);
combogen1.setEditable(true);
txtage2.setEditable(true);
combogen2.setEditable(true);
txtage3.setEditable(true);
combogen3.setEditable(true);
txtage4.setEditable(true);
combogen4.setEditable(true);
txtpos.setEditable(true);
try{
Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/infor
mation","root","");
Statement st = con.createStatement();
String sql = "SELECT * FROM PNR WHERE PNR_NO = "+pnrno;
ResultSet rs = st.executeQuery(sql);
rs.next();
clas = rs.getString(13);
p1age = rs.getString(5);
p1gen = rs.getString(6);
p2age = rs.getString(7);
p2gen = rs.getString(8);
p3age = rs.getString(9);
p3gen = rs.getString(10);
p4age = rs.getString(11);
p4gen = rs.getString(12);
pos = rs.getString(4);
comboclass.setSelectedItem(clas);
txtage1.setText(""+p1age);
Submitted by Akhil Goel & Aditya Joshi

39

Project Report on Railway Project


combogen1.setSelectedItem(p1gen);
txtage2.setText(""+p2age);
combogen2.setSelectedItem(p2gen);
txtage3.setText(""+p3age);
combogen3.setSelectedItem(p3gen);
txtage4.setText(""+p4age);
combogen4.setSelectedItem(p4gen);
txtpos.setText(""+pos);
edit.setEnabled(true);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this,e.getMessage());
}
}
private void
editActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try
{
Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/infor
mation","root","");
Statement st = con.createStatement();
pnrno = Double.parseDouble(txtpnrno.getText());
clas = (String) comboclass.getSelectedItem();
p1age =txtage1.getText();
p1gen = (String) combogen1.getSelectedItem();
p2age =txtage2.getText();
p2gen = (String) combogen2.getSelectedItem();
p3age =txtage3.getText();
p3gen = (String) combogen3.getSelectedItem();
p4age =txtage4.getText();
p4gen = (String) combogen4.getSelectedItem();
pos = txtpos.getText();
String sql = "UPDATE PNR SET clas =
'"+clas+"',p1age = "+p1age+",p1gen = '"+p1gen+"',p2age =
"+p2age+",p2gen =
'"+p2gen+"',p3age="+p3age+",p3gen='"+p3gen+"',p4age =
"+p4age+",p4gen = '"+p4gen+"',position='"+pos+"' where pnr_no
= "+pnrno;
st.executeUpdate(sql);
JOptionPane.showMessageDialog(this,"PNR
Edited");
}
catch(Exception e)
{

Submitted by Akhil Goel & Aditya Joshi

40

Project Report on Railway Project


JOptionPane.showMessageDialog(this,e.getMessage());
}
}
private void
find1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
txtpnrno.setText("");
txtpnrno.setEditable(true);
txtage1.setText("");
combogen1.setSelectedIndex(0);
txtage2.setText("");
combogen2.setSelectedIndex(0);
txtage3.setText("");
combogen3.setSelectedIndex(0);
txtage4.setText("");
combogen4.setSelectedIndex(0);
txtpos.setText("");
txtage1.setEditable(false);
combogen1.setEditable(false);
txtage2.setEditable(false);
combogen2.setEditable(false);
txtage3.setEditable(false);
combogen3.setEditable(false);
txtage4.setEditable(false);
combogen4.setEditable(false);
txtpos.setEditable(false);
}
private void
find2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.dispose();
}

Submitted by Akhil Goel & Aditya Joshi

41

Project Report on Railway Project

Source Code for trainentry form:-

import java.sql.*;
import javax.swing.JOptionPane;
private void
jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
}
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/infor
mation", "root", "");
String
no1,name1,or1,deptime1,dest1,arrtime1,daysrun1;
no1 = no.getText();
name1 = name.getText();
or1 = or.getText();
deptime1 = depttime.getText();
dest1 = dest.getText();
arrtime1 = arrtime.getText();
daysrun1 = daysrun.getText();
Statement st = con.createStatement();

Submitted by Akhil Goel & Aditya Joshi

42

Project Report on Railway Project


String sql ="INSERT INTO RAILWAY
VALUES("+no1+",'"+name1+"','"+or1+"','"+deptime1+"','"+dest1+"
','"+arrtime1+"','"+daysrun1+"')";
st.executeUpdate(sql);
JOptionPane.showMessageDialog(this, "Train
Added");
no.setText("");
name.setText("");
or.setText("");
depttime.setText("");
dest.setText("");
arrtime.setText("");
daysrun.setText("");
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this,
e.getMessage());
}
}

Source code for trainedit form:-

import java.sql.*;
import javax.swing.JOptionPane;

Submitted by Akhil Goel & Aditya Joshi

43

Project Report on Railway Project


private void
jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
}
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/infor
mation", "root", "");
String
no1,name1,or1,deptime1,dest1,arrtime1,daysrun1;
no1 = no.getText();
name1 = name.getText();
or1 = or.getText();
deptime1 = depttime.getText();
dest1 = dest.getText();
arrtime1 = arrtime.getText();
daysrun1 = daysrun.getText();
Statement st = con.createStatement();
String sql ="UPDATE RAILWAY SET
TR_NAME='"+name1+"',ORIGINcode='"+or1+"',DEPtTIME='"+deptime1+
"',DESTINATIONcode='"+dest1+"',ARRTIME='"+arrtime1+"',DAYSRUN=
'"+daysrun1+"' where trainno= "+no1;
st.executeUpdate(sql);
JOptionPane.showMessageDialog(this, "Train
Edited");
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this,
e.getMessage());
}
}
private void
jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
try {
Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/infor
mation", "root", "");
String no1 = no.getText();
Statement st = con.createStatement();
String sql = "SELECT * FROM RAILWAY WHERE Trainno
= "+no1;
ResultSet rs = st.executeQuery(sql);
while(rs.next())
{
Submitted by Akhil Goel & Aditya Joshi

44

Project Report on Railway Project


no.setText(rs.getString(1));
name.setText(rs.getString(2));
or.setText(rs.getString(3));
depttime.setText(rs.getString(4));
dest.setText(rs.getString(5));
arrtime.setText(rs.getString(6));
daysrun.setText(rs.getString(7));
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage());

}
}

Source code for deletetrain form:-

import java.sql.*;
import javax.swing.JOptionPane;
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
try{
Class.forName("java.sql.DriverManager");
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/information
","root","");
Statement st = con.createStatement();
String trno = txttrno.getText();
String sql = "DELETE FROM RAILWAY WHERE
TrainNo="+trno;
JOptionPane.showConfirmDialog(this,"Do You Really
Want to Cancel this Ticket?");
if(JOptionPane.YES_OPTION==0)
{
st.executeUpdate(sql);
JOptionPane.showMessageDialog(this,"Ticket Cancelled");

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

Submitted by Akhil Goel & Aditya Joshi

45

Project Report on Railway Project

Data Dictionary
Various tables used in this project are as follows:

S#

Table Name

Uses

RAILWAY

to store the TRAIN Details

PNR

to store the PNR status details

RAILWAY
Data Name

Data Type

Size

TR_NO

Numeric

TR_NAME

Varchar

20

ORIGIN

Varchar

20

DEP_TIME

Numeric

5,2

DESTINATIO
N

Varchar

20

ARR_TIME

Numeric

5,2

DAYS_RUN

Varchar

30

PNR
Size

Data Name

Data Type

PNRNO

Numeric

NAME

Varchar

25

POSITION

Varchar

25

Submitted by Akhil Goel & Aditya Joshi

Remarks
Primary Key

Remarks
Primary Key

46

Project Report on Railway Project

Submitted by Akhil Goel & Aditya Joshi

47

You might also like