📄 frmuseunreservedroom.frm
字号:
VERSION 5.00
Begin VB.Form frmUseUnReservedRoom
Caption = "顾客入住房间"
ClientHeight = 3360
ClientLeft = 60
ClientTop = 450
ClientWidth = 4935
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3360
ScaleWidth = 4935
StartUpPosition = 2 'CenterScreen
Begin VB.Frame Frame2
Height = 735
Left = 600
TabIndex = 5
Top = 2040
Width = 3735
Begin VB.CommandButton cmdCancel
Caption = "取消"
Height = 375
Left = 2160
TabIndex = 7
Top = 240
Width = 1215
End
Begin VB.CommandButton cmdOk
Caption = "确定"
Height = 375
Left = 360
TabIndex = 6
Top = 240
Width = 1215
End
End
Begin VB.Frame Frame1
Caption = "请输入顾客的基本信息"
Height = 1695
Left = 600
TabIndex = 0
Top = 360
Width = 3735
Begin VB.ComboBox cboRoomNo
Height = 315
Left = 2080
Style = 2 'Dropdown List
TabIndex = 4
Top = 1050
Width = 1225
End
Begin VB.TextBox txtCustName
Appearance = 0 'Flat
Height = 285
Left = 1440
TabIndex = 2
Top = 450
Width = 1865
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "顾客要入住的房间号:"
Height = 195
Left = 360
TabIndex = 3
Top = 1080
Width = 1665
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "顾 客 姓 名:"
Height = 195
Left = 360
TabIndex = 1
Top = 480
Width = 990
End
End
End
Attribute VB_Name = "frmUseUnReservedRoom"
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 rsPayOff As New ADODB.Recordset
Private rsRooms As New ADODB.Recordset
Private Sub cmdCancel_Click()
Unload frmUseUnReservedRoom '卸载窗体
End Sub
Private Sub cmdOK_Click()
If txtCustName.Text = "" Then '如果顾客姓名为空
MsgBox "顾客姓名不能为空!", vbInformation, "填写信息错误"
txtCustName.SetFocus
Exit Sub
End If
If cboRoomNo.Text = "" Then '如果房间号为空
MsgBox "请选择一个房间!", vbInformation, "填写信息错误"
cboRoomNo.SetFocus
Exit Sub
End If
cnnHotel.BeginTrans
rsPayOff.Open "SELECT 顾客姓名, 顾客预定房间号,顾客入住房间日期,顾客状态 FROM CustPayOff ", cnnHotel, adOpenKeyset, adLockOptimistic '打开新记录集
rsPayOff.AddNew '加入一条新记录
rsPayOff.Update "顾客姓名", txtCustName.Text
rsPayOff.Update "顾客预定房间号", cboRoomNo.Text
rsPayOff.Update "顾客入住房间日期", Year(Date) & "年" & Month(Date) & "月" & Day(Date) & "日"
rsPayOff.Update "顾客状态", "已经入住"
rsRooms.Open "SELECT * FROM Rooms WHERE 房间号='" & cboRoomNo.Text & "'", cnnHotel, adOpenKeyset, adLockOptimistic '打开新记录集
rsRooms.Update "房间入住日期", Year(Date) & "年" & Month(Date) & "月" & Day(Date) & "日" '房间入住日期为当前日期
rsRooms.Update "房间状态", "已经入住"
rsRooms.Update "顾客姓名", txtCustName.Text
rsRooms.Close '关闭记录集
cnnHotel.CommitTrans
MsgBox "顾客现在可以入住" & cboRoomNo.Text, vbInformation, "提示"
Unload frmUseUnReservedRoom '卸载窗体
End Sub
Private Sub Form_Load()
cnnHotel.Provider = "Microsoft.Jet.OLEDB.3.51"
cnnHotel.Open "User ID=admin;Data Source=" & GetDBPath() '建立与数据库的连接
rsRooms.Open "SELECT 房间号,房间状态 FROM Rooms WHERE 房间状态='空闲'", cnnHotel, adOpenKeyset, adLockOptimistic '打开新记录集
Do While Not rsRooms.BOF And Not rsRooms.EOF
cboRoomNo.AddItem rsRooms.Fields("房间号") '在cboRoomNo 的下拉列表选项中加如当前的已经被预定的房间号
rsRooms.MoveNext '移到下一条记录
Loop
rsRooms.Close '关闭记录集
End Sub
Private Sub Form_Unload(Cancel As Integer)
cnnHotel.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -