You are on page 1of 34

EXPERIMENT - 6 RAILWAY RESERVATION SYSTEM

ABSTRACT OBJECTIVE:

Designing the application and of Railway Reservation System for the purpose of reserving railway tickets and database maintenance about train and passenger details by the railway department only. This database helps railways to retrieve data as and when required in future. The scope of project included evaluation of the application and was primarily concerned with the transactions related to booking of tickets from the terminals operated by the railway personnel. Application controls and simulation were used to evaluate data validation and program logic. The selected data, as made available, for substantive checking of the completeness, integrity and consistency of data using computer assisted applications such as VB, MS Access. The records maintained in the database of the railways reservation centre were also reviewed. Discussions were held with the database users to gain understanding regarding the various functional aspects of the system. The booking database has passengers details like Name, Age, Gender, Total Number of Passengers Traveling, Date of Travel, and Class of Travel. The train database has train details like Train Name, Train Number, Route, From, To, Train Time, AC First Class, AC 2 Tier, AC 3 Tier, Sleeper, Second Sitting and Quota Management like General, Takkal.

SYSTEM REQUIREMENTS

SOFTWARE REQUIREMENTS:

Windows XP Professional. Visual Basic 6.0. Ms Access.


HARDWARE REQUIREMENTS:

Pentium IV 3.0GHz Processor 512 MB RAM 80 GB Hard Disk 17 Monitor Mouse, keyboard.

MODULE DESCRIPTION In our Railway Reservation System, there are four main modules available. They are

1. 2. 3. 4.

Train Master Ticket Booking Ticket Canceling Reports

1. Train Master:
The Train Master is Admin side module. The Administrator only can Add, modify and Delete the train Details. The Train Master contains the following details.

a) b) c) d) e) f) g) h) i) j) k)

Train Name Train No Source Destination Departure Time Arrival Time Total Seats Kilometers General Seats (1A, 2A, 3A, 2S, SL, CC) Takkal Seats (1A, 2A, 3A, 2S, SL, CC) Routes and Timings

2. Ticket Booking:
The Ticket Booking is user (Employee of Railway Dept.) side module. The user can book the ticket using this module. The user should follow the steps for the ticket booking.

a) First you should select the Source and Destination. b) Next, you should select the Date. While the date textbox got focus, the calendar
will display. By clicking the calendar, the date will be selected. And you cant select the yesterday and before date.

c) Select the Quota (General or Takkal). d) Click the Find button to find the trains which are available.

Note: 1. If you select the Takkal Quota and the date is day after tomorrow in the sense, you cant book the ticket for Takkal Quota for that day. The Takkal Quota will enable only today and tomorrow only.

e) After clicking the find button, the available train list will be displayed in the f)
flexgrid. By clicking the train number or train name in the flex grid, the Route button enabled. By clicking the route button, the corresponding train route, timings, and kms.

g) By clicking the class column to the corresponding train whichever you want to h) i) After Enter the details, Click the Proceed Button. j) The frame will display the overall details like Source, Destination, Travel Date, k)
Booked Date, Total Members, Quota and Total Fare. Click the Confirm Button to confirm the details. Then only the Booking details will be stored and PNR Number will be generated. 3. Ticket Canceling: The Ticket Canceling is also user (Employee of Railway Dept.) side module. The user can cancel the ticket using this module. The user should follow the steps for the ticket Cancel. travel, then Book button will enable. Click the Book button to enter the Name, Age, Sex and Berth.

a) Enter the PNR Number in the Textbox and Click Find. b) It will show the details like Train No., Train Name, Booked Date, Travel Date, c) d) e)
Source, Destination, Class, Quota, Total Fare, Kms in the Frame. It also shows the passenger names, Age, Sex, Berth, Class, Fare and status in the flex grid. Click the Name in the flex grid which you want to cancel and where the status is Booked. Click the Cancel Button to cancel the ticket.

4. Reports: The Report Module is also user (Employee of Railway Dept.) side Module. The user can take two types of reports by giving the PNR Number.

a) Booked Tickets b) Canceled Tickets


SCREENSHOTS MDI FORM

ADMIN LOGIN

TRAIN MASTER MODULE

TICKET BOOKING

REPORT MODULE

BOOKED TICKET

CANCELLED TICKET

MDI FORM

SOURCE CODE

Private Sub MDIForm_Load() conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\RRS.mdb;" Timer1.Enabled = True End Sub Private Sub MDIForm_Terminate() End End Sub Private Sub MDIForm_Unload(Cancel As Integer) End End Sub Private Sub rpts_Click() Form4.Show End Sub Private Sub Timer1_Timer() StatusBar1.Panels.Item(2).Text = Format(Now, "dd-mm-yyyy") & " " & Format(Now, "HH:mm:SS am/pm")

End Sub Private Sub tktbooking_Click() Form2.Show End Sub Private Sub tktcancelling_Click() Form3.Show End Sub Private Sub trnmas_Click() frmLogin.Show End Sub TRAIN MASTER: Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim conn As String Private Sub Command1_Click() Call clear flx1.clear Call flux Command3.Enabled = False Command5.Enabled = False Command8.Enabled = False Text1.SetFocus End Sub Private Sub Command2_Click() If Text1 = "" Or Text2 = "" Or Text3 = "" Or Text4 = "" Or Text5 = "" Or Text6 = "" Or Text7 = "" Or Text8 = "" Or Text9 = "" Or Text10 = "" Or Text11 = "" Or Text12 = "" Or Text13 = "" Or Text14 = "" Or Text15 = "" Or Text16 = "" Or Text17 = "" Or Text18 = "" Or Text19 = "" Or Text20 = "" Then MsgBox ("Please Enter All Details") Else WAIT = Val(Text7) - ((Val(Text9) + Val(Text10) + Val(Text11) + Val(Text12) + Val(Text13) + Val(Text14) + Val(Text15) + Val(Text16) + Val(Text17) + Val(Text18) + Val(Text19) + Val(Text20))) If cn.state = adStateOpen Then cn.Close End If cn.Open conn cn.BeginTrans cn.Execute ("INSERT INTO TRAIN_MASTER VALUES('" & Text1.Text & "'," & Val(Text2.Text) & ",'" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Text6.Text & "'," & Val(Text7.Text) & "," & Val(Text8.Text) & ",'" & Text9.Text & "','" & Text10.Text & "','" & Text11.Text & "','" & Text12.Text & "','" & Text13.Text & "','" & Text14.Text & "','" & Text15.Text & "','" & Text16.Text & "','" & Text17.Text & "','" & Text18.Text & "','" & Text19.Text & "','" & Text20.Text & "','" & WAIT & "')") cn.Execute ("INSERT INTO TRAIN_NAME VALUES('" & Text2.Text & "'," & Val(Text1.Text) & ")")

cn.Execute ("CREATE TABLE " & Text2 & "(stn_code Text, stn_name Text, arrival Text, dep Text, distance Number, no_of_days Number)") cn.CommitTrans If cn.state = adStateOpen Then cn.Close End If cn.Open conn cn.BeginTrans For n = 1 To flx1.Rows - 2 'cn.Execute ("INSERT INTO " & Text2 & " VALUES('" & flx1.TextMatrix(n, 0) & "','" & flx1.TextMatrix(n, 1) & "','" & flx1.TextMatrix(n, 2) & "','" & flx1.TextMatrix(n, 3) & "'," & Val(flx1.TextMatrix(n, 4)) & "'," & Val(flx1.TextMatrix(n, 5)) & ")") cn.Execute ("insert into " & Text2 & " values('" & flx1.TextMatrix(n, 0) & "','" & flx1.TextMatrix(n, 1) & "','" & flx1.TextMatrix(n, 2) & "','" & flx1.TextMatrix(n, 3) & "'," & Val(flx1.TextMatrix(n, 4)) & "," & Val(flx1.TextMatrix(n, 5)) & ")") If rs.state = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.Open ("SELECT STATION_NAME FROM STATION_MASTER where STATION_NAME='" & flx1.TextMatrix(n, 1) & "'"), conn, adOpenDynamic, adLockOptimistic If rs.RecordCount > 0 Then Else cn.Execute ("insert into STATION_MASTER values('" & flx1.TextMatrix(n, 0) & "','" & flx1.TextMatrix(n, 1) & "')") End If Next n cn.CommitTrans MDIForm1.StatusBar1.SimpleText = "RECORD UPDATED SUCCESSFULLY" MDIForm1.StatusBar1.SimpleText = "TABLE CREATED SUCCESSFULLY" Call clear End If End Sub Private Sub Command3_Click() If cn.state = adStateOpen Then cn.Close End If cn.Open conn cn.BeginTrans cn.Execute ("UPDATE TRAIN_MASTER SET TRAIN_ID=" & Val(Text2.Text) & ",TRAIN_NAME='" & Text1.Text & "',SOURCE='" & Text3.Text & "',DEP_TIME='" & Text4.Text & "',DESTINATION='" & Text5.Text & "',ARRIVAL='" & Text6.Text & "',TOTAL_SEATS=" & Val(Text7.Text) & ",KM=" & Val(Text8.Text) & ",GEN_1A='" & Text9.Text & "',GEN_2A='" & Text10.Text & "',GEN_3A='" & Text11.Text & "',GEN_2S='" & Text12.Text & "',GEN_SL='" & Text13.Text & "',GEN_CC='" & Text14.Text & "',TAK_1A='" & Text15.Text & "',TAK_2A='" & Text16.Text & "',TAK_3A='" & Text17.Text & "',TAK_2S='" & Text18.Text & "',TAK_SL='" &

Text19.Text & "',TAK_CC='" & Text20.Text & "',WL=" & 25 & " WHERE TRAIN_ID=" & Val(Text2.Text) & "") cn.Execute ("DELETE FROM " & Text2 & "") For n = 1 To flx1.Rows - 2 cn.Execute ("insert into " & Text2 & " values('" & flx1.TextMatrix(n, 0) & "','" & flx1.TextMatrix(n, 1) & "','" & flx1.TextMatrix(n, 2) & "','" & flx1.TextMatrix(n, 3) & "'," & Val(flx1.TextMatrix(n, 4)) & "," & Val(flx1.TextMatrix(n, 5)) & ")") If rs.state = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.Open ("SELECT STATION_NAME FROM STATION_MASTER where STATION_NAME='" & flx1.TextMatrix(n, 1) & "'"), conn, adOpenDynamic, adLockOptimistic If rs.RecordCount > 0 Then Else cn.Execute ("insert into STATION_MASTER values('" & flx1.TextMatrix(n, 0) & "','" & flx1.TextMatrix(n, 1) & "')") End If Next n cn.CommitTrans MDIForm1.StatusBar1.SimpleText = "RECORD UPDATED SUCCESSFULLY" Command3.Enabled = False Command8.Enabled = True Command1.Enabled = True Command2.Enabled = True Command5.Enabled = False Call clear Call flx1.clear Call flux End Sub Private Sub Command4_Click() If (flx1.Row + 1) = flx1.Rows Then MsgBox ("You Can not Delete Empty Row") Else flx1.RemoveItem (flx1.Row) cnt = flx1.Rows - 1 End If End Sub Private Sub Command5_Click() If cn.state = adStateOpen Then cn.Close End If cn.Open conn cn.BeginTrans cn.Execute ("DELETE FROM TRAIN_MASTER WHERE TRAIN_ID='" & Text2.Text & "'") cn.Execute ("DROP TABLE " & Text2 & "") cn.CommitTrans

MDIForm1.StatusBar1.SimpleText = "RECORD DELETED SUCCESSFULLY" Call clear flx1.clear Call flux End Sub Private Sub Command6_Click() Form1.Hide End Sub Private Sub Command7_Click() Frame7.Visible = False End Sub Private Sub Command8_Click() Command2.Enabled = False Command3.Enabled = True Command5.Enabled = True If Text1.Text = "" Then Frame7.Visible = False Else Frame7.Visible = True End If If rs.state = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.Open ("SELECT TRAIN_NAME,TRAIN_ID FROM TRAIN_MASTER WHERE TRAIN_NAME LIKE '" & (Text1.Text + "%") & "'"), conn, adOpenDynamic, adLockOptimistic If rs.RecordCount > 0 Then flx2.Rows = rs.RecordCount + 1 For k = 1 To rs.RecordCount flx2.TextMatrix(k, 0) = rs.Fields("TRAIN_NAME") flx2.TextMatrix(k, 1) = rs.Fields("TRAIN_ID") rs.MoveNext Next k Else Frame7.Visible = False MsgBox ("No Records Found") End If End Sub Private Sub flx2_Click() If rs.state = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.Open ("SELECT * FROM TRAIN_MASTER where TRAIN_NAME='" & flx2.TextMatrix(flx2.Row, 0) & "'"), conn, adOpenDynamic, adLockOptimistic If rs.RecordCount > 0 Then Text1 = rs.Fields("TRAIN_NAME") Text2 = rs.Fields("TRAIN_ID")

End If

Text3 = rs.Fields("SOURCE") Text4 = rs.Fields("DEP_TIME") Text5 = rs.Fields("DESTINATION") Text6 = rs.Fields("ARRIVAL") Text7 = rs.Fields("TOTAL_SEATS") Text8 = rs.Fields("KM") Text9 = rs.Fields("GEN_1A") Text10 = rs.Fields("GEN_2A") Text11 = rs.Fields("GEN_3A") Text12 = rs.Fields("GEN_2S") Text13 = rs.Fields("GEN_SL") Text14 = rs.Fields("GEN_CC") Text15 = rs.Fields("TAK_1A") Text16 = rs.Fields("TAK_2A") Text17 = rs.Fields("TAK_3A") Text18 = rs.Fields("TAK_2S") Text19 = rs.Fields("TAK_SL") Text20 = rs.Fields("TAK_CC") If rs.state = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.Open ("SELECT * FROM " & Val(Text2) & ""), conn, adOpenDynamic, adLockOptimistic If rs.RecordCount > 0 Then flx1.Rows = rs.RecordCount + 1 For m = 1 To rs.RecordCount flx1.TextMatrix(m, 0) = rs.Fields("stn_code") flx1.TextMatrix(m, 1) = rs.Fields("stn_name") flx1.TextMatrix(m, 2) = rs.Fields("arrival") flx1.TextMatrix(m, 3) = rs.Fields("dep") flx1.TextMatrix(m, 4) = rs.Fields("distance") flx1.TextMatrix(m, 5) = rs.Fields("no_of_days") rs.MoveNext flx1.Rows = flx1.Rows + 1 Next m End If

Frame7.Visible = False End Sub Private Sub Form_Load() conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\RRS.mdb;" Call flux Call flux2 End Sub Sub clear() Text1 Text2 Text3 Text4 Text5

= = = = =

"" "" "" "" ""

Text6 = "" Text7 = "" Text8 = "" Text9 = "" Text10 = "" Text11 = "" Text12 = "" Text13 = "" Text14 = "" Text15 = "" Text16 = "" Text17 = "" Text18 = "" Text19 = "" Text20 = "" flx1.clear Call flux End Sub Private Sub flux() flx1.Col = 0 flx1.Row = 0 flx1.CellForeColor = white flx1.ColWidth(0) = 2000 flx1.Text = "Station Code" flx1.Col = 1 flx1.CellForeColor = vbBlue flx1.ColWidth(1) = 3500 flx1.Text = "Station Name" flx1.Col = 2 flx1.CellForeColor = vbBlue flx1.ColWidth(2) = 1500 flx1.Text = "Arrival" flx1.Col = 3 flx1.CellForeColor = vbBlue flx1.ColWidth(3) = 1500 flx1.Text = "Departure" flx1.Col = 4 flx1.CellForeColor = vbBlue flx1.ColWidth(4) = 1500 flx1.Text = "Distance" flx1.Col = 5 flx1.CellForeColor = vbBlue flx1.ColWidth(5) = 1000 flx1.Text = "Day" flx1.Rows = 2 flx1.Row = 1 flx1.Col = 0 flx1.RowSel = flx1.Rows - 1 flx1.ColSel = flx1.Cols - 1 flx1.Row = 1 flx1.Row = 1 flx1.Col = 0 flx1.RowSel = flx1.Rows - 1

flx1.ColSel = flx1.Cols - 1 flx1.Row = 1 End Sub Private Sub flx1_KeyDown(KeyCode As Integer, Shift As Integer) flx1.Row = flx1.Row Text21.Visible = True Text21.Left = flx1.CellLeft + 450 Text21.Top = flx1.CellTop + 350 Text21.Width = flx1.CellWidth Text21.Height = flx1.CellHeight Text21 = "" Text21.SetFocus End Sub Private Sub Text21_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 13 Then flx1.Row = flx1.Row flx1.Col = flx1.Col flx1.Text = Text21.Text Text21.Visible = False flx1.SetFocus If flx1.Col = 5 Then flx1.Rows = flx1.Rows + 1 End If End If End Sub Private Sub flux2() flx2.Col = 0 flx2.Row = 0 flx2.CellForeColor = white flx2.ColWidth(0) = 1500 flx2.Text = "Train Name" flx2.Col = 1 flx2.CellForeColor = vbBlue flx2.ColWidth(1) = 1500 flx2.Text = "Train No" flx2.Rows = 2 flx2.Row = 1 flx2.Col = 0 flx2.RowSel = flx2.Rows - 1 flx2.ColSel = flx2.Cols - 1 flx2.Row = 1 flx2.Row = 1 flx2.Col = 0 flx2.RowSel = flx2.Rows - 1 flx2.ColSel = flx2.Cols - 1 flx2.Row = 1 End Sub BOOKING FORM:

Dim Dim Dim Dim Dim Dim Dim Dim Dim

cn As New ADODB.Connection rs As New ADODB.Recordset rs1 As New ADODB.Recordset rs2 As New ADODB.Recordset rs3 As New ADODB.Recordset rs4 As New ADODB.Recordset conn As String class, tname, state As String fare, tno, bal, avail_seats As Integer

Private Sub Calendar1_Click() If Calendar1.Value >= Date Then Text3.Text = Format(Calendar1.Value, "dd/mm/yyyy") Frame5.Visible = False Combo1.SetFocus End If End Sub Private Sub Combo2_LostFocus() If rs.state = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.Open ("SELECT * FROM STATION_MASTER WHERE STATION_NAME <>'" & Combo2.Text & "' ORDER BY STATION_CODE"), conn, adOpenDynamic, adLockOptimistic If rs.RecordCount > 0 Then For k = 1 To rs.RecordCount Combo3.AddItem (rs.Fields("STATION_NAME")) rs.MoveNext Next k End If End Sub Private Sub Command1_Click() If Combo2.Text <> "SOURCE" And Combo3.Text <> "DESTINATION" And Text3 <> "" And Combo1.Text <> "Select" Then da = Mid(Format(Now, "dd/mm/yyyy"), 1, 2) da_ex = Mid(Format(Now, "dd/mm/yyyy"), 1, 2) + 3 mo = Mid(Format(Now, "dd/mm/yyyy"), 4, 2) ye = Mid(Format(Now, "dd/mm/yyyy"), 7, 4) dat = Mid(Format(Now, "dd/mm/yyyy"), 3, 8) txt_da = Mid(Text3, 1, 2) txt_mo = Mid(Text3, 4, 2) txt_ye = Mid(Text3, 7, 4) d = Val(da) + 2 & dat If Combo1.Text = "Takkal" Then If Val(txt_da) >= da_ex Or Val(txt_mo) > mo Or Val(txt_ye) > ye Then MsgBox ("You Cannot book the ticket in Takkal Quota") Exit Sub End If End If flx1.clear

Call flux1 j=0 If rs.state = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.Open ("SELECT T_NO,T_NAME FROM TRAIN_NAME"), conn, adOpenDynamic, adLockOptimistic If rs.RecordCount > 0 Then For i = 1 To rs.RecordCount flx1.Rows = rs.RecordCount + 1 j=i Text1.Text = rs.Fields("T_NO") Text2.Text = rs.Fields("T_NAME") If rs1.state = adStateOpen Then rs1.Close End If rs1.CursorLocation = adUseClient 'rs1.Open ("SELECT distance FROM " & Text1 & " WHERE stn_name='" & Combo2.Text & "'"), conn, adOpenDynamic, adLockOptimistic rs1.Open ("select distance-(select distance from " & Val(Text1) & " where stn_name='" & Combo3 & "') from " & Val(Text1) & " where stn_name='" & Combo2 & "'"), conn, adOpenDynamic, adLockOptimistic If rs1.RecordCount > 0 Then If rs1.Fields(0) < 0 Then fare = -(rs1.Fields(0)) flx1.TextMatrix(j, 0) = Text1 flx1.TextMatrix(j, 1) = Text2 If rs2.state = adStateOpen Then rs2.Close End If rs2.CursorLocation = adUseClient rs2.Open ("SELECT * FROM AVAILABLE_SEATS where T_NO=" & Text1 & " and DATE= '" & Text3 & "' "), conn, adOpenDynamic, adLockOptimistic If rs2.RecordCount > 0 Then If Combo1.Text = "General" Then flx1.TextMatrix(j, 2) = rs2.Fields("DEP_TIME") flx1.TextMatrix(j, 3) = rs2.Fields("ARRIVAL") flx1.TextMatrix(j, 4) = rs2.Fields("GEN_1A") flx1.TextMatrix(j, 5) = rs2.Fields("GEN_2A") flx1.TextMatrix(j, 6) = rs2.Fields("GEN_3A") flx1.TextMatrix(j, 7) = rs2.Fields("GEN_2S") flx1.TextMatrix(j, 8) = rs2.Fields("GEN_SL") flx1.TextMatrix(j, 9) = rs2.Fields("GEN_CC") ElseIf Combo1.Text = "Takkal" Then flx1.TextMatrix(j, 2) = rs2.Fields("DEP_TIME") flx1.TextMatrix(j, 3) = rs2.Fields("ARRIVAL") flx1.TextMatrix(j, 4) = rs2.Fields("TAK_1A") flx1.TextMatrix(j, 5) = rs2.Fields("TAK_2A") flx1.TextMatrix(j, 6) = rs2.Fields("TAK_3A") flx1.TextMatrix(j, 7) = rs2.Fields("TAK_2S") flx1.TextMatrix(j, 8) = rs2.Fields("TAK_SL") flx1.TextMatrix(j, 9) = rs2.Fields("TAK_CC")

End If Else If rs3.state = adStateOpen Then rs3.Close End If rs3.CursorLocation = adUseClient rs3.Open ("SELECT * FROM TRAIN_MASTER where TRAIN_ID = " & Val(Text1) & ""), conn, adOpenDynamic, adLockOptimistic If rs3.RecordCount > 0 Then If cn.state = adStateOpen Then cn.Close End If cn.Open conn cn.BeginTrans cn.Execute ("INSERT INTO AVAILABLE_SEATS VALUES(" & Val(Text1.Text) & ",'" & Text2.Text & "'," & Val(rs3.Fields("GEN_1A")) & "," & Val(rs3.Fields("GEN_2A")) & "," & Val(rs3.Fields("GEN_3A")) & "," & Val(rs3.Fields("GEN_2S")) & "," & Val(rs3.Fields("GEN_SL")) & "," & Val(rs3.Fields("GEN_CC")) & "," & Val(rs3.Fields("TAK_1A")) & "," & Val(rs3.Fields("TAK_2A")) & "," & Val(rs3.Fields("TAK_3A")) & "," & Val(rs3.Fields("TAK_2S")) & "," & Val(rs3.Fields("TAK_SL")) & "," & Val(rs3.Fields("TAK_CC")) & ",'" & Text3.Text & "','" & rs3.Fields("SOURCE") & "','" & rs3.Fields("DESTINATION") & "','" & rs3.Fields("DEP_TIME") & "','" & rs3.Fields("ARRIVAL") & "')") cn.CommitTrans End If If rs2.state = adStateOpen Then rs2.Close End If rs2.CursorLocation = adUseClient rs2.Open ("SELECT * FROM AVAILABLE_SEATS where T_NO=" & Text1 & " and DATE='" & Text3 & "' "), conn, adOpenDynamic, adLockOptimistic If rs2.RecordCount > 0 Then If Combo1.Text = "General" Then flx1.TextMatrix(j, 2) = rs2.Fields("DEP_TIME") flx1.TextMatrix(j, 3) = rs2.Fields("ARRIVAL") flx1.TextMatrix(j, 4) = rs2.Fields("GEN_1A") flx1.TextMatrix(j, 5) = rs2.Fields("GEN_2A") flx1.TextMatrix(j, 6) = rs2.Fields("GEN_3A") flx1.TextMatrix(j, 7) = rs2.Fields("GEN_2S") flx1.TextMatrix(j, 8) = rs2.Fields("GEN_SL") flx1.TextMatrix(j, 9) = rs2.Fields("GEN_CC") ElseIf Combo1.Text = "Takkal" Then flx1.TextMatrix(j, 2) = rs2.Fields("DEP_TIME") flx1.TextMatrix(j, 3) = rs2.Fields("ARRIVAL") flx1.TextMatrix(j, 4) = rs2.Fields("TAK_1A") flx1.TextMatrix(j, 5) = rs2.Fields("TAK_2A") flx1.TextMatrix(j, 6) = rs2.Fields("TAK_3A") flx1.TextMatrix(j, 7) = rs2.Fields("TAK_2S") flx1.TextMatrix(j, 8) = rs2.Fields("TAK_SL") flx1.TextMatrix(j, 9) = rs2.Fields("TAK_CC") End If

End If End If End If End If rs.MoveNext Next i End If Else MsgBox ("Please Enter all the Details") End If End Sub Private Sub Command10_Click() On Error Resume Next Frame6.Visible = True If rs.state = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.Open ("SELECT * FROM " & Val(tno) & ""), conn, adOpenDynamic, adLockOptimistic If rs.RecordCount > 0 Then For k = 1 To rs.RecordCount flx3.Rows = 15 flx3.TextMatrix(k, 0) = rs.Fields("stn_name") flx3.TextMatrix(k, 1) = rs.Fields("arrival") flx3.TextMatrix(k, 2) = rs.Fields("dep") flx3.TextMatrix(k, 3) = rs.Fields("distance") flx3.TextMatrix(k, 4) = rs.Fields("no_of_days") rs.MoveNext Next k End If End Sub Private Sub Command11_Click() Frame6.Visible = False End Sub Private Sub Command2_Click() Combo1.clear Combo2.clear Combo3.clear Combo1.Text = "Select" Combo2.Text = "SOURCE" Combo3.Text = "DESTINATION" Text3 = "" Frame2.Visible = False Frame3.Visible = False Frame4.Visible = False flx1.clear Call combo End Sub

Private Sub Command3_Click() Form2.Hide End Sub Private Sub Command4_Click() Command10.Enabled = False Frame2.Visible = True Frame3.Visible = True Combo4.AddItem ("MALE") Combo4.AddItem ("FEMALE") If class = "1A" Or class = "2A" Or class = "3A" Then Label9.Caption = "Berth" Combo5.AddItem ("LOWER") Combo5.AddItem ("MIDDLE") Combo5.AddItem ("UPPER") Combo5.AddItem ("SIDE LOWER") Combo5.AddItem ("SIDE UPPER") Else Label9.Caption = "Place" Combo5.AddItem ("WINDOW") Combo5.AddItem ("MIDDLE") Combo5.AddItem ("LAST") End If End Sub

Private Sub Command5_Click() If Text4 = "" Or Text5 = "" Or Combo4 = "Select" Or Combo5 = "Select" Then MsgBox ("Please Check all fields have value") Else Command6.Enabled = True flx2.TextMatrix(flx2.Row, 0) = Text4 flx2.TextMatrix(flx2.Row, 1) = Text5 flx2.TextMatrix(flx2.Row, 2) = Combo4 flx2.TextMatrix(flx2.Row, 3) = Combo5 flx2.TextMatrix(flx2.Row, 4) = class If Combo1.Text = "General" Then If class = "1A" Then flx2.TextMatrix(flx2.Row, 5) = Format(Round(fare * 2.5), "0.00") ElseIf class = "2A" Then flx2.TextMatrix(flx2.Row, 5) = Format(Round(fare * 2), "0.00") ElseIf class = "3A" Then flx2.TextMatrix(flx2.Row, 5) = Format(Round(fare * 1.5), "0.00") ElseIf class = "SL" Then flx2.TextMatrix(flx2.Row, 5) = Format(Round(fare * 1), "0.00") ElseIf class = "2S" Then flx2.TextMatrix(flx2.Row, 5) = Format(Round(fare * 0.75), "0.00") ElseIf class = "CC" Then flx2.TextMatrix(flx2.Row, 5) = Format(Round(fare * 0.75), "0.00") End If ElseIf Combo1.Text = "Takkal" Then If class = "1A" Then

flx2.TextMatrix(flx2.Row, 5) = Format(Round((fare * 2.5) + 100), "0.00") ElseIf class = "2A" Then flx2.TextMatrix(flx2.Row, 5) = Format(Round((fare * 2) + 75), "0.00") ElseIf class = "3A" Then flx2.TextMatrix(flx2.Row, 5) = Format(Round((fare * 1.5) + 50), "0.00") ElseIf class = "SL" Then flx2.TextMatrix(flx2.Row, 5) = Format(Round((fare * 1) + 40), "0.00") ElseIf class = "2S" Then flx2.TextMatrix(flx2.Row, 5) = Format(Round((fare * 0.75) + 30), "0.00") ElseIf class = "CC" Then flx2.TextMatrix(flx2.Row, 5) = Format(Round((fare * 0.75) + 25), "0.00") End If End If flx2.Rows = flx2.Rows + 1 flx2.Row = flx2.Row + 1 Text4 = "" Text5 = "" Combo4 = "Select" Combo5 = "Select" Command7.Enabled = True End If End Sub Private Sub Command6_Click() Command7.Enabled = False For n = 1 To flx2.Rows - 2 tot = Val(tot) + Val(flx2.TextMatrix(n, 5)) Next n Label16 = Combo2 Label17 = Combo3 Label18 = Text3 Label19 = Format(Now, "dd/mm/yyyy") Label20 = flx2.Rows - 2 Label21 = Combo1 Label22 = Format(tot, "0.00") Frame4.Visible = True End Sub Private Sub Command7_Click() If (flx2.Row + 1) = flx2.Rows Then MsgBox ("You Can't Delete Empty Row") Else flx2.RemoveItem (flx2.Row) cnt = flx2.Rows - 1 End If End Sub Private Sub Command8_Click() Command8.Enabled = False If rs.state = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient

rs.Open ("SELECT PNR_NO_KEY FROM KEY_TABLE"), conn, adOpenDynamic, adLockOptimistic If rs.RecordCount > 0 Then pnr_key = rs.Fields(0) + 1 End If If rs4.state = adStateOpen Then rs4.Close End If rs4.CursorLocation = adUseClient rs4.Open ("SELECT dep FROM " & Val(tno) & " WHERE stn_name='" & Combo2.Text & "'"), conn, adOpenDynamic, adLockOptimistic If rs4.RecordCount > 0 Then dep_t = rs4.Fields("dep") If rs.state = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.Open ("SELECT arrival FROM " & Val(tno) & " WHERE stn_name='" & Combo3.Text & "'"), conn, adOpenDynamic, adLockOptimistic If rs.RecordCount > 0 Then arr = rs.Fields("arrival") End If End If If cn.state = adStateOpen Then cn.Close End If state = "Booked" bal = Val(avail_seats) - Val(Label20.Caption) cn.Open conn cn.BeginTrans cn.Execute ("INSERT INTO BOOK_MASTER VALUES(" & Val(pnr_key) & "," & Val(tno) & ",'" & tname & "','" & Label19.Caption & "','" & Label18.Caption & "','" & class & "','" & Label16.Caption & "','" & Label17.Caption & "','" & dep_t & "','" & arr & "','" & Label22.Caption & "'," & Val(fare) & ",'" & Label21.Caption & "','" & state & "')") cn.Execute ("UPDATE KEY_TABLE SET PNR_NO_KEY=" & pnr_key & "") If Combo1.Text = "General" Then cl = "Gen_" & class cn.Execute ("UPDATE AVAILABLE_SEATS SET " & cl & "=" & Val(bal) & " where T_NO=" & Val(tno) & " and DATE='" & Text3 & "' ") ElseIf Combo1.Text = "Takkal" Then cn.Execute ("UPDATE AVAILABLE_SEATS SET " & cl & "=" & Val(bal) & " where T_NO=" & Val(tno) & " and DATE='" & Text3 & "'") End If For t = 1 To flx2.Rows - 2 cn.Execute ("INSERT INTO BOOK_DETAIL VALUES(" & Val(pnr_key) & "," & Val(t) & ",'" & flx2.TextMatrix(t, 0) & "'," & Val(flx2.TextMatrix(t, 1)) & ",'" & flx2.TextMatrix(t, 2) & "','" & flx2.TextMatrix(t, 3) & "','" & flx2.TextMatrix(t, 4) & "','" & flx2.TextMatrix(t, 5) & "','" & state & "')") Next t cn.CommitTrans MsgBox ("Your Ticket is Confirmed and Your PNR No. is" & Val(pnr_key)) End Sub

Private Sub Command9_Click() Frame5.Visible = False End Sub Private Sub flx1_Click() On Error Resume Next Command4.Enabled = False Command10.Enabled = False If (flx1.Row <> 0 And flx1.Col <> 0 And flx1.Col <> 1 And flx1.Col <> 2 And flx1.Col <> 3) Then If (Val(flx1.TextMatrix(flx1.Row, flx1.Col))) <= 0 Then avail_seats = Val(flx1.TextMatrix(flx1.Row, flx1.Col)) Command4.Enabled = False Command10.Enabled = False Else avail_seats = Val(flx1.TextMatrix(flx1.Row, flx1.Col)) Command4.Enabled = True Command10.Enabled = False End If tno = flx1.TextMatrix(flx1.Row, 0) tname = flx1.TextMatrix(flx1.Row, 1) class = flx1.TextMatrix(0, flx1.Col) 'If rs.State = adStateOpen Then ' rs.Close 'End If 'rs.CursorLocation = adUseClient 'rs.Open ("SELECT * FROM AVAILABLE_SEATS where TRAIN_NO='" & flx1.TextMatrix(flx1.Row, 0) & "'"), conn, adOpenDynamic, adLockOptimistic 'If rs.RecordCount > 0 Then ' If Combo1.Text = "General" Then ' ' End If Else Command10.Enabled = True tno = flx1.TextMatrix(flx1.Row, 0) End If End Sub Private Sub Form_Load() conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\RRS.mdb;" Call combo End Sub Private Sub Text3_GotFocus() Frame5.Visible = True End Sub Sub combo() Combo1.AddItem ("General") Combo1.AddItem ("Takkal") If rs.state = adStateOpen Then

rs.Close End If rs.CursorLocation = adUseClient rs.Open ("SELECT * FROM STATION_MASTER ORDER BY STATION_NAME"), conn, adOpenDynamic, adLockOptimistic If rs.RecordCount > 0 Then For i = 1 To rs.RecordCount Combo2.AddItem (rs.Fields("STATION_NAME")) rs.MoveNext Next i End If Calendar1 = Now Call flux1 Call flux2 Call flux3 End Sub Private Sub flux1() flx1.Col = 0 flx1.Row = 0 flx1.CellForeColor = vbBlue flx1.ColWidth(0) = 1000 flx1.Text = "Train No" flx1.Col = 1 flx1.CellForeColor = vbBlue flx1.ColWidth(1) = 1800 flx1.Text = "Train Name" flx1.Col = 2 flx1.CellForeColor = vbBlue flx1.ColWidth(2) = 900 flx1.Text = "Depature" flx1.Col = 3 flx1.CellForeColor = vbBlue flx1.ColWidth(3) = 900 flx1.Text = "Arrival" flx1.Col = 4 flx1.CellForeColor = vbBlue flx1.ColWidth(4) = 700 flx1.Text = "1A" flx1.Col = 5 flx1.CellForeColor = vbBlue flx1.ColWidth(5) = 700 flx1.Text = "2A" flx1.Col = 6 flx1.CellForeColor = vbBlue flx1.ColWidth(6) = 700 flx1.Text = "3A" flx1.Col = 7 flx1.CellForeColor = vbBlue flx1.ColWidth(7) = 700 flx1.Text = "2S" flx1.Col = 8 flx1.CellForeColor = vbBlue

flx1.ColWidth(8) = 700 flx1.Text = "SL" flx1.Col = 9 flx1.CellForeColor = vbBlue flx1.ColWidth(9) = 700 flx1.Text = "CC" flx1.Rows = 2 flx1.Row = 1 flx1.Col = 0 flx1.RowSel = flx1.Rows - 1 flx1.ColSel = flx1.Cols - 1 End Sub Private Sub flux2() flx2.Col = 0 flx2.Row = 0 flx2.CellForeColor = white flx2.ColWidth(0) = 3500 flx2.Text = "Name" flx2.Col = 1 flx2.CellForeColor = white flx2.ColWidth(1) = 500 flx2.Text = "Age" flx2.Col = 2 flx2.CellForeColor = white flx2.ColWidth(2) = 1000 flx2.Text = "Sex" flx2.Col = 3 flx2.CellForeColor = white flx2.ColWidth(3) = 1500 flx2.Text = "Berth" flx2.Col = 4 flx2.CellForeColor = white flx2.ColWidth(4) = 500 flx2.Text = "Class" flx2.Col = 5 flx2.CellForeColor = white flx2.ColWidth(5) = 1200 flx2.Text = "Fare" flx2.Rows = 2 flx2.Row = 1 flx2.Col = 0 flx2.RowSel = flx2.Rows - 1 flx2.ColSel = flx2.Cols - 1 End Sub Private Sub flux3() flx3.Col = 0 flx3.Row = 0 flx3.CellForeColor = white flx3.ColWidth(0) = 3500 flx3.Text = "Station Name" flx3.Col = 1 flx3.CellForeColor = white flx3.ColWidth(1) = 700

flx3.Text = "Arrival" flx3.Col = 2 flx3.CellForeColor = white flx3.ColWidth(2) = 700 flx3.Text = "Departure" flx3.Col = 3 flx3.CellForeColor = white flx3.ColWidth(3) = 500 flx3.Text = "Distance" flx3.Col = 4 flx3.CellForeColor = white flx3.ColWidth(4) = 500 flx3.Text = "No_of_days" flx3.Rows = 2 flx3.Row = 1 flx3.Col = 0 flx3.RowSel = flx3.Rows - 1 flx3.ColSel = flx3.Cols - 1 End Sub Private Sub Text5_GotFocus() Text4 = UCase(Text4) End Sub

TICKET CANCEL FORM: Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim rs1 As New ADODB.Recordset Dim rs2 As New ADODB.Recordset Dim conn As String Dim pname, state, stat As String Private Sub Command1_Click() If rs.state = adStateOpen Then rs.Close End If rs.CursorLocation = adUseClient rs.Open ("SELECT * FROM BOOK_MASTER WHERE PNR_NO =" & Val(Text2) & " "), conn, adOpenDynamic, adLockOptimistic If rs.RecordCount > 0 Then Label15.Caption = rs.Fields("PNR_NO") Label16.Caption = rs.Fields("TR_NO") Label17.Caption = rs.Fields("TR_NAME") Label18.Caption = rs.Fields("BOOKING_DATE") Label19.Caption = rs.Fields("TRAVEL_DATE") Label20.Caption = rs.Fields("QUOTA") Label21.Caption = rs.Fields("SOURCE") Label22.Caption = rs.Fields("DESTINATION") Label23.Caption = rs.Fields("TOTAL_FARE") Label8.Caption = rs.Fields("CLASS")

Label9.Caption = rs.Fields("KMS") If rs2.state = adStateOpen Then rs2.Close End If rs2.CursorLocation = adUseClient rs2.Open ("SELECT * FROM BOOK_DETAIL WHERE PNR_NO =" & Val(Text2) & " "), conn, adOpenDynamic, adLockOptimistic If rs2.RecordCount > 0 Then flx2.Rows = rs2.RecordCount + 1 For i = 1 To rs2.RecordCount flx2.TextMatrix(i, 0) = rs2.Fields("PASSENGER_NAME") flx2.TextMatrix(i, 1) = rs2.Fields("AGE") flx2.TextMatrix(i, 2) = rs2.Fields("SEX") flx2.TextMatrix(i, 3) = rs2.Fields("BERTH") flx2.TextMatrix(i, 4) = rs2.Fields("CLASS") flx2.TextMatrix(i, 5) = rs2.Fields("FARE") flx2.TextMatrix(i, 6) = rs2.Fields("STATUS") rs2.MoveNext Next i End If Else MsgBox ("Please Enter a Valid PNR Number") End If End Sub Private Sub Command5_Click() If rs2.state = adStateOpen Then rs2.Close End If rs2.CursorLocation = adUseClient rs2.Open ("SELECT * FROM BOOK_DETAIL WHERE PNR_NO =" & Val(Label15.Caption) & " AND PASSENGER_NAME='" & pname & "' AND STATUS='" & state & "'"), conn, adOpenDynamic, adLockOptimistic If rs2.RecordCount > 0 Then stat = "Cancelled" If cn.state = adStateOpen Then cn.Close End If cn.Open conn cn.BeginTrans cn.Execute ("UPDATE BOOK_DETAIL SET STATUS = '" & stat & "' WHERE PNR_NO = " & Val(Label15.Caption) & " AND PASSENGER_NAME='" & pname & "' AND STATUS='" & state & "'") cn.Execute ("INSERT INTO CANCEL_MASTER VALUES(" & Val(Label15.Caption) & "," & Val(Label16.Caption) & ",'" & Label17.Caption & "','" & Label18.Caption & "','" & Label19.Caption & "','" & Format(Now, "dd/mm/yyyy") & "','" & Label8.Caption & "','" & Label21.Caption & "','" & Label22.Caption & "','" & Label23.Caption & "'," & Val(Label9.Caption) & ",'" & Label20.Caption & "')") cn.Execute ("INSERT INTO CANCEL_DETAIL VALUES(" & Val(Label15.Caption) & ",'" & flx2.TextMatrix(t, 0) & "'," & Val(flx2.TextMatrix(t, 1)) & ",'" & flx2.TextMatrix(t,

2) & "','" & flx2.TextMatrix(t, 3) & "','" & flx2.TextMatrix(t, 4) & "','" & flx2.TextMatrix(t, 5) & "','" & state & "')") cn.CommitTrans End If End Sub Private Sub flx2_Click() On Error Resume Next Command5.Enabled = False If (flx2.Row <> 0) Then If (flx2.TextMatrix(flx2.Row, flx2.Col)) <> "" Then Command5.Enabled = True Else Command5.Enabled = False End If pname = flx2.TextMatrix(flx2.Row, 0) state = flx2.TextMatrix(flx2.Row, 6) End If End Sub Private Sub Form_Load() conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\RRS.mdb;" Call flux2 End Sub Private Sub flux2() flx2.Col = 0 flx2.Row = 0 flx2.CellForeColor = white flx2.ColWidth(0) = 3000 flx2.Text = "Name" flx2.Col = 1 flx2.CellForeColor = white flx2.ColWidth(1) = 500 flx2.Text = "Age" flx2.Col = 2 flx2.CellForeColor = white flx2.ColWidth(2) = 800 flx2.Text = "Sex" flx2.Col = 3 flx2.CellForeColor = white flx2.ColWidth(3) = 1500 flx2.Text = "Berth" flx2.Col = 4 flx2.CellForeColor = white flx2.ColWidth(4) = 500 flx2.Text = "Class" flx2.Col = 5 flx2.CellForeColor = white flx2.ColWidth(5) = 1200

flx2.Text = "Fare" flx2.Col = 6 flx2.CellForeColor = white flx2.ColWidth(6) = 1000 flx2.Text = "Status" flx2.Rows = 2 flx2.Row = 1 flx2.Col = 0 flx2.RowSel = flx2.Rows - 1 flx2.ColSel = flx2.Cols - 1 End Sub REPORT FORM: Private Sub Command1_Click() Frame3.Visible = False Frame2.Visible = True End Sub Private Sub Command2_Click() Frame2.Visible = False Frame3.Visible = True End Sub Private Sub Command3_Click() If DataEnvironment1.Connection1.state = adStateOpen Then DataEnvironment1.Connection1.Close End If DataEnvironment1.Connection1.Open DataEnvironment1.Booked_Tickets_Grouping Val(Text1) DataReport1.Show End Sub Private Sub Command4_Click() Frame2.Visible = False End Sub Private Sub Command5_Click() Frame3.Visible = False End Sub Private Sub Command6_Click() If DataEnvironment1.Connection1.state = adStateOpen Then DataEnvironment1.Connection1.Close End If DataEnvironment1.Connection1.Open DataEnvironment1.Cancelled_Tickets_Grouping Text1 DataReport2.Show End Sub MODULE:

Public tno As Integer Public class As String

CONCLUSION This project is about the designing the railway reservation system using M S Access, as back end and Visual Basic 6.0 as front end. This project presents an investigative view of present railway reservation system including the history of booking tickets and cancelled tickets. Present system of railway reservation system is having some shortcoming on which we have tried to work on that to eliminate the disadvantages. We have made a database for passengers and trains and connected these two tables from the custom made data entry form built in Visual Basic 6.0. There are options for new entry which will be stored in M S Access database and retrieved from database in future.

This project was a small attempt to make the railway reservation system using M S Access, and Visual Basic 6.0. In the last we conclude that Indian Railway is having a strong IT Infrastructure and a well- equipped railway reservation system but there is some shortcoming in the system on which we have tried to work on it and successfully completed our project.

FUTURE ENHANCEMENT If anyone wants to extend this project then he or she can make an additional database of WAITING LIST. And database for updated seat allocation on that specific coach of the train. Etc. He or she can also add some more controls in the existing software and extend working of the existing software.

You might also like