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

📄 main_kfdj.frm

📁 宾馆客房管理系统
💻 FRM
📖 第 1 页 / 共 3 页
字号:
  Case 5
    '按回车键ZSDJ(6)获得焦点
    If KeyCode = vbKeyReturn Then ZSDJ(6).SetFocus
  Case 6
    If KeyCode = vbKeyReturn Then ZSDJ(10).SetFocus
  Case 8
     '按回车键ZSDJ(10)获得焦点
     If KeyCode = vbKeyReturn Then ZSDJ(10).SetFocus
  Case 10
    'ZSDJ(11)获得焦点
    If KeyCode = vbKeyReturn Then ZSDJ(11).SetFocus
  Case 11
    '按回车键Comok获得焦点
    If KeyCode = vbKeyReturn Then Comok.SetFocus
 End Select
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
 '按回车键ZSDJ(1)获得焦点
 If KeyCode = vbKeyReturn Then ZSDJ(1).SetFocus
End Sub
Private Sub DTP2_KeyDown(KeyCode As Integer, Shift As Integer)
  '按回车键tim3获得焦点
  If KeyCode = vbKeyReturn Then tim3.SetFocus
End Sub
Private Sub DTP3_KeyDown(KeyCode As Integer, Shift As Integer)
  '按回车键tim4获得焦点
  If KeyCode = vbKeyReturn Then tim4.SetFocus
End Sub
Private Sub tim3_KeyDown(KeyCode As Integer, Shift As Integer)
  '按回车键DTP3获得焦点
  If KeyCode = vbKeyReturn Then DTP3.SetFocus
End Sub
Private Sub tim4_KeyDown(KeyCode As Integer, Shift As Integer)
  '按回车键Text10获得焦点
  If KeyCode = vbKeyReturn Then Text10.SetFocus
End Sub
Private Sub Dcomfjhm_LostFocus()
If Dcomfjhm.Text = "" Then
   Exit Sub
End If
'查询空闲房间信息
 '判断数据集对象DBrs1和DBrs2的状态,如果是打开状态,则先关闭,
'以防止出现重复打开数据集对象的错误
 If DBrs2.State = 1 Then
    DBrs2.Close
 End If
 If DBrs1.State = 1 Then
    DBrs1.Close
 End If
 '设置并执行SQL语句并返回相应的数据集,以找到房间号为用户分配的
 '房间号并且房态为空房的记录
 sqlstr = "select * from kf where 房间号='" & Trim(Dcomfjhm.Text) & _
          "' and 房态 like '%空房%'"
 DBrs2.Open sqlstr, DBcnn, adOpenStatic, adLockBatchOptimistic
'查询住宿登记信息
'设置并执行SQL语句并返回相应的数据集,以找到房间号为用户分配的
'房间号并且标志为1的记录
 sqlstr = "select * from djb where 房间号='" & Trim(Dcomfjhm.Text) & "'and 标志='1'"
 DBrs1.Open sqlstr, DBcnn, adOpenStatic, adLockBatchOptimistic
 '根据DBrs2的记录判断是否存在房间号为用户分配的房间号并且房态为空房的记录
 If DBrs2.RecordCount > 0 Then
   '在表kf中存在房间号为用户分配的房间号并且房态为空房的记录,接着在
   '表djb中判断该房间的标志是否为1
   If DBrs1.RecordCount = 0 Then
     '存在符合条件的记录,在与“房间类型”和“房间价格”对应的文框中
     '显示该房间的相应信息
     ZSDJ(4).Text = DBrs2.Fields("房间类型")
     ZSDJ(5).Text = DBrs2.Fields("价格")
    Else
     '不存在符合条件的记录,给出错误提示
     MsgBox ("此房间已占用或停止使用!!")
   End If
 Else
    '不存在符合条件的记录,给出错误提示
    MsgBox ("此房间已占用或停止使用!!")
 End If
End Sub
Private Sub Dcomfjhm_KeyDown(KeyCode As Integer, Shift As Integer)
 'ZSDJ(5)获得焦点
 If KeyCode = vbKeyReturn Then ZSDJ(5).SetFocus
End Sub
Private Sub comdj_Click()
'查询空闲房间信息
'判断数据集对象DBrs1、DBrs2和DBrs3的状态,如果是打开状态,则先关闭,
'以防止出现重复打开数据集对象的错误
If DBrs1.State = 1 Then
    DBrs1.Close
 End If
 If DBrs2.State = 1 Then
    DBrs2.Close
 End If
 If DBrs3.State = 1 Then
    DBrs3.Close
 End If
 '设置并执行SQL语句并返回相应的数据集,以在kf表中找到空房的房间号
sqlstr = "select * from kf where 房态='空房'"
DBrs2.Open sqlstr, DBcnn, adOpenStatic, adLockBatchOptimistic
sqlstr = "select * from kf where 房态='空房'"
DBrs3.Open sqlstr, DBcnn, adOpenStatic, adLockBatchOptimistic
Set Dcomfjhm.RowSource = DBrs3
Dcomfjhm.ListField = DBrs3.Fields("房间号").Name
'设置并执行SQL语句并返回相应的数据集,以返回djb表中的所有记录生成凭证号码
sqlstr = "select * from djb order by 凭证号码"
DBrs1.Open sqlstr, DBcnn, adOpenDynamic, adLockBatchOptimistic
'根据djb表中的凭证号码,生成此次住宿登记表的凭证编号
If Not DBrs1.EOF Then DBrs1.MoveLast
If DBrs1.Fields("凭证号码").Value = "" Then
    bh.Text = Date & "d" & Format(1, "###000")
End If
If DBrs1.Fields("凭证号码").Value <> "" Then
  Dim y1 As String
  Dim y2 As String
  y1 = Right(Left(Format(Date, "yyyy-MM-dd"), 7), 2)
 y2 = Right(Left(DBrs1.Fields("凭证号码").Value, 7), 2)
  If y1 = y2 Then
    bh.Text = Format(Date, "yyyy-MM-dd") & "d" & _
             Format(Val(Right(DBrs1.Fields("凭证号码").Value, 3)) + 1, "###000")
  End If
  If y1 <> y2 Then
    bh.Text = Format(Date, "yyyy-MM-dd") & "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 = ""
 Dcomfjhm.Text = ""
 ZSDJ(8).Enabled = True
 ZSDJ(10).Enabled = True
 ZSDJ(11).Enabled = True
 Dcomfjhm.Enabled = True
 Combo1.Enabled = True
 Combo2.Enabled = True
 '设置命令按钮控件的使能状态
 Comok.Enabled = True
 Comdj.Enabled = False
 Comprint.Enabled = False
  '将光标定位在“姓名”对应的文本框中
  ZSDJ(0).SetFocus
End Sub
Private Sub comok_Click()
  '判断数据集对象DBrs4的状态,如果是打开状态,则先关闭,
'以防止出现重复打开数据集对象的错误
 If DBrs4.State = 1 Then
    DBrs4.Close
 End If
  '设置并执行SQL语句并返回相应的数据集,
 sqlstr = "select * from djys"
 DBrs4.Open sqlstr, DBcnn, adOpenStatic, adLockBatchOptimistic
  '设置数据集对象DBrs1的Filter属性,以在住宿登记表(djb)找到房间号等于
  '用户输入的房间号并且标志等于1的记录
 sqlstr = "房间号 like '" & Dcomfjhm.Text & "' and 标志 like '" & "1'"
 DBrs1.Filter = sqlstr
 '判断是否存在符合条件的记录
 If DBrs1.EOF Then
  '不存在符合条件的记录,在住宿登记表(djb)中添加一条住宿信息
  DBrs1.AddNew
  '设置新添加的住宿信息记录的各个字段的值
  If bh.Text <> "" Then DBrs1.Fields("凭证号码") = bh.Text
  If ZSDJ(0).Text <> "" Then DBrs1.Fields("姓名") = ZSDJ(0).Text
  If Combo1.Text <> "" Then DBrs1.Fields("证件名称") = Combo1.Text
  If ZSDJ(1).Text <> "" Then DBrs1.Fields("证件号码") = ZSDJ(1).Text
  If ZSDJ(2).Text <> "" Then DBrs1.Fields("详细地址") = ZSDJ(2).Text
  If ZSDJ(3).Text <> "" Then DBrs1.Fields("出差事由") = ZSDJ(3).Text
  If Dcomfjhm.Text <> "" Then DBrs1.Fields("房间号") = Val(Dcomfjhm.Text)
  If ZSDJ(4).Text <> "" Then DBrs1.Fields("客房类型") = ZSDJ(4).Text
  If DTP1.Value <> "" Then DBrs1.Fields("住宿日期") = DTP1.Value
  If tim1.Value <> "" Then DBrs1.Fields("住宿时间") = tim1.Value
  If ZSDJ(5).Text <> "" Then DBrs1.Fields("客房价格") = Val(ZSDJ(5).Text)
  If ZSDJ(6).Text <> "" Then DBrs1.Fields("住宿天数") = ZSDJ(6).Text
  If ZSDJ(8).Text <> "" Then DBrs1.Fields("折扣") = ZSDJ(8).Text
  If ZSDJ(7).Text <> "" Then DBrs1.Fields("宿费") = ZSDJ(7).Text
  If Combo2.Text <> "" Then DBrs1.Fields("结款方式") = Combo2.Text
  If ZSDJ(9).Text <> "" Then DBrs1.Fields("应收宿费") = ZSDJ(9).Text
  If ZSDJ(10).Text <> "" Then DBrs1.Fields("预收金额") = Val(ZSDJ(10).Text)
  If DTP2.Value <> "" Then DBrs1.Fields("提醒日期") = DTP2.Value
  If tim2.Value <> "" Then DBrs1.Fields("提醒时间") = tim2.Value
  If DTP3.Value <> "" Then DBrs1.Fields("退宿日期") = DTP3.Value
  If tim3.Value <> "" Then DBrs1.Fields("退宿时间") = tim3.Value
  If ZSDJ(11).Text <> "" Then DBrs1.Fields("备注") = ZSDJ(11).Text
  DBrs1.Fields("日期") = Date
  DBrs1.Fields("时间") = Time
  sqlstr = Left(Date, 4) & Right(Left(Format(Date, "yyyy-MM-dd"), 7), 2) & _
           Right(Date, 2) & Left(Time, 2) & Left(Right(Time, 5), 2)
  DBrs1.Fields("BZ") = sqlstr
  DBrs1.Fields("标志") = "1"
  '向数据库提交此次添加
  DBrs1.UpdateBatch adAffectCurrent
  '在住宿预收表(djbys)中添加一条住宿预收信息
  DBrs4.AddNew
   '设置新添加的住宿预收信息记录的各个字段的值
  If bh.Text <> "" Then DBrs4.Fields("凭证号码") = bh.Text
  If ZSDJ(0).Text <> "" Then DBrs4.Fields("姓名") = ZSDJ(0).Text
  If Combo1.Text <> "" Then DBrs4.Fields("证件名称") = Combo1.Text
  If ZSDJ(1).Text <> "" Then DBrs4.Fields("证件号码") = ZSDJ(1).Text
  If ZSDJ(2).Text <> "" Then DBrs4.Fields("详细地址") = ZSDJ(2).Text
  If ZSDJ(3).Text <> "" Then DBrs4.Fields("出差事由") = ZSDJ(3).Text
  If Dcomfjhm.Text <> "" Then DBrs4.Fields("房间号") = Val(Dcomfjhm.Text)
  If ZSDJ(5).Text <> "" Then DBrs4.Fields("客房价格") = Val(ZSDJ(5).Text)
  If DTP1.Value <> "" Then DBrs4.Fields("住宿日期") = DTP1.Value
  If tim1.Value <> "" Then DBrs4.Fields("住宿时间") = tim1.Value
  If ZSDJ(6).Text <> "" Then DBrs4.Fields("住宿天数") = ZSDJ(6).Text
  If Combo2.Text <> "" Then DBrs4.Fields("结款方式") = Combo2.Text
  If ZSDJ(8).Text <> "" Then DBrs4.Fields("折扣") = ZSDJ(8).Text
  If ZSDJ(7).Text <> "" Then DBrs4.Fields("宿费") = ZSDJ(7).Text
  If ZSDJ(9).Text <> "" Then DBrs4.Fields("应收宿费") = ZSDJ(9).Text
  If ZSDJ(10).Text <> "" Then DBrs4.Fields("预收金额") = Val(ZSDJ(10).Text)
  If DTP2.Value <> "" Then DBrs4.Fields("提醒日期") = DTP2.Value
  If tim2.Value <> "" Then DBrs4.Fields("提醒时间") = tim2.Value
  If DTP3.Value <> "" Then DBrs4.Fields("退宿日期") = DTP3.Value
  If tim3.Value <> "" Then DBrs4.Fields("退宿时间") = tim3.Value
  If ZSDJ(11).Text <> "" Then DBrs4.Fields("备注") = ZSDJ(11).Text
  DBrs4.Fields("日期") = Date
  DBrs4.Fields("时间") = Time
  sqlstr = Left(Date, 4) & Right(Left(Format(Date, "yyyy-MM-dd"), 7), 2) & _
           Right(Date, 2) & Left(Time, 2) & Left(Right(Time, 5), 2)
  DBrs4.Fields("BZ") = sqlstr
  DBrs4.Fields("标志") = "1"
  ' 向数据库提交此次添加
  DBrs4.UpdateBatch
  '设置并执行sql语句,以更新分配的房间的使用状态
  sqlstr = "update kf set 房态='入住' where 房间号 like '" & Trim(Dcomfjhm.Text) & "'"
  DBcnn.Execute (sqlstr)
 '设置与"姓名"、"联系地址"和"证件号码"等信息对应的文本框中的使能状态
  For i = 0 To 6
     ZSDJ(i).Enabled = False
  Next i
  ZSDJ(8).Enabled = False
  ZSDJ(10).Enabled = False
  ZSDJ(11).Enabled = False
  Dcomfjhm.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
 Dcomfjhm.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 "房间号:" & Dcomfjhm.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 + -