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

📄 frmregedit.frm

📁 酒店管理系统 基于VB和SQL的一个很好的程序 可以实现酒店的日常管理工作
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         Height          =   255
         Left            =   2040
         TabIndex        =   12
         Top             =   803
         Width           =   975
      End
      Begin VB.CommandButton Cmd_Cust 
         Caption         =   "选择客户"
         Height          =   375
         Left            =   1920
         TabIndex        =   3
         Top             =   1200
         Width           =   1095
      End
      Begin VB.Label lblCid 
         AutoSize        =   -1  'True
         Caption         =   "lblCid"
         Height          =   180
         Left            =   840
         TabIndex        =   9
         Top             =   360
         Width           =   540
      End
      Begin VB.Label lblCname 
         AutoSize        =   -1  'True
         Caption         =   "lblCname"
         Height          =   180
         Left            =   840
         TabIndex        =   8
         Top             =   840
         Width           =   720
      End
      Begin VB.Label lblCtype 
         AutoSize        =   -1  'True
         Caption         =   "lblCtype"
         Height          =   180
         Left            =   840
         TabIndex        =   7
         Top             =   1320
         Width           =   720
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "姓 名:"
         Height          =   180
         Left            =   120
         TabIndex        =   6
         Top             =   840
         Width           =   540
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "类 型:"
         Height          =   180
         Left            =   120
         TabIndex        =   5
         Top             =   1320
         Width           =   540
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "编 号:"
         Height          =   180
         Left            =   120
         TabIndex        =   4
         Top             =   360
         Width           =   540
      End
   End
   Begin VB.CommandButton Cmd_Close 
      Caption         =   "关 闭"
      Height          =   495
      Left            =   9120
      TabIndex        =   1
      Top             =   4403
      Width           =   1095
   End
   Begin VB.CommandButton Cmd_OK 
      Caption         =   "确 定"
      Height          =   495
      Left            =   7680
      TabIndex        =   0
      Top             =   4403
      Width           =   1095
   End
   Begin VB.Label Label11 
      AutoSize        =   -1  'True
      Caption         =   "操作人员"
      Height          =   180
      Left            =   240
      TabIndex        =   35
      Top             =   4560
      Width           =   720
   End
   Begin VB.Label lblEmpName 
      AutoSize        =   -1  'True
      Caption         =   "lblEmpName"
      Height          =   180
      Left            =   1200
      TabIndex        =   34
      Top             =   4560
      Width           =   900
   End
End
Attribute VB_Name = "FrmRegEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Modify As Boolean  '添加(false)、修改(true)设置
Public TmpId As Integer  '入住登记编号

'计算预定当前房间的总费用
Private Sub Cal_Total()
  lblTotal = Round(Val(txtPrice) * Val(ComboRate) * Val(txtDays) / 100, 0) + Val(txtOtherFee)
End Sub

'根据入住日期计算退房日期
Private Sub Cat_LeaveDate()
  txtLeaveDate.Text = DateAdd("d", Val(txtDays), Trim(txtInDate))
End Sub

Private Sub Refresh_Room()
  '客房信息记录,只显示空房列表,即status=0
  Adodc1.ConnectionString = Conn
  Adodc1.RecordSource = "SELECT r.RoomNo As 房间编号, t.TypeName As 房间类型," _
                + " t.RoomNum As 房间个数, t.Bednum As 床位数量, r.Position As 朝向," _
                + " r.Price as 价格, r.ObjList as 物品清单 FROM Room r, RoomType t" _
                + " WHERE r.TypeId=t.TypeId And r.Status=0 ORDER BY r.RoomNo"
  Adodc1.Refresh
  Set DataGrid1.DataSource = Adodc1
  With DataGrid1
  .Columns(0).Width = 0
  .Columns(1).Width = 1000
  .Columns(2).Width = 1000
  .Columns(3).Width = 1000
  .Columns(4).Width = 1000
  .Columns(5).Width = 1000
  .Columns(6).Width = 1000
  End With
End Sub

Private Sub Refresh_OrderList()
  '显示指定客户的所有预定信息
  Adodc1.ConnectionString = Conn
  Adodc1.RecordSource = "SELECT l.ListId as 编号, l.RoomNo as 客房编号, l.Days as 预定天数, " _
                      + " l.Price As 预定单价, l.Rate As 预定折扣, l.OtherFee As 其他收费," _
                      + " l.Memo As 备注说明, l.OrderId FROM OrderList l, OrderRoom o" _
                      + " WHERE l.OrderId=o.OrderId And o.CustId='" + Trim(lblCid) _
                      + "' ORDER BY ListId"
  Adodc1.Refresh
  Set DataGrid1.DataSource = Adodc1
  With DataGrid1
  .Columns(0).Width = 0
  .Columns(1).Width = 1000
  .Columns(2).Width = 1000
  .Columns(3).Width = 1000
  .Columns(4).Width = 1000
  .Columns(5).Width = 1000
  .Columns(6).Width = 1000
  .Columns(7).Width = 0
  End With
End Sub

Private Sub Check1_Click()
  If Check1.Value = 1 Then '有预定,显示与此客户有关的预定信息
    Refresh_OrderList
  Else  '没有预定,则显示空闲客房信息
    Refresh_Room
  End If
End Sub

Private Sub Cmd_Close_Click()
  Unload Me
End Sub

Private Sub Cmd_Cust_Click()
  FrmCustSlt.Show 1
  lblCid.Caption = FrmCustSlt.TmpCustId
  lblCname.Caption = FrmCustSlt.TmpCustName
  lblCtype.Caption = FrmCustSlt.TmpCustType
  '如果选中“有预定”,则根据选择的客户显示预定信息
  If Check1.Value = 1 Then
    Refresh_OrderList
  End If
End Sub

Private Sub Cmd_OK_Click()
  '对用户输入数据的有效性进行判断
  If lblCid = "" Then
    MsgBox "请选择客户"
    Exit Sub
  End If
  If lblRoomNo = "" Then
    MsgBox "请选择房间"
    Exit Sub
  End If
  If Trim(txtInDate) = False Then
    MsgBox "请录入入住日期"
    txtInDate.SetFocus
    Exit Sub
  End If
  If Trim(txtLeaveDate) = False Then
    MsgBox "请录入退房日期"
    txtLeaveDate.SetFocus
    Exit Sub
  End If
  If Val(txtDays) <= 0 Then
    MsgBox "请录入入住天数"
    txtDays.SetFocus
    Exit Sub
  End If
  If Val(txtPrice) <= 0 Then
    MsgBox "请录入有效的报价"
    txtPrice.SetFocus
    Exit Sub
  End If
  If Val(ComboRate) <= 0 Or Val(ComboRate) > 100 Then
    MsgBox "折扣应该在0~100之间"
    ComboRate.SetFocus
    Exit Sub
  End If
  If Val(txtOtherFee) < 0 Then
    MsgBox "请录入有效的其他费用"
    txtOtherFee.SetFocus
    Exit Sub
  End If
  If Val(txtFirstPay) < 0 Then
    MsgBox "请录入有效的押金"
    txtFirstPay.SetFocus
    Exit Sub
  End If
  '将此入住记录保存
  With MyReg
  .CustId = lblCid
  .RoomNo = lblRoomNo
  .InDate = MakeStr(txtInDate)
  .LeaveDate = MakeStr(txtLeaveDate)
  .Days = Val(txtDays)
  .Price = Val(txtPrice)
  .Rate = Val(ComboRate)
  .OtherFee = Val(txtOtherFee)
  .FirstPay = Val(txtFirstPay)
  .Memo = MakeStr(txtMemo)
  .UserName = CurUser.UserName
  '根据变量modify决定插入数据或修改数据
  If Modify = False Then
    .Insert
  Else
    .Update (TmpId)
    '如果是修改数据,则不允许更新房间等信息,所以退出
    Unload Me
  End If
  End With
  '如果选择预定信息,则更新表OrderList,表OrderRoom和表Room中的数据
  If Check1.Value = 1 Then
    '删除预定房间数据
    MyOrderList.Delete (Adodc1.Recordset.Fields(0))
    '如果表OrderList中当前预定编号中的所有预定房间都被删除,则从表OrderRoom中删除预定记录
    If MyOrderList.GetRoomNum(Adodc1.Recordset.Fields(7)) = 0 Then
      MyOrderRoom.Delete (Adodc1.Recordset.Fields(7))
    End If
  End If
  
  '更新房间状态为入住,即Status=2
  MyRoom.Status = 2
  MyRoom.UpdateStatus (lblRoomNo)
  Unload Me
End Sub

Private Sub ComboRate_Change()
  Cal_Total
End Sub

Private Sub ComboRate_Click()
  Cal_Total
End Sub

Private Sub DataGrid1_Click()
  Dim TmpRoomNo As String
  '如果没有选择记录,则返回
  If Adodc1.Recordset.EOF = True Then
    Exit Sub
  End If
  If Check1.Value = 1 Then '将预定记录中的房间信息带入到入住登记信息中
    '客户信息
    
    '房间号
    TmpRoomNo = Trim(Adodc1.Recordset.Fields(1))
    lblRoomNo = TmpRoomNo
    '入住日期
    txtInDate = Date
    '入住天数
    txtDays = Trim(Adodc1.Recordset.Fields(2))
    '报价
    txtPrice = Trim(Adodc1.Recordset.Fields(3))
    '折扣
    ComboRate = Trim(Adodc1.Recordset.Fields(4))
    '其他费用
    txtOtherFee = Trim(Adodc1.Recordset.Fields(5))
    '其他说明
    If IsNull(Adodc1.Recordset.Fields(6)) = True Then
      txtMemo = ""
    Else
      txtMemo = Trim(Adodc1.Recordset.Fields(6))
    End If
  Else '从房间信息中带入数据
    lblRoomNo.Caption = Trim(Adodc1.Recordset.Fields(0))
    txtPrice = Trim(Adodc1.Recordset.Fields(5))
  End If
End Sub


Private Sub Form_Load()
  If Check1.Value = 1 Then '有预定,显示与此客户有关的预定信息
    Refresh_OrderList
  Else  '没有预定,则显示空闲客房信息
    Refresh_Room
  End If
End Sub

Private Sub txtDays_Change()
  Cal_Total
  Cat_LeaveDate
End Sub

Private Sub txtOtherFee_Change()
  Cal_Total
End Sub

Private Sub txtPrice_Change()
  Cal_Total
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -