Professional Documents
Culture Documents
ACKNOWLEDGEMENT
The extensive endeavor, bliss euphoria that accompanies the successful completion of any task would not be complete without the expression of gratitude to the people whose guidance and encouragement helped us in winding up this project.
We would like to thanks Miss. Bahavana jain Co-Ordinetor of LBS College Kota, Who proved to be perennial source of inspiration to us.
We are deeply indebted to Mrs. Rashmi Shrivastav for their able guidance, cooperation and constant encouragement throughout the period of compilation of dissertation work. We got not only technical support from them but a lot of moral support also. We will be thankful to them forever.
Shakti Singh Mayur Nama Prakash Jhala Neeraj Nagar Ravi Pathak Manish Gautam (BCA Final yr)
CERTIFICATE
This is to certify that the Minor project entitled Railway Reservation System has been submitted to University of Kota, Kota in partial fulfillment of the requirements for the award of the degree of Bachelor of Computer Application by following student of BCA final year.
Shakti Singh Mayur Nama Prakash Jhala Neeraj Nagar Ravi Pathak Manish Gautam (BCA Final yr)
ABSTRACT
3
This system is basically concerned with the reservation and cancellation of railway tickets to the passengers. The need of this system arose because as is the known fact that India has the largest railway network in the whole of the world and to handle it manually is quite a tough job. By computerizing it, we will be able to overcome many of its limitations and will be able to make it more efficient. The handling of data and records for such a vast system is a very complex task if done manually but it can be made much easier if the system is computerized. It reserves and cancels seats for the passenger. It contains information about the trains. It contains information about the passenger. It contains the details of reservation fees, any concessions etc. It makes entries for reservation, waiting, cancelled tickets. It will update for uptime and downtime trains.
SYNOPSIS
4
Objective: - Desingning a Database that gives us information about railway reservation of tickets. This database helps railways to retrieve data as and when required in future. Introduction:- Layout of railway reservation form and connection of this form with the database required to store information. PASSENGERS DATABASE: database of passengers contains following fields. 1. Name 2. Age 3. Gender.. 4. Total Number Of Passengers Travelling Number of Adults.. Number Of children.. Senior Citizen 5. 6. Date Of Travel Class of Travel.
TRAIN DATABASE : database of train contains following fields. 1. Train Name.. 2. Train Number.. 3. RouteFrom..To.. 4. Train Time 5. Number of Compartments.. 1ST AC 2ND AC 3RD AC Sleeper.. General
SYSTEM
The Indian Railways (IR) carries about 5.5 lakh passengers in reserved accommodation every day. The computerized Passenger Reservation System (PRS) facilitates booking and cancelling of tickets from any of the 4000 terminals (i.e. PRS booking windows) all over the country. These tickets can be booked or cancelled for journeys commencing in any part of India and ending in any other part, with travel times as long as 72 hours and distances up to several thousand kilometers. The pilot project of PRS was launched on 15 November 1985, over Northern Railway with the installation of the Integrated Multiple Train Passenger Reservation System (IMPRESS), an online transaction processing system developed by the Indian Railways in association with Computer Maintenance Corporation (CMC) Ltd., at New Delhi. The objective was to provide r e s e r v e d accommodation on any train from any counter, preparation of t r a i n c h a r t s a n d accounting of the money collected. This application was subsequently implemented in 1987, at Mumbai, Chennai, Kolkata and Secunderabad. With the addition of new locations and many redefinitions, the IMPRESS system fell short of growing expectations of the travelling public. Hence a new application software, i.e., Country Wide Network for Computerized Enhanced Reservation and Ticketing (CONCERT) was developed by the Centre for Railway Information Systems (CRIS), New Delhi primarily using C and also using FORTRAN. The application was first implemented at the Secunderabad PRS site in September 1994 and subsequently at the o t h e r f o u r P R S s i t e s . .
Communication of all the terminals with their server was established u s i n g Railway/Department of Telecommunication (DOT) channel lines, fibre 7
optic cable/microwave c h a n n e l s , s w i t c h e s , m o d e m , m u l t i p l e x e r s e t c . T h e inter-networking of five PRS nodes was completed in April 1999. Interconnectivity is established between the five PRS centres over 2mbps leased Bharat Sanchar Nigam Limited (BSNL) lines. The system has the capability of issuing reserved tickets from anywhere to anywhere, in any train, date or class between any pair of stations from any booking terminal of the PRS. The main modules of the PRS are the Reservation module, the Cancellation and Modification M o d u l e , Charting Module. passengers request for reservation, cancellation and modification of journey are handled by the system through requisition slips. Major outputs generated by the system are Reservation cumjourney tickets, Cancellation/Modification tickets, Reservation Charts and Daily Terminal Cash Summary. The system is also capable of generating different types of Management Information System (MIS) Reports. Indian railway is having ten zonal railways namely Eastern Railway (ER), Northern Railway (NR), Southern Railway (SR), Central Railway(CR), Western Railway (WR), South Central Railway (SCR), North Eastern Railway (NER),South Eastern Railway (SER), North East Frontier Railway (NFR) and East Central Railway(ECR). Module, the Accounting Module, and the the Database
ONLINE BOOKING: This facility is given to general public by railway department. With the help of this facility people can book their tickets through internet, sitting in their home by a single click of the mouse. Using their credit card people can easily get their tickets done within minutes. There are certain charges for online booking as well.
COUNTER BOOKING: This is oldest method of booking the ticket. The reservation counters are there at railway departments from where people can get the tickets to their respective destinations. Nowadays there are various ticket counters, apart from railway station counters where tickets are available.
1. The acquisition and maintenance of a relational database with the help of hardware, communication network and software including system design. 2. To assess if the system chosen in the project operates in an adequately controlled environment. 3. Whether the applications controls are adequate and if the system is in compliance with rules. 4. Adequate security from possibilities of fraud. 5. To show an effective mechanism to ensure most economic usage of available resources. 6. The control mechanism for credit card transactions were adequate.
10
- Intel Pentium processor - Mother Board: - 845 OR 915,995 FOR PENTIUM or VIA K8M800+8237R PLUS CHIPSET FOR AMD ATHALON - Free Space in Hard Disk 2 GB (Minimum)
Software Requirement: -Front End: - Microsoft Visual Basic 6.0 -Back End: - Microsoft Access
11
Reservation storage file Ticket generatio n process Passenger Reservatio n Process Report To Admin
Confirmation Process
Cancellation Process Ticket Generation process Cancellation Table Railway dept Generate Ticket
Enquir y
Reservation Table
Waitin g
Generate report
13
PROJECT SNAP
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
PROJECT CODE
35
FrmSplash Private Sub Form_Load() Prgbar.Value = 0 End Sub Private Sub Timer1_Timer() If Prgbar.Value < 100 Then Prgbar.Value = Prgbar.Value + 2 Else frmLogin.Show End If End Sub
36
frmLogin Private Sub cmdCancel_Click() End End Sub Private Sub cmdOk_Click() If txtUserName.Text = "kota" And txtPassword.Text = "1234" Then Unload Me Unload frmSplash MDIFORM1.Show Else MsgBox "enter correct password" End If End Sub Private Sub Form_Resize() Label1.Width = frmLogin.Width End Sub
37
MDIFORM1 Private Sub MNU_RAIL_Click() FRM_ABT_RAIL.Show End Sub Private Sub mnucan_Click() frmcancel.Show End Sub Private Sub mnuExit_Click() End End Sub Private Sub mnuF_Cfare_Click() frmreserve.Show End Sub Private Sub mnuI_trains_Click() frmT_SDpair.Show End Sub Private Sub mnuIf_detail_Click() frmFare_enq.Show End Sub Private Sub mnuISCode_Click() frmScode_enq.Show End Sub Private Sub MNUMAP_Click() frmmap.Show End Sub
38
Private Sub mnuMod_Click() frmT_modify.Show End Sub Private Sub mnuR_ref_Click() frmRefund.Show End Sub Private Sub mnuR_res_Click() frmreserve.Show End Sub Private Sub MNUREPORT_Click() frmReport.Show End Sub Private Sub mnures_Click() frmres.Show End Sub Private Sub mnuT_sch_Click() frmTschedule.Show End Sub Private Sub mnuT_type_Click() frmT_detail.Show End Sub Private Sub mnuUser_Click() frmUser_detail.Show End Sub Private Sub report_Click() frmReport.Show 39
End Sub Private Sub ttime_Click() Dim temp As New ADODB.Recordset originname = InputBox("Enter Source Name", "Source") originname = UCase(originname) If temp.State = adStateOpen Then temp.Close temp.Open "SELECT * FROM STATION WHERE STATION_NAME='" & originname & "'", db, adOpenKeyset, adLockReadOnly If Not temp.EOF Then origincode = temp.Fields(0) frmT_time.Show Else MsgBox "Source does not exist", vbInformation, "Not Exist" Exit Sub End If End Sub
40
frmres Dim rs As New ADODB.Recordset Private Sub Combo1_Click() rs.Open "select * from TRAINS where TRAIN_NO=" & Val(Combo1.Text), db, adOpenDynamic Text1.Text = rs(1) rs.Close End Sub Private Sub Command1_Click() rs.Open "select * from RESERVATION", db, adOpenDynamic, adLockOptimistic rs.AddNew rs.Fields(1) = Val(Combo1.Text) rs.Fields(2) = Text1 rs.Fields(3) = Text2 rs.Fields(4) = Text3 rs.Fields(5) = Combo2.Text rs.Fields(6) = Text4.Text rs.Fields(7) = Text5.Text rs.Fields(8) = Combo3 rs.Fields(9) = Check1.Value rs.Fields(10) = DTPicker1.Value rs.Fields(11) = "Reserv" rs.Update rs.Close frmres.Hide frmconfirm.Show End Sub Private Sub Command3_Click() Unload Me MDIFORM1.Show End Sub 41
Private Sub Command4_Click() Text1 = "" Text2 = "" Text3 = "" Text4 = "" Text5 = "" End Sub Private Sub Form_Load() rs.Open "select Train_No from TRAINS", db, adOpenDynamic While Not rs.EOF Combo1.AddItem rs(0) rs.MoveNext Wend rs.Close rs.Open "select * from COACHES", db, adOpenDynamic, adLockOptimistic While Not rs.EOF Combo2.AddItem (rs(1)) rs.MoveNext Wend rs.Close End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) KeyAscii = onlychar(KeyAscii) End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) KeyAscii = onlychar(KeyAscii) End Sub
42
Private Sub Text3_KeyPress(KeyAscii As Integer) KeyAscii = onlychar(KeyAscii) End Sub Private Sub Text4_KeyPress(KeyAscii As Integer) KeyAscii = onlychar(KeyAscii) End Sub Private Sub Text5_KeyPress(KeyAscii As Integer) KeyAscii = onlydigit(KeyAscii) End Sub
43
frmconfirm Dim i As Integer Dim rs As New ADODB.Recordset Private Sub cmdconfirm_Click() rs.Open "SELECT * FROM FARE_DETAIL WHERE TRAIN_NO =" & frmres.Combo1, db, adOpenKeyset, adLockReadOnly If Not rs.EOF Then Label7.Caption = rs.Fields(4) End If rs.Close Command2.Enabled = True End Sub Private Sub Command2_Click() Unload Me frmticket.Show End Sub Private Sub Form_Load() Label14.Caption = Val(frmres.Combo1) Label5.Caption = frmres.Text2 Label6.Caption = frmres.Text3 i = frmres.Text5 If i > 14 And i < 60 Then Text1.Text = 1 ElseIf i And i < 14 Then Text2.Text = 1 ElseIf i >= 60 Then Text3.Text = 1 End If Command2.Enabled = False End Sub
44
frmticket Dim rs As New ADODB.Recordset Dim p As Integer Private Sub Form_Load() Text1.Text = Val(frmres.Combo1) Text4.Text = frmres.Combo2 Label9.Caption = Val(frmconfirm.Label7) Label11.Caption = Val(frmconfirm.Text1) Label13.Caption = Val(frmconfirm.Text2) Label15.Caption = Val(frmconfirm.Text3) Text18.Text = frmres.Text1 Text19.Text = frmres.Text2 Text20.Text = frmres.Text3 Text2.Text = frmres.DTPicker1.Value Label22.Caption = frmres.DTPicker1.Value rs.Open "select PNR_NO from RESERVATION", db, adOpenDynamic rs.MoveLast Text3.Text = rs(0) rs.Close s_grid f_grid rs.Open "SELECT * FROM FARE_DETAIL WHERE TRAIN_NO =" & frmres.Combo1, db, adOpenKeyset, adLockReadOnly If Not rs.EOF Then Label9.Caption = rs.Fields(4) End If rs.Close rs.Open "select * from TRAIN_SCHEDULE WHERE TRAIN_NO=" & Text1.Text, db, adOpenDynamic If Not rs.EOF Then Label20.Caption = rs.Fields(1) Label24.Caption = rs.Fields(2) 45
End If rs.Close End Sub Public Sub s_grid() With Grid .Rows = 1 .Cols = 5 .Row = 0 .Col = 0 .Text = "Name" .Col = 1 .Text = "Age" .Col = 2 .Text = "Sex" .Col = 3 .Text = "Senior Citizen" .Col = 4 .Text = "Seat No." End With End Sub Public Sub f_grid() If rs.State = adStateOpen Then rs.Close rs.Open "SELECT * from RESERVATION WHERE PNR_NO =" & Val(Text3.Text), db, adOpenDynamic If Not rs.EOF Then rs.MoveFirst While Not rs.EOF Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = rs.Fields(6) Grid.TextMatrix(Grid.Rows - 1, 1) = rs.Fields(7) Grid.TextMatrix(Grid.Rows - 1, 2) = rs.Fields(8) Grid.TextMatrix(Grid.Rows - 1, 3) = rs.Fields(9) 46
rs.MoveNext Wend End If rs.Close End Sub Private Sub Command1_Click() Command1.Visible = False Dim Beginpage, EndPage, NumCopies, orientation, i CommonDialog1.CancelError = True On Error GoTo ErrHandler CommonDialog1.ShowPrinter Beginpage = CommonDialog1.FromPage EndPage = CommonDialog1.ToPage NumCopies = CommonDialog1.Copies orientation = CommonDialog1.orientation For i = 1 To NumCopies Form7.PrintForm Next Exit Sub ErrHandler: Exit Sub End Sub
47
frmcancel Dim rs As New ADODB.Recordset Private Sub Command1_Click() Unload Me End Sub Private Sub Command2_Click() Dim cmd As New Command cmd.ActiveConnection = db cmd.CommandText = "Update Reservation set Status='Cancel' where PNR_NO=" & Text1.Text cmd.Execute MsgBox "Cancelled" Unload Me Form7.Show End Sub Private Sub Command3_Click() f_grid End Sub Private Sub Form_Load() s_grid End Sub Public Sub s_grid() With Grid .Rows = 1 .Cols = 5 .Row = 0 .Col = 0 .Text = "Name" .Col = 1 48
.Text = "Age" .Col = 2 .Text = "Sex" .Col = 3 .Text = "Senior Citizen" .Col = 4 .Text = "Seat No." End With End Sub Public Sub f_grid() If rs.State = adStateOpen Then rs.Close rs.Open "SELECT * from RESERVATION WHERE PNR_NO =" & Val(Text1.Text) & "and Status='Reserv'", db, adOpenDynamic If Not rs.EOF Then rs.MoveFirst While Not rs.EOF Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = rs.Fields(6) Grid.TextMatrix(Grid.Rows - 1, 1) = rs.Fields(7) Grid.TextMatrix(Grid.Rows - 1, 2) = rs.Fields(8) Grid.TextMatrix(Grid.Rows - 1, 3) = rs.Fields(9) rs.MoveNext Wend End If End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) KeyAscii = onlydigit(KeyAscii) End Sub
49
form7 Private Sub Command1_Click() Command1.Visible = False Dim Beginpage, EndPage, NumCopies, orientation, i CommonDialog1.CancelError = True On Error GoTo ErrHandler CommonDialog1.ShowPrinter Beginpage = CommonDialog1.FromPage EndPage = CommonDialog1.ToPage NumCopies = CommonDialog1.Copies orientation = CommonDialog1.orientation For i = 1 To NumCopies Form7.PrintForm Next Exit Sub ErrHandler: Exit Sub End Sub Private Sub Form_Load() Label9.Caption = "Rs. 60" Text3.Text = frmcancel.Text1 Text5.Text = frmcancel.Text1 End Sub
50
frmScode_enq Dim rs As New ADODB.Recordset Private Sub cmdClear_Click() txtSname.Text = "" End Sub Private Sub cmdGet_Click() txtSname.Text = UCase(txtSname.Text) If rs.State = adStateOpen Then rs.Close rs.Open "SELECT * FROM STATION WHERE STATION_NAME='" & txtSname.Text & "'", db, adOpenKeyset, adLockReadOnly If rs.EOF Then MsgBox "Sorry! no matching station found", vbInformation, "Sorry!!!!" Exit Sub End If frmSname.Show End Sub Private Sub Command1_Click() Unload Me End Sub Private Sub Form_Load() Me.Height = 4470 Me.Width = 6000 CenterForm Me lblDate.Caption = Format(Date, "dddd,mmmm dd,yyyy") lblTime.Caption = Format(Time(), "hh:mm:ss") End Sub Private Sub Timer1_Timer() lblTime.Caption = Time End Sub 51
Private Sub txtSname_KeyPress(KeyAscii As Integer) If KeyAscii >= 48 And KeyAscii <= 57 Then KeyAscii = 0 End If End Sub
52
frmSname Dim rs As New ADODB.Recordset Private Sub Cmdhome_Click() Unload Me frmScode_enq.Show End Sub Private Sub Form_Load() Me.Height = 5055 Me.Width = 7470 CenterForm Me lblDate.Caption = Format(Date, "dddd,mmmm dd,yyyy") lblTime.Caption = Format(Time(), "hh:mm:ss") Dim name As String name = frmScode_enq.txtSname.Text If rs.State = adStateOpen Then rs.Close rs.Open "SELECT * FROM STATION WHERE STATION_NAME='" & name & "'", db, adOpenKeyset, adLockReadOnly If Not rs.EOF Then TxtScode.Text = rs.Fields(0) txtSname.Text = rs.Fields(1) End If End Sub Private Sub Timer1_Timer() lblTime.Caption = Time End Sub
53
frmT_SDpair Private Sub cmdClear_Click() txtDscode.Text = "" txtSscode.Text = "" End Sub Private Sub cmdGet_Click() Dim rs As New ADODB.Recordset If rs.State = adStateOpen Then rs.Close txtSscode.Text = UCase(txtSscode.Text) txtDscode.Text = UCase(txtDscode.Text) rs.Open "SELECT *FROM STATION WHERE STATION_NO='" & txtSscode.Text & "' OR STATION_NO='" & txtDscode.Text & "'", db, adOpenKeyset, adLockReadOnly If rs.EOF Then MsgBox "STATION CODE DOES NOT EXIST ", vbInformation, "Not Exist" Exit Sub End If frmT_Stpair.Show End Sub Private Sub cmdScode_Click() frmS_detail.Show End Sub Private Sub Command1_Click() Unload Me End Sub Private Sub Form_Load() Me.Height = 6735 Me.Width = 7515 CenterForm Me lblDate.Caption = Format(Date, "dddd,mmmm dd,yyyy") 54
lblTime.Caption = Format(Time(), "hh:mm:ss") fill_combo End Sub Private Sub Timer1_Timer() lblTime.Caption = Time End Sub Private Sub fill_combo() Dim temp As New ADODB.Recordset If temp.State = adStateOpen Then temp.Close temp.Open "SELECT CLASS FROM COACHES", db, adOpenKeyset, adLockReadOnly If Not temp.EOF Then temp.MoveFirst While Not temp.EOF cmbClass.AddItem (temp.Fields(0)) temp.MoveNext Wend End If End Sub Private Sub txtDscode_KeyPress(KeyAscii As Integer) If KeyAscii >= 48 And KeyAscii <= 57 Then KeyAscii = 0 End If End Sub Private Sub txtSscode_KeyPress(KeyAscii As Integer) If KeyAscii >= 48 And KeyAscii <= 57 Then KeyAscii = 0 End If End Sub
55
frmT_Stpair Dim rs As New ADODB.Recordset Dim class As String Dim scode As String Dim dcode As String Private Sub Cmdhome_Click() Unload Me End Sub Private Sub Form_Load() Me.Height = 6645 Me.Width = 8655 CenterForm Me scode = frmT_SDpair.txtSscode.Text dcode = frmT_SDpair.txtDscode.Text class = frmT_SDpair.cmbClass.Text lblEorigin.Caption = scode lblEdest.Caption = dcode lblEclass.Caption = class set_grid fill_grid End Sub Sub set_grid() With grid .Rows = 1 .Cols = 6 .Row = 0 .Col = 0 .Text = "Train No" .Col = 1 .Text = "Train Name" 56
.Col = 2 .Text = "Origin" .Col = 3 .Text = "Dep.Time" .Col = 4 .Text = "Destination" .Col = 5 .Text = "Arr.Time" .RowHeight(0) = 650 .ColWidth(0) = 1000 .ColWidth(1) = 1800 End With End Sub Sub fill_grid() Dim temp As New ADODB.Recordset Dim TNM As New ADODB.Recordset If temp.State = adStateOpen Then temp.Close temp.Open "SELECT * FROM TRAIN_SCHEDULE WHERE SOURCE ='" & scode & "' and DESTINATION = '" & dcode & "'", db, adOpenKeyset, adLockReadOnly If TNM.State = adStateOpen Then TNM.Close TNM.Open "SELECT A.TRAIN_NAME FROM TRAINS A , TRAIN_SCHEDULE B WHERE A.TRAIN_NO=B.TRAIN_NO AND SOURCE ='" & scode & "' and DESTINATION = '" & dcode & "'", db, adOpenKeyset, adLockReadOnly If Not temp.EOF Then temp.MoveFirst TNM.MoveFirst While Not temp.EOF grid.Rows = grid.Rows + 1 grid.TextMatrix(grid.Rows - 1, 0) = temp.Fields(0) grid.TextMatrix(grid.Rows - 1, 2) = temp.Fields(3) grid.TextMatrix(grid.Rows - 1, 3) = temp.Fields(2) grid.TextMatrix(grid.Rows - 1, 4) = temp.Fields(4) grid.TextMatrix(grid.Rows - 1, 5) = temp.Fields(1) 57
58
frmfare_enq Dim rs As New ADODB.Recordset Private Sub cmdClear_Click() txtT_no.Text = "" txtOs_code.Text = "" txtDs_code.Text = "" txtAge.Text = "" End Sub Private Sub cmdGet_Click() CHECK_SCODE check_tno Me.Hide frmF_detail.Show End Sub Private Sub cmdScode_Click() frmS_detail.Show End Sub Private Sub cmdTno_Click() frmT_detail.Show End Sub Private Sub Command1_Click() Unload Me End Sub Private Sub Form_Load() Me.Height = 8055 Me.Width = 7500 CenterForm Me 59
lblDate.Caption = Format(Date, "dddd,mmmm dd,yyyy") lblTime.Caption = Format(Time(), "hh:mm:ss") clear_controls FILL_CMBCLASS fill_cmbcatg End Sub Private Sub FILL_CMBCLASS() If rs.State = adStateOpen Then rs.Close rs.Open "SELECT CLASS FROM COACHES", db, adOpenKeyset, adLockReadOnly If Not rs.EOF Then cmbClass.AddItem (rs.Fields(0)) rs.MoveNext End If cmbClass.ListIndex = 0 End Sub Private Sub txtAge_KeyPress(KeyAscii As Integer) If (KeyAscii < Asc(0) Or KeyAscii > Asc(9)) And KeyAscii <> 8 Then KeyAscii = 0 End If End Sub Private Sub fill_cmbcatg() cmbCatg.AddItem ("GENERAL") cmbCatg.AddItem ("MINISTER") cmbCatg.AddItem ("BHARAT SCOUTS/GUIDES") cmbCatg.AddItem ("BLIND") cmbCatg.AddItem ("CANCER PATIENT") cmbCatg.ListIndex = 0 End Sub Private Sub CHECK_SCODE() Dim temp As New ADODB.Recordset 60
temp.Open "SELECT STATION_NO FROM STATION WHERE STATION_NO='" & txtOs_code.Text & "'", db, adOpenKeyset, adLockReadOnly If temp.EOF Then MsgBox "ORIGINATING STATION CODE DOES NOT EXIST ", vbInformation, "Not Exist" Exit Sub End If temp.Close temp.Open "SELECT STATION_NO FROM STATION WHERE STATION_NO='" & txtDs_code.Text & "'", db, adOpenKeyset, adLockReadOnly If temp.EOF Then MsgBox "DESTINATION STATION CODE DOES NOT EXIST ", vbInformation, "Not Exist" Exit Sub End If End Sub Private Sub check_tno() If rs.State = adStateOpen Then rs.Close rs.Open "SELECT TRAIN_NAME FROM TRAINS WHERE TRAIN_NO=" & Val(txtT_no.Text), db, adOpenKeyset, adLockReadOnly If rs.EOF Then MsgBox "Sorry Train Number for which you are queried is not exist", vbInformation, "Not Exist" Exit Sub End If End Sub Private Sub clear_controls() txtAge.Text = "" txtDs_code.Text = "" txtOs_code.Text = "" txtT_no.Text = "" End Sub 61
Private Sub txtDs_code_KeyPress(KeyAscii As Integer) If KeyAscii >= 48 And KeyAscii <= 57 Then KeyAscii = 0 End If End Sub Private Sub txtOs_code_KeyPress(KeyAscii As Integer) If KeyAscii >= 48 And KeyAscii <= 57 Then KeyAscii = 0 End If End Sub Private Sub txtT_no_KeyPress(KeyAscii As Integer) If (KeyAscii < Asc(0) Or KeyAscii > Asc(9)) And KeyAscii <> 8 Then KeyAscii = 0 End If End Sub
62
frmF_detail Dim rs As New ADODB.Recordset Dim tno As Integer Dim scode As String Dim dcode As String Dim class As String Dim age As Integer Dim cat As String Dim total As Long Private Sub Cmdhome_Click() Unload Me frmFare_enq.Show End Sub Private Sub Form_Load() Dim c_no As String Dim temp As New ADODB.Recordset Me.Height = 7200 Me.Width = 8000 CenterForm Me lblDate.Caption = Format(Date, "dddd,mmmm dd,yyyy") lblTime.Caption = Format(Time(), "hh:mm:ss") tno = Val(frmFare_enq.txtT_no.Text) scode = frmFare_enq.txtOs_code.Text dcode = frmFare_enq.txtDs_code.Text class = frmFare_enq.cmbClass.Text cat = frmFare_enq.cmbCatg.Text If frmFare_enq.txtAge.Text <> "" Then age = Val(frmFare_enq.txtAge.Text) End If set_grid fill_grid 63
If rs.State = adStateOpen Then rs.Close rs.Open "SELECT COACH_NO FROM COACHES WHERE CLASS ='" & class & "'", db, adOpenKeyset, adLockReadOnly c_no = rs.Fields(0) rs.Close If temp.State = adStateOpen Then temp.Close temp.Open "SELECT * FROM FARE_DETAIL WHERE COACH_NO = '" & c_no & "' AND TRAIN_NO =" & tno, db, adOpenKeyset, adLockReadOnly If Not temp.EOF Then txtB_ch.Text = temp.Fields(2) txtR_fare.Text = temp.Fields(3) End If If temp.State = adStateOpen Then temp.Close temp.Open "SELECT AMOUNT FROM STATION_DETAIL WHERE SOURCE='" & scode & "' AND DESTINATION='" & dcode & "'", db, adOpenKeyset, adLockReadOnly If Not temp.EOF Then txtDist_ch.Text = temp.Fields(0) End If total = Val(txtB_ch.Text) + Val(txtR_fare.Text) + Val(txtDist_ch.Text) If age < 12 Then If cat = "BLIND" Then txtTot.Text = total * 0.75 txtCsn.Text = "75%" ElseIf cat = "CANCER PATIENT" Then txtTot.Text = total * 0.75 txtCsn.Text = "75%" ElseIf cat = "BHARAT SCOUTS/GUIDES" Then txtTot.Text = total / 2 txtCsn.Text = "50%" Else txtTot.Text = total / 2 txtCsn.Text = "50%" End If ElseIf age <= 60 Then 64
If cat = "BLIND" Then txtTot.Text = total * 0.75 txtCsn.Text = "75%" ElseIf cat = "CANCER PATIENT" Then txtTot.Text = total * 0.75 txtCsn.Text = "75%" ElseIf cat = "BHARAT SCOUTS/GUIDES" Then txtTot.Text = total / 2 txtCsn.Text = "50%" Else txtTot.Text = total txtCsn.Text = "NIL" End If ElseIf age > 60 Then If cat = "BLIND" Then txtTot.Text = total * 0.75 txtCsn.Text = "75%" ElseIf cat = "CANCER PATIENT" Then txtTot.Text = total * 0.75 txtCsn.Text = "75%" Else txtTot.Text = total / 2 txtCsn.Text = "50%" End If End If End Sub
65
Sub fill_grid() Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = tno Grid.TextMatrix(Grid.Rows - 1, 1) = scode Grid.TextMatrix(Grid.Rows - 1, 2) = dcode Grid.TextMatrix(Grid.Rows - 1, 3) = class Grid.TextMatrix(Grid.Rows - 1, 4) = age Grid.TextMatrix(Grid.Rows - 1, 5) = cat End Sub Sub set_grid() With Grid .Rows = 1 .Cols = 6 .Row = 0 .Col = 0 .Text = "Train No." .Col = 1 .Text = "Source" .Col = 2 .Text = "Destination" .Col = 3 .Text = "Class" .Col = 4 .Text = "Age" .Col = 5 .Text = "Category" .RowHeight(0) = 650 .ColWidth(0) = 900 .ColWidth(1) = 1200 .ColWidth(2) = 1200 .ColWidth(3) = 1200 .ColWidth(4) = 1200 66
.ColWidth(5) = 1200 End With End Sub Private Sub Timer1_Timer() lblTime.Caption = Time End Sub
67
frmTschedule Dim rs As New ADODB.Recordset Dim temp As New ADODB.Recordset Private Sub cmdClear_Click() txtDs_code.Text = "" txtOs_code = "" txtTno.Text = "" End Sub Private Sub cmdClick_Click() frmS_detail.Show End Sub Private Sub cmdGet_Click() If rs.State = adStateOpen Then rs.Close If temp.State = adStateOpen Then temp.Close txtOs_code.Text = UCase(txtOs_code.Text) txtDs_code.Text = UCase(txtDs_code.Text) rs.Open "SELECT TRAIN_NAME FROM TRAINS WHERE TRAIN_NO=" & Val(txtTno.Text), db, adOpenKeyset, adLockReadOnly temp.Open "SELECT STATION_NO FROM STATION WHERE STATION_NO='" & txtOs_code.Text & "'", db, adOpenKeyset, adLockReadOnly If temp.EOF Then MsgBox "ORIGINATING STATION CODE DOES NOT EXIST ", vbInformation, "Not Exist" Exit Sub End If temp.Close temp.Open "SELECT STATION_NO FROM STATION WHERE STATION_NO='" & txtDs_code.Text & "'", db, adOpenKeyset, adLockReadOnly If temp.EOF Then
68
MsgBox "DESTINATION STATION CODE DOES NOT EXIST ", vbInformation, "Not Exist" Exit Sub End If If rs.EOF Then MsgBox "Sorry Train Number for which you are queried is not exist", vbInformation, "Not Exist" Exit Sub Else frmT_route.Show End If End Sub Private Sub Command1_Click() Unload Me End Sub Private Sub Form_Load() Me.Height = 6285 Me.Width = 7470 CenterForm Me lblDate.Caption = Format(Date, "dddd,mmmm dd yyyy") lblTime.Caption = Format(Time(), "hh:mm:ss") End Sub Private Sub txtDs_code_KeyPress(KeyAscii As Integer) If KeyAscii >= 48 And KeyAscii <= 57 Then KeyAscii = 0 Else End If End Sub Private Sub txtOs_code_KeyPress(KeyAscii As Integer) If KeyAscii >= 48 And KeyAscii <= 57 Then 69
KeyAscii = 0 End If End Sub Private Sub txtTno_KeyPress(KeyAscii As Integer) If (KeyAscii < Asc(0) Or KeyAscii > Asc(9)) And KeyAscii <> 8 Then KeyAscii = 0 End If End Sub
70
frmT_route Dim rs As New ADODB.Recordset Dim temp As New ADODB.Recordset Dim tno As Integer Dim Source As String Dim desc As String Private Sub Cmdhome_Click() frmTschedule.Show Unload Me End Sub Private Sub Form_Load() Me.Height = 5670 Me.Width = 10785 CenterForm Me lblDate.Caption = Format(Date, "dddd,mmmm dd,yyyy") lblTime.Caption = Format(Time(), "hh:mm:ss") tno = Val(frmTschedule.txtTno.Text) Source = frmTschedule.txtOs_code.Text desc = frmTschedule.txtDs_code.Text lblETno.Caption = tno If rs.State = adStateOpen Then rs.Close If temp.State = adStateOpen Then temp.Close temp.Open "SELECT STATION_NAME FROM STATION", db, adOpenKeyset, adLockReadOnly rs.Open "SELECT TRAIN_NAME FROM TRAINS WHERE TRAIN_NO=" & tno, db, adOpenKeyset, adLockReadOnly If Not rs.EOF Then lblETname.Caption = rs.Fields(0) lblEScode.Caption = Source End If If Not temp.EOF Then 71
lblESource.Caption = temp.Fields(0) lblESname.Caption = temp.Fields(0) End If runs_on End Sub Private Sub runs_on() Dim trs As New ADODB.Recordset If trs.State = adStateOpen Then trs.Close trs.Open "SELECT * FROM TRAIN_SCHEDULE WHERE TRAIN_NO = " & tno & "AND SOURCE='" & Source & "' AND DESTINATION= '" & desc & "'", db, adOpenKeyset, adLockReadOnly If Not trs.EOF Then If trs.Fields("MON").Value = "T" Then lblM.Caption = "MON" Else lblM.Caption = "" End If If trs.Fields("TUE").Value = "T" Then lblT.Caption = "TUE" Else lblT.Caption = "" End If If trs.Fields("WED").Value = "T" Then lblW.Caption = "WED" Else lblW.Caption = "" End If If trs.Fields("THU").Value = "T" Then lblTh.Caption = "THU" Else lblTh.Caption = "" End If If trs.Fields("FRI").Value = "T" Then 72
lblF.Caption = "FRI" Else lblF.Caption = "" End If If trs.Fields("SAT").Value = "T" Then lblSat.Caption = "SAT" Else lblSat.Caption = "" End If If trs.Fields("SUN").Value = "T" Then lblSun.Caption = "SUN" Else lblSun.Caption = "" End If lblEAtime.Caption = trs.Fields("ARRIVAL_TIME").Value lblEDtime.Caption = trs.Fields("DEPARTURE_TIME").Value End If If trs.State = adStateOpen Then trs.Close trs.Open "SELECT DISTANCE FROM STATION_DETAIL WHERE SOURCE='" & Source & "' AND DESTINATION='" & desc & "'", db, adOpenKeyset, adLockReadOnly If Not trs.EOF Then lblEDist.Caption = trs.Fields(0) End If End Sub Private Sub Timer1_Timer() lblTime.Caption = Time End Sub
73
frmT_detail Private Sub Cmdhome_Click() Unload Me End Sub Private Sub Form_Load() set_grid fill_grid Me.Height = 5500 Me.Width = 7210 CenterForm Me lblDate.Caption = Format(Date, "dddd,mmmm dd,yyyy") lblTime.Caption = Format(Time(), "hh:mm:ss") End Sub Sub fill_grid() Dim temp As New ADODB.Recordset If temp.State = adStateOpen Then temp.Close temp.Open "SELECT * FROM TRAINS", db, adOpenKeyset, adLockReadOnly If Not temp.EOF Then temp.MoveFirst While Not temp.EOF Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = temp.Fields(0) Grid.TextMatrix(Grid.Rows - 1, 1) = temp.Fields(1) Grid.TextMatrix(Grid.Rows - 1, 2) = temp.Fields(2) temp.MoveNext Wend End If End Sub Sub set_grid() With Grid 74
.Rows = 1 .Cols = 3 .Row = 0 .Col = 0 .Text = "Train No." .Col = 1 .Text = "Train Name" .Col = 2 .Text = "Train Type" .RowHeight(0) = 650 .ColWidth(0) = 1000 .ColWidth(1) = 2500 .ColWidth(2) = 2500 End With End Sub Private Sub Timer1_Timer() lblTime.Caption = Time End Sub
75
frmT_time Private Sub Cmdhome_Click() Unload Me End Sub Private Sub Form_Load() lblSource.Caption = originname set_grid fill_grid Me.Height = 5000 Me.Width = 10000 CenterForm Me lblDate.Caption = Format(Date, "dddd,mmmm dd,yyyy") lblTime.Caption = Format(Time(), "hh:mm:ss") End Sub Private Sub set_grid() With Grid .Rows = 1 .Cols = 11 .Row = 0 .Col = 0 .Text = "Train No." .Col = 1 .Text = "Train Name" .Col = 2 .Text = "Arrival Time" .Col = 3 .Text = "Departure Time" .Col = 4 .Text = "Mon" .Col = 5 .Text = "Tue" 76
.Col = 6 .Text = "Wed" .Col = 7 .Text = "Thu" .Col = 8 .Text = "Fri" .Col = 9 .Text = "Sat" .Col = 10 .Text = "Sun" .ColWidth(0) = 800 .ColWidth(1) = 1500 .ColWidth(2) = 1800 .ColWidth(3) = 2000 .ColWidth(4) = 450 .ColWidth(5) = 450 .ColWidth(6) = 600 .ColWidth(7) = 450 .ColWidth(8) = 450 .ColWidth(9) = 450 .ColWidth(10) = 450 End With End Sub Private Sub fill_grid() Dim temp As New ADODB.Recordset If temp.State = adStateOpen Then temp.Close temp.Open "SELECT T.TRAIN_NO,T.TRAIN_NAME,TS.ARRIVAL_TIME,TS.DEPARTURE_TIME, TS.MON,TS.TUE,TS.WED,TS.THU,TS.FRI,TS.SAT,TS.SUN FROM TRAINS T,TRAIN_SCHEDULE TS WHERE T.TRAIN_NO =TS.TRAIN_NO AND TS.SOURCE='" & origincode & "'", db, adOpenKeyset, adLockReadOnly If Not temp.EOF Then temp.MoveFirst 77
While Not temp.EOF Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = temp.Fields(0) Grid.TextMatrix(Grid.Rows - 1, 1) = temp.Fields(1) Grid.TextMatrix(Grid.Rows - 1, 2) = temp.Fields(2) Grid.TextMatrix(Grid.Rows - 1, 3) = temp.Fields(3) Grid.TextMatrix(Grid.Rows - 1, 4) = temp.Fields(4) Grid.TextMatrix(Grid.Rows - 1, 5) = temp.Fields(5) Grid.TextMatrix(Grid.Rows - 1, 6) = temp.Fields(6) Grid.TextMatrix(Grid.Rows - 1, 7) = temp.Fields(7) Grid.TextMatrix(Grid.Rows - 1, 8) = temp.Fields(8) Grid.TextMatrix(Grid.Rows - 1, 9) = temp.Fields(9) Grid.TextMatrix(Grid.Rows - 1, 10) = temp.Fields(10) temp.MoveNext Wend End If End Sub Private Sub Timer1_Timer() lblTime.Caption = Time End Sub
78
frmreservation Private Sub Cmdhome_Click() Unload Me End Sub Private Sub Form_Load() Me.Height = 5790 Me.Width = 8430 CenterForm Me lblDate.Caption = Format(Date, "dddd,mmmm dd,yyyy") lblTime.Caption = Format(Time(), "hh:mm:ss") Call set_grid Call fill_grid End Sub Sub fill_grid() Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = "Senior Citizen" Grid.TextMatrix(Grid.Rows - 1, 1) = "50%" Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = "Minister" Grid.TextMatrix(Grid.Rows - 1, 1) = "100%" Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = "Cancer Patient" Grid.TextMatrix(Grid.Rows - 1, 1) = "75% " Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = "Bharat Scouts/Guides" Grid.TextMatrix(Grid.Rows - 1, 1) = "50%" Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = "Children Below 12yrs " Grid.TextMatrix(Grid.Rows - 1, 1) = "50%" Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = "Blind Concession " 79
Grid.TextMatrix(Grid.Rows - 1, 1) = "75%" End Sub Sub set_grid() With Grid .Rows = 1 .Cols = 2 .Row = 0 .Col = 0 .Text = "Category" .Col = 1 .Text = "Concession" .RowHeight(0) = 650 .ColWidth(0) = 3000 .ColWidth(1) = 2500 End With End Sub Private Sub Timer1_Timer() lblTime.Caption = Time End Sub
80
frmRefund Private Sub Cmdhome_Click() Unload Me End Sub Private Sub Form_Load() Me.Height = 5925 Me.Width = 9975 CenterForm Me lblDate.Caption = Format(Date, "dddd,mmmm dd,yyyy") lblTime.Caption = Format(Time(), "hh:mm:ss") Call set_grid Call fill_grid End Sub Sub fill_grid() Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = "Before 3 hours of train departure" Grid.TextMatrix(Grid.Rows - 1, 1) = "20 Rs." Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = "Upto 3 hours of train departure" Grid.TextMatrix(Grid.Rows - 1, 1) = "25% of total amount" Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = "After 3 hours of train departure" Grid.TextMatrix(Grid.Rows - 1, 1) = "50% of total amount" Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = "After 12 hours of train departure" Grid.TextMatrix(Grid.Rows - 1, 1) = "75% of total amount" Grid.Rows = Grid.Rows + 1 Grid.TextMatrix(Grid.Rows - 1, 0) = "Otherwise" Grid.TextMatrix(Grid.Rows - 1, 1) = "None" End Sub
81
Sub set_grid() With Grid .Rows = 1 .Cols = 2 .Row = 0 .Col = 0 .Text = "Time Of Cancellation" .Col = 1 .Text = "Cancellation Charge" .RowHeight(0) = 750 .ColWidth(0) = 4000 .ColWidth(1) = 3500 End With End Sub
82
FRM_ABT_RAIL Private Sub CMDNEXT_Click() FRMINTRO.Show End Sub Private Sub Form_Load() Height = 11520 Width = 11325 End Sub
83
84
frmreport Private Sub cmdExit_Click() End End Sub Private Sub cmdShow_Click() If optres.Value = True Then resreport.Show End If If optcancel.Value = True Then cancelreport.Show End If End Sub Private Sub Form_Load() Height = 7725 Width = 10890 End Sub
85
Reports
86
resreport
87
cancelreport
88
Highlights Addressing and changing Forms, Controls and records Responding to clicks, typing and other events.
The VBA-language itself is rather simple and has the same components as many other programming languages, for instance Java and C++. The difficult part is how the program cooperates with the built-in objects and how these objects really work. This is our focus in this chapter
89
The Visual Basic window may contain many frames. In Access 2000 and 2003, 2007 they may be docked inside the window or undocked , i.e. floating as separate small windows. By accident it can be docked or undocked, and it may be very frustrating trying to get them back where it is wanted. The frame will dock somewhere along a side of the window. Where it docks does not depend on where the frame is when the mouse button is released. It depends on where the mouse pointer is when we release the button. Project Explorer: To the left there is a list of all forms in the database. In objectoriented terminology, each form is a class. The class has a code module with event procedures for the controls on the form. When you double-click a form on the list, you will see the code module to the right in the Visual Basic window. The database may also contain code modules (classes) that are not forms. They are shown at the bottom of the Project Explorer list. All code modules may contain procedures and declare variables. VBA offers three kinds of modules: Form module: A form module has event procedures for all controls on the form, and it may have ordinary procedures too. It may declare variables. When you open a form, you get an object based on the form class. The object is a visible form and it has a set of variables corresponding to the declarations. We get more form objects, appearing as other open copies of the form. Each copy has its own variables, but the same code. When the code uses addresses such as Me.txtName , it refers to the controls and variables of this particular copy of the form. Class module: A class module corresponds to a class in other object-oriented languages. It has procedures and declares variables, and you can create multiple objects based on the class, each with their own variables. The only difference between form modules and class modules is that the latter are not visible to the user and have no controls. Module (simple): A simple module is similar to a class but there is only one object based on the module. The system creates this object automatically. The first versions of Visual Basic had no class modules, only simple module.
91
Code window: To the right in the Visual Basic window, there is a code window with the Visual Basic program. Scroll to other event procedures and controls, or they can be selected by means of the two combo boxes at the top. Creating an event procedure: Initially, the event procedures are not in the code, but if we select one of them by means of the combo boxes,Visual Basic creates it. The same thing happens if an event procedure is selected through the control's property window. However, Access doesn't always coordinate these two things. An event procedure may be created in the code window, but it doesn't appear in the property box. As a result, Access never calls the event procedure.
92
93
94
95
It not only provides reservation but cancellation can also be done through this system at ease and one can use a credit card to complete the process. This being a big step in terms of improvement in the railway system it is widely accepted across the country.
96
CONCLUSION
This project is about the designing the railway reservation database system using M S Access, and Visual Basic 6.0. This project presents an investigative view of present railway reservation system including the history of railways and detail of network topology of PRS. Present system of Indian 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 database system using M S Access, and Visual Basic 6.0. We have talked with some of railway officers about the features and shortcoming of present railway reservation system after the research with the associated p e o p l e a n d o t h e r s o u r c e s w e w e r e a b l e t o f o u n d o u t s o m e o f t h e m a j o r f a c t s r e g a r d i n g t h e reservation system and tried to eliminate the shortcoming of system. In the last we conclude that Indian Railway is h a v i n g a s t r o n g I T I n f r a s t r u c t u r e a n d a w e l l - 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.
97
FUTURE
If anyone wants to extend this project then he or she can make an additional database and database for updated availability of seats which is available after the cancellation of ticket on that specific train. Etc. He or she can also add some more command buttons in the existing software and extend working of the existing software.
98
REFERENCE
Reference Books: - Steven Holzner-Visual Basic 6 Programming (Black Book) Gary Cornell-Visual Basic 6 form the Ground up- Tata McGraw Hill Noel Jerke-Visual Basic 6-Tata McGraw Hill Reference Sites: - http://www.5starsupport.com/info/vb.htm
http://www.devdos.com/vb/Visual_Basic.shtml
http://www.visual-basic-dox.net
http://www.vb6.us/tutorials/conditional-expressions-visual-basic-tutorial
99