📄 frmbegintouse.frm
字号:
VERSION 5.00
Begin VB.Form frmUseReservedRoom
Caption = "顾客入住房间"
ClientHeight = 3405
ClientLeft = 60
ClientTop = 450
ClientWidth = 5430
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3405
ScaleWidth = 5430
StartUpPosition = 2 'CenterScreen
Begin VB.Frame Frame3
Height = 2295
Left = 3960
TabIndex = 5
Top = 360
Width = 1095
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 375
Left = 120
TabIndex = 11
Top = 1680
Width = 855
End
Begin VB.CommandButton cmdOk
Caption = "确定"
Height = 375
Left = 120
TabIndex = 10
Top = 360
Width = 855
End
End
Begin VB.Frame Frame2
Caption = "顾客的基本信息"
Height = 1455
Left = 360
TabIndex = 2
Top = 1200
Width = 3495
Begin VB.Label labCustReserveDate
AutoSize = -1 'True
Height = 195
Left = 1320
TabIndex = 9
Top = 1080
Width = 45
End
Begin VB.Label labCustAddress
AutoSize = -1 'True
Height = 195
Left = 960
TabIndex = 8
Top = 720
Width = 45
End
Begin VB.Label labCustName
AutoSize = -1 'True
Height = 195
Left = 960
TabIndex = 7
Top = 360
Width = 45
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "顾客地址:"
Height = 195
Left = 120
TabIndex = 6
Top = 720
Width = 765
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "预定房间日期:"
Height = 195
Left = 120
TabIndex = 4
Top = 1080
Width = 1125
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "顾客姓名:"
Height = 195
Left = 120
TabIndex = 3
Top = 360
Width = 765
End
End
Begin VB.Frame Frame1
Caption = "Frame1"
Height = 735
Left = 360
TabIndex = 0
Top = 360
Width = 3495
Begin VB.ComboBox cboRoomNo
Height = 315
Left = 120
Style = 2 'Dropdown List
TabIndex = 1
Top = 240
Width = 2535
End
End
End
Attribute VB_Name = "frmUseReservedRoom"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private cnnHotel As New ADODB.Connection
Private rsCustReserveInfo As New ADODB.Recordset
Private rsPayOff As New ADODB.Recordset
Private rsRooms As New ADODB.Recordset
Private Sub cboRoomNo_Click()
Frame2.Caption = cboRoomNo.Text & "客户的基本信息" '改变Frame2的标题
rsCustReserveInfo.Open "SELECT * FROM CustReserveInfo WHERE 顾客预定房间号='" & cboRoomNo.Text & "'", cnnHotel, adOpenKeyset, adLockOptimistic '打开新记录集
Set labCustName.DataSource = rsCustReserveInfo
labCustName.DataField = "顾客姓名"
Set labCustAddress.DataSource = rsCustReserveInfo
labCustAddress.DataField = "顾客地址"
Set labCustReserveDate.DataSource = rsCustReserveInfo
labCustReserveDate.DataField = "顾客预定房间日期"
rsCustReserveInfo.Close '关闭记录集
End Sub
Private Sub cmdCancel_Click()
Unload frmUseReservedRoom
End Sub
Private Sub cmdOk_Click()
If cboRoomNo.Text = "" Then
MsgBox "请选择一个已经预定的房间", vbInformation, "错误"
Exit Sub
End If
rsRooms.Open "SELECT * FROM Rooms WHERE 房间号='" & cboRoomNo.Text & "'", cnnHotel, adOpenKeyset, adLockOptimistic '打开新记录集
rsCustReserveInfo.Open "SELECT * FROM CustReserveInfo WHERE 顾客预定房间号='" & cboRoomNo.Text & "'", cnnHotel, adOpenKeyset, adLockOptimistic '打开新记录集
rsPayOff.Open "SELECT * FROM CustPayOff ", cnnHotel, adOpenKeyset, adLockOptimistic '打开新记录集
cnnHotel.BeginTrans
rsRooms.Update "房间状态", "已经入住" '修改房间状态
rsRooms.Update "房间入住日期", Year(Date) & "年" & Month(Date) & "月" & Day(Date) & "日" '房间入住日期为当前日期
rsRooms.Update "顾客姓名", labCustName.Caption
rsPayOff.AddNew
rsPayOff.Update "顾客姓名", rsCustReserveInfo.Fields(0)
rsPayOff.Update "顾客地址", rsCustReserveInfo.Fields(1)
rsPayOff.Update "顾客电话号码", rsCustReserveInfo.Fields(2)
rsPayOff.Update "顾客信用卡号", rsCustReserveInfo.Fields(3)
rsPayOff.Update "顾客预定房间号", rsCustReserveInfo.Fields(4)
rsPayOff.Update "顾客预定房间日期", rsCustReserveInfo.Fields(5)
rsPayOff.Update "顾客预定房间所付定金", rsCustReserveInfo.Fields(6)
rsPayOff.Update "顾客入住房间日期", Year(Date) & "年" & Month(Date) & "月" & Day(Date) & "日"
rsPayOff.Update "顾客状态", "已经入住"
rsCustReserveInfo.Delete '顾客入住房间后则删除顾客预定信息
If rsCustReserveInfo.BOF Or rsCustReserveInfo.EOF Then '如果到达记录头或记录尾
rsCustReserveInfo.MoveLast '删除当前记录后移到最后一条记录
End If
cnnHotel.CommitTrans
MsgBox "顾客已经可以入住" & cboRoomNo.Text, vbInformation, "提示"
Unload frmUseReservedRoom
End Sub
Private Sub Form_Load()
cnnHotel.Provider = "Microsoft.Jet.OLEDB.3.51"
cnnHotel.Open "User ID=admin;Data Source=" & GetDBPath() '建立与数据库的连接
If CustClass = "Reserved" Then '如果顾客类型为已经预定房间的顾客
Frame1.Caption = "请选择顾客已经预定的房间号"
rsRooms.Open "SELECT 房间号,房间状态 FROM Rooms WHERE 房间状态='已预定'", cnnHotel, adOpenKeyset, adLockOptimistic '打开新记录集
Do While Not rsRooms.BOF And Not rsRooms.EOF '当rsRooms.BOF,rsRooms.EOF都为False 时
cboRoomNo.AddItem rsRooms.Fields("房间号") '在cboRoomNo 的下拉列表选项中加如当前的已经被预定的房间号
rsRooms.MoveNext '移到下一条记录
Loop
rsRooms.Close '关闭记录集
Else '如果顾客的类型为没有预定房间的顾客
MsgBox ""
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
cnnHotel.Close '关闭连接
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -