📄 frmguestinfoedit.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form frmGuestInfoEdit
BorderStyle = 1 'Fixed Single
Caption = "Form1"
ClientHeight = 2460
ClientLeft = 45
ClientTop = 330
ClientWidth = 4860
KeyPreview = -1 'True
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
ScaleHeight = 164
ScaleMode = 3 'Pixel
ScaleWidth = 324
StartUpPosition = 1 '所有者中心
Begin VB.TextBox txtRoomNo
Height = 300
Left = 1245
TabIndex = 11
Text = "Text4"
Top = 1476
Width = 1800
End
Begin VB.CommandButton cmdOk
Caption = "确定(&O)"
Height = 375
Left = 3360
TabIndex = 10
TabStop = 0 'False
Top = 1320
Width = 1215
End
Begin VB.CommandButton cmdCancel
Caption = "取消(&C)"
Height = 375
Left = 3360
TabIndex = 9
TabStop = 0 'False
Top = 1830
Width = 1215
End
Begin MSComCtl2.DTPicker dtpBookDate
Height = 300
Left = 1245
TabIndex = 3
TabStop = 0 'False
Top = 1905
Width = 1800
_ExtentX = 3175
_ExtentY = 529
_Version = 393216
Format = 23068673
CurrentDate = 37917
End
Begin VB.TextBox txtCardID
Height = 300
Left = 1245
MaxLength = 18
TabIndex = 2
Text = "Text3"
Top = 1049
Width = 1800
End
Begin VB.TextBox txtGuestName
Height = 300
Left = 1245
TabIndex = 1
Text = "Text2"
Top = 622
Width = 1800
End
Begin VB.TextBox txtBookNo
Height = 300
Left = 1245
MaxLength = 8
TabIndex = 0
Text = "text1"
Top = 195
Width = 1800
End
Begin VB.Label Label11
AutoSize = -1 'True
Caption = "登记日期:"
Height = 180
Left = 345
TabIndex = 8
Top = 1965
Width = 900
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "房间号:"
Height = 180
Left = 525
TabIndex = 7
Top = 1560
Width = 720
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "身份证号码:"
Height = 180
Left = 165
TabIndex = 6
Top = 1095
Width = 1080
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "客人姓名:"
Height = 180
Left = 345
TabIndex = 5
Top = 645
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "登记号:"
Height = 180
Left = 525
TabIndex = 4
Top = 240
Width = 720
End
End
Attribute VB_Name = "frmGuestInfoEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim pRoomNo As String
Private Sub cmdCancel_Click()
'退出窗体
Unload Me
End Sub
Private Sub cmdOk_Click()
With frmMDI.adoGuest.Recordset
If Not txtBookNo.Locked Then '可修改状态表示是添加记录
If Trim(txtBookNo.Text) = "" Then
MsgBox "登记号不能为空!", vbOKOnly + vbInformation, "提示"
txtBookNo.SetFocus
Exit Sub
End If
.Find "BookNo='" & txtBookNo.Text & "'", , adSearchForward, 1
If Not .EOF Then '有就提示,然后退出
MsgBox "已经有相同登记号!", vbOKOnly + vbInformation, "提示"
txtBookNo.SetFocus
Exit Sub
End If
frmMDI.adoRoom.Recordset.Find "RoomNo='" & Trim(txtRoomNo.Text) & "'", , adSearchForward, 1
If Not frmMDI.adoRoom.Recordset.EOF Then '有就提示,然后退出
If frmMDI.adoRoom.Recordset!RoomStatus Then
MsgBox "已有客人居住!", vbOKOnly + vbInformation, "提示"
txtRoomNo.SetFocus
Exit Sub
End If
Else
MsgBox "没有此客房编号,请重新输入!", vbOKOnly + vbInformation, "提示"
txtRoomNo.SetFocus
Exit Sub
End If
If Trim(txtGuestName.Text) = "" Then
MsgBox "客人姓名不能为空!", vbOKOnly + vbInformation, "提示"
txtGuestName.SetFocus
Exit Sub
End If
.AddNew
!BookNo = Trim(txtBookNo.Text)
frmMDI.adoRoom.Recordset.Find "RoomNo='" & Trim(txtRoomNo.Text) & "'", , adSearchForward, 1
frmMDI.adoRoom.Recordset!RoomStatus = True
End If
'给字段赋值
!GuestName = txtGuestName.Text
!CardID = txtCardID.Text
If txtBookNo.Locked Then
If Trim(txtRoomNo.Text) <> pRoomNo Then
With frmMDI.adoRoom.Recordset
.Find "RoomNo='" & Trim(txtRoomNo.Text) & "'", , adSearchForward, 1
!RoomStatus = True
.Find "RoomNo='" & pRoomNo & "'", , adSearchForward, 1
!RoomStatus = False
End With
End If
End If
!RoomNo = Trim(txtRoomNo.Text)
!BookDate = dtpBookDate.Value
.Update
'退出窗体
Unload Me
End With
End Sub
Private Sub Form_Activate()
pRoomNo = Trim(txtRoomNo.Text)
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{TAB}"
End If
End Sub
Private Sub Form_Load()
Me.Left = (frmMDI.Width - Me.Width) / 2
Me.Top = (frmMDI.Height - Me.Height) / 4
End Sub
Private Sub txtBookNo_KeyPress(KeyAscii As Integer)
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub txtCardID_keypress(KeyAscii As Integer)
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
Private Sub txtRoomNo_KeyPress(KeyAscii As Integer)
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -