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

📄 main_kfdj.frm

📁 visual basic 酒店管理系统
💻 FRM
📖 第 1 页 / 共 3 页
字号:
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   330
      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 & "\kfgl.mdb"
 Data2.DatabaseName = App.Path & "\kfgl.mdb"
 Data3.DatabaseName = App.Path & "\kfgl.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 & "\kfgl.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 + -