📄 main_tf.frm
字号:
'设置数据集对象DBrs1的Filter属性,以在djb中找到凭证号码为输入的凭证号码的记录
sqlstr = "凭证号码='" & Trim(Dcompzhm.Text) & "'"
DBrs1.Filter = sqlstr
'在no对应的文本框中显示该记录的凭证号码
bh.Text = "T" & Dcompzhm.Text
If DBrs1.RecordCount > 0 Then
'在“姓名”、“证件号码”和“证件名称”信息对应的文本框中
'显示该条住宿信息的相关字段值
If DBrs1.Fields("姓名") <> "" Then
Texxm.Text = DBrs1.Fields("姓名")
End If
If DBrs1.Fields("证件名称") <> "" Then
Combo1.Text = DBrs1.Fields("证件名称")
End If
If DBrs1.Fields("证件号码") <> "" Then
Texsfz.Text = DBrs1.Fields("证件号码")
End If
If DBrs1.Fields("详细地址") <> "" Then
Texdz.Text = DBrs1.Fields("详细地址")
End If
If DBrs1.Fields("房间号") <> "" Then
Dcomfjh.Text = DBrs1.Fields("房间号")
End If
If DBrs1.Fields("客房类型") <> "" Then
Dcomkflx.Text = DBrs1.Fields("客房类型")
End If
If DBrs1.Fields("客房价格") <> "" Then
Dcomkfjg.Text = DBrs1.Fields("客房价格")
End If
If DBrs1.Fields("住宿日期") <> "" Then
DTP1.Value = DBrs1.Fields("住宿日期")
End If
If DBrs1.Fields("住宿时间") <> "" Then
tim1.Value = DBrs1.Fields("住宿时间")
End If
If DBrs1.Fields("住宿天数") <> "" Then
Texts.Text = DBrs1.Fields("住宿天数")
End If
If DBrs1.Fields("预收金额") <> "" Then
Texyj.Text = DBrs1.Fields("预收金额")
Else
Texyj.Text = "0"
End If
If DBrs1.Fields("结款方式") <> "" Then
Combo2.Text = DBrs1.Fields("结款方式")
End If
If DBrs1.Fields("折扣") <> "" Then
Texzk.Text = DBrs1.Fields("折扣")
End If
'根据住宿日期和退宿日期值计算住宿天数
If DTP2.Value > DTP1.Value Then
If tim2.Value > #11:59:00 AM# Then
If tim2.Value > #6:00:00 PM# Then
Texts.Text = DTP2.Value - CDate(DTP1.Value) + 1
Else
Texts.Text = DTP2.Value - CDate(DTP1.Value) + 0.5
End If
Else
Texts.Text = DTP2.Value - CDate(DTP1.Value)
End If
Else
If tim1.Value < #6:00:00 PM# Then
If tim2.Value > #6:00:00 PM# Then Texts.Text = 1 Else Texts.Text = "0.5"
Else
Texts.Text = "0.5"
End If
End If
'在“宿费”对应的文本框中显示此次宿费
Texxf.Text = Val(Texts.Text) * Val(Dcomkfjg.Text)
'计算住宿费的折后金额
Texzhje.Text = Val(Texxf.Text) * Val(Texzk.Text) / 100
'计算退还金额
Texthje.Text = Val(Texyj.Text) - Val(Texzhje.Text) - Val(Texzf.Text) - Val(Texdhf.Text)
End If
End If
End Sub
Private Sub Dcompzhm_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Texzk.SetFocus '按回车键Texzk获得焦点
End Sub
Private Sub TIM2_Change()
Call JS '调用函数
End Sub
Private Sub DTP2_Change()
Call JS '调用函数
End Sub
Private Sub texxm_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Texsfz.SetFocus '按回车键Texsfz获得焦点
End Sub
Private Sub texzhje_Change()
Call ssje '调用函数
End Sub
Private Sub texzf_Change()
Call ssje '调用函数
End Sub
Private Sub texdhf_Change()
Call ssje '调用函数
End Sub
Private Sub texssje_Change()
Texxf.Text = Val(Texts.Text) * Val(Dcomkfjg.Text) '计算宿费
Call ssje '调用函数
End Sub
Private Sub texssje_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Texbz.SetFocus
End Sub
Private Sub texpcf_Change()
Call ssje '调用函数
End Sub
Private Sub texhyf_Change()
Call ssje '调用函数
End Sub
Private Sub texfjf_Change()
Texfjf.Text = Val(Texfjf.Text)
If Combo3.Text = "电话费" Then Texdhf.Text = Val(Texfjf.Text)
If Combo3.Text = "杂费" Then Texzf.Text = Val(Texfjf.Text)
If Combo3.Text = "会议费" Then Texhyf.Text = Val(Texfjf.Text)
If Combo3.Text = "停车费" Then Textcf.Text = Val(Texfjf.Text)
If Combo3.Text = "赔偿费" Then Texpcf.Text = Val(Texfjf.Text)
End Sub
Private Sub texfjf_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Texssje.SetFocus
End Sub
Private Sub textcf_Change()
Call ssje '调用函数
End Sub
Private Sub texts_Change()
Texxf.Text = Val(Texts.Text) * Val(Dcomkfjg.Text) '计算宿费
Texzhje.Text = Val(Texxf.Text) * Val(Texzk.Text) / 100 '计算折后金额
'计算退还金额
Texthje.Text = Val(Texyj.Text) - Val(Texzhje.Text) - Val(Texzf.Text) - Val(Texdhf.Text)
End Sub
Private Sub texts_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Texzk.SetFocus '回车Texzk获得焦点
End Sub
Private Sub texts_LostFocus()
Texts.Text = Format(Val(Texts.Text), "0.0") '格式化天数
End Sub
Private Sub texzk_Change()
Texzk.Text = Val(Texzk.Text)
Texzhje.Text = Val(Texxf.Text) * Val(Texzk.Text) / 100 '计算折后金额
'计算退还金额
Texthje.Text = Val(Texyj.Text) - Val(Texzhje.Text) - Val(Texzf.Text) - Val(Texdhf.Text)
End Sub
Private Sub texbz_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Comok.SetFocus
End Sub
Private Sub zj_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Texts.SetFocus
End Sub
Private Sub texsfz_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Texdz.SetFocus
End Sub
Private Sub texzk_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Texfjf.SetFocus
End Sub
Private Sub comdj_Click() '登记
Texxm.Text = "": Texsfz.Text = "": Texfjf.Text = "": Texdz.Text = "": Texts.Text = ""
Texzk.Text = "": Texyj.Text = "": Dcompzhm.Text = "": Texzhje.Text = "": Texthje.Text = ""
Texxf.Text = "": Dcomkflx.Text = "": Dcomkfjg.Text = "": Dcomfjh.Text = "": Texbz.Text = ""
Textcf.Text = "0": Texzf.Text = "0": Texdhf.Text = "0": Texssje.Text = "0": Texpcf.Text = "0"
Texhyf.Text = "0"
Comok.Enabled = True: Comcancel.Enabled = True: Comdj.Enabled = False
Comprint.Enabled = False: Dcompzhm.Enabled = True: Texzk.Enabled = True
Dcompzhm.SetFocus
End Sub
'保存输入的退宿信息
Private Sub comok_Click()
'判断用户输入或选择的结帐方式是否是“挂账”并且已经填写挂账单位,
'如果没有则给出错误提示,并退出该过程
If Combo2.Text = "挂帐" And Texgzdw.Text = "" Then
MsgBox ("挂帐单位为空,清填写挂帐单位!")
Exit Sub
End If
'判断输入的姓名和住宿费是否同时为空,如果同时为空,
'则弹出错误提示"请录入正确的数据"
If Texxm.Text <> "" And Texts.Text <> "" Then
'输入的姓名和住宿费不同时为空,定义用于返回退房表(tf)
'和住宿登记表(djb)中记录的的数据集对象DBrs6和DBrs7
Dim DBrs6 As New ADODB.Recordset
Dim DBrs7 As New ADODB.Recordset
'判断数据集对象DBrs6的状态,如果是打开状态,则先关闭,
'以防止出现重复打开数据集对象的错误
If DBrs6.State = 1 Then
DBrs6.Close
End If
'设置并执行sql语句以返回退房表(tf)中的所有记录
sqlstr = "select * from tfd"
DBrs6.Open sqlstr, DBcnn, adOpenDynamic, adLockBatchOptimistic
'判断数据集对象DBrs7的状态,如果是打开状态,则先关闭,
'以防止出现重复打开数据集对象的错误
If DBrs7.State = 1 Then
DBrs7.Close
End If
'设置并执行sql语句以返回住宿登记表(djb)中的所有记录
sqlstr = "select * from djb "
DBrs7.Open sqlstr, DBcnn, adOpenDynamic, adLockBatchOptimistic
'在退房表(tf)中添加一条退宿记录
DBrs6.AddNew
'设置新添加的退宿信息记录的各个字段的值
If bh.Text <> "" Then DBrs6.Fields("凭证号码") = bh.Text
If Texxm.Text <> "" Then DBrs6.Fields("姓名") = Texxm.Text
If Combo1.Text <> "" Then DBrs6.Fields("证件名称") = Combo1.Text
If Texsfz.Text <> "" Then DBrs6.Fields("证件号码") = Texsfz.Text
If Texdz.Text <> "" Then DBrs6.Fields("详细地址") = Texdz.Text
If Textcf.Text <> "" Then DBrs6.Fields("工作单位") = Textcf.Text
If Dcomfjh.Text <> "" Then DBrs6.Fields("房间号") = Dcomfjh.Text
If Dcomkflx.Text <> "" Then DBrs6.Fields("客房类型") = Dcomkflx.Text
If Dcomkfjg.Text <> "" Then DBrs6.Fields("客房价格") = Dcomkfjg.Text
If DTP1.Value <> "" Then DBrs6.Fields("住宿日期") = DTP1.Value
If tim1.Value <> "" Then DBrs6.Fields("住宿时间") = tim1.Value
If DTP2.Value <> "" Then DBrs6.Fields("退房日期") = DTP2.Value
If tim2.Value <> "" Then DBrs6.Fields("退房时间") = tim2.Value
If Texts.Text <> "" Then DBrs6.Fields("住宿天数") = Val(Texts.Text)
If Texzk.Text <> "" Then DBrs6.Fields("折扣") = Val(Texzk.Text)
If Combo2.Text <> "" Then DBrs6.Fields("折扣或招待") = Combo2.Text
If Texxf.Text <> "" Then DBrs6.Fields("宿费") = Format(Texxf.Text, "0.00")
If Texzhje.Text <> "" Then DBrs6.Fields("应收宿费") = Texzhje.Text
If Texyj.Text <> "" Then DBrs6.Fields("预收宿费") = Texyj.Text
If Texthje.Text <> "" Then DBrs6.Fields("退还宿费") = Texthje.Text
If Texzf.Text <> "" Then DBrs6.Fields("杂费") = Val(Texzf.Text) Else DBrs6.Fields("杂费") = "0"
If Texdhf.Text <> "" Then
DBrs6.Fields("电话费") = Val(Texdhf.Text)
Else
DBrs6.Fields("电话费") = "0"
End If
If Texhyf.Text <> "" Then
DBrs6.Fields("会议费") = Val(Texhyf.Text)
Else
DBrs6.Fields("会议费") = "0"
End If
If Texpcf.Text <> "" Then
DBrs6.Fields("赔偿费") = Val(Texpcf.Text)
Else
DBrs6.Fields("赔偿费") = "0"
End If
If Textcf.Text <> "" Then
DBrs6.Fields("存车费") = Val(Textcf.Text)
Else
DBrs6.Fields("存车费") = "0"
End If
If Texssje.Text <> "" Then DBrs6.Fields("金额总计") = Val(Texssje.Text)
If Texbz.Text <> "" Then DBrs6.Fields("备注") = Texbz.Text
DBrs6.Fields("日期") = Date
DBrs6.Fields("时间") = Time
DBrs6.Fields("BZ") = Left(Date, 4) & Right(Left(Format(Date, "yyyy-MM-dd"), 7), 2) & _
Right(Date, 2) & Left(Time, 2) & Left(Right(Time, 5), 2)
DBrs6.UpdateBatch
DBrs1.Fields("标志") = 0
DBrs1.UpdateBatch
sqlstr = "凭证号码 ='" & Dcompzhm.Text & "'"
DBrs4.Filter = sqlstr
DBrs4.Fields("标志") = 0
DBrs4.UpdateBatch adAffectCurrent
sqlstr = "房间号 ='" & Dcomfjh.Text & "'"
DBrs2.Filter = sqlstr
DBrs2.Fields("房态") = "空房"
'向数据库提交此次添加
DBrs2.UpdateBatch
'判断此次结帐的方式是否是“挂账”方式
If Combo2.Text = "挂帐" Then
'此次结帐的方式是“挂账”方式,设置并执行sql语句以返回
'挂账明细表(gzmx)中等于用户输入的挂账单位的记录
sqlstr = "挂账单位='" & Texgzdw.Text & "'"
DBrs3.Filter = sqlstr
If DBrs3.EOF = False Then DBrs3.MoveLast
'判断挂账明细表(gzmx)中是否有符合条件的记录,如果有,
'则在“金额累计”对应的文本框中,显示该单位的住宿金额累计
If DBrs3.RecordCount > 0 Then
If DBrs3.Fields("金额累计") <> "" Then gzje.Text = DBrs3.Fields("金额累计")
End If
'在挂账明细表(gzmx)中添加一条挂帐记录
DBrs3.AddNew
DBrs3.Fields("日期") = Date
DBrs3.Fields("时间") = Time
DBrs3.Fields("票号") = "T" & Dcompzhm.Text
DBrs3.Fields("日期") = Date
DBrs3.Fields("姓名") = Texxm.Text
DBrs3.Fields("证件号码") = Texsfz.Text
DBrs3.Fields("房间标准") = Dcomkflx.Text
DBrs3.Fields("房间价格") = Dcomkfjg.Text
DBrs3.Fields("时间") = Time
DBrs3.Fields("挂账单位") = Texgzdw.Text
DBrs3.Fields("住宿金额") = Texssje.Text
DBrs3.Fields("摘要") = "住宿日期:" & DTP1.Value & " 住宿天数: " & Texts.Text
DBrs3.Fields("欠款金额") = Val(Texssje.Text)
DBrs3.Fields("金额累计") = Val(Texssje.Text) + Val(gzje.Text)
'向数据库提交此次添加
DBrs3.UpdateBatch
End If
Else
MsgBox ("请录入正确的数据")
End If
'设置并执行sql语句,以重新设置客房(kf)表中的该客房的住宿状态
sqlstr = "房态='空房'"
DBrs2.Filter = sqlstr
DBrs5.Requery
Comprint.Enabled = True
Comok.Enabled = False
Comcancel.Enabled = False
Comdj.Enabled = True
Comprint.SetFocus
End Sub
Private Sub comcancel_Click() '取消操作
Texxm.Text = "": Texsfz.Text = "": Texfjf.Text = "": Texdz.Text = "": Texts.Text = ""
Texzk.Text = "": Texyj.Text = "": Dcompzhm.Text = "": Texzhje.Text = "": Texthje.Text = ""
Texxf.Text = "": Dcomkflx.Text = "": Dcomkfjg.Text = "": Dcomfjh.Text = "": Texbz.Text = ""
Textcf.Text = "0": Texzf.Text = "0": Texdhf.Text = "0": Texssje.Text = "0": Texpcf.Text = "0"
Texhyf.Text = "0"
Comdj.Enabled = True: Comcancel.Enabled = False: Comok.Enabled = False: Comprint.Enabled = False
End Sub
Private Sub comprint_Click() '打印退宿信息
Printer.Height = 7000: Printer.Width = 12000
Printer.CurrentX = 4000: Printer.CurrentY = 800
Printer.FontSize = 16
Printer.Print " 龙海宾馆退宿结账单 "
Dim A, B, C, D As Integer
A = 360: B = 1100: C = 3800: D = 350
Printer.FontSize = 10
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print Date & " " & Time & " NO." & bh.Text
B = B + D
Printer.Line (60 + A, B + 100)-(11000 + A, B + 100)
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "姓名:" & Texxm.Text
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "房间号:" & Dcomfjh.Text
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "房价:" & Format(Dcomkfjg.Text, "0.00") & "元" & " " & "入住天数: " & Texts.Text & "天 " & "宿费 " & Format(Texxf.Text, "0.00") & "元 " & Combo2.Text & ":" & Texzk.Text & "%"
If Texdhf.Text <> "0" Then
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "电话费:" & Format(Texdhf.Text, "0.00") & "元"
End If
If Texzf.Text <> "0" Then
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "杂费:" & Format(Texzf.Text, "0.00") & "元"
End If
If Texhyf.Text <> "0" Then
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "会议费:" & Format(Texhyf.Text, "0.00") & "元"
End If
If Textcf.Text <> "0" Then
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "停车费:" & Format(Textcf.Text, "0.00") & "元"
End If
If Texpcf.Text <> "0" Then
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "赔偿费:" & Format(Texpcf.Text, "0.00") & "元"
End If
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "实收金额:" & Format(Texssje.Text, "0.00") & "元 " & "押金: " & Format(Texyj.Text, "0.00") & "元 " & "退还金额: " & Format(Texthje.Text, "0.00") & "元"
B = B + D
Printer.CurrentX = 100 + A
Printer.CurrentY = B + 200
Printer.Print "备注:" & Texbz.Text
B = B + D
Printer.Line (60 + A, B + 100)-(11000 + A, B + 100)
Printer.CurrentX = 400
Printer.CurrentY = B + 200
Printer.Print "日期: "; Date & " " & Time
Printer.CurrentX = 3000 + A
Printer.CurrentY = B + 200
Printer.Print "操作员: " & czy.Text
Printer.CurrentX = 6000 + A
Printer.CurrentY = B + 200
Printer.Print "顾客签名: 签章: "
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 + -