📄 main_kfdj.frm
字号:
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
Left = 180
TabIndex = 28
Top = 3435
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 '定义一个整型变量
Dim Fdate As String, Ftime As String
Private Sub Combo3_Click()
'查询客房信息
Adodc1.RecordSource = "select * from tb_kf where 房间号='" & Combo3.text & "'and 房态 = '空房'"
Adodc1.Refresh
'查询住宿登记信息
Adodc2.RecordSource = "select * from tb_djb where 房间号='" & Combo3.text & "'and 标志='1'"
Adodc2.Refresh
If Adodc1.Recordset.RecordCount > 0 Then '如果存在空房
If Adodc2.Recordset.RecordCount = 0 Then '如果选择的房间没被登记
ZSDJ(4).text = Adodc1.Recordset.Fields("房间类型") '为“客房标准”文本框赋值
ZSDJ(5).text = Adodc1.Recordset.Fields("价格") '为“客房价格”文本框赋值
End If
End If
End Sub
Private Sub Form_Load()
Fdate = Format(Date, "YYYY-MM-DD")
Ftime = Format(Time, "HH:MM:SS")
'自动识别数据库路径
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from tb_kf "
Adodc1.Refresh
Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"
Adodc2.RecordSource = "select * from tb_djb"
Adodc2.Refresh
Adodc3.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"
Adodc3.RecordSource = "select * from tb_kf where 房态 = '空房'"
Adodc3.Refresh
If Adodc3.Recordset.RecordCount > 0 Then
For i = 1 To Adodc3.Recordset.RecordCount
Combo3.AddItem Adodc3.Recordset.Fields("房间号").Value
Adodc3.Recordset.MoveNext
Next i
End If
Combo3.Enabled = False
Comok.Enabled = False
End Sub
Private Sub Form_Activate()
'初始化日期及时间
DTP1.Value = Fdate: tim1.Value = Ftime
tim2.Value = #12:00:00 PM#: DTP2.Value = Fdate: DTP3.Value = Fdate
'DateTimePicker控件使您可以提供格式化的日期字段,使得进行日期选择很容易。另外,用户还可以从类似于MonthView控件的下拉式日历界面中选择日期。
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 = False '设置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") '计算折前宿费
'Format 函数返回 Variant (String),其中含有一个表达式,它是根据格式表达式中的指令来格式化的。
ZSDJ(9).text = ZSDJ(7).text '赋值给ZSDJ(9)
ZSDJ(8).text = 100
DTP3.Value = DTP1.Value + Val(ZSDJ(6).text) '计算退宿日期
'Val 函数返回包含于字符串内的数字,字符串中是一个适当类型的数值。
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)) '计算提醒日期
'Int函数返回参数的整数部分。
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 Combo3.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 Combo3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then ZSDJ(5).SetFocus 'ZSDJ(5)获得焦点
End Sub
Private Sub comdj_Click()
'查询空闲房间信息
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from tb_kf where 房态='空房'" '查询客房数据表
Adodc1.Refresh
Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"
Adodc2.RecordSource = "select * from tb_djb order by 凭证号码" '按凭证号码排序数据
Adodc2.Refresh
If Not Adodc2.Recordset.EOF Then Adodc2.Recordset.MoveLast '移动记录集到最后一条记录
If lsph.text = "" Then bh.text = Fdate & "d" & Format(1, "###000") '当lsph值为空为凭证号码文本框赋值
If lsph.text <> "" Then '当lsph值不空时
y1.text = Month(Fdate) '把当前月份赋给y1
y2.text = Month(Left(lsph.text, 10)) '把lsph中的月份赋给y2
If y1.text = y2.text Then '如果y1文本框中内容与y2相同
bh.text = Fdate & "d" & Format(Val(Right(lsph.text, 3)) + 1, "###000") '为凭证号码文本框赋值
Text1.text = Val(Right(lsph.text, 3)) + 1 'text1中存储lsph文本框中后三位数
End If
If y1.text <> y2.text Then '如果y1文本框中内容与y2不同
bh.text = Fdate & "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 = "": Combo3.text = ""
'设置控件有效或无效
Comok.Enabled = True: Comdj.Enabled = False: Comprint.Enabled = False: ZSDJ(8).Enabled = True
ZSDJ(10).Enabled = True: ZSDJ(11).Enabled = True: Combo3.Enabled = True: Combo1.Enabled = True
Combo2.Enabled = True: ZSDJ(0).SetFocus 'ZSDJ(0)获得焦点
Adodc3.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"
Adodc3.RecordSource = "select * from tb_kf where 房态 = '空房'"
Adodc3.Refresh
Combo3.Clear
If Adodc3.Recordset.RecordCount > 0 Then
For i = 1 To Adodc3.Recordset.RecordCount
Combo3.AddItem Adodc3.Recordset.Fields("房间号").Value
Adodc3.Recordset.MoveNext
Next i
End If
End Sub
Private Sub comok_Click()
If ZSDJ(0) = "" Or Combo3 = "" Then
MsgBox "请输入完整信息", , "系统提示"
Else
'查寻登记表中信息
Adodc2.RecordSource = "select * from tb_djb where 房间号 = '" & Combo3.text & "' and 标志 like '1'"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount = 0 Then
Adodc2.Recordset.AddNew
'将记录保存在tb_djb中
If bh.text <> "" Then Adodc2.Recordset.Fields("凭证号码") = bh.text
If ZSDJ(0).text <> "" Then Adodc2.Recordset.Fields("姓名") = ZSDJ(0).text
If Combo1.text <> "" Then Adodc2.Recordset.Fields("证件名称") = Combo1.text
If ZSDJ(1).text <> "" Then Adodc2.Recordset.Fields("证件号码") = ZSDJ(1).text
If ZSDJ(2).text <> "" Then Adodc2.Recordset.Fields("详细地址") = ZSDJ(2).text
If ZSDJ(3).text <> "" Then Adodc2.Recordset.Fields("住宿事由") = ZSDJ(3).text
If Combo3.text <> "" Then Adodc2.Recordset.Fields("房间号") = Val(Combo3.text)
If ZSDJ(4).text <> "" Then Adodc2.Recordset.Fields("客房类型") = ZSDJ(4).text
If DTP1.Value <> "" Then Adodc2.Recordset.Fields("住宿日期") = DTP1.Value
If tim1.Value <> "" Then Adodc2.Recordset.Fields("住宿时间") = tim1.Value
If ZSDJ(5).text <> "" Then Adodc2.Recordset.Fields("客房价格") = Val(ZSDJ(5).text)
If ZSDJ(6).text <> "" Then Adodc2.Recordset.Fields("住宿天数") = ZSDJ(6).text
If ZSDJ(8).text <> "" Then Adodc2.Recordset.Fields("折扣") = ZSDJ(8).text
If ZSDJ(7).text <> "" Then Adodc2.Recordset.Fields("宿费") = ZSDJ(7).text
If Combo2.text <> "" Then Adodc2.Recordset.Fields("结款方式") = Combo2.text
If ZSDJ(9).text <> "" Then Adodc2.Recordset.Fields("应收宿费") = ZSDJ(9).text
If ZSDJ(10).text <> "" Then Adodc2.Recordset.Fields("预收金额") = Val(ZSDJ(10).text)
If DTP2.Value <> "" Then Adodc2.Recordset.Fields("提醒日期") = DTP2.Value
If tim2.Value <> "" Then Adodc2.Recordset.Fields("提醒时间") = tim2.Value
If DTP3.Value <> "" Then Adodc2.Recordset.Fields("退宿日期") = DTP3.Value
If tim3.Value <> "" Then Adodc2.Recordset.Fields("退宿时间") = tim3.Value
If ZSDJ(11).text <> "" Then Adodc2.Recordset.Fields("备注") = ZSDJ(11).text
Adodc2.Recordset.Fields("日期") = Fdate '“日期”保存为当前系统日期
Adodc2.Recordset.Fields("时间") = Ftime '“时间”保存为当前系统时间
Adodc2.Recordset.Fields("BZ") = Left(Fdate, 4) & Right(Left(Fdate, 7), 2) & Right(Fdate, 2) & Left(Ftime, 2) & Left(Right(Ftime, 5), 2) '计算“BZ”的值
Adodc2.Recordset.Fields("标志") = "1" '“标志”设置为“1”
'更新记录
Adodc2.Recordset.Update
Adodc2.Refresh
'添加住宿预收信息
adocon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"
adoRs.Open "select * from tb_djys", adocon, adOpenKeyset, adLockOptimistic '打开tb_djys表
adoRs.AddNew
If bh.text <> "" Then adoRs.Fields("凭证号码") = bh.text
If ZSDJ(0).text <> "" Then adoRs.Fields("姓名") = ZSDJ(0).text
If Combo1.text <> "" Then adoRs.Fields("证件名称") = Combo1.text
If ZSDJ(1).text <> "" Then adoRs.Fields("证件号码") = ZSDJ(1).text
If ZSDJ(2).text <> "" Then adoRs.Fields("详细地址") = ZSDJ(2).text
If ZSDJ(3).text <> "" Then adoRs.Fields("住宿事由") = ZSDJ(3).text
If ZSDJ(4).text <> "" Then adoRs.Fields("客房类型") = ZSDJ(4).text
If Combo3.text <> "" Then adoRs.Fields("房间号") = Val(Combo3.text)
If ZSDJ(5).text <> "" Then adoRs.Fields("客房价格") = Val(ZSDJ(5).text)
If DTP1.Value <> "" Then adoRs.Fields("住宿日期") = DTP1.Value
If tim1.Value <> "" Then adoRs.Fields("住宿时间") = tim1.Value
If ZSDJ(6).text <> "" Then adoRs.Fields("住宿天数") = ZSDJ(6).text
If Combo2.text <> "" Then adoRs.Fields("结款方式") = Combo2.text
If ZSDJ(8).text <> "" Then adoRs.Fields("折扣") = ZSDJ(8).text
If ZSDJ(7).text <> "" Then adoRs.Fields("宿费") = ZSDJ(7).text
If ZSDJ(9).text <> "" Then adoRs.Fields("应收宿费") = ZSDJ(9).text
If ZSDJ(10).text <> "" Then adoRs.Fields("预收金额") = Val(ZSDJ(10).text)
If DTP2.Value <> "" Then adoRs.Fields("提醒日期") = DTP2.Value
If tim2.Value <> "" Then adoRs.Fields("提醒时间") = tim2.Value
If DTP3.Value <> "" Then adoRs.Fields("退宿日期") = DTP3.Value
If tim3.Value <> "" Then adoRs.Fields("退宿时间") = tim3.Value
If ZSDJ(11).text <> "" Then adoRs.Fields("备注") = ZSDJ(11).text
adoRs.Fields("日期") = Fdate
adoRs.Fields("时间") = Ftime
adoRs.Fields("BZ") = Left(Fdate, 4) & Right(Left(Fdate, 7), 2) & Right(Fdate, 2) & Left(Ftime, 2) & Left(Right(Ftime, 5), 2)
adoRs.Fields("标志") = "1"
'更新记录
adoRs.Update
'更新房间状态
adocon.Close
Adodc1.RecordSource = "select * from tb_kf where 房间号 like '" + Combo3.text + "'"
If Combo3.text <> "" Then Adodc1.Recordset.Fields("房态") = "入住"
Adodc1.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
Combo3.Enabled = False: Combo1.Enabled = False
End If
Comok.Enabled = False: Comprint.Enabled = True: Comdj.Enabled = True
Comprint.SetFocus
End If
End Sub
Private Sub comcancel_Click() '取消操作
For i = 0 To 11
ZSDJ(i).Enabled = False
Next i
Comprint.Enabled = False: Comok.Enabled = False: Combo3.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()
On Error GoTo 1 '出错转向标签“1”
Dim X As Printer
'打印住宿登记单据
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 d & " " & t & " NO." & bh.text '打印日期、时间和凭证号码
B = B + d '为变量B赋值
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 "房间号:" & Combo3.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 "补交日期: " & Format(DTP2.Value, "YYYY-MM-DD") '打印补交日期
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 '输出给打印机
Exit Sub
1 If Err.Number = 482 Then
MsgBox "请连接打印机!", , "系统提示"
Err.Clear
End If
End Sub
Private Sub comend_Click()
Unload Me
Main.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -