⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main_tf.frm

📁 visual basic 酒店管理系统
💻 FRM
📖 第 1 页 / 共 3 页
字号:
     End If
   Else
     Texts.Text = DTP2.Value - DTP1.Value
   End If
 Else
 If tim1.Value < #2:00:00 AM# Then
   If tim2.Value > #2:00:00 AM# Then
     If tim2.Value > #12:00:00 PM# Then
       If tim2.Value > #6:00:00 PM# Then
         Texts.Text = 1 + 1
       Else
         Texts.Text = 1 + 0.5
       End If
     Else
       Texts.Text = 1
     End If
   Else
     Texts.Text = 1
   End If
  Else
   Texts.Text = 1
  End If
 End If
End Sub
Public Sub ssje()     '定义计算实收金额和退还金额的函数
 Texssje.Text = Val(Texzhje.Text) + Val(Texzf.Text) + Val(Texdhf.Text) + Val(Texpcf.Text) + Val(Texhyf.Text) + Val(Textcf.Text)
 Texthje.Text = Val(Texyj.Text) - Val(Texssje.Text)
End Sub
Private Sub Form_Load()
'自动识别数据库路径
 Data1.DatabaseName = App.Path & "\KFGL.MDB"
 Data2.DatabaseName = App.Path & "\KFGL.MDB"
 Data3.DatabaseName = App.Path & "\KFGL.MDB"
 Data4.DatabaseName = App.Path & "\KFGL.MDB"
 Data5.DatabaseName = App.Path & "\KFGL.MDB"
End Sub
Private Sub Form_Activate()
 czy.Text = main.StatusBar1.Panels(4).Text     '赋值给czy
 DTP2.Value = Date: tim2.Value = Time
'查询住宿登记信息
 Data5.RecordSource = "select 凭证号码 from djb where 标志='1'order by 凭证号码"
 Data5.Refresh
End Sub
Private Sub Form_Unload(Cancel As Integer)
 main.Enabled = True     '设置主窗体有效
End Sub
Private Sub DBCombo1_KeyDown(KeyCode As Integer, Shift As Integer)
 If KeyCode = vbKeyReturn Then DBCombo2.SetFocus      '按回车键DBCombo2获得焦点
End Sub
Private Sub DBCOMBO2_KeyDown(KeyCode As Integer, Shift As Integer)
 If KeyCode = vbKeyReturn Then DTP1.SetFocus     '按回车键DTP1获得焦点
End Sub
Private Sub Combo2_Click()
If Combo2.Text = "折扣" Then
  Texzk.Text = 100     '赋值给Texzk.text
 Else
  Texzk.Text = 0
End If
If Combo2.Text = "挂帐" Then
  Lab10.Visible = True
  Texgzdw.Visible = True
  Texgzdw.Text = Texxm.Text     '赋值给Texxm.text
Else
  Lab10.Visible = False
  Texgzdw.Visible = False     '设置Texgzdw不可见
  Texgzdw.Text = ""
End If
End Sub
Private Sub Combo3_Click()
 Texfjf.SetFocus     'Texfjf获得焦点
 Texfjf.Text = "0"     '赋值给Texfjf.text
End Sub
Private Sub DBCombo4_Change()
 If DBCombo4.Text <> "" Then
 '查询住宿登记信息
  Data1.RecordSource = "select * from djb where 凭证号码='" + DBCombo4.Text + "'"
  Data1.Refresh
  bh.Text = "T" & DBCombo4.Text
  '赋值给texxm.text等
  If Data1.Recordset.RecordCount > 0 Then
  If Data1.Recordset.Fields("姓名") <> "" Then Texxm.Text = Data1.Recordset.Fields("姓名")
  If Data1.Recordset.Fields("证件名称") <> "" Then Combo1.Text = Data1.Recordset.Fields("证件名称")
  If Data1.Recordset.Fields("证件号码") <> "" Then Texsfz.Text = Data1.Recordset.Fields("证件号码")
  If Data1.Recordset.Fields("详细地址") <> "" Then Texdz.Text = Data1.Recordset.Fields("详细地址")
  If Data1.Recordset.Fields("房间号") <> "" Then DBCombo3.Text = Data1.Recordset.Fields("房间号")
  If Data1.Recordset.Fields("客房类型") <> "" Then DBCombo1.Text = Data1.Recordset.Fields("客房类型")
  If Data1.Recordset.Fields("客房价格") <> "" Then DBCombo2.Text = Data1.Recordset.Fields("客房价格")
  If Data1.Recordset.Fields("住宿日期") <> "" Then DTP1.Value = Data1.Recordset.Fields("住宿日期")
  If Data1.Recordset.Fields("住宿时间") <> "" Then tim1.Value = Data1.Recordset.Fields("住宿时间")
  If Data1.Recordset.Fields("住宿天数") <> "" Then Texts.Text = Data1.Recordset.Fields("住宿天数")
  If Data1.Recordset.Fields("预收金额") <> "" Then Texyj.Text = Data1.Recordset.Fields("预收金额") Else Texyj.Text = "0"
  If Data1.Recordset.Fields("结款方式") <> "" Then Combo2.Text = Data1.Recordset.Fields("结款方式")
  If Data1.Recordset.Fields("折扣") <> "" Then Texzk.Text = Data1.Recordset.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(DBCombo2.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 Sub
Private Sub DBCombo4_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(DBCombo2.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(DBCombo2.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 = "": DBCombo4.Text = "": Texzhje.Text = "": Texthje.Text = ""
 Texxf.Text = "": DBCombo1.Text = "": DBCombo2.Text = "": DBCombo3.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: DBCombo4.Enabled = True: Texzk.Enabled = True
 DBCombo4.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
  Dim mydb1 As Database
  Dim myrs1 As Recordset
  Dim myrs2 As Recordset
  Set mydb1 = Workspaces(0).OpenDatabase(App.Path & "\KFGL.MDB")
  Set myrs1 = mydb1.OpenRecordset("tfd", dbOpenTable)
  Set myrs2 = mydb1.OpenRecordset("djb", dbOpenTable)
  myrs1.AddNew       '添加退宿记录
  If bh.Text <> "" Then myrs1.Fields("凭证号码") = bh.Text
  If Texxm.Text <> "" Then myrs1.Fields("姓名") = Texxm.Text
  If Combo1.Text <> "" Then myrs1.Fields("证件名称") = Combo1.Text
  If Texsfz.Text <> "" Then myrs1.Fields("证件号码") = Texsfz.Text
  If Texdz.Text <> "" Then myrs1.Fields("详细地址") = Texdz.Text
  If Textcf.Text <> "" Then myrs1.Fields("工作单位") = Textcf.Text
  If DBCombo3.Text <> "" Then myrs1.Fields("房间号") = DBCombo3.Text
  If DBCombo1.Text <> "" Then myrs1.Fields("客房类型") = DBCombo1.Text
  If DBCombo2.Text <> "" Then myrs1.Fields("客房价格") = DBCombo2.Text
  If DTP1.Value <> "" Then myrs1.Fields("住宿日期") = DTP1.Value
  If tim1.Value <> "" Then myrs1.Fields("住宿时间") = tim1.Value
  If DTP2.Value <> "" Then myrs1.Fields("退房日期") = DTP2.Value
  If tim2.Value <> "" Then myrs1.Fields("退房时间") = tim2.Value
  If Texts.Text <> "" Then myrs1.Fields("住宿天数") = Val(Texts.Text)
  If Texzk.Text <> "" Then myrs1.Fields("折扣") = Val(Texzk.Text)
  If Combo2.Text <> "" Then myrs1.Fields("折扣或招待") = Combo2.Text
  If Texxf.Text <> "" Then myrs1.Fields("宿费") = Format(Texxf.Text, "0.00")
  If Texzhje.Text <> "" Then myrs1.Fields("应收宿费") = Texzhje.Text
  If Texyj.Text <> "" Then myrs1.Fields("预收宿费") = Texyj.Text
  If Texthje.Text <> "" Then myrs1.Fields("退还宿费") = Texthje.Text
  If Texzf.Text <> "" Then myrs1.Fields("杂费") = Val(Texzf.Text) Else myrs1.Fields("杂费") = "0"
  If Texdhf.Text <> "" Then myrs1.Fields("电话费") = Val(Texdhf.Text) Else myrs1.Fields("电话费") = "0"
  If Texhyf.Text <> "" Then myrs1.Fields("会议费") = Val(Texhyf.Text) Else myrs1.Fields("会议费") = "0"
  If Texpcf.Text <> "" Then myrs1.Fields("赔偿费") = Val(Texpcf.Text) Else myrs1.Fields("赔偿费") = "0"
  If Textcf.Text <> "" Then myrs1.Fields("存车费") = Val(Textcf.Text) Else myrs1.Fields("存车费") = "0"
  If Texssje.Text <> "" Then myrs1.Fields("金额总计") = Val(Texssje.Text)
  If Texbz.Text <> "" Then myrs1.Fields("备注") = Texbz.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.Update     '更新记录
  Data1.Recordset.Edit
  Data1.Recordset.Fields("标志") = 0
  Data1.Recordset.Update     '更新记录
  Data4.RecordSource = "select * from djys where 凭证号码 ='" & DBCombo4.Text & "'"
  Data4.Refresh
  Data4.Recordset.Edit
  Data4.Recordset.Fields("标志") = 0
  Data4.Recordset.Update
  Data2.Recordset.FindFirst "房间号 ='" & DBCombo3.Text & "'"
  Data2.Recordset.Edit
  Data2.Recordset.Fields("房态") = "空房"
  Data2.Recordset.Update
  If Combo2.Text = "挂帐" Then
   '查询挂帐单位
   Data3.RecordSource = "select * from gzmx where 挂账单位='" & Texgzdw.Text & "'order by 日期,时间"
   Data3.Refresh
   If Data3.Recordset.EOF = False Then Data3.Recordset.MoveLast
   If Data3.Recordset.RecordCount > 0 Then
   If Data3.Recordset.Fields("金额累计") <> "" Then gzje.Text = Data3.Recordset.Fields("金额累计")
   End If
   '添加挂帐记录
   Data3.Recordset.AddNew
   Data3.Recordset.Fields("日期") = Date
   Data3.Recordset.Fields("时间") = Time
   Data3.Recordset.Fields("票号") = "T" & DBCombo4.Text
   Data3.Recordset.Fields("日期") = Date
   Data3.Recordset.Fields("姓名") = Texxm.Text
   Data3.Recordset.Fields("证件号码") = Texsfz.Text
   Data3.Recordset.Fields("房间标准") = DBCombo1.Text
   Data3.Recordset.Fields("房间价格") = DBCombo2.Text
   Data3.Recordset.Fields("时间") = Time
   Data3.Recordset.Fields("挂账单位") = Texgzdw.Text
   Data3.Recordset.Fields("住宿金额") = Texssje.Text
   Data3.Recordset.Fields("摘要") = "住宿日期:" & DTP1.Value & " 住宿天数: " & Texts.Text
   Data3.Recordset.Fields("欠款金额") = Val(Texssje.Text)
   Data3.Recordset.Fields("金额累计") = Val(Texssje.Text) + Val(gzje.Text)
   Data3.Recordset.Update     '更新记录
  End If
 Else
  MsgBox ("请录入正确的数据")
 End If
 Data2.RecordSource = "select * from kf where 房态='空房'"
 Data2.Refresh
 Data5.Refresh
 '设置控件有效或无效
 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 = "": DBCombo4.Text = "": Texzhje.Text = "": Texthje.Text = ""
 Texxf.Text = "": DBCombo1.Text = "": DBCombo2.Text = "": DBCombo3.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 "房间号:" & DBCombo3.Text
 B = B + D
 Printer.CurrentX = 100 + A
 Printer.CurrentY = B + 200
 Printer.Print "房价:" & Format(DBCombo2.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 + -