Anda di halaman 1dari 12

Dim l As Integer Private Sub Command1_Click() If Command1.

Caption = "Add" Then frm_room_reserve End If End Sub Private Sub fillfields() With rsroom txt_cust.Text = .Fields("Custno") txt_Fname.Text = .Fields("FirstName") txt_Mname.Text = .Fields("MiddleName") txt_Lname.Text = .Fields("LastName") cmbgender.Text = .Fields("Gender") txt_age.Text = .Fields("Age") txt_add.Text = .Fields("Address") txt_phone.Text = .Fields("Phoneno") txt_pin.Text = .Fields("Pin") cmbnational.Text = .Fields("Nationality") txt_country.Text = .Fields("Country") txt_city.Text = .Fields("City") lbl_type.Caption = .Fields("Roomtype") txt_Rno.Text = .Fields("Rno") End With End Sub Private Sub savedata() Dim qry As String With rsroom .AddNew .Fields("Custno") = txt_cust.Text .Fields("FirstName") = txt_Fname.Text .Fields("MiddleName") = txt_Mname.Text .Fields("LastName") = txt_Lname.Text .Fields("Gender") = cmbgender.Text .Fields("Age") = txt_age.Text ' .Fields("Address") = txt_add.Text .Fields("Phoneno") = txt_phone.Text .Fields("Pin") = txt_pin.Text .Fields("City") = txt_city.Text .Fields("Nationality") = cmbnational.TabIndex .Fields("Country") = txt_country.Text .Fields("Roomtype") = lbl_type.Caption .Fields("Rno") = txt_Rno.Text .Fields("Arrivaldate") = DTPicker2.Value .Fields("Time") = Text10.Text .Fields("Ddate") = DTPicker3.Value

.Update End With qry = "update roominformation set Reserved=true where roomno='" & txt_Rno.Text & "'" cmdresroom.ActiveConnection = con cmdresroom.CommandType = adCmdUnknown cmdresroom.CommandText = qry cmdresroom.Execute End Sub Private Sub Command2_Click() Unload Me 'Text1.SetFocus End Sub Private Sub Command3_Click() On Error GoTo ErrH: If List1.List(List1.ListIndex) = "" Then MsgBox "select some room first" End If txt_Rno = List1.List(List1.ListIndex) List1.RemoveItem List1.ListIndex Exit Sub ErrH: MsgBox "select some room first" End Sub Private Sub Command4_Click() Dim a As String a = MsgBox("Do u want to save", vbYesNo) If a = vbYes Then Call savedata MsgBox "Successfully saved", vbInformation + vbOKOnly, "Save info." rsroom.MoveLast l = Len(rsroom.Fields("Custno")) txt_cust.Text = "C" & Val(Right((rsroom!Custno), l - 1)) + 1 Command2.SetFocus ElseIf a = vbNo Then 'rsroom.Fields("Custno") = txt_cust.Text List1.AddItem txt_Rno frm_room_reserve

End If End Sub Private Sub Form_Load() Left = (Screen.Width - Width) / 2

Top = (Screen.Height - Height) / 2 Text10 = Time DTPicker2.Value = Date Set rsroom = New ADODB.Recordset Set rsgetrooms = New ADODB.Recordset rsgetrooms.Open "select Roomno,Type,Reserved from roominformation where Reserved=false", con, adOpenKeyset, adLockReadOnly Set cmdresroom = New ADODB.Command While rsgetrooms.EOF <> True List1.AddItem rsgetrooms.Fields("Roomno") rsgetrooms.MoveNext Wend DTPicker1.Value = Date Text1.Text = WeekdayName(Weekday(Date)) rsroom.Open " select * from roomreserve order by Custno ", con, adOpenKeyset, adLockPessimistic rsroom.MoveLast l = Len(rsroom.Fields("Custno")) txt_cust.Text = "C" & Val(Right((rsroom!Custno), l - 1)) + 1 End Sub Private Sub frm_room_reserve() txt_Fname.Text = "" txt_Mname.Text = "" txt_Lname.Text = "" cmbgender.Text = "" txt_age.Text = "" txt_city.Text = "" txt_add.Text = "" txt_phone.Text = "" txt_city.Text = "" cmbnational.Text = "" txt_country.Text = "" txt_Rno.Text = "" txt_pin.Text = "" End Sub Public Sub find(str As String) Set rstmp = New ADODB.Recordset rstmp.CursorType = adOpenKeyset rstmp.LockType = adLockOptimistic rstmp.Source = str rstmp.ActiveConnection = con rstmp.Open End Sub

Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single) End Sub Private Sub List1_Click() rsgetrooms.MoveFirst Do If (rsgetrooms.Fields(0) = List1.Text) Then 'rsgetrooms.find ("Roomno='" & List1.Text & " '") 'rsgetrooms.find ("Type ='" & List1.Text & " ' ") lbl_type.Caption = rsgetrooms.Fields(1) txt_Rno.Text = rsgetrooms.Fields(0) Exit Sub End If rsgetrooms.MoveNext Loop Until rsgetrooms.EOF End Sub Private Sub Timer2_Timer() Text10.Text = Time$ End Sub Private Sub txt_age_KeyPress(KeyAscii As Integer) If ((KeyAscii >= 49 And KeyAscii <= 57) Or (KeyAscii = 8)) Then Else MsgBox ("must be numeric data") KeyAscii = 0 txt_age.SetFocus End If End Sub Private Sub txt_age_LostFocus() If txt_age.Text = "" Then txt_age.SetFocus MsgBox ("cannot leave a field blank") End If End Sub

Private Sub txt_city_KeyPress(KeyAscii As Integer) If ((KeyAscii >= 97 And KeyAscii <= 122) Or (KeyAscii >= 65 And KeyAscii <= 90) Or (KeyAscii = 8)) Then Else KeyAscii = 0 MsgBox ("must be character type data") txt_city.SetFocus End If End Sub Private Sub txt_city_LostFocus()

If txt_city.Text = "" Then txt_city.SetFocus MsgBox ("cannot leave a field blank") End If End Sub

Private Sub txt_country_KeyPress(KeyAscii As Integer) If ((KeyAscii >= 97 And KeyAscii <= 122) Or (KeyAscii >= 65 And KeyAscii <= 90) Or (KeyAscii = 8)) Then Else KeyAscii = 0 MsgBox ("must be character type data") txt_country.SetFocus End If End Sub Private Sub txt_country_LostFocus() If txt_country.Text = "" Then txt_country.SetFocus MsgBox ("cannot leave a field blank") End If End Sub Private Sub txt_Fname_KeyPress(KeyAscii As Integer) If ((KeyAscii >= 97 And KeyAscii <= 122) Or (KeyAscii >= 65 And KeyAscii <= 90) Or (KeyAscii = 8)) Then Else KeyAscii = 0 MsgBox ("must be character type data") txt_Fname.SetFocus End If End Sub Private Sub txt_Fname_LostFocus() If txt_Fname.Text = "" Then txt_Fname.SetFocus MsgBox ("cannot leave a field blank") End If End Sub

Private Sub txt_Lname_KeyPress(KeyAscii As Integer) If ((KeyAscii >= 97 And KeyAscii <= 122) Or (KeyAscii >= 65 And KeyAscii <= 90) Or (KeyAscii = 8)) Then Else KeyAscii = 0 MsgBox ("must be character type data")

txt_Lname.SetFocus End If End Sub Private Sub txt_Lname_LostFocus() If txt_Lname.Text = "" Then txt_Lname.SetFocus MsgBox ("cannot leave a field blank") End If End Sub Private Sub txt_Mname_KeyPress(KeyAscii As Integer) If ((KeyAscii >= 97 And KeyAscii <= 122) Or (KeyAscii >= 65 And KeyAscii <= 90) Or (KeyAscii = 8)) Then Else KeyAscii = 0 MsgBox ("must be character type data") txt_Mname.SetFocus End If End Sub Private Sub txt_Mname_LostFocus() If txt_Mname.Text = "" Then txt_Mname.SetFocus MsgBox ("cannot leave a field blank") End If End Sub

Private Sub txt_phone_KeyPress(KeyAscii As Integer) If ((KeyAscii >= 49 And KeyAscii <= 57) Or (KeyAscii = 8)) Then Else MsgBox ("must be numeric data") KeyAscii = 0 txt_phone.SetFocus End If End Sub Private Sub txt_phone_LostFocus() If txt_phone.Text = "" Then txt_phone.SetFocus MsgBox ("cannot leave a field blank") End If End Sub

Private Sub txt_pin_KeyPress(KeyAscii As Integer) If ((KeyAscii >= 49 And KeyAscii <= 57) Or (KeyAscii = 8)) Then Else

MsgBox ("must be numeric data") KeyAscii = 0 txt_pin.SetFocus End If End Sub Private Sub txt_pin_LostFocus() If txt_pin.Text = "" Then txt_pin.SetFocus MsgBox ("cannot leave a field blank") End If End Sub

Table reservation
Private Sub Command1_Click() If Command1.Caption = "AddNew" Then Call frm_tablerese End If End Sub Private Sub fillfields() With rstreserve Text3.Text = .Fields("Fname") Text4.Text = .Fields("Mname") Text5.Text = .Fields("Lname") Text7.Text = .Fields("tableno") Text9.Text = .Fields("Timings") Text2.Text = .Fields("Cash") Text8.Text = .Fields("Time") Text6.Text = .Fields("Phoneno")

End With End Sub

Private Sub savedata() Dim qry As String

With rstreserve .AddNew .Fields("Date") = DTPicker1.Value .Fields("Fname") = Text3.Text .Fields("Mname") = Text4.Text .Fields("Lname") = Text5.Text .Fields("tableno") = Text7.Text '.Fields("Cash") = Text2.Text '.Fields("Time") = Text8.Text '.Fields("Ptime") = Text6.Text '.Fields("Timings") = Text10.Text '.Fields("Day") = Text1.Text .Update End With qry = "update tableinfo set Reserved=true where tno='" & Text7.Text & "'" cmdrestable.ActiveConnection = con cmdrestable.CommandType = adCmdUnknown cmdrestable.CommandText = qry cmdrestable.Execute End Sub Private Sub Command2_Click() Unload Me End Sub

Private Sub Command4_Click() Dim a As String a = MsgBox("Do u want to save", vbYesNo) If a = vbYes Then Call savedata MsgBox "Successfully saved", vbInformation + vbOKOnly, "Save info." ElseIf a = vbNo Then List1.AddItem Text7 frm_tablerese End If

End Sub Private Sub Form_Load() Left = (Screen.Width - Width) / 2 Top = (Screen.Height - Height) / 2 Set rstreserve = New ADODB.Recordset rstreserve.Open " tablereserve", con, adOpenKeyset, adLockPessimistic Set rsgettable = New ADODB.Recordset rsgettable.Open " select Tno,Reserved from tableinfo where Reserved=false", con, adOpenKeyset, adLockReadOnly Set cmdrestable = New ADODB.Command While rsgettable.EOF <> True List1.AddItem rsgettable.Fields("Tno") rsgettable.MoveNext Wend DTPicker1.Value = Date Text1.Text = WeekdayName(Weekday(Date)) End Sub Private Sub frm_tablerese() Text2.Text = "" Text3.Text = "" Text4.Text = ""

Text5.Text = "" Text7.Text = "" Text8.Text = "" Text6.Text = ""

End Sub

Private Sub Label4_Click() End Sub Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single) End Sub Private Sub List1_Click() On Error GoTo ErrH: If List1.List(List1.ListIndex) = "" Then MsgBox "select some room first" End If Text7.Text = List1.List(List1.ListIndex) List1.RemoveItem List1.ListIndex Exit Sub ErrH: MsgBox Err.Description End Sub Private Sub Option1_Click() If (Option1 = True) Then Label3.Enabled = False Label4.Enabled = False Text2.Enabled = False Text8.Enabled = False Option4 = False End If Label5.Enabled = True Text6.Enabled = True

End Sub

Private Sub Option4_Click() If (Option4 = True) Then Label5.Enabled = False Text6.Enabled = False Option1 = False Label3.Enabled = True Label4.Enabled = True Text2.Enabled = True Text8.Enabled = True End If End Sub Private Sub Text6_GotFocus() If Text2.Enabled = False Then Text2 = 0 End If End Sub Private Sub Timer1_Timer() Text10.Text = Time$ End Sub

Login
Public login As Boolean Private Sub cmd_log_cancel_Click() Unload Me End End Sub

Private Sub cmd_log_ok_Click() If txtUserName = "hotel" And txtLogPass = "aa" Then login = True Unload Me MDIForm1.Show MDIForm1.Enabled = True ElseIf txtUserName.Text = "" Then MsgBox "Enter the USERNAME and PASSWORD", , "login" ElseIf txtLogPass = "" Then MsgBox "Please enter the Password", , "login" Else MsgBox " Wrong Password,Try again!", , "login" txtUserName.Text = "" txtLogPass.Text = "" txtUserName.SetFocus 'SendKeys "{home}+{end}" End If End Sub Private Sub Form_Load() Left = (Screen.Width - Width) / 2 Top = (Screen.Height - Height) / 2 MDIForm1.Show MDIForm1.Enabled = False End Sub

Anda mungkin juga menyukai