📄 房态图.frm
字号:
'数据库相连,连接字符串存放在LOCAT.DAT文件中.(当前存放为e:\hotel2\room.mdb)
'---------------------------------------------------------------
'将ACCESS中所有表导入SQL中,并将有的表中的ID字段改为自动编码,就可以使用.
'---------------------------------------------------------------------
'
'
Dim CuanWeiShu As Long
Dim ZhuKeRenShu As Long
Dim Room(5) As Long
Dim Q_Name As String
Private Sub Command1_Click()
On Error GoTo err13
Dim List_item As ListItem
If Me.Text2.Text <> "" Then
Adodc9.ConnectionString = My_PROVIDER
Adodc9.CommandType = adCmdText
Adodc9.RecordSource = "select * from 客房 where 楼号 like '" & Me.Text1.Text & "' and 层 like '" & Me.Text2.Text & "'"
Adodc9.Refresh
Else
Adodc9.ConnectionString = My_PROVIDER
Adodc9.CommandType = adCmdText
Adodc9.RecordSource = "select * from 客房 where 楼号 like '" & Me.Text1.Text & "'"
Adodc9.Refresh
End If
Me.ListView1.ListItems.Clear
While Not Adodc9.Recordset.EOF
Select Case Adodc9.Recordset.Fields("当前状态")
Case "空房"
ListView1.ListItems.Add , , Adodc9.Recordset.Fields("房号"), 1
Case "脏房"
ListView1.ListItems.Add , , Adodc9.Recordset.Fields("房号"), 2
Case "维修房"
ListView1.ListItems.Add , , Adodc9.Recordset.Fields("房号"), 3
Case "售出"
ListView1.ListItems.Add , , Adodc9.Recordset.Fields("房号"), 4
Case "预订"
ListView1.ListItems.Add , , Adodc9.Recordset.Fields("房号"), 5
Case Else
ListView1.ListItems.Add , , Adodc9.Recordset.Fields("房号"), 1
End Select
Adodc9.Recordset.MoveNext
Wend
Adodc9.Recordset.Close
Exit Sub
err13:
MsgBox "操作错误,错误代码1013", 48, "提示"
End Sub
Private Sub Command2_Click()
On Error GoTo err14
Dim List_item As ListItem
Dim i As Long
If Me.Option3 Then
Adodc9.ConnectionString = My_PROVIDER
Adodc9.CommandType = adCmdText
Adodc9.RecordSource = "select * from 客房 where 类型 like '" & Me.Combo1.Text & "'"
Adodc9.Refresh
Else
Adodc9.ConnectionString = My_PROVIDER
Adodc9.CommandType = adCmdText
Adodc9.RecordSource = "select * from 客房 where 当前状态 like '" & Me.Combo1.Text & "'"
Adodc9.Refresh
End If
Me.ListView1.ListItems.Clear
For i = 0 To 4
Room(i) = 0
Next
While Not Adodc9.Recordset.EOF
Select Case Adodc9.Recordset.Fields("当前状态")
Case "空房"
ListView1.ListItems.Add , , Adodc9.Recordset.Fields("房号"), 1
Room(0) = Room(0) + 1
Case "脏房"
ListView1.ListItems.Add , , Adodc9.Recordset.Fields("房号"), 2
Room(1) = Room(1) + 1
Case "维修房"
ListView1.ListItems.Add , , Adodc9.Recordset.Fields("房号"), 3
Room(2) = Room(2) + 1
Case "售出"
ListView1.ListItems.Add , , Adodc9.Recordset.Fields("房号"), 4
Room(3) = Room(3) + 1
Case "预订"
ListView1.ListItems.Add , , Adodc9.Recordset.Fields("房号"), 5
Room(4) = Room(4) + 1
Case Else
ListView1.ListItems.Add , , Adodc9.Recordset.Fields("房号"), 1
End Select
Adodc9.Recordset.MoveNext
Wend
Adodc9.Recordset.Close
Me.Label7.Caption = "空房:" & CStr(Room(0))
Me.Label8.Caption = "脏房:" & CStr(Room(1))
Me.Label9.Caption = "维修房:" & CStr(Room(2))
Me.Label10.Caption = "售出:" & CStr(Room(3))
Me.Label11.Caption = "预订:" & CStr(Room(4))
Me.Label12.Caption = "合计:" & CStr(Room(0) + Room(1) + Room(2) + Room(3) + Room(4))
Me.Label13.Caption = "出租率:" & (Round(Room(3) / (Room(0) + Room(1) + Room(2) + Room(3) + Room(4)), 2) * 100) & "%"
Exit Sub
err14:
MsgBox "操作错误,错误代码1014", 48, "提示"
End Sub
Private Sub Command3_Click()
RoomNO = ""
Room_Rate = 0
Room_Statu = ""
Unload Me
End Sub
Private Sub Command4_Click()
On Error GoTo E200204
If QAccount_ID = "" Then
MsgBox "请注意:没有登记帐号,请通过其他方式查询!", 48, "提示"
Else
Registration_Type = "显示"
住宿登录.Show
End If
Exit Sub
E200204:
MsgBox "请注意:可能重复打开窗口,请先关闭后再查询!", 64, "提示"
End Sub
Private Sub Command5_Click()
On Error GoTo err15
If Registration_Type <> "快速入住" Then
If Room_Statu = "空房" Then
If Load_Statu = "使用" Then
Room_Use_Type = "包房"
Room_Update = True
Adodc9.Recordset.Close
Unload Me
End If
Else
If Room_Statu = "预订" Then
If Account_ID = QAccount_ID Then
Room_Use_Type = "包房"
Room_Update = True
Adodc9.Recordset.Close
Unload Me
Else
MsgBox "请注意:" & RoomNO & "房间当前状态是:[" & Room_Statu & "],被[" & QAccount_ID & "]帐号" & Room_Share_Type & ",不能" & Registration_Type & "!", 48, "提示"
Room_Update = False
End If
Else
If Room_Statu = "售出" Then
Select Case Room_Share_Type
Case "共享"
MsgBox "请注意:" & RoomNO & "房间当前状态是:[" & Room_Statu & "],被[" & QAccount_ID & "]帐号" & Room_Share_Type & ",不能" & Registration_Type & "!", 48, "提示"
Case "包房"
MsgBox "请注意:" & RoomNO & "房间当前状态是:[" & Room_Statu & "],被[" & QAccount_ID & "]帐号" & Room_Share_Type & ",不能" & Registration_Type & "!", 48, "提示"
Case Else
MsgBox "房间状态错误,请核查!", 64, "提示"
End Select
Room_Update = False
End If
End If
End If
Else
'快速入住
If Room_Statu = "空房" Then
Room_Use_Type = "包房"
Q_Name = ""
Q_Name = InputBox("请输入客人姓名:", "快速入住", "")
If Q_Name <> "" Then
Adodc1.ConnectionString = My_PROVIDER
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from 参数"
Adodc1.Refresh
Adodc1.Recordset.Fields("帐号") = Adodc1.Recordset.Fields("帐号") + 1
Account_ID = Format(Adodc1.Recordset.Fields("帐号"), "000000")
Adodc1.Recordset.Update
Adodc1.Recordset.Close
Adodc1.ConnectionString = My_PROVIDER
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from 住宿情况 where 姓名 like '" & Q_Name & "' order by 帐号 desc"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
If MsgBox("系统记录有同名客人档案" & CStr(Adodc1.Recordset.RecordCount) & "人,是否直接调用?", 65, "提示") = vbOK Then
Set Me.DataGrid1.DataSource = Adodc1
DataGrid1.ReBind
DataGrid1.Refresh
Me.Picture3.Visible = True
End If
Else
Adodc9.ConnectionString = My_PROVIDER
Adodc9.CommandType = adCmdText
Adodc9.RecordSource = "select * from 客房 where 房号 like '" & RoomNO & "'"
Adodc9.Refresh
Adodc9.Recordset.Fields("当前状态") = "售出"
Adodc9.Recordset.Fields("出售方式") = "包房"
Adodc9.Recordset.Fields("帐号") = Account_ID
Adodc9.Recordset.Update
Adodc9.Recordset.Close
Adodc1.ConnectionString = My_PROVIDER
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from 住宿情况"
Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("帐号") = Account_ID
Adodc1.Recordset.Fields("姓名") = Q_Name
Adodc1.Recordset.Fields("房号") = RoomNO
Adodc1.Recordset.Fields("房价") = Room_Rate
Adodc1.Recordset.Fields("房类") = Room_Type
Adodc1.Recordset.Fields("操作员") = CzyName
Adodc1.Recordset.Fields("当前状态") = "入住"
Adodc1.Recordset.Fields("日期") = System_Date
Adodc1.Recordset.Fields("到店日期") = System_Date
Adodc1.Recordset.Fields("到店时间") = Left(Time, 5)
Adodc1.Recordset.Fields("时间") = Left(Time, 5)
Adodc1.Recordset.Update
Adodc1.Recordset.Close
Call ReLoadStatu
MsgBox "新客人 {" & Q_Name & "} 入住" & RoomNO & "房间成功!", 64, "提示"
End If
Else
MsgBox "没有客人姓名,不能入住!", 16, "提示"
End If
'不是空房
Else
If Room_Statu = "预订" Then
If Account_ID = QAccount_ID Then
Room_Use_Type = "包房"
Room_Update = True
Adodc9.Recordset.Close
Unload Me
Else
MsgBox "请注意:" & RoomNO & "房间当前状态是:[" & Room_Statu & "],被[" & QAccount_ID & "]帐号" & Room_Share_Type & ",不能" & Registration_Type & "!", 48, "提示"
Room_Update = False
End If
Else
If Room_Statu = "售出" Then
Select Case Room_Share_Type
Case "共享"
MsgBox "请注意:" & RoomNO & "房间当前状态是:[" & Room_Statu & "],被[" & QAccount_ID & "]帐号" & Room_Share_Type & ",不能" & Registration_Type & "!", 48, "提示"
Case "包房"
MsgBox "请注意:" & RoomNO & "房间当前状态是:[" & Room_Statu & "],被[" & QAccount_ID & "]帐号" & Room_Share_Type & ",不能" & Registration_Type & "!", 48, "提示"
Case Else
MsgBox "房间状态错误,请核查!", 64, "提示"
End Select
Room_Update = False
Else
MsgBox "请注意:" & RoomNO & "房间当前状态是:[" & Room_Statu & "],不能" & Registration_Type & "!", 48, "提示"
End If
End If
End If
End If
Exit Sub
err15:
MsgBox "操作错误,错误代码1015", 48, "提示"
End Sub
Private Sub Command6_Click()
On Error GoTo err16
Dim Q_Name As String
If Registration_Type <> "快速入住" Then
If Room_Statu = "空房" Then
If Load_Statu = "使用" Then
Room_Use_Type = "共享"
Room_Update = True
Adodc9.Recordset.Close
Unload Me
End If
Else
If Room_Statu = "预订" Then
If Account_ID = QAccount_ID Then
Room_Use_Type = "共享"
Room_Update = True
Adodc9.Recordset.Close
Unload Me
Else
MsgBox "请注意:1." & RoomNO & "房间当前状态是:[" & Room_Statu & "],被[" & QAccount_ID & "]帐号" & Room_Share_Type & ",不能" & Registration_Type & "!", 48, "提示"
Room_Update = False
End If
Else
If Room_Statu = "售出" Then
Select Case Room_Share_Type
Case "共享"
'MsgBox "请注意:2." & RoomNO & "房间当前状态是:[" & Room_Statu & "],被[" & QAccount_ID & "]帐号" & Room_Share_Type & ",不能" & Registration_Type & "!", 48, "提示"
Room_Use_Type = "共享"
Room_Update = True
Room_Rate = 0
'MsgBox RoomNO
Adodc9.Recordset.Close
Unload Me
Case "包房"
MsgBox "请注意:3." & RoomNO & "房间当前状态是:[" & Room_Statu & "],被[" & QAccount_ID & "]帐号" & Room_Share_Type & ",不能" & Registration_Type & "!", 48, "提示"
Room_Update = False
Case Else
MsgBox "房间状态错误,请核查!", 64, "提示"
Room_Update = False
End Select
End If
End If
End If
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -