Dim PassengerRs As Recordset Dim TempRs As Recordset Dim TempRs1 As Recordset Dim x Private Sub Combo1_KeyPress(KeyAscii As Integer) Set TempRs = RailwayDB.OpenRecordset("select TrainNo ,Type from Train_Master where Description='" + Trim(Combo1.Text) + "'") Text3.Text = TempRs(0) Text4.Text = TempRs(1) Combo2.Clear If Trim(Text4.Text) = "Mail/Express" Then With Combo2 .AddItem "A.C. First Class" .AddItem "A.C. 2-Tier Sleeper" .AddItem "First Class" .AddItem "A.C. 3-Tier Sleeper" .AddItem "A.C. Chair" .AddItem "Sleeper Class" .AddItem "Second Class" End With Else With Combo2 .AddItem "First Class" .AddItem "Sleeper Class" .AddItem "Second Class" End With End If Combo2.SetFocus End Sub
Private Sub Combo2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then If Len(Trim(Combo2.Text)) > 0 Then Text5.SetFocus End If End If End Sub
Private Sub Combo3_KeyPress(KeyAscii As Integer)
If Combo4.ListCount < Val(Text8.Text) + Val(Text9.Text) Then If KeyAscii = 13 Then If Len(Trim(Combo3.Text)) > 0 Then List1.AddItem Combo3.Text Combo4.AddItem Combo4.Text If List2.ListCount = 0 Then List2.AddItem Val(Text12.Text) Else List2.AddItem Val(List2.List(List2.ListCount - 1)) + 1 End If Combo4.SetFocus End If End If Else Command1(0).Enabled = True Command1(0).SetFocus End If End Sub
Private Sub Combo4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then If Len(Trim(Combo4.Text)) > 0 Then Combo3.SetFocus End If End If End Sub
Private Sub Command1_Click(Index As Integer)
Dim Reply Select Case Index Case 0 Reply = MsgBox("Generate Ticket", vbYesNo, "Railway Reservation System") If Reply = vbYes Then TicketRs.AddNew Add_Rec TicketRs.Update Add_Recs Reply = MsgBox("Send to Printer", vbYesNo, "Railway Reservation system") If Reply = vbYes Then DataEnvironment1.Command1_Grouping Text1.Text, Text2.Text DataReport1.Show End If Clear_Rec Command1(0).Enabled = False End If Case 1 Clear_Rec Case 2 x = InputBox("Please Enter Ticket No", "Railway Reservation System") Load_Rec Reply = MsgBox("Do You Want to Cancel", vbYesNo + vbCritical, "Railway Reservation System") If Reply = vbYes Then RailwayDB.Execute "update ticket_master set cancel_yn=0 where ticketno='" + Trim(Text1.Text) + "'" MsgBox "Ticket Canceled Successfully", , "Railway Reservation Sys" DataEnvironment1.Command1_Grouping Text1.Text, Text2.Text DataReport6.Show End If Case 3 TicketRs.MoveFirst On Error GoTo ErrHandler x = TicketRs(0) Load_Rec Case 4 TicketRs.MovePrevious On Error GoTo ErrHandler x = TicketRs(0) Load_Rec Case 5 TicketRs.MoveNext On Error GoTo ErrHandler x = TicketRs(0) Load_Rec Case 6 TicketRs.MoveLast On Error GoTo ErrHandler x = TicketRs(0) Load_Rec Case 7 x = InputBox("Please Enter Ticket No", "Railway Reservation System") Load_Rec Case 8 Case 9 If Len(Trim(Text1.Text)) > 0 And Len(Trim(Text2.Text)) > 0 Then DataEnvironment1.Command1_Grouping Text1.Text, Text2.Text DataReport1.Show End If Case 10 Reply = MsgBox("Quit Y/N", vbYesNo, "Railway Reservation System") If Reply = vbYes Then Unload Me End If End Select Exit Sub ErrHandler: MsgBox "There are no more records", , "Railway Reservation" End Sub
Private Sub Form_Load()
Init_Proc With Combo3 .AddItem "Male" .AddItem "Female" End With Set TicketRs = RailwayDB.OpenRecordset("Ticket_Master", dbOpenDynaset) Set TempTrainRs = RailwayDB.OpenRecordset("Select Description,Type from Train_Master") Set PassengerRs = RailwayDB.OpenRecordset("Passenger_Master", dbOpenDynaset) Do While Not TempTrainRs.EOF Combo1.AddItem TempTrainRs(0) TempTrainRs.MoveNext Loop If TicketRs.RecordCount > 0 Then TicketRs.MoveLast End If Text1.Text = TicketRs.RecordCount + 1 End Sub
Private Sub Text10_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then If Val(Text10.Text) >= 18 And Val(Text10.Text) <= 125 Then Combo3.SetFocus End If End If End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then If IsDate(Trim(Text2.Text)) = True And CDate(Trim(Text2.Text)) >= Format(Date$, "dd-mm- yyyy") Then Combo1.SetFocus End If End If End Sub Private Sub Text5_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyDown Then Form6.Data1.RecordSource = "select Kms,Stations,Departure_Time from Train_Details where TrainNo='" + Trim(Text3.Text) + "'" Form6.Data1.Refresh Form6.Show End If End Sub Private Sub Text6_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyDown Then Form6.Data1.RecordSource = "select Kms,Stations,Departure_Time from Train_Details where TrainNo='" + Trim(Text3.Text) + "' and kms>" + Str(x) Form6.Data1.Refresh Form6.Show End If End Sub
Private Sub Text8_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Text9.SetFocus End If End Sub
Private Sub Text9_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then If Val(Text8.Text) + Val(Text9.Text) <= 6 Then Set TempRs1 = RailwayDB.OpenRecordset("select rate from fare_master where type='" + Trim(Text4.Text) + "' and category='" + Trim(Combo2.Text) + "' and distance>=" + Str(x) + " and distance<=" + Str(y), dbOpenDynaset) On Error GoTo A Text10.Text = Val(Text7.Text) * TempRs1(0) * (Val(Text8.Text) + Val(Text9.Text) / 2) Set TempRs = RailwayDB.OpenRecordset("select coachno,sum(seatsfrom+seatsto) from Ticket_Master where trainno='" + Trim(Text3.Text) + "' and traveldate=#" + Trim(Text2.Text) + " # and category='" + Trim(Combo2.Text) + "' group by coachno") If TempRs.RecordCount = 0 Then Set TempRs1 = RailwayDB.OpenRecordset("select coachno from coach_details,train_master where coach_details.trainno=train_master.trainno and coach_details.trainno='" + Trim(Text3.Text) + "' and type='" + Trim(Text4.Text) + "' and category='" + Trim(Combo2.Text) + "'") If TempRs1.RecordCount > 0 Then Text11.Text = TempRs1(0) Text12.Text = 1 Text13.Text = Val(Text8.Text) + Val(Text9.Text) Combo4.SetFocus Else MsgBox "Coach is Not Available", vbCritical, "Please Try other Coach" End If ElseIf TempRs(0) > 0 And TempRs(1) < 30 Then Set TempRs1 = RailwayDB.OpenRecordset("select coachno,seatsfrom,seatsto from Ticket_Master where trainno='" + Trim(Text3.Text) + "' and traveldate=#" + Trim(Text2.Text) + "# and category='" + Trim(Combo2.Text) + "'") TempRs1.MoveLast Text11.Text = TempRs1(0) Text12.Text = TempRs1(2) + 1 Text13.Text = TempRs1(2) + Val(Text8.Text) + Val(Text9.Text) Combo4.SetFocus Else MsgBox "Coach is Full", vbCritical, "Please Try other Coach" End If End If End If Exit Sub A: End Sub
Dim i For i = 0 To Combo4.ListCount - 1 PassengerRs.AddNew PassengerRs(0) = Text1.Text PassengerRs(1) = Combo4.List(i) PassengerRs(2) = List1.List(i) PassengerRs(3) = List2.List(i) PassengerRs.Update Next End Sub
Public Sub Load_Rec()
Dim i Combo4.Clear List1.Clear List2.Clear Set TempRs = RailwayDB.OpenRecordset("SELECT ticket_master.ticketno,traveldate,ticket_master.trainno,description,type,ticket_master.source, ticket_master.to,distance,adult,child,fare,coachno,seatsfrom,seatsto,category,age,sex,seatno from ticket_master,passenger_master,train_master where ticket_master.trainno=train_master.trainno and ticket_master.ticketno=passenger_master.ticketno and ticket_master.ticketno='" + Trim(x) + "'") If TempRs.RecordCount > 0 Then TempRs.MoveLast TempRs.MoveFirst For i = 0 To TempRs.RecordCount - 1 Text1.Text = TempRs(0) Text2.Text = TempRs(1) Text3.Text = TempRs(2) Combo1.Text = TempRs(3) Text4.Text = TempRs(4) Text5.Text = TempRs(5) Text6.Text = TempRs(6) Text7.Text = TempRs(7) Text8.Text = TempRs(8) Text9.Text = TempRs(9) Text10.Text = TempRs(10) Text11.Text = TempRs(11) Text12.Text = TempRs(12) Text13.Text = TempRs(13) Combo2.Text = TempRs(14) Combo4.AddItem TempRs(15) List1.AddItem TempRs(16) List2.AddItem TempRs(17) TempRs.MoveNext Next Else MsgBox "Record not found", , "Railway Reservation Sys" End If End Sub
(Music of The African Diaspora) Robin D. Moore-Music and Revolution - Cultural Change in Socialist Cuba (Music of The African Diaspora) - University of California Press (2006) PDF