You are on page 1of 85

1

TERMPAPER:-RAILWAY TICKET RESERVATION

COURSE CODE: - CAP 407

COURSE INSTRUCTOR: -: PANKAJ SHARMA

COURSE TUTOR:-NONE

D.O.A:-10/02/2010

D.O.D:-12/05/2010

STUDENT ROLLNO: - 19

SECTION: - D3802

DECLARATION:

I declare that this term paper is my individual work. I have not copied from any student work or
from any other source accept due acknowledgement is made explicitly in the text nor has a any
part being written for by another person.

EVALUATORS COMMENTS:

STUDENT SIGNATURE:

PYARELAL KUMAR
2

Certificate

This is to certify that the Minor Project entitled “RAILWAY TICKET RESERVATION” is
bonfires work done by pyarelal Kumar, under Mr. Pankaj Sharma guidance in partial fulfillment of the

requirements of the projects in RAILWAY TICKET RESERVATION.

Pyarelal Kumar
Date 10/02/2010
Place Jalandhar
3

Declaration

I hereby declare that this project report on, “RAILWAY TICKET RESERVATION” as
a partial fulfillment for the work carried out by me under the guidance of pankaj Sharma.
Associate of faculty of Lovely professional university of jalandhar. I further declare that this
project word has not been submitted anywhere else for any purpose.

Date: 02/05/2010

Place: Jalandhar pyarelal Kumar


4

Acknowledgement
I am thankful to Mr. Pankaj Sharma, faculty member of lovely professional university, jalandhar,
for suggesting the topic for this minor project. I gratefully express my profound sense of
gratitude and indebtedness to him, for inspiring guidance, encouragement and continuous
support. Her helpful suggestions and valuable advice enabled me to complete my project
successfully.
I am also grateful to all member of lovely professional university, Project Assistants, Project
Trainees and my Co-trainees for their continuous encouragement and help in completing this
project.

Likewise I am indebted to my family members and friends for their encouragement and
assistance in this project work.

(Pyarelal Kumar)
5

Abstract
Inasmuch as journalism is involved, new media complements other media in regard to
influencing the shape and space of press freedom. At the same time, the freedom of new media -
like other media - is dynamically related to the overall societal context as regards press freedom
dispensations. Old and new media realms do have different issues, and there are particular
matters for developing countries. But there is also much in common between old and new media,
and between developing and developed countries, and all have interdependent interests in a free
environment for journalism.
6

TABLE OF CONTENTS

1. DFD (Data Flow Diagram)

1.2 DFD for Railway Reservation and Confirmation.

1.2 DFD for Train Records.

1.3 DFD for Station Records.

1.4 1.4 DFD for Railway Reservation System.

1.5 E-R Diagram of Railway Reservation System

2. CODING

3. BIBLIOGRAPHY AND REFERENCES

1. DFD (Data Flow Diagram)


1. DFD for Railway Reservation and Confirmation

2. DFD for Train Records

3. DFD for Station Records

4. DFD for Railway Reservation System


7

1.1 DFD for Railway Reservation and


Confirmation:

TICKET
RAILWAY

DATABASE

Reservation 2
Form
Verify

1.1 1.2
1.3 2.1 2.2 TICKET
Passenger Get
Reserve Confirm Cancel
Details Amount
RAILWAY
TRAIN
DATABASE
1.2 DFD for Train Records:
1

Train
Records

1.3
1.1 1.2
Train
Modify Delete Fair

TRAIN
8

1.3 DFD for Station Records: RAILWAY


STATION
DATABASE

Station
Records

1.1 1.2

Modify Delete

STATION
9

1.4 DFD for Railway Reservation System:

CUSTOMER

RAILWAY

DATABASE

Reservation 2 2.1
Counter
Reservation Available
10

TICKET

2.1
2.2
Available
Not
Available

1.5 E-R Diagram of Railway Reservation System

CUSTOMER

Train Applicant
P.N.R Name
P.N.R Age
No. Name Seat No.

PASSENGER
DETAILS

agains
RESERVATION t

in
Above
2000

TRAIN FARE INFO.


Class
Train
No.
11

Arrival
Time

TRAIN RECORDS
Has

Train
Name

SEAT RECORD
Has

Train No.

Free Seats
Train
Class
No.

2.) CODING

Form1 - Welcome.frm (Welcome Screen)

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

frmLogin.Show

End Sub

Private Sub Form_Unload(Cancel As Integer)

End

End Sub

Private Sub Timer1_Timer()

Label1.ForeColor = QBColor(Rnd * 15)

End Sub
12

Private Sub Timer2_Timer()

frmLogin.Show

Timer2.Enabled = False

End Sub

Form2 - Reservation.frm (Reservation Form)

Dim pnr As Integer

Dim rec1 As New Recordset

Dim rec As New Recordset

Dim rec2 As New Recordset

Private Sub cmdback_Click()

Unload Me

End Sub

Private Sub cmdcancel_Click()

txtpnr.Text = ""

txttrainname.Text = ""

txttrainno.Text = ""

txtdate.Text = ""

comboclass.Text = ""

combofrom.Text = ""

comboto.Text = ""

txtnoberth.Text = ""
13

txtboggieno.Text = ""

txtamount.Text = ""

txtaddress.Text = ""

txttelno.Text = ""

txtname.Text = ""

txttrainname.Locked = True

txttrainno.Locked = True

txtdate.Locked = True

comboclass.Locked = True

combofrom.Locked = True

comboto.Locked = True

txtnoberth.Locked = True

txtboggieno.Locked = True

txtamount.Locked = True

txtaddress.Locked = True

txttelno.Locked = True

txtname.Locked = True

cmdsave.Enabled = False

cmdgetamtno.Enabled = False

cmdcancel.Enabled = False

cmdpassendetails.Enabled = False

cmdNew.Enabled = True

End Sub

Private Sub cmdgetamtno_Click()


14

If IsNumeric(txttelno.Text) = False Then

MsgBox "Enter numeric data for telephone number"

txttelno.Text = ""

txttelno.SetFocus

End If

If IsNumeric(txtname.Text) Then

MsgBox "Enter valid name"

txtname.Text = ""

txtname.SetFocus

End If

Dim get_km, amt, tot_amt As Long

Dim a As Integer

Dim berth As Integer

berth = Val(txtnoberth)

If txtnoberth.Text = "" Or txttrainno.Text = "" Or comboclass.Text = "Select Class" Then

MsgBox "Enter Train no, Class & number of berths", vbDefaultButton2, "Reservation Record"

Exit Sub

End If

Set rec2 = New Recordset

rec2.Source = "select * from station_distance where source_station='" & combofrom.Text & "'"
& "and dest_station= '" & comboto.Text & "'"

rec2.CursorLocation = adUseClient

rec2.CursorType = adOpenDynamic

rec2.LockType = adLockOptimistic

rec2.Open , conn
15

If rec2.BOF And rec2.EOF Then

a = MsgBox("Distance From One Station to another station is not defined so amount cannot be
calculated " & vbCrLf & "Enter Distance !", vbInformation, "Railway Amount Calculation
Record")

Exit Sub

End If

get_km = rec2(2)

rec2.Close

Set rec1 = New Recordset

rec1.Source = "select * from train_fare_info where train_no=" & txttrainno.Text & "and class= '"
& comboclass.Text & "'"

rec1.CursorLocation = adUseClient

rec1.CursorType = adOpenDynamic

rec1.LockType = adLockOptimistic

rec1.Open , conn

If get_km <= 100 Then

amt = rec1(4)

ElseIf get_km > 100 And get_km <= 500 Then

amt = rec1(5)

ElseIf get_km > 500 And get_km <= 1000 Then

amt = rec1(6)

ElseIf get_km > 1000 And get_km <= 2000 Then

amt = rec1(7)

Else

amt = rec1(8)

End If
16

tot_amt = amt * berth

txtamount.Text = tot_amt

rec1.Close

End Sub

Private Sub cmdNew_Click()

txttrainname.Locked = False

'txttrainno.Locked = False

txtdate.Locked = False

comboclass.Locked = False

combofrom.Locked = False

comboto.Locked = False

txtnoberth.Locked = False

txtboggieno.Locked = False

txtamount.Locked = False

txtaddress.Locked = False

txttelno.Locked = False

txtname.Locked = False

If rec.BOF And rec.EOF Then

pnr = 1

Else

rec.MoveLast

pnr = rec(0)

pnr = pnr + 1

End If
17

txtpnr.Text = pnr

txtpnr.SetFocus

cmdcancel.Enabled = True

cmdsave.Enabled = True

cmdgetamtno.Enabled = True

cmdNew.Enabled = False

End Sub

Private Sub cmdpassendetails_Click()

If txtnoberth.Text = "" Or txttrainno.Text = "" Or comboclass.Text = "Select Class" Then

MsgBox "Enter Train no, Class & number of berths", vbDefaultButton2, "Reservation Record"

Exit Sub

End If

If Val(txtnoberth) > 6 Then

MsgBox "Number of Berth Cannot exceed from 6", vbCritical, "Number of Berth Record"

txtnoberth.Text = ""

txtnoberth.SetFocus

Exit Sub

End If

Form11.txtpnr = txtpnr.Text

Form11.total.Caption = txtnoberth

Form11.Show

End Sub

Private Sub cmdsave_Click()


18

If (txttrainname.Text = "" Or txttrainno.Text = "" Or txtdate.Text = "" Or comboclass.Text = ""


Or comboto.Text = "" Or txtnoberth.Text = "" Or txtboggieno.Text = "" Or txtamount.Text = ""
Or txtaddress.Text = "" Or txtname.Text = "" Or combofrom.Text = "") Then

MsgBox ("Fill all the Fields")

Exit Sub

End If

rec.AddNew

rec(0) = txtpnr.Text

rec(1) = txttrainname.Text

rec(2) = txttrainno.Text

rec(3) = txtdate.Text

rec(4) = comboclass.Text

rec(5) = combofrom.Text

rec(6) = comboto.Text

rec(7) = txtnoberth.Text

rec(8) = txtboggieno.Text

rec(9) = txtamount.Text

rec(10) = txtaddress.Text

If (txttelno.Text = "") Then

Else

rec(11) = txttelno.Text

End If

rec(12) = txtname.Text

rec.Update

MsgBox "Reservation is done", vbInformation, "Railway Reservation System"

txttrainname.Text = ""
19

txttrainno.Text = ""

txtdate.Text = ""

comboclass.Text = ""

combofrom.Text = ""

comboto.Text = ""

txtnoberth.Text = ""

txtboggieno.Text = ""

txtamount.Text = ""

txtaddress.Text = ""

txttelno.Text = ""

txtname.Text = ""

txttrainno.Enabled = False

txttrainname.Locked = True

txttrainno.Locked = True

txtdate.Locked = True

comboclass.Locked = True

combofrom.Locked = True

comboto.Locked = True

txtnoberth.Locked = True

txtboggieno.Locked = True

txtamount.Locked = True

txtaddress.Locked = True

txttelno.Locked = True

txtname.Locked = True

cmdNew.Enabled = True
20

End Sub

Private Sub Form_Load()

Set rec = New Recordset

rec.Source = "select * from station_code"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

rec.MoveFirst

While Not rec.EOF

combofrom.AddItem (rec(1))

comboto.AddItem (rec(1))

rec.MoveNext

Wend

rec.Close

Set rec = New Recordset

rec.Source = "select * from reservation"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

End Sub

Private Sub txtnoberth_LostFocus()

If Len(txtnoberth) > 0 Then


21

cmdpassendetails.Enabled = True

Else

cmdpassendetails.Enabled = False

End If

End Sub

Private Sub txtPNR_LostFocus()

txttrainno.Locked = False

txttrainno.Enabled = True

End Sub

Private Sub txttrainno_LostFocus()

Dim train_no As Integer

If txttrainno.Text = "" Then

MsgBox "Enter Train Number", vbCritical, "Train Record"

txttrainno.SetFocus

Exit Sub

End If

train_no = Val(txttrainno)

Set rec1 = New Recordset

rec1.Source = "select * from train_record where train_no=" & train_no

rec1.CursorLocation = adUseClient

rec1.CursorType = adOpenDynamic

rec1.LockType = adLockOptimistic

rec1.Open , conn

If rec1.BOF And rec1.EOF Then

MsgBox "Train no does not exist", vbInformation, "Train Record"


22

Exit Sub

End If

txttrainname.Text = rec1(1)

rec1.Close

Set rec1 = New Recordset

rec1.Source = "select * from train_fare_info where train_no=" & train_no

rec1.CursorLocation = adUseClient

rec1.CursorType = adOpenDynamic

rec1.LockType = adLockOptimistic

rec1.Open , conn

rec1.MoveFirst

comboclass.Clear

While Not rec1.EOF

comboclass.AddItem (rec1(1))

rec1.MoveNext

Wend

rec1.Close

End Sub

Form3 - add train.frm (Add Train Records)

Dim rec As New Recordset

Dim stat_code As Integer

Dim stat_name As String

Dim rec1 As New Recordset


23

Private Sub cmdback_Click()

Unload Me

MDIForm1.Show

End Sub

Private Sub cmdcancel_Click()

Frame1.Enabled = False

cmdsave.Enabled = False

cmdcancel.Enabled = False

cmdNew.Enabled = True

text1.Text = ""

text2.Text = ""

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Text6.Text = ""

Text7.Text = ""

Text8.Text = ""

Text9.Text = ""

text15.Text = ""

text16.Text = ""

combo1.Text = "select code"

combo2.Text = "select code"

combo3.Text = "select station"


24

combo4.Text = "select station"

Combo6.Text = "select class"

End Sub

Private Sub cmdNew_Click()

Frame1.Enabled = True

Command1.Enabled = True

cmdsave.Enabled = True

cmdcancel.Enabled = True

cmdNew.Enabled = False

text1.Enabled = True

text1.Text = ""

text1.SetFocus

End Sub

Private Sub cmdsave_Click()

Dim ans As Variant

If text1.Text = "" Or text2.Text = "" Or text15.Text = "" Or text16.Text = "" Or combo1.Text = ""
Or combo2.Text = "" Or combo3.Text = "" Or combo4.Text = "" Then

MsgBox "Fill the missing entries", vbOKOnly + vbCritical, "Railway Reservation System"

Exit Sub

End If

If combo1.Text = combo2.Text Then

MsgBox "Select Different Stations", vbOKOnly + vbCritical, "Railway Reservation System"

Exit Sub
25

End If

ans = MsgBox("Do you want to save the train information ", vbYesNo + vbDefaultButton3,
"Railway Reservation System ::[Train Record]")

If ans = vbYes Then

Set rec = New Recordset

rec.Source = "select * from train_record"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

rec.AddNew

rec(0) = text1.Text

rec(1) = text2.Text

rec(2) = combo1.Text

rec(3) = combo2.Text

rec(4) = text15.Text

rec(5) = text16.Text

On Error GoTo label

rec.Update

MsgBox "Train Record Scuessfully Saved !", vbOKOnly + vbDefaultButton4, "Railway


Reservation System ::[Train Record]"

rec.Close

Frame1.Enabled = False

cmdsave.Enabled = False

cmdcancel.Enabled = False

cmdNew.Enabled = True
26

text1.Enabled = False

text2.Text = ""

text15.Text = ""

text16.Text = ""

combo1.Text = "Select Station Code"

combo2.Text = "Select Station Code"

combo3.Text = "Select Station Name"

combo4.Text = "Select Station Name"

Exit Sub

label:

MsgBox "Either Train Number Already Exist!", vbCritical, "Railway Reservation System"

End If

End Sub

Private Sub Combo1_click()

stat_code = combo1.Text

Set rec = New Recordset

rec.Source = "select * from station_code where code= " & stat_code

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

combo3.Text = rec(1)

rec.Close
27

End Sub

Private Sub combo2_Click()

stat_code = combo2.Text

Set rec = New Recordset

rec.Source = "select * from station_code where code= " & stat_code

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

combo4.Text = rec(1)

rec.Close

End Sub

Private Sub combo3_Click()

stat_name = combo3.Text

Set rec = New Recordset

rec.Source = "select * from station_code where name like '" & stat_name & "'"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

combo1.Text = rec(0)

rec.Close
28

End Sub

Private Sub combo4_Click()

stat_name = combo4.Text

Set rec = New Recordset

rec.Source = "select * from station_code where name like '" & stat_name & "'"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

combo2.Text = rec(0)

rec.Close

End Sub

Private Sub Command1_Click()

If IsNumeric(text1.Text) = False Then

MsgBox ("Enter numeric data for train number")

text1.Text = ""

text1.SetFocus

Exit Sub

End If

Frame3.Enabled = True

End Sub

Private Sub Command2_Click()

If text1.Text = "" Then


29

MsgBox "Enter Train no. first", vbDefaultButton1, "Railway Fare Details"

Exit Sub

End If

Set rec = New Recordset

rec.Source = "select * from train_fare_info"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

rec.AddNew

rec(0) = text1.Text

rec(1) = Combo6.Text

rec(2) = Text3.Text

rec(3) = Text4.Text

rec(4) = Text5.Text

rec(5) = Text6.Text

rec(6) = Text7.Text

rec(7) = Text8.Text

rec(8) = Text9.Text

rec.Update

Set rec1 = New Recordset

rec1.Source = "select * from seat_record"

rec1.CursorLocation = adUseClient

rec1.CursorType = adOpenDynamic

rec1.LockType = adLockOptimistic
30

rec1.Open , conn

rec1.AddNew

rec1(0) = text1.Text

rec1(1) = Combo6.Text

rec1(2) = Text3.Text

rec1(3) = Text4.Text

rec1(4) = Text3.Text

rec1(5) = Val(Text3) * Val(Text4)

rec1.Update

rec1.Close

MsgBox "Class & Fare detail is Stored !", vbOKOnly, "Railway Fare Details"

Combo6.Text = "Select Class"

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Text6.Text = ""

Text7.Text = ""

Text8.Text = ""

Text9.Text = ""

Command2.Enabled = False

Combo6.SetFocus

End Sub

Private Sub Form_Load()

Set rec = New Recordset


31

rec.Source = "select * from station_code"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

rec.MoveFirst

While rec.EOF = False

combo1.AddItem (rec(0))

combo2.AddItem (rec(0))

combo3.AddItem (rec(1))

combo4.AddItem (rec(1))

rec.MoveNext

Wend

rec.Close

End Sub

Private Sub Text9_KeyPress(KeyAscii As Integer)

Command2.Enabled = True

End Sub
32

Form4 - add station code.frm (Add Station Code)

Dim rec As New Recordset

Dim code As Integer

Private Sub cmdadd_Click()

text1.Text = ""

text2.Text = ""

text1.Locked = False

text1.SetFocus

cmdsave.Enabled = True

cmdcancel.Enabled = True

Command1.Enabled = True

cmdadd.Enabled = False

cmdnext.Enabled = False

cmdprev.Enabled = False

End Sub

Private Sub cmdback_Click()

Unload Me

End Sub

Private Sub cmdcancel_Click()

text1.Text = ""

text1.Locked = True
33

text2.Text = ""

End Sub

Private Sub cmdnext_Click()

If rec.BOF And rec.EOF Then

MsgBox "The Code directory is empty", vbOKOnly, "Railway Confirmation"

Exit Sub

End If

If rec.EOF Then

rec.MoveFirst

text1.Text = rec(1)

text2.Text = rec(0)

Exit Sub

End If

rec.MoveNext

If rec.BOF = False And rec.EOF = False Then

text1.Text = rec(1)

text2.Text = rec(0)

End If

End Sub

Private Sub cmdprev_Click()

If rec.BOF And rec.EOF Then

MsgBox "The Code directory is empty", vbOKOnly, "Railway Confirmation"


34

Exit Sub

End If

If rec.BOF Then

rec.MoveLast

text1.Text = rec(1)

text2.Text = rec(0)

Exit Sub

End If

rec.MovePrevious

If rec.BOF = False And rec.EOF = False Then

text1.Text = rec(1)

text2.Text = rec(0)

End If

End Sub

Private Sub cmdsave_Click()

If text1.Text = "" Then

MsgBox "Enter Station Name", vbOKOnly, "Railway Reservation"

Exit Sub

End If

If text2.Text = "" Then

MsgBox "Generate Code and then Save!", vbOKOnly, "Railway Reservation"

Exit Sub

End If

rec.AddNew
35

rec(0) = text2.Text

rec(1) = text1.Text

rec.Update

MsgBox "Station Code is Saved!", vbOKOnly, "Railway Station Code Confirmation"

lblcount.Caption = rec.RecordCount

text1.Text = ""

text2.Text = ""

text1.Locked = True

cmdsave.Enabled = False

cmdcancel.Enabled = False

Command1.Enabled = False

cmdadd.Enabled = True

cmdnext.Enabled = True

cmdprev.Enabled = True

End Sub

Private Sub Command1_Click()

Dim name, str As String

If text1.Text = "" Then

MsgBox "Enter Station Name first", vbOKOnly

text1.SetFocus

Exit Sub

End If

str = StrConv(text1.Text, vbUpperCase)

rec.MoveFirst
36

While rec.EOF = False

name = (StrConv(rec(1), vbUpperCase))

If str = name Then

MsgBox "Station Name has already got Station Code ! " & vbCrLf & "Enter another station",
vbOKOnly, "Railway Reservation System"

text1.Text = ""

text1.SetFocus

Exit Sub

Else

rec.MoveNext

End If

Wend

If rec.BOF And rec.EOF Then

text2.Text = 1

Exit Sub

End If

rec.MoveFirst

code = 1

While rec.EOF = False

code = code + 1

rec.MoveNext

Wend

text2.Text = code

End Sub
37

Private Sub Form_Load()

Set rec = New Recordset

rec.Source = "select * from station_code"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

lblcount.Caption = rec.RecordCount

End Sub

Form5 - modify code.frm (Modify Station Name)

Dim rec As New Recordset

Dim code As Integer

Private Sub cmdadd_Click()

text1.Locked = False

text1.SetFocus

cmdsave.Enabled = True

cmdcancel.Enabled = True

cmdadd.Enabled = False

cmdnext.Enabled = False

cmdprev.Enabled = False

End Sub
38

Private Sub cmdback_Click()

Unload Me

End Sub

Private Sub cmdcancel_Click()

text1.Locked = True

End Sub

Private Sub cmdnext_Click()

If rec.BOF And rec.EOF Then

MsgBox "The Code directory is empty", vbOKOnly, "Railway Confirmation"

Exit Sub

End If

If rec.EOF Then

rec.MoveFirst

text1.Text = rec(1)

text2.Text = rec(0)

Exit Sub

End If

rec.MoveNext

If rec.BOF = False And rec.EOF = False Then

text1.Text = rec(1)
39

text2.Text = rec(0)

End If

cmdadd.Enabled = True

End Sub

Private Sub cmdprev_Click()

If rec.BOF And rec.EOF Then

MsgBox "The Code directory is empty", vbOKOnly, "Railway Confirmation"

Exit Sub

End If

cmdadd.Enabled = True

If rec.BOF Then

rec.MoveLast

text1.Text = rec(1)

text2.Text = rec(0)

Exit Sub

End If

rec.MovePrevious

If rec.BOF = False And rec.EOF = False Then

text1.Text = rec(1)

text2.Text = rec(0)

End If
40

End Sub

Private Sub cmdsave_Click()

If text1.Text = "" Or text2.Text = "" Then

MsgBox "Enter Station Name", vbOKOnly, "Railway Reservation"

Exit Sub

End If

If rec.BOF Or rec.EOF Then

MsgBox "You are either in BOF or EOF", vbOKOnly, "Railway Reservation System"

GoTo next_line

End If

rec(0) = text2.Text

rec(1) = text1.Text

rec.Update

MsgBox "Station Name is Updated!", vbOKOnly, "Railway Station Code Confirmation"

lblcount.Caption = rec.RecordCount

next_line:

text1.Locked = True

cmdsave.Enabled = False

cmdcancel.Enabled = False

cmdadd.Enabled = True

cmdnext.Enabled = True
41

cmdprev.Enabled = True

End Sub

Private Sub Form_Load()

Set rec = New Recordset

rec.Source = "select * from station_code"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

lblcount.Caption = rec.RecordCount

End Sub

Form6 del code.frm (Delete Station Code)

Dim rec As New Recordset

Dim code As Integer

Dim ans As Variant

Private Sub cmdback_Click()

Unload Me

End Sub

Private Sub cmddelete_Click()

If rec.BOF And rec.EOF Then


42

MsgBox "The Code directory is empty", vbOKOnly, "Railway Confirmation"

text1.Text = ""

text2.Text = ""

Exit Sub

End If

If rec.BOF Or rec.EOF Then

MsgBox "You are either in BOF or EOF", vbOKOnly, "Railway Confirmation"

text1.Text = ""

text2.Text = ""

Exit Sub

End If

ans = MsgBox("Do you really want to delete this record", vbYesNo, "Railway Delete Record")

If ans = vbYes Then

rec.Delete

MsgBox "Record Deleted", vbOKOnly, "Railway Delete Record"

rec.MoveNext

If rec.BOF = False And rec.EOF = False Then

text1.Text = rec(1)

text2.Text = rec(0)

End If

lblcount.Caption = rec.RecordCount

End If

End Sub

Private Sub cmdnext_Click()


43

If rec.BOF And rec.EOF Then

MsgBox "The Code directory is empty", vbOKOnly, "Railway Confirmation"

Exit Sub

End If

cmddelete.Enabled = True

If rec.EOF Then

rec.MoveFirst

text1.Text = rec(1)

text2.Text = rec(0)

Exit Sub

End If

rec.MoveNext

If rec.BOF = False And rec.EOF = False Then

text1.Text = rec(1)

text2.Text = rec(0)

End If

End Sub

Private Sub cmdprev_Click()

If rec.BOF And rec.EOF Then

MsgBox "The Code directory is empty", vbOKOnly, "Railway Confirmation"

Exit Sub

End If

cmddelete.Enabled = True

If rec.BOF Then
44

rec.MoveLast

text1.Text = rec(1)

text2.Text = rec(0)

Exit Sub

End If

rec.MovePrevious

If rec.BOF = False And rec.EOF = False Then

text1.Text = rec(1)

text2.Text = rec(0)

End If

End Sub

Private Sub Form_Load()

cmddelete.Enabled = False

Set rec = New Recordset

rec.Source = "select * from station_code"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

lblcount.Caption = rec.RecordCount

End Sub

Form7 - station distance.frm (Station Distance)


45

Dim rec As New Recordset

Private Sub cmdback_Click()

Unload Me

End Sub

Private Sub cmdcancel_Click()

combo1.Text = "Select station code"

combo2.Text = "Select station code"

txtdistance.Text = ""

cmdcancel.Enabled = False

cmdsave.Enabled = False

End Sub

Private Sub cmdsave_Click()

Dim ans As String

If txtdistance.Text = "" Then

MsgBox "Enter Distance in km!", vbOKOnly, "Railway Reservation System"

Exit Sub

End If

If combo1.Text = combo2.Text Then

MsgBox "Station Names are Same!", vbOKOnly, "Railway Reservation System"

Exit Sub

End If

Set rec = New Recordset


46

rec.Source = "select * from station_distance where source_station like '" & combo1.Text & "' And
dest_station like '" & combo2.Text & "'"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

If Not rec.EOF Or Not rec.BOF Then

ans = MsgBox("The distance between these two stations has been entered already. Do you
want to modify it.", vbOKCancel + vbDefaultButton2)

If ans = vbOK Then

rec(0) = combo1.Text

rec(1) = combo2.Text

rec(2) = txtdistance.Text

rec.Update

MsgBox "Station Distance Updated !", vbOKOnly, "Railway Reservation System"

cmdsave.Enabled = False

cmdcancel.Enabled = False

combo1.Text = "Select station Name"

combo2.Text = "Select station Name"

txtdistance.Text = ""

rec.Close

Exit Sub

Else
47

rec.Close

Exit Sub

End If

Else

rec.Close

End If

Set rec = New Recordset

rec.Source = "select * from station_distance"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

rec.AddNew

rec(0) = combo1.Text

rec(1) = combo2.Text

rec(2) = txtdistance.Text

rec.Update

MsgBox "Station Distance Saved !", vbOKOnly, "Railway Reservation System"

cmdsave.Enabled = False

cmdcancel.Enabled = False

combo1.Text = "Select Station Name"

combo2.Text = "Select Station Name"

txtdistance.Text = ""

rec.Close

End Sub
48

Private Sub Combo1_click()

cmdcancel.Enabled = True

cmdsave.Enabled = True

End Sub

Private Sub combo2_Click()

cmdcancel.Enabled = True

cmdsave.Enabled = True

End Sub

Private Sub Form_Load()

combo1.Text = "Select Station Name"

combo2.Text = "Select Station Name"

combo1.AddItem ("Select Station Name")

combo2.AddItem ("Select Station Name")

Set rec = New Recordset

rec.Source = "select * from station_code"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

While Not rec.EOF


49

combo1.AddItem (rec(1))

combo2.AddItem (rec(1))

rec.MoveNext

Wend

rec.Close

End Sub

Form8 - del stat distance.frm (Delete Station Distance)

Dim rec As New Recordset

Dim ans As Variant

Private Sub cmdback_Click()

Unload Me

End Sub

Private Sub cmdcancel_Click()

combo1.Text = ""

combo2.Text = ""

txtdistance.Text = ""

cmdcancel.Enabled = False

cmddelete.Enabled = False

End Sub

Private Sub cmddelete_Click()


50

rec.Source = "Select * from station_distance where source_station like '" & combo1.Text & "'
And dest_station like '" & combo2.Text & "'"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

If rec.BOF Or rec.EOF Then

rec.Close

Exit Sub

End If

ans = MsgBox("Do you really want to delete this station distance", vbYesNo, "Railway Delete
Record")

If ans = vbYes Then

rec.Delete

MsgBox ("Distance record betwen these two stations deleted")

cmddelete.Enabled = False

combo1.Text = ""

combo2.Text = ""

Label5.Caption = ""

Label6.Caption = ""

Label7.Caption = ""

End If

rec.Close

End Sub

Private Sub Combo1_click()


51

getdistance

End Sub

Private Sub combo2_Click()

getdistance

End Sub

Private Sub Form_Load()

rec.Source = "select * from station_code"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

While Not rec.EOF

combo1.AddItem (rec(1))

combo2.AddItem (rec(1))

rec.MoveNext

Wend

rec.Close

End Sub

Private Sub getdistance()

If combo1.Text = "" Or combo2.Text = "" Then

Exit Sub

End If
52

rec.Source = "Select * from station_distance where source_station like '" & combo1.Text & "'
And dest_station like '" & combo2.Text & "'"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

If rec.EOF Or rec.BOF Then

Label7.Caption = ""

cmddelete.Enabled = False

rec.Close

Exit Sub

Else

Label7.Caption = rec(2)

cmddelete.Enabled = True

End If

rec.Close

End Sub

Form9 - Modify train.frm (Modify train)

Dim rec As New Recordset

Dim rec1 As New Recordset

Dim rec2 As New Recordset

Dim stat_code As Integer

Dim stat_name As String


53

Private Sub cmdback_Click()

Unload Me

MDIForm1.Show

End Sub

Private Sub cmdcancel_Click()

Frame1.Enabled = False

cmdsave.Enabled = False

cmdcancel.Enabled = False

cmdNew.Enabled = True

End Sub

Private Sub cmdNew_Click()

Dim trn As Integer

Frame1.Enabled = True

Frame3.Enabled = True

cmdsave.Enabled = True

cmdcancel.Enabled = True

cmdNew.Enabled = False

Combo10.Enabled = True

trn = Combo10.Text

Set rec2 = New Recordset

rec2.Source = "select * from train_fare_info where train_no= " & trn

rec2.CursorLocation = adUseClient
54

rec2.CursorType = adOpenDynamic

rec2.LockType = adLockOptimistic

rec2.Open , conn

rec2.MoveFirst

Combo6.Clear

While Not rec2.EOF

Combo6.AddItem (rec2(1))

rec2.MoveNext

Wend

rec2.Close

End Sub

Private Sub cmdsave_Click()

Dim ans As Variant

If Combo10.Text = "" Or text2.Text = "" Or text15.Text = "" Or text16.Text = "" Or combo1.Text =


"" Or combo2.Text = "" Or combo3.Text = "" Or combo4.Text = "" Then

MsgBox "Fill the missing entries", vbOKOnly + vbCritical, "Railway Reservation System"

Exit Sub

End If

If combo1.Text = combo2.Text Then

MsgBox "Select Different Stations", vbOKOnly + vbCritical, "Railway Reservation System"

Exit Sub

End If

ans = MsgBox("Do you want to Update the train information ", vbYesNo + vbDefaultButton3,
"Railway Reservation System ::[Train Record]")

If ans = vbYes Then


55

Set rec = New Recordset

rec.Source = "select * from train_record where train_no=" & Combo10.Text

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

rec(1) = text2.Text

rec(2) = combo1.Text

rec(3) = combo2.Text

rec(4) = text15.Text

rec(5) = text16.Text

On Error GoTo label

rec.Update

MsgBox "Train Record Scuessfully Updated!", vbOKOnly + vbDefaultButton4, "Railway


Reservation System ::[Train Record]"

rec.Close

Frame1.Enabled = False

cmdsave.Enabled = False

cmdcancel.Enabled = False

cmdNew.Enabled = True

text2.Text = ""

text15.Text = ""

text16.Text = ""

combo1.Text = "Select Station Code"

combo2.Text = "Select Station Code"


56

combo3.Text = "Select Station Name"

combo4.Text = "Select Station Name"

Exit Sub

label:

MsgBox "Time format is incorrect!", vbCritical, "Railway Reservation System"

End If

End Sub

Private Sub Combo1_Change()

On Error GoTo combo1

stat_code = combo1.Text

Set rec = New Recordset

rec.Source = "select * from station_code where code= " & stat_code

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

combo3.Text = rec(1)

rec.Close

combo1:

End Sub

Private Sub Combo1_click()

stat_code = combo1.Text

Set rec = New Recordset


57

rec.Source = "select * from station_code where code= " & stat_code

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

combo3.Text = rec(1)

rec.Close

End Sub

Private Sub Combo10_Click()

Set rec1 = New Recordset

rec1.Source = "select * from train_record where train_no =" & Combo10.Text

rec1.CursorLocation = adUseClient

rec1.CursorType = adOpenDynamic

rec1.LockType = adLockOptimistic

rec1.Open , conn

text2.Text = rec1(1)

combo1.Text = rec1(2)

combo2.Text = rec1(3)

text15.Text = rec1(4)

text16.Text = rec1(5)

rec1.Close

cmdNew.Enabled = True

End Sub
58

Private Sub combo2_Change()

On Error GoTo combo2

stat_code = combo2.Text

Set rec = New Recordset

rec.Source = "select * from station_code where code= " & stat_code

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

combo4.Text = rec(1)

rec.Close

combo2:

End Sub

Private Sub combo2_Click()

stat_code = combo2.Text

Set rec = New Recordset

rec.Source = "select * from station_code where code= " & stat_code

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

combo4.Text = rec(1)

rec.Close
59

End Sub

Private Sub combo3_Click()

stat_name = combo3.Text

Set rec = New Recordset

rec.Source = "select * from station_code where name like '" & stat_name & "'"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

combo1.Text = rec(0)

rec.Close

End Sub

Private Sub combo4_Click()

stat_name = combo4.Text

Set rec = New Recordset

rec.Source = "select * from station_code where name like '" & stat_name & "'"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

combo2.Text = rec(0)

rec.Close

End Sub
60

Private Sub Combo6_Click()

Set rec = New Recordset

rec.Source = "select * from train_fare_info where train_no=" & Combo10.Text & "and class= '"
& Combo6.Text & "'"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

If rec.BOF And rec.EOF Then

MsgBox "Record does not found", vbOKOnly, "Railway Fare Details"

Command2.Enabled = True

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Text6.Text = ""

Text7.Text = ""

Text8.Text = ""

Text9.Text = ""

rec.Close

Exit Sub

End If

Command2.Enabled = True

Text3.Text = rec(2)

Text4.Text = rec(3)

Text5.Text = rec(4)
61

Text6.Text = rec(5)

Text7.Text = rec(6)

Text8.Text = rec(7)

Text9.Text = rec(8)

rec.Close

End Sub

Private Sub Command2_Click()

If Combo10.Text = "" Then

MsgBox "Enter Train no. first", vbDefaultButton1, "Railway Fare Details"

Exit Sub

End If

Set rec = New Recordset

rec.Source = "select * from train_fare_info where train_no=" & Combo10.Text & "and class= '"
& Combo6.Text & "'"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

If rec.BOF And rec.EOF Then

rec.AddNew

rec(0) = Combo10.Text

rec(1) = Combo6.Text

rec(2) = Text3.Text
62

rec(3) = Text4.Text

rec(4) = Text5.Text

rec(5) = Text6.Text

rec(6) = Text7.Text

rec(7) = Text8.Text

rec(8) = Text9.Text

rec.Update

rec.Close

Set rec1 = New Recordset

rec1.Source = "select * from seat_record"

rec1.CursorLocation = adUseClient

rec1.CursorType = adOpenDynamic

rec1.LockType = adLockOptimistic

rec1.Open , conn

rec1.AddNew

rec1(0) = Combo10.Text

rec1(1) = Combo6.Text

rec1(2) = Text3.Text

rec1(3) = Text4.Text

rec1(4) = Text3.Text

rec1(5) = Val(Text3) * Val(Text4)

rec1.Update

rec1.Close
63

MsgBox "Class & Fare detail is Stored !", vbOKOnly, "Railway Fare Details"

Combo6.Text = "Select Class"

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Text6.Text = ""

Text7.Text = ""

Text8.Text = ""

Text9.Text = ""

Command2.Enabled = False

Exit Sub

End If

rec(1) = Combo6.Text

rec(2) = Text3.Text

rec(3) = Text4.Text

rec(4) = Text5.Text

rec(5) = Text6.Text

rec(6) = Text7.Text

rec(7) = Text8.Text

rec(8) = Text9.Text

rec.Update

rec.Close

Set rec1 = New Recordset


64

rec1.Source = "select * from seat_record where train_no=" & Combo10.Text & "and class= '" &
Combo6.Text & "'"

rec1.CursorLocation = adUseClient

rec1.CursorType = adOpenDynamic

rec1.LockType = adLockOptimistic

rec1.Open , conn

rec1(1) = Combo6.Text

rec1(2) = Text3.Text

rec1(3) = Text4.Text

rec1(4) = Text3.Text

rec1(5) = Val(Text3) * Val(Text4)

rec1.Update

rec1.Close

MsgBox "Class & Fare detail is Updated !", vbOKOnly, "Railway Fare Details"

Combo6.Text = "Select Class"

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Text6.Text = ""

Text7.Text = ""

Text8.Text = ""

Text9.Text = ""

Command2.Enabled = False

End Sub
65

Private Sub Form_Load()

Set rec = New Recordset

rec.Source = "select * from station_code"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

rec.MoveFirst

While rec.EOF = False

combo1.AddItem (rec(0))

combo2.AddItem (rec(0))

combo3.AddItem (rec(1))

combo4.AddItem (rec(1))

rec.MoveNext

Wend

rec.Close

Set rec = New Recordset

rec.Source = "select * from train_record"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

If rec.BOF And rec.EOF Then

MsgBox "Train Record is empty", vbInformation, "Train Record information"

Exit Sub
66

End If

rec.MoveFirst

While rec.EOF = False

Combo10.AddItem (rec(0))

rec.MoveNext

Wend

rec.Close

End Sub

Form10 - del train.frm (Remove Train Record)

Dim rec As New Recordset

Dim rec1 As New Recordset

Private Sub cmdback_Click()

Unload Me

End Sub

Private Sub cmdremove_Click()

Dim ans As Variant

ans = MsgBox("Are you sure you want to delete this train record !", vbYesNo +
vbDefaultButton1, "Delete Train Record")

If ans = vbYes Then


67

Set rec = New Recordset

rec.Source = "select * from train_record where train_no=" & Text1.Text

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

rec.Delete

rec.Close

Set rec = New Recordset

rec.Source = "delete * from train_fare_info where train_no=" & Text1.Text

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

Set rec = New Recordset

rec.Source = "delete * from seat_record where train_no=" & Text1.Text

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

MsgBox "Train record is Removed !", vbDefaultButton1, "Delete Train Record"

Text1.Text = ""

End If

End Sub
68

Private Sub text1_Change()

If Val(Text1.Text) > 0 Then

Set rec = New Recordset

rec.Source = "select * from train_record where train_no=" & Text1.Text

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

On Error GoTo msg

label3.Caption = rec(1)

Set rec1 = New Recordset

rec1.Source = "select * from station_code where code=" & rec(2)

rec1.CursorLocation = adUseClient

rec1.CursorType = adOpenDynamic

rec1.LockType = adLockOptimistic

rec1.Open , conn

label4.Caption = rec1(1)

rec1.Close

Set rec1 = New Recordset

rec1.Source = "select * from station_code where code=" & rec(3)

rec1.CursorLocation = adUseClient

rec1.CursorType = adOpenDynamic

rec1.LockType = adLockOptimistic

rec1.Open , conn

label5.Caption = rec1(1)
69

rec1.Close

cmdremove.Enabled = True

rec.Close

Exit Sub

msg:

rec.Close

label3.Caption = ""

label4.Caption = ""

label5.Caption = ""

cmdremove.Enabled = False

Else

label3.Caption = ""

label4.Caption = ""

label5.Caption = ""

cmdremove.Enabled = False

End If

End Sub

Form11 - pass_details.frm (Passenger Personal Details)

Dim rec As New Recordset

Dim rec1 As New Recordset

Dim train_no As Integer

Dim clas As String

Dim free_seat, free_bogg, tot_seat, tot_bogg, bogg_no, seat_no As Integer


70

Private Sub cmdback_Click()

Unload Me

End Sub

Private Sub cmdgetseatno_Click()

If txtname.Text = "" Or txtage.Text = "" Then

MsgBox "Fill Passenger Name & age", vbCritical, "Passenger Detail Record"

Exit Sub

End If

train_no = Form2.txttrainno

clas = Form2.comboclass

Set rec1 = New Recordset

rec1.Source = "select * from seat_record where train_no=" & train_no & "and class= '" & clas &
"'"

rec1.CursorLocation = adUseClient

rec1.CursorType = adOpenDynamic

rec1.LockType = adLockOptimistic

rec1.Open , conn

tot_bogg = rec1(2)

tot_seat = rec1(3)

free_bogg = rec1(4)

free_seat = rec1(5)

If (free_seat / free_bogg) = tot_seat Then


71

free_bogg = free_bogg - 1

free_seat = free_seat - 1

Else

free_seat = free_seat - 1

End If

bogg_no = tot_bogg - free_bogg

seat_no = (tot_bogg * tot_seat) - free_seat

If seat_no > tot_seat Then

seat_no = seat_no - tot_seat

End If

rec1(2) = tot_bogg

rec1(3) = tot_seat

rec1(4) = free_bogg

rec1(5) = free_seat

rec1.Update

rec1.Close

txtboggieno.Text = bogg_no

txtseatno.Text = seat_no

End Sub

Private Sub cmdsave_Click()

If txtname.Text = "" Or txtage.Text = "" Or txtboggieno.Text = "" Or txtseatno.Text = "" Then

MsgBox "Fill all the missing fields", vbCritical, "Passenger Detail Record"

Exit Sub
72

End If

Set rec = New Recordset

rec.Source = "Select * from pass_details"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

rec.AddNew

rec(0) = txtPNR.Text

rec(1) = txtname.Text

rec(2) = txtage.Text

rec(3) = txtsex.Text

rec(4) = txtboggieno.Text

rec(5) = txtseatno.Text

rec.Update

rec.Close

If txtsno.Text = total Then

MsgBox "Details of all passengers received", vbInformation, "Passenger details Operation


completed"

Form2.txtboggieno = bogg_no

Unload Me

Exit Sub

Else

txtsno.Text = txtsno.Text + 1

End If
73

txtname.Text = ""

txtage.Text = ""

txtboggieno.Text = ""

txtseatno.Text = ""

txtname.SetFocus

End Sub

Form12 - confirm.frm (Reservation Information)

Dim rec As New Recordset

Private Sub cmdback_Click()

Unload Me

End Sub

Private Sub cmdget_Click()

If txtPNR = "" Then

MsgBox "Enter P.N.R number", vbCritical, "Confirm Reservation"

Exit Sub

End If

If IsNumeric(txtPNR.Text) = False Then

MsgBox "Enter valid P_N_R number"

txtPNR.Text = ""

txtPNR.SetFocus

Exit Sub

End If
74

Set rec = New Recordset

rec.Source = "Select * from reservation where p_n_r=" & txtPNR.Text

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

If rec.BOF And rec.EOF Then

MsgBox "No seats have not been reserved against this P N R no", vbInformation, "NO record
found"

Exit Sub

End If

Form13.lblpnr.Caption = rec(0)

Form13.lbltrainname.Caption = rec(1)

Form13.lbltrainno.Caption = rec(2)

Form13.lblfrom.Caption = rec(5)

Form13.lblto.Caption = rec(6)

Form13.lblclass.Caption = rec(4)

Form13.lblnoberths.Caption = rec(7)

Form13.lblboggieno.Caption = rec(8)

Form13.lbldate.Caption = rec(3)

Form13.lblheading.Caption = Form13.lblnoberths.Caption + " " + Form13.lblclass.Caption + " "


+ "seats have been reserved against this PNR no"

'Form13.lbldate.Caption = Format(Form13.lbldate.Caption, "m/d/yy")

Form13.Show

End Sub
75

Private Sub Command1_Click()

DataReport5.Refresh

End Sub

Form13 - confirm_result.frm (Confirm Reservation Result)

Dim rec As New Recordset

Private Sub cmdagain_Click()

Unload Me

End Sub

Private Sub cmdMain_Click()

Unload Form12

Unload Me

End Sub

Private Sub cmdprint_Click()

Set rec = New Recordset

rec.Source = "select * from temp"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

rec.AddNew

rec(0) = lblpnr.Caption
76

rec(1) = lbltrainname.Caption

rec(2) = lbltrainno.Caption

rec(3) = lbldate.Caption

rec(4) = lblclass.Caption

rec(5) = lblfrom.Caption

rec(6) = lblto.Caption

rec(7) = lblnoberths.Caption

rec.Update

rec.Close

DataReport5.Show

Set rec = New Recordset

rec.Source = "delete * from temp"

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

End Sub

Form14 - cancel reser.frm (Reservation Details of P.N.R. No.)

Dim rec As New Recordset

Private Sub cmdback_Click()

Unload Me

End Sub
77

Private Sub cmdcancel_Click()

rec.Delete

rec.Close

Set rec = New Recordset

rec.Source = "delete * from pass_details where p_n_r=" & txtpnr.Text

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

MsgBox "Reservation Canceled", vbInformation, "Reservation Cancel Record"

cmdcancel.Enabled = False

txtpnr.Text = ""

lbltrainname.Caption = ""

lbltrainno.Caption = ""

lblsource.Caption = ""

lbldest.Caption = ""

lblnoberths.Caption = ""

lbldate.Caption = ""

lblamount.Caption = ""

lblrefund.Caption = ""

End Sub

Private Sub cmdget_Click()

If IsNumeric(txtpnr.Text) = False Then

MsgBox "Enter valid P_N_R number", vbCritical, "Confirm Reservation"


78

txtpnr.Text = ""

txtpnr.SetFocus

Exit Sub

End If

If txtpnr = "" Then

MsgBox "Enter P.N.R number", vbCritical, "Confirm Reservation"

Exit Sub

End If

cmdcancel.Enabled = True

Set rec = New Recordset

rec.Source = "Select * from reservation where p_n_r=" & txtpnr.Text

rec.CursorLocation = adUseClient

rec.CursorType = adOpenDynamic

rec.LockType = adLockOptimistic

rec.Open , conn

If rec.BOF And rec.EOF Then

MsgBox "No seats have not been reserved against this P N R no", vbInformation, "NO record
found"

Exit Sub

End If

lbltrainname.Caption = rec(1)

lbltrainno.Caption = rec(2)

lblsource.Caption = rec(5)

lbldest.Caption = rec(6)

lblnoberths.Caption = rec(7)
79

lblamount.Caption = rec(9)

lblrefund.Caption = lblamount.Caption - ((lblamount.Caption * 10) / 100)

End Sub

Form19 - exit.frm (Do Want To Terminate)

Private Sub Command3_Click()

If Option1.Value = True Then

Me.Hide

End

End If

If Option2.Value = True Then

Me.Hide

End If

End Sub

frmLogin - login.frm (Login Screen)

Option Explicit

Public LoginSucceeded As Boolean

Private Sub cmdcancel_Click()

'set the global var to false

'to denote a failed login

LoginSucceeded = False

Me.Hide
80

End Sub

Private Sub cmdOK_Click()

'check for correct password

If txtUserName = "" And txtPassword = "" Then

'place code to here to pass the

'success to the calling sub

'setting a global var is the easiest

LoginSucceeded = True

Me.Hide

Form1.Hide

MDIForm1.Show

Else

MsgBox "Invalid UserName or Password, try again!", , "Login"

txtPassword.SetFocus

SendKeys "{Home}+{End}"

End If

End Sub

frmSplash.frm (Splash Form)

Option Explicit

Private Sub Form_KeyPress(KeyAscii As Integer)

Unload Me

End Sub
81

Private Sub Timer1_Timer()

Unload Me

Form1.Show

Timer1.Enabled = False

End Sub

MDIForm1 - main.frm (Menu Bar)

Private Sub canel_Click()

Form14.Show

End Sub

Private Sub conf_Click()

Form12.Show

End Sub

Private Sub d_Click()

Form8.Show

End Sub

Private Sub mnl_Click()

Form17.Show

End Sub
82

Private Sub mnu_about_Click()

Form20.Show

End Sub

Private Sub mnu_add_Click()

Form3.Show

End Sub

Private Sub mnu_codd_Click()

DataReport1.Show

DataReport2.Hide

DataReport3.Hide

DataReport4.Hide

End Sub

Private Sub mnu_de_Click()

Form6.Show

End Sub

Private Sub mnu_del_Click()

Form10.Show

End Sub

Private Sub mnu_delat_Click()

DataReport4.Show

DataReport1.Hide
83

DataReport2.Hide

DataReport3.Hide

End Sub

Private Sub mnu_distt_Click()

DataReport2.Show

DataReport1.Hide

DataReport3.Hide

DataReport4.Hide

End Sub

Private Sub mnu_exit_Click()

Form19.Show

End Sub

Private Sub mnu_info_Click()

Form12.Show

End Sub

Private Sub mnu_li_Click()

Form16.Show

End Sub

Private Sub mnu_m_Click()

Form5.Show
84

End Sub

Private Sub mnu_modi_Click()

Form9.Show

End Sub

Private Sub mnu_n_Click()

Form4.Show

End Sub

Private Sub mnu_tot_Click()

DataReport3.Show

DataReport1.Hide

DataReport2.Hide

DataReport4.Hide

End Sub

Private Sub mnua_Click()

Form7.Show

End Sub

Private Sub mnui_Click()

Form15.Show

End Sub
85

Private Sub new_res_Click()

Form2.Show

End Sub

Private Sub PsgrDetails_Click()

Form18.Show

End Sub

BIBLIOGRAPHY AND REFERENCES

• www.indianrail.gov.in
• www.irctc.co.in
• www.primetravels.com/railschedule.htm
• www.indiarail.info
• Chehru, Phagwara and Kathua (J & K) Railway Staff
• Visual Basic 6 Programming Black Book by Steven Holzner
• Visual Basic 6 by Parteek Bhatia
• eBook: The Visual Basic Editor by Martin Green
• eBook: VB Guide
• ebook: 10 Minute Guide to Microsoft Access
eBook: Learn Microsoft Office