Coding

52
Welcome Form Private Sub DRAW() Dim X As Single, Y As Single, RADI As Single, R As Single Dim A As Single, THE As Single Call Randomize Scale (3, -3)-(-3, 3) RADI = 8 * Atn(1) forcolor = QBColor(Rnd() * 13) form1.ForeColor = forcolor A = 2 * Rnd() For THE = 0 To RADI Step 0.01 R = A * Sin(10 * THE) X = R * Cos(THE) Y = R * Sin(THE) PSet (X, Y) Next THE End Sub Private Sub Form_KeyPress(KeyAscii As Integer) form1.Hide Form2.Show End Sub Private Sub Timer2_Timer() Call DRAW End Sub Private Sub Timer1_Timer() If Label1.Visible = True Then Label1.Visible = False Else Label1.Visible = True End If End Sub Private Sub Timer3_Timer() Unload Me frmLogin.Show

description

For BCA

Transcript of Coding

Page 1: Coding

Welcome Form

Private Sub DRAW() Dim X As Single, Y As Single, RADI As Single, R As Single Dim A As Single, THE As Single Call Randomize Scale (3, -3)-(-3, 3) RADI = 8 * Atn(1) forcolor = QBColor(Rnd() * 13) form1.ForeColor = forcolor A = 2 * Rnd() For THE = 0 To RADI Step 0.01 R = A * Sin(10 * THE) X = R * Cos(THE) Y = R * Sin(THE) PSet (X, Y) Next THEEnd Sub

Private Sub Form_KeyPress(KeyAscii As Integer)form1.HideForm2.ShowEnd Sub

Private Sub Timer2_Timer() Call DRAWEnd Sub

Private Sub Timer1_Timer()If Label1.Visible = True Then Label1.Visible = False Else Label1.Visible = TrueEnd IfEnd Sub

Private Sub Timer3_Timer() Unload Me frmLogin.ShowEnd Sub

Private Sub Timer5_Timer()Label1.ForeColor = QBColor(10 * Rnd)End Sub

Page 2: Coding

Reservation Form

Dim con As New ADODB.ConnectionDim record As New ADODB.RecordsetDim records As New ADODB.Recordset

Private Sub CMBtrainno_Click()On Error GoTo burecord.Open "Select train_no,train_name from table1 where train_no=" & CMBtrainno.Text CMBtrainno.Text = record.Fields(0) txttrainname = record.Fields(1)record.Closerecord.Open "Select stationfrom,stationto from farelist where trainno=" & CMBtrainno.Text cmbStFrom.Clear cmbStto.Clear record.MoveFirst While record.EOF = False cmbStFrom.AddItem record.Fields(0) cmbStto.AddItem record.Fields(1) record.MoveNext Wend cmbStFrom.Text = cmbStFrom.List(0) cmbStto = cmbStto.List(0)record.Closebu: MsgBox "Please insert the station detail to CountDetail"End Sub

Private Sub Command1_Click()Dim A As IntegerDim I As IntegerOn Error GoTo bu

If TXTbIRTH = "" ThenMsgBox "PLEASE FILL THE BIRTH INFORMATION " Exit SubElseFor I = 0 To (TXTbIRTH.Text) - 1 If txtseat1(I).Text = "" Or txtName(I).Text = "" Or cmbsex(I).Text = "" Or txtAge(I).Text = "" Then MsgBox "YOU CAN NOT RESERVE AN EMPTY SEAT. PLEASE FILL THE INFORMATION ABOUT CUSTOMER"

Page 3: Coding

Exit Sub End IfNextEnd IfIf txtticnum.Text = "" Then MsgBox "PLEASE ENTER THE TICKET NUMBER" Exit SubEnd If '************************ FOR INSERTING RESERVE SEATS **********If record.State = 1 Then record.CloseEnd Ifrecord.Open "select * from status_table where train_no=" & CMBtrainno A = 1 If cmbChoice.ListIndex = 0 Then record.Fields(1) = record.Fields(1) + TXTbIRTH ElseIf cmbChoice.ListIndex = 1 Then record.Fields(2) = record.Fields(2) + TXTbIRTH ElseIf cmbChoice.ListIndex = 2 Then record.Fields(3) = record.Fields(3) + TXTbIRTH ElseIf cmbChoice.ListIndex = 3 Then record.Fields(4) = record.Fields(4) + TXTbIRTH End If record.Updaterecord.Closerecord.Open "pNAME"For I = 0 To Val(TXTbIRTH) - 1 record.AddNew record!TRAINNO = CMBtrainno record!TICKETNO = txtticnum record!SEATNO = txtseat1(I).Text record!Name = txtName(I).Text record!SEX = cmbsex(I).Text record!AGE = txtAge(I).Text record!CHOICE = cmbChoice.Text record.UpdateNext record.Close

Command1.Enabled = False'******************************************************frmticket.lbl(1).Caption = CMBtrainnofrmticket.lbl(3).Caption = cmbStFromfrmticket.lbl(4).Caption = cmbSttofrmticket.lbl(5).Caption = txtdatefrmticket.lbl(0).Caption = txtticnum

Page 4: Coding

frmticket.lbl(6).Caption = TXTbIRTHfrmticket.lbl(7).Caption = cmbChoicefrmticket.lbl(2).Caption = txttrainnameFor I = 0 To Val(TXTbIRTH) - 1 frmticket.txtsno(I).Text = txtseat1(I) frmticket.txtName(I).Text = txtseat1(I) frmticket.txtName(I).Text = txtName(I) frmticket.txtsex(I).Text = cmbsex(I) frmticket.txtAge(I).Text = txtAge(I)Nextfrmticket.lbl(8).Caption = txtamt'******************************************************frmticket.ShowExit Sub

bu:

If A = 1 Then MsgBox "Not found" record.AddNew record.Fields(0) = CMBtrainno.Text If cmbChoice.ListIndex = 0 Then record.Fields(1) = Val(TXTbIRTH) ElseIf cmbChoice.ListIndex = 1 Then record.Fields(2) = Val(TXTbIRTH) ElseIf cmbChoice.ListIndex = 2 Then record.Fields(3) = Val(TXTbIRTH) ElseIf cmbChoice.ListIndex = 3 Then record.Fields(4) = Val(TXTbIRTH) End If record.Update record.CloseEnd Ifrecord.Open "pNAME"For I = 0 To Val(TXTbIRTH) - 1 record.AddNew record!TRAINNO = CMBtrainno record!TICKETNO = txtticnum.Text record!SEATNO = txtseat1(I).Text record!Name = txtName(I).Text record!SEX = cmbsex(I).Text record!AGE = txtAge(I).Text record!CHOICE = cmbChoice.Text record.UpdateNext

Page 5: Coding

record.CloseCommand1.Enabled = Falsefrmticket.lbl(1).Caption = CMBtrainnofrmticket.lbl(3).Caption = cmbStFromfrmticket.lbl(4).Caption = cmbSttofrmticket.lbl(5).Caption = txtdatefrmticket.lbl(0).Caption = txtticnumfrmticket.lbl(6).Caption = TXTbIRTHfrmticket.lbl(7).Caption = cmbChoicefrmticket.lbl(2).Caption = txttrainnameFor I = 0 To Val(TXTbIRTH) - 1 frmticket.txtsno(I).Text = txtseat1(I) frmticket.txtName(I).Text = txtseat1(I) frmticket.txtName(I).Text = txtName(I) frmticket.txtsex(I).Text = cmbsex(I) frmticket.txtAge(I).Text = txtAge(I)Nextfrmticket.lbl(8).Caption = txtamt'******************************************************frmticket.Show

End Sub

Private Sub Command2_Click()Unload MeEnd Sub

Private Sub Command3_Click()Form10.HideForm2.ShowEnd Sub

Private Sub Command4_Click()Dim A As IntegerCommand1.Enabled = TrueDim I As IntegerDim RES As IntegerDim TOT As IntegerOn Error GoTo BYIf record.State = 1 Then record.CloseEnd IfA = 1record.Open "Select max(Ticketno) from pname"txtticnum.Text = record.Fields(0) + 1record.Close

Page 6: Coding

If record.State = 1 Then record.CloseEnd IfA = 0record.Open ("FareList") If cmbChoice.ListIndex = 0 Then txtamt = record!fairACfirst * TXTbIRTH ElseIf cmbChoice.ListIndex = 1 Then txtamt = record!fairACsecond * TXTbIRTH ElseIf cmbChoice.ListIndex = 2 Then txtamt = record!fairchairCar * TXTbIRTH ElseIf cmbChoice.ListIndex = 3 Then txtamt = record!fairSleeper * TXTbIRTH End Ifrecord.Close

If TXTbIRTH.Text = "" Or cmbChoice.Text = "" Then MsgBox "PLEASE INSERT THE INFORMATION ABOUT BIRTH AND SEAT" Exit SubEnd IfIf TXTbIRTH = 1 Then txtseat1(0).Enabled = True txtName(0).Enabled = True cmbsex(0).Enabled = True txtAge(I).Enabled = True For I = 1 To 4 txtseat1(I).Enabled = False txtName(I).Enabled = False cmbsex(I).Enabled = False txtAge(I).Enabled = False Next Call ONE_BIRTH ElseIf TXTbIRTH = 2 Then For I = 0 To 1 txtseat1(I).Enabled = True txtName(I).Enabled = True cmbsex(I).Enabled = True txtAge(I).Enabled = True Next For I = 2 To 4 txtseat1(I).Enabled = False txtName(I).Enabled = False

Page 7: Coding

cmbsex(I).Enabled = False txtAge(I).Enabled = False Next Call TWO_BIRTHElseIf TXTbIRTH = 3 Then For I = 0 To 2 txtseat1(I).Enabled = True txtName(I).Enabled = True cmbsex(I).Enabled = True txtAge(I).Enabled = True Next For I = 3 To 4 txtseat1(I).Enabled = False txtName(I).Enabled = False cmbsex(I).Enabled = False txtAge(I).Enabled = False Next Call THREE_BIRTH

ElseIf TXTbIRTH = 4 Then For I = 0 To 3 txtseat1(I).Enabled = True txtName(I).Enabled = True cmbsex(I).Enabled = True txtAge(I).Enabled = True Next For I = 4 To 4 txtseat1(I).Enabled = False txtName(I).Enabled = False cmbsex(I).Enabled = False txtAge(I).Enabled = False Next Call FOUR_BIRTHElseIf TXTbIRTH = 5 Then For I = 0 To 4 txtseat1(I).Enabled = True txtName(I).Enabled = True cmbsex(I).Enabled = True txtAge(I).Enabled = True Next Call FIVE_BIRTHEnd IfIf record.State = 1 Then record.CloseEnd Ifrecord.Open "SELECT *FROM TABLE1 WHERE TRAIN_NO=" & CMBtrainno

Page 8: Coding

If cmbChoice.ListIndex = 0 Then If txtseat1(TXTbIRTH) >= record!ACFSEAT Then MsgBox "YOU CAN NOT RESERVE SEATS BECAUSE TOTAL SEATS ARE RESERVED" End If ElseIf cmbChoice.ListIndex = 1 Then If txtseat1(TXTbIRTH) >= record!ACSSEAT Then MsgBox "YOU CAN NOT RESERVE SEATS BECAUSE TOTAL SEATS ARE RESERVED" End If ElseIf cmbChoice.ListIndex = 2 Then If txtseat1(TXTbIRTH) >= record!CHAIRCARSEAT Then MsgBox "YOU CAN NOT RESERVE SEATS BECAUSE TOTAL SEATS ARE RESERVED" End If ElseIf cmbChoice.ListIndex = 3 Then If txtseat1(TXTbIRTH) >= record!SLEEPER Then MsgBox "YOU CAN NOT RESERVE SEATS BECAUSE TOTAL SEATS ARE RESERVED" End If End IfExit Sub

'********************************************************

'*************************************************************BY: If A = 1 Then txtticnum.Text = 1 Else If record.State = 1 Then record.Close End If If TXTbIRTH = 1 Then txtseat1(0).Text = 1 ElseIf TXTbIRTH = 2 Then txtseat1(0).Text = 1 txtseat1(1).Text = 2 ElseIf TXTbIRTH = 3 Then txtseat1(0).Text = 1 txtseat1(1).Text = 2 txtseat1(2).Text = 3 ElseIf TXTbIRTH = 4 Then txtseat1(0).Text = 1 txtseat1(1).Text = 2

Page 9: Coding

txtseat1(2).Text = 3 txtseat1(3).Text = 4 ElseIf TXTbIRTH = 5 Then txtseat1(0).Text = 1 txtseat1(1).Text = 2 txtseat1(2).Text = 3 txtseat1(3).Text = 4 txtseat1(4).Text = 5 End If End If ' MsgBox Err.Number & " " & Err.DescriptionEnd Sub

Private Sub Form_Load()Command1.Enabled = FalseDim I As IntegerIf con.State = 1 Then con.CloseEnd Ifcon.Open ("Pro")record.ActiveConnection = conrecord.CursorType = adOpenDynamicrecord.LockType = adLockOptimisticrecord.Open "table1" record.MoveFirst While record.EOF = False CMBtrainno.AddItem record.Fields(0) record.MoveNext Wend CMBtrainno = CMBtrainno.List(0) record.Closerecord.Open "Select train_name from table1 where train_no=" & CMBtrainno txttrainname = record.Fields(0)record.Closerecord.Open "Select stationfrom,stationto from farelist where trainno=" & CMBtrainno.Text cmbStFrom.Clear cmbStto.Clear record.MoveFirst While record.EOF = False cmbStFrom.AddItem record.Fields(0) cmbStto.AddItem record.Fields(1) record.MoveNext Wend

Page 10: Coding

cmbStFrom.Text = cmbStFrom.List(0) cmbStto = cmbStto.List(0)record.Close'********************************************For I = 0 To 4 txtseat1(I).Enabled = False txtName(I).Enabled = False cmbsex(I).Enabled = False txtAge(I).Enabled = FalseNextEnd Sub

Private Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer)Form2.ShowEnd Sub

Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)

End Sub

Private Sub Label7_Click()

End Sub

Private Sub txtdate_LostFocus()On Error Resume NextDim DATES As DateDim RR As Integer

DATES = Text9.Month & "/" & Text9.Day & "/" & Text9.YearRR = DateDiff("D", Date, DATES)If RR < 0 ThenMsgBox "DATE JOURNEY MOST BE GRATER THEN CURRENT DATE"Text9.SetFocusEnd If

End Sub

Private Sub TWO_BIRTH() If cmbChoice.ListIndex = 0 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(ACFSEAT_RES) from status_table where train_no=" & CMBtrainno

Page 11: Coding

record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 1 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(ACSSEAT_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 2 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(CHAIRCARSEAT_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 3 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(SLEEPER_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 End If record.Close End If

End SubPrivate Sub ONE_BIRTH()

Page 12: Coding

If cmbChoice.ListIndex = 0 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(ACFSEAT_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 1 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(ACSSEAT_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 2 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(CHAIRCARSEAT_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 3 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(SLEEPER_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 End If record.Close End If

Page 13: Coding

End SubPrivate Sub THREE_BIRTH() If cmbChoice.ListIndex = 0 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(ACFSEAT_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 txtseat1(2) = txtseat1(1) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 1 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(ACSSEAT_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 txtseat1(2) = txtseat1(1) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 2 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(CHAIRCARSEAT_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 txtseat1(2) = txtseat1(1) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 3 Then If record.State = 1 Then record.Close End If

Page 14: Coding

record.Open "Select MAX(SLEEPER_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 txtseat1(2) = txtseat1(1) + 1 End If record.Close End If

End Sub

Private Sub FOUR_BIRTH() If cmbChoice.ListIndex = 0 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(ACFSEAT_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 txtseat1(2) = txtseat1(1) + 1 txtseat1(3) = txtseat1(2) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 1 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(ACSSEAT_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 txtseat1(2) = txtseat1(1) + 1 txtseat1(3) = txtseat1(2) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 2 Then If record.State = 1 Then record.Close End If

Page 15: Coding

record.Open "Select MAX(CHAIRCARSEAT_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 txtseat1(2) = txtseat1(1) + 1 txtseat1(3) = txtseat1(2) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 3 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(SLEEPER_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 txtseat1(2) = txtseat1(1) + 1 txtseat1(3) = txtseat1(2) + 1 End If record.Close End If

End SubPrivate Sub FIVE_BIRTH() If cmbChoice.ListIndex = 0 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(ACFSEAT_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 txtseat1(2) = txtseat1(1) + 1 txtseat1(3) = txtseat1(2) + 1 txtseat1(4) = txtseat1(3) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 1 Then If record.State = 1 Then record.Close

Page 16: Coding

End If record.Open "Select MAX(ACSSEAT_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 txtseat1(2) = txtseat1(1) + 1 txtseat1(3) = txtseat1(2) + 1 txtseat1(4) = txtseat1(3) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 2 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(CHAIRCARSEAT_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 txtseat1(2) = txtseat1(1) + 1 txtseat1(3) = txtseat1(2) + 1 txtseat1(4) = txtseat1(3) + 1 End If record.Close ElseIf cmbChoice.ListIndex = 3 Then If record.State = 1 Then record.Close End If record.Open "Select MAX(SLEEPER_RES) from status_table where train_no=" & CMBtrainno record.MoveFirst If record.EOF = False Then txtseat1(0) = record.Fields(0) + 1 txtseat1(1) = txtseat1(0) + 1 txtseat1(2) = txtseat1(1) + 1 txtseat1(3) = txtseat1(2) + 1 txtseat1(4) = txtseat1(3) + 1 End If record.Close End If

End Sub

Page 17: Coding

COUNT FARE

Dim con As New ADODB.ConnectionDim records As New ADODB.RecordsetDim record As New ADODB.RecordsetPrivate Sub Combo1_Click()record.ActiveConnection = conrecord.CursorType = adOpenDynamicrecord.LockType = adLockOptimistic

record.Open "select train_name from table1 where train_no=" & Combo1.Text record.MoveFirst txtTrainName = record.Fields(0) record.Close

End Sub

Private Sub Command1_Click()If debugt = 0 Then Exit SubElseIf debugt = 1 Thenrecords.Fields(0) = Combo1.Textrecords.Fields(1) = txtTrainNamerecords.Fields(2) = txtSTFromrecords.Fields(3) = txtStTorecords.Fields(4) = txtDistancerecords.Fields(5) = txtfACrecords.Fields(6) = txtSACrecords.Fields(7) = txtSleeprecords.Fields(8) = txtChair

records.UpdateEnd IfEnd Sub

Private Sub Command3_Click()Form10.HideForm2.Show

End Sub

Private Sub Command4_Click()On Error Resume Next

Page 18: Coding

records.MoveFirstCall ShowDetEnd Sub

Private Sub Command5_Click()On Error Resume Nextrecords.MoveLastCall ShowDetEnd Sub

Private Sub Command6_Click()On Error Resume Nextrecords.MovePreviousCall ShowDetEnd Sub

Private Sub Command7_Click()On Error Resume Nextrecords.MoveNextCall ShowDetEnd Sub

Private Sub Command8_Click()Call TextBoxEnable(1)Call ClearTextBoxIf records.State = 1 Then records.CloseEnd Ifrecords.Open "farelist"records.AddNewrecord.Open "table1", con, adOpenDynamic, adLockOptimistic record.MoveFirst While record.EOF = False Combo1.AddItem record.Fields(0) record.MoveNext Wend Combo1.Text = Combo1.List(0) record.Close

record.ActiveConnection = conrecord.CursorType = adOpenDynamicrecord.LockType = adLockOptimistic

record.Open "select train_name from table1 where train_no=" & Combo1.Text record.MoveFirst txtTrainName = record.Fields(0)

Page 19: Coding

record.Close

End Sub

Private Sub Form_Load()On Error GoTo buCall TextBoxEnable(0)con.Open ("Pro")records.ActiveConnection = conrecords.Open "farelist", con, adOpenDynamic, adLockOptimisticrecords.MoveFirstrecord.ActiveConnection = conCall ShowDetExit Subbu:MsgBox "There is no any record to display. You can only insert values"End Sub

Private Sub ShowDet()Combo1.Text = records.Fields(0)txtTrainName = records.Fields(1)txtSTFrom = records.Fields(2)txtStTo = records.Fields(3)txtDistance = records.Fields(4)txtfAC = records.Fields(5)txtSAC = records.Fields(6)txtSleep = records.Fields(7)txtChair = records.Fields(8)End Sub

Private Sub ClearTextBox()txtTrainName = ""txtSTFrom = ""txtStTo = ""txtDistance = ""txtfAC = ""txtSAC = ""txtSleep = ""txtChair = ""

End Sub

Private Sub TextBoxEnable(l As Integer)Dim cont As ControlIf l = 0 ThenCombo1.Enabled = False

Page 20: Coding

txtTrainName.Enabled = FalsetxtSTFrom.Enabled = FalsetxtStTo.Enabled = FalsetxtDistance.Enabled = FalsetxtfAC.Enabled = FalsetxtSAC.Enabled = FalsetxtSleep.Enabled = FalsetxtChair.Enabled = FalseElseIf l = 1 ThenCombo1.Enabled = TruetxtTrainName.Enabled = TruetxtSTFrom.Enabled = TruetxtStTo.Enabled = TruetxtDistance.Enabled = TruetxtfAC.Enabled = TruetxtSAC.Enabled = TruetxtSleep.Enabled = TruetxtChair.Enabled = True

End If

End Sub

Private Function debugt() As Integer

If txtTrainName = "" Then MsgBox "Please enter the train name" debugt = 0 Exit FunctionEnd IfIf txtSTFrom = "" Then MsgBox "Please enter the Station from" debugt = 0 Exit FunctionEnd IfIf txtStTo = "" Then MsgBox "Please enter the Station to" debugt = 0 Exit FunctionEnd IfIf txtDistance = "" Then MsgBox "Please enter the Distance" debugt = 0 Exit FunctionEnd IfIf txtfAC = "" Then

Page 21: Coding

MsgBox "Please enter the AC first Fare" debugt = 0 Exit FunctionEnd IfIf txtSAC = "" Then MsgBox "Please enter the AC second Fare" debugt = 0 Exit FunctionEnd IfIf txtSleep = "" Then MsgBox "Please enter the Sleeper Fare" debugt = 0 Exit FunctionEnd IfIf txtChair = "" Then MsgBox "Please enter the Chair Car Fare" debugt = 0 Exit FunctionEnd Ifdebugt = 1End Function

Private Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer)Form2.ShowUnload MeEnd Sub

Page 22: Coding

Main Form

Private Sub ab_Click()frmAbout.ShowEnd Sub

Private Sub AddRecord_Click() Unload Me Form3.ShowEnd Sub

Private Sub Command1_Click()Unload MeForm8.ShowEnd Sub

Private Sub Command2_Click()Unload MeForm8.ShowEnd Sub

Private Sub cancel_Click()Unload MeForm7.ShowEnd Sub

Private Sub chpass_Click()frmChPass.ShowEnd Sub

Private Sub DeleteRecord_Click()Unload MeForm6.ShowEnd Sub

Private Sub DisplayRecord_Click()Unload MeForm9.ShowEnd Sub

Private Sub ExitFor_Click()EndEnd Sub

Private Sub FINDRecord_Click()

Page 23: Coding

Unload MeForm9.ShowEnd Sub

Private Sub FARE_Click()Unload MeForm11.ShowEnd Sub

Private Sub fird_Click()Unload MeForm9.ShowEnd Sub

Private Sub ModifyRecord_Click()Unload MeForm4.ShowEnd Sub

Private Sub researvation1_Click()Unload MeForm10.ShowEnd Sub

Private Sub Timer1_Timer()

Image1.Left = Image1.Left + 400If Image1.Left = Form2.Width ThenImage1.Left = 0ElseImage1.Left = Image1.Left + 400End IfEnd Sub

Private Sub reser_Click()DataReport1.ShowEnd Sub

Private Sub sh_Click()frmticshow.ShowEnd Sub

Private Sub trainre_Click()DataReport2.ShowEnd Sub

Page 24: Coding

Add record Form

Dim P As BooleanDim A As IntegerDim B As IntegerDim con As ADODB.ConnectionDim rs As ADODB.RecordsetPrivate Sub Command1_Click()On Error GoTo buCall PASTErs.UpdateCommand8.Enabled = TrueCommand1.Enabled = FalseExit Subbu: MsgBox Err.DescriptionEnd SubPrivate Sub Command3_Click() Unload Me Form2.ShowEnd Sub

Private Sub Command4_Click()On Error Resume Nextrs.MoveFirstCall COPYEnd Sub

Private Sub Command5_Click()On Error Resume Nextrs.MoveLastCall COPYEnd Sub

Private Sub Command6_Click()If rs.BOF = False Thenrs.MovePreviousCall COPYEnd IfEnd Sub

Private Sub Command7_Click()If rs.EOF = False Then

Page 25: Coding

rs.MoveNextCall COPYEnd If

End Sub

Private Sub Command8_Click()Command8.Enabled = FalseCommand1.Enabled = Truers.AddNewCall BLKText1.SetFocusEnd Sub

Private Sub Form_Activate()Command1.Enabled = Falsers.MoveFirstCall COPY

End Sub

Private Sub Form_Load()Set con = New ADODB.Connectioncon.ConnectionString = "dsn=pro"con.OpenSet rs = New ADODB.Recordsetrs.ActiveConnection = conrs.CursorType = adOpenKeysetrs.LockType = adLockPessimisticrs.Source = "SELECT * FROM table1"rs.OpenEnd Sub

Private Sub Label6_Click()

End Sub

Private Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer)

Form2.ShowUnload MeEnd Sub

Page 26: Coding

Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)

End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then Text2.SetFocusEnd IfEnd Sub

Private Sub Text11_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText12.SetFocusEnd If

End Sub

Private Sub Text12_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText3.SetFocusEnd If

End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText11.SetFocusEnd IfEnd Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then Text4.SetFocusEnd IfEnd Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText5.SetFocusEnd IfEnd Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText8.SetFocusEnd If

Page 27: Coding

End Sub

Private Sub Text8_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenCommand1.SetFocusEnd If

End Sub

Private Sub COPY() If rs.EOF = False Then If rs.BOF = True Then Exit Sub End If Text1.Text = rs.Fields("TRAIN_NO") Text2.Text = rs.Fields("TRAIN_NAME") Text3.Text = rs.Fields("ARR_TIME") Text4.Text = rs.Fields("DEP_TIME") Text11.Text = rs.Fields("STA_FROM") Text12.Text = rs.Fields("STA_TO") txtACF.Text = rs.Fields("ACFSEAT") txtACs.Text = rs.Fields("ACSSEAT")TXTChair.Text = rs.Fields("ChairCarSEAT")txtSleeper.Text = rs.Fields("Sleeper") End If End Sub

Private Sub PASTE()rs.Fields("TRAIN_NO") = Text1.Textrs.Fields("TRAIN_NAME") = Text2.Textrs.Fields("ARR_TIME") = Text3.Textrs.Fields("DEP_TIME") = Text4.Textrs.Fields("ACFSEAT") = txtACF.Textrs.Fields("ACSSEAT") = txtACs.Textrs.Fields("ChairCarSEAT") = TXTChair.Textrs.Fields("Sleeper") = txtSleeper.Textrs.Fields("STA_FROM") = Text11.Textrs.Fields("STA_TO") = Text12.TextEnd SubPublic Sub BLK() Text1.Text = "" Text2.Text = ""

Page 28: Coding

Text3.Text = ""Text4.Text = ""txtACF.Text = ""txtACs.Text = ""TXTChair.Text = ""txtSleeper.Text = ""Text11.Text = ""Text12.Text = ""End Sub

Private Sub Timer1_Timer()Image3.Picture = Image1.PictureImage1.Picture = Image2.PictureImage2.Picture = Image3.PictureEnd Sub

Private Sub Timer2_Timer()Label7.ForeColor = QBColor(10 * Rnd)

End Sub

Page 29: Coding

Modify Records

Dim con As ADODB.ConnectionDim rs As ADODB.RecordsetDim com As New ADODB.Command

Private Sub cmdDelete_Click()com.ActiveConnection = con

com.CommandType = adCmdTextcom.CommandText = "delete * from table1 where train_no ='" & Text1.Text & "'"com.Executers.MoveFirstCall DisplayEnd Sub

Private Sub cmdMain_Click() Unload Me Form2.ShowEnd Sub

Private Sub cmdMoveNext_Click()On Error Resume Nextrs.MoveNextCall DisplayEnd Sub

Private Sub cmdMovePre_Click()On Error Resume Nextrs.MovePreviousCall DisplayEnd Sub

Private Sub Command1_Click()txtTrainNum.Enabled = TruetxtTrainName.Enabled = TruetxtStationFrom.Enabled = TruetxtStationTo.Enabled = TruetxtARRTime.Enabled = TruetxtDEp.Enabled = True txtACF.Enabled = True txtACs.Enabled = TrueTXTChair.Enabled = TruetxtSleeper.Enabled = True

End Sub

Page 30: Coding

Private Sub Command2_Click()rs!train_no = txtTrainNumrs!train_name = txtTrainNamers!sta_from = txtStationFromrs!sta_to = txtStationTors!arr_time = txtARRTimers!DEP_time = txtDEprs.Fields("ACFSEAT") = txtACF.Textrs.Fields("ACSSEAT") = txtACs.Textrs.Fields("ChairCarSEAT") = TXTChair.Textrs.Fields("Sleeper") = txtSleeper.Textrs.UpdatetxtTrainNum.Enabled = FalsetxtTrainName.Enabled = FalsetxtStationFrom.Enabled = FalsetxtStationTo.Enabled = FalsetxtARRTime.Enabled = FalsetxtDEp.Enabled = False txtACF.Enabled = False txtACs.Enabled = FalseTXTChair.Enabled = FalsetxtSleeper.Enabled = FalseEnd Sub

Private Sub Form_Load()Set con = New ADODB.Connectioncon.ConnectionString = "dsn=pro"con.OpenSet rs = New ADODB.Recordsetrs.ActiveConnection = conrs.CursorType = adOpenKeysetrs.LockType = adLockPessimisticrs.Source = "SELECT * FROM table1"rs.OpenCall DisplayEnd Sub

Private Sub Display()txtTrainNum = rs!train_notxtTrainName = rs!train_nametxtStationFrom = rs!sta_fromtxtStationTo = rs!sta_totxtARRTime = rs!arr_timetxtDEp = rs!DEP_time txtACF.Text = rs.Fields("ACFSEAT")

Page 31: Coding

txtACs.Text = rs.Fields("ACSSEAT")TXTChair.Text = rs.Fields("ChairCarSEAT")txtSleeper.Text = rs.Fields("Sleeper")

txtTrainNum.Enabled = FalsetxtTrainName.Enabled = FalsetxtStationFrom.Enabled = FalsetxtStationTo.Enabled = FalsetxtARRTime.Enabled = FalsetxtDEp.Enabled = False txtACF.Enabled = False txtACs.Enabled = FalseTXTChair.Enabled = FalsetxtSleeper.Enabled = False

End Sub

Private Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer)Form2.ShowUnload MeEnd Sub

Page 32: Coding

Delete Record

Dim A As IntegerDim B As IntegerDim con As ADODB.ConnectionDim rs As ADODB.RecordsetPrivate Sub Command1_Click()If rs.EOF = False Thenrs.Deleters.MoveFirstCall COPYElseMsgBox ("you are at last possition")Exit SubEnd IfEnd SubPrivate Sub Command3_Click() Unload Me Form2.ShowEnd Sub

Private Sub Command4_Click()On Error Resume Nextrs.MoveFirstCall COPYEnd Sub

Private Sub Command5_Click()On Error Resume Nextrs.MoveLastCall COPYEnd Sub

Private Sub Command6_Click()If rs.BOF = False Thenrs.MovePreviousCall COPYEnd IfEnd Sub

Private Sub Command7_Click()If rs.EOF = False Thenrs.MoveNextCall COPYEnd If

Page 33: Coding

End Sub

Private Sub Command8_Click()Command8.Enabled = FalseCommand1.Enabled = Truers.AddNewCall BLKEnd Sub

Private Sub Form_Activate()rs.MoveFirstCall COPYEnd Sub

Private Sub Form_Load()Set con = New ADODB.ConnectionIf con.State = 1 Then con.CloseEnd If

con.ConnectionString = "dsn=pro"con.OpenSet rs = New ADODB.Recordsetrs.ActiveConnection = conrs.CursorType = adOpenKeysetrs.LockType = adLockPessimisticrs.Source = "SELECT * FROM table1"rs.OpenEnd Sub

Private Sub Frame4_DragDrop(Source As Control, X As Single, Y As Single)

End Sub

Private Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer)Form2.ShowUnload MeEnd Sub

Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)

End Sub

Page 34: Coding

Private Sub Text1_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then Text2.SetFocusEnd IfEnd Sub

Private Sub Text11_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText12.SetFocusEnd If

End Sub

Private Sub Text12_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText3.SetFocusEnd If

End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText11.SetFocusEnd IfEnd Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then Text4.SetFocusEnd IfEnd Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText5.SetFocusEnd IfEnd Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText8.SetFocusEnd IfEnd Sub

Page 35: Coding

Private Sub Text8_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenCommand1.SetFocusEnd If

End Sub

Private Sub COPY() If rs.EOF = False Then If rs.BOF = True Then Exit Sub End If Text1.Text = rs.Fields("TRAIN_NO") Text2.Text = rs.Fields("TRAIN_NAME") Text3.Text = rs.Fields("ARR_TIME") Text4.Text = rs.Fields("DEP_TIME") txtACF.Text = rs.Fields("ACFSEAT") txtACs.Text = rs.Fields("ACSSEAT")TXTChair.Text = rs.Fields("ChairCarSEAT")txtSleeper.Text = rs.Fields("Sleeper") Text11.Text = rs.Fields("STA_FROM") Text12.Text = rs.Fields("STA_TO") End If End Sub

Private Sub PASTE()rs.Fields("TRAIN_NO") = Text1.Textrs.Fields("TRAIN_NAME") = Text2.Textrs.Fields("ARR_TIME") = Text3.Textrs.Fields("DEP_TIME") = Text4.Textrs.Fields("ACFSEAT") = txtACF.Textrs.Fields("ACSSEAT") = txtACs.Textrs.Fields("ChairCarSEAT") = TXTChair.Textrs.Fields("Sleeper") = txtSleeper.Textrs.Fields("STA_FROM") = Text11.Textrs.Fields("STA_TO") = Text12.TextEnd SubPublic Sub BLK() Text1.Text = "" Text2.Text = "" Text3.Text = ""Text4.Text = ""Text11.Text = ""Text12.Text = ""

Page 36: Coding

txtACF.Text = ""txtACs.Text = ""TXTChair.Text = ""txtSleeper.Text = ""End Sub

Private Sub Timer1_Timer()Image3.Picture = Image1.PictureImage1.Picture = Image2.PictureImage2.Picture = Image3.PictureEnd Sub

Private Sub Timer2_Timer()Label6.ForeColor = QBColor(10 * Rnd)End Sub

Page 37: Coding

Cancellation Form

Private Sub cmdCancel_Click()On Error GoTo sIf txtticNum = "" Then MsgBox "First Enter the Ticket Number" Exit SubEnd IfDim con As New ADODB.ConnectionDim comm As New ADODB.Commandcon.Open ("Pro")comm.ActiveConnection = concomm.CommandText = "Delete *from pname where ticketno=" & txtticNumcomm.ExecuteMsgBox "Reservation have been cancled successfully"Exit Subs: MsgBox "The ticket number not found"End Sub

Private Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer)Form2.ShowUnload MeEnd Sub

Find RecordsDim A As IntegerDim B As IntegerDim con As ADODB.ConnectionDim rs As ADODB.RecordsetPrivate Sub Command1_Click()Dim FLAG%, I%ST = Val(InputBox("ENTER THE TRAIN NUMBER"))FLAG = 0rs.MoveFirstWhile rs.EOF = FalseIf ST = rs.Fields("TRAIN_NO") ThenFLAG = 1Call COPYExit SubEnd Ifrs.MoveNextWendIf FLAG = 0 Then

Page 38: Coding

MsgBox ("RECORD NOT FOUND"), vbCriticalEnd IfEnd Sub

Private Sub Command3_Click() Unload Me Form2.ShowEnd Sub

Private Sub Command4_Click()On Error Resume Nextrs.MoveFirstCall COPYEnd Sub

Private Sub Command5_Click()On Error Resume Nextrs.MoveLastCall COPYEnd Sub

Private Sub Command6_Click()If rs.BOF = False Thenrs.MovePreviousCall COPYEnd IfEnd Sub

Private Sub Command7_Click()If rs.EOF = False Thenrs.MoveNextCall COPYEnd IfEnd Sub

Private Sub Form_Activate()rs.MoveFirstCall COPYCommand1.SetFocusEnd Sub

Private Sub Form_Load()Set con = New ADODB.Connectioncon.ConnectionString = "dsn=pro"con.Open

Page 39: Coding

Set rs = New ADODB.Recordsetrs.ActiveConnection = conrs.CursorType = adOpenKeysetrs.LockType = adLockPessimisticrs.Source = "SELECT * FROM table1"rs.OpenEnd Sub

Private Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer)Form2.ShowUnload MeEnd Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then Text2.SetFocusEnd IfEnd Sub

Private Sub Text11_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText12.SetFocusEnd If

End Sub

Private Sub Text12_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText3.SetFocusEnd If

End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText11.SetFocusEnd IfEnd Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then Text4.SetFocusEnd IfEnd Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)

Page 40: Coding

If KeyAscii = 13 ThenText5.SetFocusEnd IfEnd Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenText8.SetFocusEnd IfEnd Sub

Private Sub Text8_KeyPress(KeyAscii As Integer)If KeyAscii = 13 ThenCommand1.SetFocusEnd IfEnd SubPrivate Sub COPY() If rs.EOF = False Then If rs.BOF = True Then Exit Sub End If Text1.Text = rs.Fields("TRAIN_NO") Text2.Text = rs.Fields("TRAIN_NAME") Text3.Text = rs.Fields("ARR_TIME") Text4.Text = rs.Fields("DEP_TIME") txtACF.Text = rs.Fields("ACFSEAT") txtACs.Text = rs.Fields("ACSSEAT") TXTChair.Text = rs.Fields("ChairCarSEAT") txtSleeper.Text = rs.Fields("Sleeper") Text11.Text = rs.Fields("STA_FROM") Text12.Text = rs.Fields("STA_TO") End If End Sub

Private Sub PASTE()rs.Fields("TRAIN_NO") = Text1.Textrs.Fields("TRAIN_NAME") = Text2.Textrs.Fields("ARR_TIME") = Text3.Textrs.Fields("DEP_TIME") = Text4.Textrs.Fields("ACFSEAT") = txtACF.Textrs.Fields("ACSSEAT") = txtACs.Textrs.Fields("ChairCarSEAT") = TXTChair.Textrs.Fields("Sleeper") = txtSleeper.Textrs.Fields("STA_FROM") = Text11.Textrs.Fields("STA_TO") = Text12.Text

Page 41: Coding

End SubPublic Sub BLK() Text1.Text = "" Text2.Text = "" Text3.Text = ""Text4.Text = ""txtACF.Text = ""txtACs.Text = ""TXTChair.Text = ""txtSleeper.Text = ""Text11.Text = ""Text12.Text = ""End Sub

Private Sub Timer1_Timer()Image3.Picture = Image1.PictureImage1.Picture = Image2.PictureImage2.Picture = Image3.PictureEnd Sub

Private Sub Timer2_Timer()Label6.ForeColor = QBColor(10 * Rnd)End Sub

Page 42: Coding

Change Password Form

Dim con As New ADODB.ConnectionDim rs As New ADODB.RecordsetPrivate Sub Command1_Click()If txtUser = "" Or txtPass = "" Or txtCoPass = "" Then MsgBox "Please Type new uaername o Password and then try again" Exit SubEnd IfIf txtPass <> txtCoPass Then MsgBox "The Passwords are not match . Please enter a right password" Exit SubEnd If

If con.State = 1 Then con.CloseEnd Ifcon.Open "pro"rs.ActiveConnection = conrs.CursorType = adOpenDynamicrs.LockType = adLockOptimisticrs.Open "Login"rs.MoveFirstrs.Fields(0) = txtUserrs.Fields(1) = txtCoPassrs.UpdateMsgBox "UserName and Password have been changed successfully"Unload MeEnd Sub

Private Sub Command2_Click()Unload MeEnd Sub

Page 43: Coding

Login Form

Dim con As ADODB.ConnectionDim rs As ADODB.RecordsetDim F As Integer

Private Sub cmdCancel_Click()EndEnd Sub

Private Sub CMDOK_CLICK()Set rs = New ADODB.Recordsetrs.ActiveConnection = conrs.CursorType = adOpenKeysetrs.LockType = adLockPessimisticrs.Source = "select * from login"rs.OpenWhile Not rs.EOF If rs("loginname") = txtUserName And rs("passward") = txtPassword Then Form2.Show Unload Me Else MsgBox "Invalid username/passward", vbCritical End If rs.MoveNextWendtxtUserName.Text = ""txtPassword.Text = ""rs.CloseEnd Sub

Private Sub Form_Load()Set con = New ADODB.Connectioncon.ConnectionString = "dsn=Pro"con.OpenEnd Sub

Page 44: Coding

Ticket Information Form

Private Sub Command1_Click()Adodc1.CommandType = adCmdTextAdodc1.RecordSource = "Select *from pname where ticketno=" & txtticAdodc1.RefreshEnd Sub