Option Explicit
Dim c As New Connection
Dim r As New Recordset
Dim sql As String
Private Sub cmdBill_Click()
frmbill.Show
frmbill.Label14.Caption = Date
frmbill.Label7.Caption = Form2.txtCno.Text
frmbill.Label8.Caption = Form2.txtCname.Text
frmbill.Label9.Caption = Form2.cmbRno.Text
frmbill.Label10.Caption = Form2.txtDt.Text
frmbill.Label11.Caption = Form2.txtDays.Text
frmbill.Label13.Caption = Form2.txtTotal.Text
End Sub
Private Sub cmdExit_Click()
c.Close
Unload Me
End Sub
Private Sub cmdRes_Click()
If cmdRes.Caption = "Reserve" Then
Dim d As Date
sql = "select * from Room "
r.Open sql, c, adOpenDynamic, adLockOptimistic
While Not r.EOF
If cmbRno.Text = r.Fields(2).Value Then
d = txtDt.Text
a = DateDiff("d", r.Fields(3).Value, d)
nd = r.Fields(4).Value
If a <= nd Then
flag = 1
End If
End If
r.MoveNext
Wend
If flag = 1 Then
MsgBox "Room already booked"
r.Close
Else
cmdRes.Caption = "Save"
End If
End If
If cmdRes.Caption = "Save" Then
r.Close
sql = "insert into Room values (" & txtCno.Text & ",' " & txtCname.Text & " '," & cmbRno.Text & ",' " & txtDt.Text & " '," & txtDays.Text & "," & txtTotal.Text & ")"
r.Open sql, c, 3, 3
If n > 0 Then MsgBox "Successfully Added"
txtCno.Text = " "
txtCname.Text = " "
cmbRno.Text = " "
txtDt.Text = " "
txtDays.Text = " "
txtTotal.Text = ""
txtCno.SetFocus
End If
End Sub
Private Sub Form_Load()
c.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\VB slip solution\slip 19\Ques-2\Hotel.mdb;Persist Security Info=False"
cmbRno.AddItem "101"
cmbRno.AddItem "102"
cmbRno.AddItem "103"
cmbRno.AddItem "104"
cmbRno.AddItem "105"
cmdRes.Caption = "Reserve"
End Sub
Private Sub txtDays_Change()
txtTotal.Text = Val(txtDays.Text) * 250
End Sub
Dim c As New Connection
Dim r As New Recordset
Dim sql As String
Dim n As Integer
Dim charge As Integer
Private Sub cmdDel_Click()
n = Val(InputBox("Enter Customer number"))
sql = "select * from Room where (cno=" & n & ")"
r.Open sql, c, adOpenDynamic, adLockOptimistic
charge = r.Fields(5).Value * 0.4
rno = r.Fields(2).Value
cdt = r.Fields(3).Value
r.Close
sql = "insert into Stock values (" & rno & ", '" & cdt & "'," & charge & ")"
r.Open sql, c, adOpenDynamic, adLockOptimistic
sql = "delete from Room where (cno=" & n & ")"
r.Open sql, c, adOpenDynamic, adLockOptimistic
grid.Clear
sql = "select * from Room"
r.Open sql, c, 3, 3
grid.Row = 1
grid.FormatString = "|cust no|cust name|Room no|Check in date|Days"
grid.ColWidth(1) = 1000
grid.ColWidth(2) = 1500
grid.ColWidth(3) = 1000
grid.ColWidth(4) = 2000
grid.ColWidth(5) = 1200
grid.ColWidth(6) = 1200
While r.EOF = False
grid.TextMatrix(grid.Row, 1) = r.Fields(0).Value
grid.TextMatrix(grid.Row, 2) = r.Fields(1).Value
grid.TextMatrix(grid.Row, 3) = r.Fields(2).Value
grid.TextMatrix(grid.Row, 4) = r.Fields(3).Value
grid.TextMatrix(grid.Row, 5) = r.Fields(4).Value
grid.TextMatrix(grid.Row, 6) = r.Fields(5).Value
grid.Row = grid.Row + 1
r.MoveNext
Wend
r.Close
End Sub
Private Sub Form_Load()
grid.Refresh
c.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\VB slip solution\slip 19\Ques-2\Hotel.mdb;Persist Security Info=False"
sql = "select * from Room"
r.Open sql, c, 3, 3
grid.Row = 1
grid.FormatString = "|cust no|cust name|Room no|Check in date|Days|Total Amount"
grid.ColWidth(1) = 1000
grid.ColWidth(2) = 1500
grid.ColWidth(3) = 1000
grid.ColWidth(4) = 2000
grid.ColWidth(5) = 1200
grid.ColWidth(6) = 1200
While r.EOF = False
grid.TextMatrix(grid.Row, 1) = r.Fields(0).Value
grid.TextMatrix(grid.Row, 2) = r.Fields(1).Value
grid.TextMatrix(grid.Row, 3) = r.Fields(2).Value
grid.TextMatrix(grid.Row, 4) = r.Fields(3).Value
grid.TextMatrix(grid.Row, 5) = r.Fields(4).Value
grid.TextMatrix(grid.Row, 6) = r.Fields(5).Value
grid.Row = grid.Row + 1
r.MoveNext
Wend
r.Close
End Sub
Recent Posts
Posted on 2019-07-18
Posted on 2019-07-18
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-07-17
Posted on 2019-05-28
Posted on 2019-05-24
Posted on 2019-05-24
Posted on 2019-05-23
Posted on 2019-05-23
Posted on 2019-05-23
Posted on 2019-05-23
Posted on 2019-05-23
Posted on 2019-05-23
Posted on 2019-05-23
Posted on 2019-05-23
Posted on 2019-05-23