You are on page 1of 44

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
End Sub
Private Sub Timer5_Timer()
Label1.ForeColor = QBColor(10 * Rnd)
End Sub

Reservation Form
Dim con As New ADODB.Connection
Dim record As New ADODB.Recordset
Dim records As New ADODB.Recordset
Private Sub CMBtrainno_Click()
On Error GoTo bu
record.Open "Select train_no,train_name from table1 where train_no=" &
CMBtrainno.Text
CMBtrainno.Text = record.Fields(0)
txttrainname = record.Fields(1)
record.Close
record.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.Close
bu:
MsgBox "Please insert the station detail to CountDetail"
End Sub
Private Sub Command1_Click()
Dim A As Integer
Dim I As Integer
On Error GoTo bu
If TXTbIRTH = "" Then
MsgBox "PLEASE FILL THE BIRTH INFORMATION "
Exit Sub
Else
For 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"

Exit Sub
End If
Next
End If
If txtticnum.Text = "" Then
MsgBox "PLEASE ENTER THE TICKET NUMBER"
Exit Sub
End If
'************************ FOR INSERTING RESERVE SEATS **********
If record.State = 1 Then
record.Close
End If
record.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.Update
record.Close
record.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.Update
Next
record.Close
Command1.Enabled = False
'******************************************************
frmticket.lbl(1).Caption = CMBtrainno
frmticket.lbl(3).Caption = cmbStFrom
frmticket.lbl(4).Caption = cmbStto
frmticket.lbl(5).Caption = txtdate
frmticket.lbl(0).Caption = txtticnum

frmticket.lbl(6).Caption = TXTbIRTH
frmticket.lbl(7).Caption = cmbChoice
frmticket.lbl(2).Caption = txttrainname
For 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)
Next
frmticket.lbl(8).Caption = txtamt
'******************************************************
frmticket.Show
Exit 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.Close
End If
record.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.Update
Next

record.Close
Command1.Enabled = False
frmticket.lbl(1).Caption = CMBtrainno
frmticket.lbl(3).Caption = cmbStFrom
frmticket.lbl(4).Caption = cmbStto
frmticket.lbl(5).Caption = txtdate
frmticket.lbl(0).Caption = txtticnum
frmticket.lbl(6).Caption = TXTbIRTH
frmticket.lbl(7).Caption = cmbChoice
frmticket.lbl(2).Caption = txttrainname
For 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)
Next
frmticket.lbl(8).Caption = txtamt
'******************************************************
frmticket.Show
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
Form10.Hide
Form2.Show
End Sub
Private Sub Command4_Click()
Dim A As Integer
Command1.Enabled = True
Dim I As Integer
Dim RES As Integer
Dim TOT As Integer
On Error GoTo BY
If record.State = 1 Then
record.Close
End If
A=1
record.Open "Select max(Ticketno) from pname"
txtticnum.Text = record.Fields(0) + 1
record.Close

If record.State = 1 Then
record.Close
End If
A=0
record.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 If
record.Close
If TXTbIRTH.Text = "" Or cmbChoice.Text = "" Then
MsgBox "PLEASE INSERT THE INFORMATION ABOUT BIRTH AND SEAT"
Exit Sub
End If
If 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

cmbsex(I).Enabled = False
txtAge(I).Enabled = False
Next
Call TWO_BIRTH
ElseIf 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_BIRTH
ElseIf 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_BIRTH
End If
If record.State = 1 Then
record.Close
End If
record.Open "SELECT *FROM TABLE1 WHERE TRAIN_NO=" & CMBtrainno

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 If
Exit 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

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.Description
End Sub
Private Sub Form_Load()
Command1.Enabled = False
Dim I As Integer
If con.State = 1 Then
con.Close
End If
con.Open ("Pro")
record.ActiveConnection = con
record.CursorType = adOpenDynamic
record.LockType = adLockOptimistic
record.Open "table1"
record.MoveFirst
While record.EOF = False
CMBtrainno.AddItem record.Fields(0)
record.MoveNext
Wend
CMBtrainno = CMBtrainno.List(0)
record.Close
record.Open "Select train_name from table1 where train_no=" & CMBtrainno
txttrainname = record.Fields(0)
record.Close
record.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.Close
'********************************************
For I = 0 To 4
txtseat1(I).Enabled = False
txtName(I).Enabled = False
cmbsex(I).Enabled = False
txtAge(I).Enabled = False
Next
End Sub
Private Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer)
Form2.Show
End 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 Next
Dim DATES As Date
Dim RR As Integer
DATES = Text9.Month & "/" & Text9.Day & "/" & Text9.Year
RR = DateDiff("D", Date, DATES)
If RR < 0 Then
MsgBox "DATE JOURNEY MOST BE GRATER THEN CURRENT DATE"
Text9.SetFocus
End 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

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 Sub
Private Sub ONE_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
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

End Sub
Private 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

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

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 Sub
Private 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

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

COUNT FARE
Dim con As New ADODB.Connection
Dim records As New ADODB.Recordset
Dim record As New ADODB.Recordset
Private Sub Combo1_Click()
record.ActiveConnection = con
record.CursorType = adOpenDynamic
record.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 Sub
ElseIf debugt = 1 Then
records.Fields(0) = Combo1.Text
records.Fields(1) = txtTrainName
records.Fields(2) = txtSTFrom
records.Fields(3) = txtStTo
records.Fields(4) = txtDistance
records.Fields(5) = txtfAC
records.Fields(6) = txtSAC
records.Fields(7) = txtSleep
records.Fields(8) = txtChair
records.Update
End If
End Sub
Private Sub Command3_Click()
Form10.Hide
Form2.Show
End Sub
Private Sub Command4_Click()
On Error Resume Next

records.MoveFirst
Call ShowDet
End Sub
Private Sub Command5_Click()
On Error Resume Next
records.MoveLast
Call ShowDet
End Sub
Private Sub Command6_Click()
On Error Resume Next
records.MovePrevious
Call ShowDet
End Sub
Private Sub Command7_Click()
On Error Resume Next
records.MoveNext
Call ShowDet
End Sub
Private Sub Command8_Click()
Call TextBoxEnable(1)
Call ClearTextBox
If records.State = 1 Then
records.Close
End If
records.Open "farelist"
records.AddNew
record.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 = con
record.CursorType = adOpenDynamic
record.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 Form_Load()
On Error GoTo bu
Call TextBoxEnable(0)
con.Open ("Pro")
records.ActiveConnection = con
records.Open "farelist", con, adOpenDynamic, adLockOptimistic
records.MoveFirst
record.ActiveConnection = con
Call ShowDet
Exit Sub
bu:
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 Control
If l = 0 Then
Combo1.Enabled = False

txtTrainName.Enabled = False
txtSTFrom.Enabled = False
txtStTo.Enabled = False
txtDistance.Enabled = False
txtfAC.Enabled = False
txtSAC.Enabled = False
txtSleep.Enabled = False
txtChair.Enabled = False
ElseIf l = 1 Then
Combo1.Enabled = True
txtTrainName.Enabled = True
txtSTFrom.Enabled = True
txtStTo.Enabled = True
txtDistance.Enabled = True
txtfAC.Enabled = True
txtSAC.Enabled = True
txtSleep.Enabled = True
txtChair.Enabled = True
End If
End Sub
Private Function debugt() As Integer
If txtTrainName = "" Then
MsgBox "Please enter the train name"
debugt = 0
Exit Function
End If
If txtSTFrom = "" Then
MsgBox "Please enter the Station from"
debugt = 0
Exit Function
End If
If txtStTo = "" Then
MsgBox "Please enter the Station to"
debugt = 0
Exit Function
End If
If txtDistance = "" Then
MsgBox "Please enter the Distance"
debugt = 0
Exit Function
End If
If txtfAC = "" Then

MsgBox "Please enter the AC first Fare"


debugt = 0
Exit Function
End If
If txtSAC = "" Then
MsgBox "Please enter the AC second Fare"
debugt = 0
Exit Function
End If
If txtSleep = "" Then
MsgBox "Please enter the Sleeper Fare"
debugt = 0
Exit Function
End If
If txtChair = "" Then
MsgBox "Please enter the Chair Car Fare"
debugt = 0
Exit Function
End If
debugt = 1
End Function
Private Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer)
Form2.Show
Unload Me
End Sub

Main Form
Private Sub ab_Click()
frmAbout.Show
End Sub
Private Sub AddRecord_Click()
Unload Me
Form3.Show
End Sub
Private Sub Command1_Click()
Unload Me
Form8.Show
End Sub
Private Sub Command2_Click()
Unload Me
Form8.Show
End Sub
Private Sub cancel_Click()
Unload Me
Form7.Show
End Sub
Private Sub chpass_Click()
frmChPass.Show
End Sub
Private Sub DeleteRecord_Click()
Unload Me
Form6.Show
End Sub
Private Sub DisplayRecord_Click()
Unload Me
Form9.Show
End Sub
Private Sub ExitFor_Click()
End
End Sub
Private Sub FINDRecord_Click()

Unload Me
Form9.Show
End Sub
Private Sub FARE_Click()
Unload Me
Form11.Show
End Sub
Private Sub fird_Click()
Unload Me
Form9.Show
End Sub
Private Sub ModifyRecord_Click()
Unload Me
Form4.Show
End Sub
Private Sub researvation1_Click()
Unload Me
Form10.Show
End Sub
Private Sub Timer1_Timer()
Image1.Left = Image1.Left + 400
If Image1.Left = Form2.Width Then
Image1.Left = 0
Else
Image1.Left = Image1.Left + 400
End If
End Sub
Private Sub reser_Click()
DataReport1.Show
End Sub
Private Sub sh_Click()
frmticshow.Show
End Sub
Private Sub trainre_Click()
DataReport2.Show
End Sub

Add record Form


Dim P As Boolean
Dim A As Integer
Dim B As Integer
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Command1_Click()
On Error GoTo bu
Call PASTE
rs.Update
Command8.Enabled = True
Command1.Enabled = False
Exit Sub
bu:
MsgBox Err.Description
End Sub
Private Sub Command3_Click()
Unload Me
Form2.Show
End Sub
Private Sub Command4_Click()
On Error Resume Next
rs.MoveFirst
Call COPY
End Sub
Private Sub Command5_Click()
On Error Resume Next
rs.MoveLast
Call COPY
End Sub
Private Sub Command6_Click()
If rs.BOF = False Then
rs.MovePrevious
Call COPY
End If
End Sub
Private Sub Command7_Click()
If rs.EOF = False Then

rs.MoveNext
Call COPY
End If
End Sub
Private Sub Command8_Click()
Command8.Enabled = False
Command1.Enabled = True
rs.AddNew
Call BLK
Text1.SetFocus
End Sub
Private Sub Form_Activate()
Command1.Enabled = False
rs.MoveFirst
Call COPY
End Sub
Private Sub Form_Load()
Set con = New ADODB.Connection
con.ConnectionString = "dsn=pro"
con.Open
Set rs = New ADODB.Recordset
rs.ActiveConnection = con
rs.CursorType = adOpenKeyset
rs.LockType = adLockPessimistic
rs.Source = "SELECT * FROM table1"
rs.Open
End Sub

Private Sub Label6_Click()


End Sub
Private Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer)
Form2.Show
Unload Me
End Sub

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.SetFocus
End If
End Sub
Private Sub Text11_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text12.SetFocus
End If
End Sub
Private Sub Text12_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text3.SetFocus
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text11.SetFocus
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text4.SetFocus
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text5.SetFocus
End If
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text8.SetFocus
End If

End Sub
Private Sub Text8_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1.SetFocus
End 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.Text
rs.Fields("TRAIN_NAME") = Text2.Text
rs.Fields("ARR_TIME") = Text3.Text
rs.Fields("DEP_TIME") = Text4.Text
rs.Fields("ACFSEAT") = txtACF.Text
rs.Fields("ACSSEAT") = txtACs.Text
rs.Fields("ChairCarSEAT") = TXTChair.Text
rs.Fields("Sleeper") = txtSleeper.Text
rs.Fields("STA_FROM") = Text11.Text
rs.Fields("STA_TO") = Text12.Text
End Sub
Public 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.Picture
Image1.Picture = Image2.Picture
Image2.Picture = Image3.Picture
End Sub
Private Sub Timer2_Timer()
Label7.ForeColor = QBColor(10 * Rnd)
End Sub

Modify Records
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim com As New ADODB.Command
Private Sub cmdDelete_Click()
com.ActiveConnection = con
com.CommandType = adCmdText
com.CommandText = "delete * from table1 where train_no ='" & Text1.Text & "'"
com.Execute
rs.MoveFirst
Call Display
End Sub
Private Sub cmdMain_Click()
Unload Me
Form2.Show
End Sub
Private Sub cmdMoveNext_Click()
On Error Resume Next
rs.MoveNext
Call Display
End Sub
Private Sub cmdMovePre_Click()
On Error Resume Next
rs.MovePrevious
Call Display
End Sub
Private Sub Command1_Click()
txtTrainNum.Enabled = True
txtTrainName.Enabled = True
txtStationFrom.Enabled = True
txtStationTo.Enabled = True
txtARRTime.Enabled = True
txtDEp.Enabled = True
txtACF.Enabled = True
txtACs.Enabled = True
TXTChair.Enabled = True
txtSleeper.Enabled = True
End Sub

Private Sub Command2_Click()


rs!train_no = txtTrainNum
rs!train_name = txtTrainName
rs!sta_from = txtStationFrom
rs!sta_to = txtStationTo
rs!arr_time = txtARRTime
rs!DEP_time = txtDEp
rs.Fields("ACFSEAT") = txtACF.Text
rs.Fields("ACSSEAT") = txtACs.Text
rs.Fields("ChairCarSEAT") = TXTChair.Text
rs.Fields("Sleeper") = txtSleeper.Text
rs.Update
txtTrainNum.Enabled = False
txtTrainName.Enabled = False
txtStationFrom.Enabled = False
txtStationTo.Enabled = False
txtARRTime.Enabled = False
txtDEp.Enabled = False
txtACF.Enabled = False
txtACs.Enabled = False
TXTChair.Enabled = False
txtSleeper.Enabled = False
End Sub
Private Sub Form_Load()
Set con = New ADODB.Connection
con.ConnectionString = "dsn=pro"
con.Open
Set rs = New ADODB.Recordset
rs.ActiveConnection = con
rs.CursorType = adOpenKeyset
rs.LockType = adLockPessimistic
rs.Source = "SELECT * FROM table1"
rs.Open
Call Display
End Sub
Private Sub Display()
txtTrainNum = rs!train_no
txtTrainName = rs!train_name
txtStationFrom = rs!sta_from
txtStationTo = rs!sta_to
txtARRTime = rs!arr_time
txtDEp = rs!DEP_time
txtACF.Text = rs.Fields("ACFSEAT")

txtACs.Text = rs.Fields("ACSSEAT")
TXTChair.Text = rs.Fields("ChairCarSEAT")
txtSleeper.Text = rs.Fields("Sleeper")
txtTrainNum.Enabled = False
txtTrainName.Enabled = False
txtStationFrom.Enabled = False
txtStationTo.Enabled = False
txtARRTime.Enabled = False
txtDEp.Enabled = False
txtACF.Enabled = False
txtACs.Enabled = False
TXTChair.Enabled = False
txtSleeper.Enabled = False
End Sub
Private Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer)
Form2.Show
Unload Me
End Sub

Delete Record
Dim A As Integer
Dim B As Integer
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Command1_Click()
If rs.EOF = False Then
rs.Delete
rs.MoveFirst
Call COPY
Else
MsgBox ("you are at last possition")
Exit Sub
End If
End Sub
Private Sub Command3_Click()
Unload Me
Form2.Show
End Sub
Private Sub Command4_Click()
On Error Resume Next
rs.MoveFirst
Call COPY
End Sub
Private Sub Command5_Click()
On Error Resume Next
rs.MoveLast
Call COPY
End Sub
Private Sub Command6_Click()
If rs.BOF = False Then
rs.MovePrevious
Call COPY
End If
End Sub
Private Sub Command7_Click()
If rs.EOF = False Then
rs.MoveNext
Call COPY
End If

End Sub
Private Sub Command8_Click()
Command8.Enabled = False
Command1.Enabled = True
rs.AddNew
Call BLK
End Sub
Private Sub Form_Activate()
rs.MoveFirst
Call COPY
End Sub
Private Sub Form_Load()
Set con = New ADODB.Connection
If con.State = 1 Then
con.Close
End If
con.ConnectionString = "dsn=pro"
con.Open
Set rs = New ADODB.Recordset
rs.ActiveConnection = con
rs.CursorType = adOpenKeyset
rs.LockType = adLockPessimistic
rs.Source = "SELECT * FROM table1"
rs.Open
End 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.Show
Unload Me
End Sub
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.SetFocus
End If
End Sub
Private Sub Text11_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text12.SetFocus
End If
End Sub
Private Sub Text12_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text3.SetFocus
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text11.SetFocus
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text4.SetFocus
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text5.SetFocus
End If
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text8.SetFocus
End If
End Sub

Private Sub Text8_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
Command1.SetFocus
End 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.Text
rs.Fields("TRAIN_NAME") = Text2.Text
rs.Fields("ARR_TIME") = Text3.Text
rs.Fields("DEP_TIME") = Text4.Text
rs.Fields("ACFSEAT") = txtACF.Text
rs.Fields("ACSSEAT") = txtACs.Text
rs.Fields("ChairCarSEAT") = TXTChair.Text
rs.Fields("Sleeper") = txtSleeper.Text
rs.Fields("STA_FROM") = Text11.Text
rs.Fields("STA_TO") = Text12.Text
End Sub
Public Sub BLK()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text11.Text = ""
Text12.Text = ""

txtACF.Text = ""
txtACs.Text = ""
TXTChair.Text = ""
txtSleeper.Text = ""
End Sub
Private Sub Timer1_Timer()
Image3.Picture = Image1.Picture
Image1.Picture = Image2.Picture
Image2.Picture = Image3.Picture
End Sub
Private Sub Timer2_Timer()
Label6.ForeColor = QBColor(10 * Rnd)
End Sub

Cancellation Form
Private Sub cmdCancel_Click()
On Error GoTo s
If txtticNum = "" Then
MsgBox "First Enter the Ticket Number"
Exit Sub
End If
Dim con As New ADODB.Connection
Dim comm As New ADODB.Command
con.Open ("Pro")
comm.ActiveConnection = con
comm.CommandText = "Delete *from pname where ticketno=" & txtticNum
comm.Execute
MsgBox "Reservation have been cancled successfully"
Exit Sub
s:
MsgBox "The ticket number not found"
End Sub
Private Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer)
Form2.Show
Unload Me
End Sub

Find Records
Dim A As Integer
Dim B As Integer
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Command1_Click()
Dim FLAG%, I%
ST = Val(InputBox("ENTER THE TRAIN NUMBER"))
FLAG = 0
rs.MoveFirst
While rs.EOF = False
If ST = rs.Fields("TRAIN_NO") Then
FLAG = 1
Call COPY
Exit Sub
End If
rs.MoveNext
Wend
If FLAG = 0 Then

MsgBox ("RECORD NOT FOUND"), vbCritical


End If
End Sub
Private Sub Command3_Click()
Unload Me
Form2.Show
End Sub
Private Sub Command4_Click()
On Error Resume Next
rs.MoveFirst
Call COPY
End Sub
Private Sub Command5_Click()
On Error Resume Next
rs.MoveLast
Call COPY
End Sub
Private Sub Command6_Click()
If rs.BOF = False Then
rs.MovePrevious
Call COPY
End If
End Sub
Private Sub Command7_Click()
If rs.EOF = False Then
rs.MoveNext
Call COPY
End If
End Sub
Private Sub Form_Activate()
rs.MoveFirst
Call COPY
Command1.SetFocus
End Sub
Private Sub Form_Load()
Set con = New ADODB.Connection
con.ConnectionString = "dsn=pro"
con.Open

Set rs = New ADODB.Recordset


rs.ActiveConnection = con
rs.CursorType = adOpenKeyset
rs.LockType = adLockPessimistic
rs.Source = "SELECT * FROM table1"
rs.Open
End Sub
Private Sub Form_QueryUnload(cancel As Integer, UnloadMode As Integer)
Form2.Show
Unload Me
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub
Private Sub Text11_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text12.SetFocus
End If
End Sub
Private Sub Text12_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text3.SetFocus
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text11.SetFocus
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text4.SetFocus
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then
Text5.SetFocus
End If
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text8.SetFocus
End If
End Sub
Private Sub Text8_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1.SetFocus
End 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.Text
rs.Fields("TRAIN_NAME") = Text2.Text
rs.Fields("ARR_TIME") = Text3.Text
rs.Fields("DEP_TIME") = Text4.Text
rs.Fields("ACFSEAT") = txtACF.Text
rs.Fields("ACSSEAT") = txtACs.Text
rs.Fields("ChairCarSEAT") = TXTChair.Text
rs.Fields("Sleeper") = txtSleeper.Text
rs.Fields("STA_FROM") = Text11.Text
rs.Fields("STA_TO") = Text12.Text

End Sub
Public 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.Picture
Image1.Picture = Image2.Picture
Image2.Picture = Image3.Picture
End Sub
Private Sub Timer2_Timer()
Label6.ForeColor = QBColor(10 * Rnd)
End Sub

Change Password Form


Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
If txtUser = "" Or txtPass = "" Or txtCoPass = "" Then
MsgBox "Please Type new uaername o Password and then try again"
Exit Sub
End If
If txtPass <> txtCoPass Then
MsgBox "The Passwords are not match . Please enter a right password"
Exit Sub
End If
If con.State = 1 Then
con.Close
End If
con.Open "pro"
rs.ActiveConnection = con
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
rs.Open "Login"
rs.MoveFirst
rs.Fields(0) = txtUser
rs.Fields(1) = txtCoPass
rs.Update
MsgBox "UserName and Password have been changed successfully"
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub

Login Form
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim F As Integer
Private Sub cmdCancel_Click()
End
End Sub
Private Sub CMDOK_CLICK()
Set rs = New ADODB.Recordset
rs.ActiveConnection = con
rs.CursorType = adOpenKeyset
rs.LockType = adLockPessimistic
rs.Source = "select * from login"
rs.Open
While 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.MoveNext
Wend
txtUserName.Text = ""
txtPassword.Text = ""
rs.Close
End Sub
Private Sub Form_Load()
Set con = New ADODB.Connection
con.ConnectionString = "dsn=Pro"
con.Open
End Sub

Ticket Information Form


Private Sub Command1_Click()
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "Select *from pname where ticketno=" & txttic
Adodc1.Refresh
End Sub

You might also like