📄 main_kfdj.frm
字号:
Left = 180
TabIndex = 30
Top = 3255
Width = 8295
End
End
Attribute VB_Name = "main_kfdj"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer '定义一个整型变量
Private Sub Form_Load()
'自动识别数据库路径
Data1.DatabaseName = App.Path & "\db.mdb"
Data2.DatabaseName = App.Path & "\db.mdb"
Data3.DatabaseName = App.Path & "\db.mdb"
End Sub
Private Sub Form_Activate()
'初始化日期及时间
DTP1.Value = Date: TIM1.Value = Time
TIM2.Value = #12:00:00 PM#: DTP2.Value = Date: DTP3.Value = Date
czy.Text = main.StatusBar1.Panels(4).Text '赋值给czy
Comdj.SetFocus 'Comdj获得焦点
End Sub
Private Sub Form_Unload(Cancel As Integer)
main.Enabled = True '设置主窗体有效
End Sub
Private Sub Combo2_Click()
If Combo2.Text = "折扣" Then
zsdj(8).Enabled = True '设置ZSDJ(8)有效
zsdj(8).SetFocus 'ZSDJ(8)获得焦点
End If
If Combo2.Text = "招待" Then
zsdj(8).Enabled = True '设置ZSDJ(8)有效
zsdj(8).Text = 0 '赋值给ZSDJ(8)
End If
End Sub
Private Sub ZSDJ_Change(Index As Integer)
Select Case Index
Case 6
zsdj(7).Text = Format(Val(zsdj(6).Text) * Val(zsdj(5).Text), "0.00") '计算折前宿费
zsdj(9).Text = zsdj(7).Text '赋值给ZSDJ(9)
zsdj(8).Text = 100
DTP3.Value = DTP1.Value + Val(zsdj(6).Text) '计算退宿日期
Case 8
zsdj(9).Text = Format(Val(zsdj(7).Text) * Val(zsdj(8).Text) / 100, "0.00") '计算实际宿费
Case 10
If zsdj(10).Text <> "" Then
zsdj(10).Text = Val(zsdj(10).Text) '用val函数将字符串转换为数字
DTP2.Value = DTP1.Value + Int(Val(zsdj(10).Text) / Val(zsdj(5).Text)) '计算提醒日期
If (Val(zsdj(10).Text) - Int(Val(zsdj(10).Text) / Val(zsdj(5).Text))) > 0.5 * Val(zsdj(5).Text) Then
TIM2.Value = #6:00:00 PM#
Else
TIM2.Value = #12:00:00 AM#
End If
End If
End Select
End Sub
Private Sub ZSDJ_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
Select Case Index
Case 0
If KeyCode = vbKeyReturn Then Combo1.SetFocus '按回车键Combo1获得焦点
Case 1
If KeyCode = vbKeyReturn Then zsdj(2).SetFocus '按回车键ZSDJ(2)获得焦点
Case 2
If KeyCode = vbKeyReturn Then zsdj(3).SetFocus '按回车键ZSDJ(3)获得焦点
Case 3
If KeyCode = vbKeyReturn Then DBCombo1.SetFocus '按回车键ZSDJ(2)获得焦点
Case 4
If KeyCode = vbKeyReturn Then zsdj(5).SetFocus '按回车键ZSDJ(5)获得焦点
Case 5
If KeyCode = vbKeyReturn Then zsdj(6).SetFocus '按回车键ZSDJ(6)获得焦点
Case 6
If KeyCode = vbKeyReturn Then zsdj(10).SetFocus
Case 8
If KeyCode = vbKeyReturn Then zsdj(10).SetFocus '按回车键ZSDJ(10)获得焦点
Case 10
If KeyCode = vbKeyReturn Then zsdj(11).SetFocus 'ZSDJ(11)获得焦点
Case 11
If KeyCode = vbKeyReturn Then Comok.SetFocus '按回车键Comok获得焦点
End Select
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then zsdj(1).SetFocus '按回车键ZSDJ(1)获得焦点
End Sub
Private Sub DTP2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then tim3.SetFocus '按回车键tim3获得焦点
End Sub
Private Sub DTP3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then tim4.SetFocus '按回车键tim4获得焦点
End Sub
Private Sub tim3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then DTP3.SetFocus '按回车键DTP3获得焦点
End Sub
Private Sub tim4_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text10.SetFocus '按回车键Text10获得焦点
End Sub
Private Sub DBCombo1_Change()
'查询空闲房间信息
Data2.RecordSource = "select * from kf where 房间号='" & DBCombo1.Text & "'and 房态='空房'"
Data2.Refresh
'查询住宿登记信息
Data1.RecordSource = "select * from djb where 房间号='" & DBCombo1.Text & "'and 标志='1'"
Data1.Refresh
If Data2.Recordset.RecordCount > 0 Then
If Data1.Recordset.RecordCount = 0 Then
zsdj(4).Text = Data2.Recordset.Fields("房间类型") '赋值给ZSDJ(4)
zsdj(5).Text = Data2.Recordset.Fields("价格") '赋值给ZSDJ(5)
Else
MsgBox ("此房间已占用或停止使用!!")
End If
End If
End Sub
Private Sub DBCombo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then zsdj(5).SetFocus 'ZSDJ(5)获得焦点
End Sub
Private Sub comdj_Click()
'查询空闲房间信息
Data2.RecordSource = "select * from kf where 房态='空房'"
Data2.Refresh
Data3.RecordSource = "select * from kf where 房态='空房'"
Data3.Refresh
'生成凭证号码
Data1.RecordSource = "select * from djb order by 凭证号码"
Data1.Refresh
If Not Data1.Recordset.EOF Then Data1.Recordset.MoveLast
If lsph.Text = "" Then bh.Text = Date & "d" & Format(1, "###000")
If lsph.Text <> "" Then
Y1.Text = Month(Date)
'y2.Text = Month(Left(lsph.Text, 10))
If Y1.Text = Y2.Text Then
bh.Text = Date & "d" & Format(Val(Right(lsph.Text, 3)) + 1, "###000")
End If
If Y1.Text <> Y2.Text Then
bh.Text = Date & "d" & Format(1, "###000")
End If
End If
'清空数据
For i = 0 To 6
zsdj(i).Text = ""
zsdj(i).Enabled = True
Next i
zsdj(8).Text = "": zsdj(10).Text = "": zsdj(11).Text = "": DBCombo1.Text = "": DBCombo1.Text = ""
'设置控件有效或无效
Comok.Enabled = True: Comdj.Enabled = False: Comprint.Enabled = False: zsdj(8).Enabled = True
zsdj(10).Enabled = True: zsdj(11).Enabled = True: DBCombo1.Enabled = True: Combo1.Enabled = True
Combo2.Enabled = True: zsdj(0).SetFocus 'ZSDJ(0)获得焦点
End Sub
Private Sub comok_Click()
Dim mydb1 As Database
Dim myrs1 As Recordset
Set mydb1 = Workspaces(0).OpenDatabase(App.Path & "\db.mdb")
Set myrs1 = mydb1.OpenRecordset("djys", dbOpenTable)
Data1.Recordset.FindFirst "房间号 like" + Chr(34) + DBCombo1.Text + Chr(34) + "and 标志 like" + Chr(34) + "1" + Chr(34) + ""
If Data1.Recordset.NoMatch Then
'添加住宿信息
Data1.Recordset.AddNew
If bh.Text <> "" Then Data1.Recordset.Fields("凭证号码") = bh.Text
If zsdj(0).Text <> "" Then Data1.Recordset.Fields("姓名") = zsdj(0).Text
If Combo1.Text <> "" Then Data1.Recordset.Fields("证件名称") = Combo1.Text
If zsdj(1).Text <> "" Then Data1.Recordset.Fields("证件号码") = zsdj(1).Text
If zsdj(2).Text <> "" Then Data1.Recordset.Fields("详细地址") = zsdj(2).Text
If zsdj(3).Text <> "" Then Data1.Recordset.Fields("出差事由") = zsdj(3).Text
If DBCombo1.Text <> "" Then Data1.Recordset.Fields("房间号") = Val(DBCombo1.Text)
If zsdj(4).Text <> "" Then Data1.Recordset.Fields("客房类型") = zsdj(4).Text
If DTP1.Value <> "" Then Data1.Recordset.Fields("住宿日期") = DTP1.Value
If TIM1.Value <> "" Then Data1.Recordset.Fields("住宿时间") = TIM1.Value
If zsdj(5).Text <> "" Then Data1.Recordset.Fields("客房价格") = Val(zsdj(5).Text)
If zsdj(6).Text <> "" Then Data1.Recordset.Fields("住宿天数") = zsdj(6).Text
If zsdj(8).Text <> "" Then Data1.Recordset.Fields("折扣") = zsdj(8).Text
If zsdj(7).Text <> "" Then Data1.Recordset.Fields("宿费") = zsdj(7).Text
If Combo2.Text <> "" Then Data1.Recordset.Fields("结款方式") = Combo2.Text
If zsdj(9).Text <> "" Then Data1.Recordset.Fields("应收宿费") = zsdj(9).Text
If zsdj(10).Text <> "" Then Data1.Recordset.Fields("预收金额") = Val(zsdj(10).Text)
If DTP2.Value <> "" Then Data1.Recordset.Fields("提醒日期") = DTP2.Value
If TIM2.Value <> "" Then Data1.Recordset.Fields("提醒时间") = TIM2.Value
If DTP3.Value <> "" Then Data1.Recordset.Fields("退宿日期") = DTP3.Value
If tim3.Value <> "" Then Data1.Recordset.Fields("退宿时间") = tim3.Value
If zsdj(11).Text <> "" Then Data1.Recordset.Fields("备注") = zsdj(11).Text
Data1.Recordset.Fields("日期") = Date
Data1.Recordset.Fields("时间") = Time
'Data1.Recordset.Fields("BZ") = Left(Date, 4) & Right(Left(Date, 7), 2) & Right(Date, 2) & Left(Time, 2) & Left(Right(Time, 5), 2)
Data1.Recordset.Fields("标志") = "1"
'更新记录
Data1.Recordset.Update
'添加住宿预收信息
myrs1.AddNew
If bh.Text <> "" Then myrs1.Fields("凭证号码") = bh.Text
If zsdj(0).Text <> "" Then myrs1.Fields("姓名") = zsdj(0).Text
If Combo1.Text <> "" Then myrs1.Fields("证件名称") = Combo1.Text
If zsdj(1).Text <> "" Then myrs1.Fields("证件号码") = zsdj(1).Text
If zsdj(2).Text <> "" Then myrs1.Fields("详细地址") = zsdj(2).Text
If zsdj(3).Text <> "" Then myrs1.Fields("出差事由") = zsdj(3).Text
If DBCombo1.Text <> "" Then myrs1.Fields("房间号") = Val(DBCombo1.Text)
If zsdj(5).Text <> "" Then myrs1.Fields("客房价格") = Val(zsdj(5).Text)
If DTP1.Value <> "" Then myrs1.Fields("住宿日期") = DTP1.Value
If TIM1.Value <> "" Then myrs1.Fields("住宿时间") = TIM1.Value
If zsdj(6).Text <> "" Then myrs1.Fields("住宿天数") = zsdj(6).Text
If Combo2.Text <> "" Then myrs1.Fields("结款方式") = Combo2.Text
If zsdj(8).Text <> "" Then myrs1.Fields("折扣") = zsdj(8).Text
If zsdj(7).Text <> "" Then myrs1.Fields("宿费") = zsdj(7).Text
If zsdj(9).Text <> "" Then myrs1.Fields("应收宿费") = zsdj(9).Text
If zsdj(10).Text <> "" Then myrs1.Fields("预收金额") = Val(zsdj(10).Text)
If DTP2.Value <> "" Then myrs1.Fields("提醒日期") = DTP2.Value
If TIM2.Value <> "" Then myrs1.Fields("提醒时间") = TIM2.Value
If DTP3.Value <> "" Then myrs1.Fields("退宿日期") = DTP3.Value
If tim3.Value <> "" Then myrs1.Fields("退宿时间") = tim3.Value
If zsdj(11).Text <> "" Then myrs1.Fields("备注") = zsdj(11).Text
myrs1.Fields("日期") = Date
myrs1.Fields("时间") = Time
' myrs1.Fields("BZ") = Left(Date, 4) & Right(Left(Date, 7), 2) & Right(Date, 2) & Left(Time, 2) & Left(Right(Time, 5), 2)
myrs1.Fields("标志") = "1"
'更新记录
myrs1.Update
'更新房间状态
Data2.Recordset.FindFirst "房间号 like " + Chr(34) + DBCombo1.Text + Chr(34) + ""
Data2.Recordset.Edit
Data2.Recordset.Fields("房态") = "入住"
Data2.Recordset.Update
'设置控件有效或无效
For i = 0 To 6
zsdj(i).Enabled = False
Next i
zsdj(8).Enabled = False: zsdj(10).Enabled = False: zsdj(11).Enabled = False
DBCombo1.Enabled = False: Combo1.Enabled = False
End If
Comok.Enabled = False: Comprint.Enabled = True: Comdj.Enabled = True
Comprint.SetFocus
End Sub
Private Sub comcancel_Click() '取消操作
For i = 0 To 11
zsdj(i).Enabled = False
Next i
Comprint.Enabled = False: Comok.Enabled = False: DBCombo1.Enabled = False
Combo1.Enabled = False: Combo2.Enabled = False: DTP2.Enabled = False: DTP3.Enabled = False
TIM2.Enabled = False: tim3.Enabled = False: Comdj.Enabled = True
End Sub
Private Sub comprint_Click() '打印住宿登记单据
Printer.Height = 8000: Printer.Width = 8000
Printer.CurrentX = 1100: Printer.CurrentY = 300
Printer.FontSize = 12
Printer.Print "龙海宾馆 (住宿证) "
Dim A, B, C, D As Integer
A = 100: B = 500: C = 4800: D = 400
Printer.FontSize = 10
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print Date & " " & Time & " NO." & bh.Text
B = B + D
Printer.Line (A, B + 100)-(C, B + 100)
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "姓名:" & zsdj(0).Text
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "房间号:" & DBCombo1.Text
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "押金:" & Format(zsdj(10).Text, "0.00")
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print Combo2.Text & ":" & zsdj(8).Text & "%"
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "补交日期: " & DTP2.Value
B = B + D
Printer.Line (A, B + 100)-(C, B + 100)
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "操作员: " & czy.Text & " 欢迎光临"
Printer.EndDoc
End Sub
Private Sub comend_Click()
Unload Me
main.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -