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

📄 dengji.frm

📁 一部酒店管理系统
💻 FRM
📖 第 1 页 / 共 4 页
字号:

    
    Dim str As String
    str = "select * from house where nam='" & m_name & "'"
     
    Dim myrs As ADODB.Recordset
    Set myrs = New ADODB.Recordset
    
    myrs.CursorLocation = adUseClient
    myrs.LockType = adLockOptimistic
    myrs.CursorType = adOpenDynamic
    myrs.Open str, myCon
    myrs.MoveFirst
            
    LoadChuang2 = Int(myrs("chuang")) - Int(myrs("zhu"))
       
End Function

Private Function GetTime() As String

    GetTime = Date + Time

End Function

'添加顾客选择房间信息

Private Sub SelHouse()
    
    m_val = m_val + 1

    If m_val > 2 Then
         
        MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
        
    End If
    
    Dim n As Integer '循环变量
    Dim key As Integer
    Dim m_no As Integer '房间名
        
    key = 0
    
    For n = 0 To MSFlexGrid1.Rows - 2
    
        If MSFlexGrid1.TextMatrix(n, 0) = m_name Then '已有相同房间名
            
            key = 1
            m_no = n
            Exit For
        End If
    Next
        
        If CheckZhuangTai1 = True Then
            
            MsgBox "维修中,不可入住!", vbExclamation
            MSFlexGrid1.Rows = MSFlexGrid1.Rows - 1
            Exit Sub
        End If
        
        If CheckZhuangTai2 = True Then
            
            MsgBox "清扫中,不可入住!", vbExclamation
            MSFlexGrid1.Rows = MSFlexGrid1.Rows - 1
            Exit Sub
        
        End If
        
        If IfYuding = True Then
            
            MsgBox "该房间已被预订!", vbExclamation
            MSFlexGrid1.Rows = MSFlexGrid1.Rows - 1
            Exit Sub
        
        End If
        
        If key = 0 Then
        
            If LoadChuang2 = 0 Then
                MsgBox "该房间已满,不可入住", vbExclamation
                MSFlexGrid1.Rows = MSFlexGrid1.Rows - 1
                Exit Sub
            End If
            
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 0) = m_name
            MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 1) = LoadChuang2
        Else
            MSFlexGrid1.RemoveItem (m_no)
            MSFlexGrid1.Rows = MSFlexGrid1.Rows - 1
            Text1.Visible = False
            VScroll3.Visible = False
            
        End If
        
End Sub


'房间保存
Private Sub RegHouse()
    
    Dim n As Integer
    Dim m_houseno As String
    Dim m_sum   As String
    Dim strSQL As String
    
    For n = 1 To MSFlexGrid1.Rows - 1
    
        m_houseno = MSFlexGrid1.TextMatrix(n, 0)
        m_sum = MSFlexGrid1.TextMatrix(n, 1)
        
        strSQL = "insert into guestinfo(numb,houseno,sums) " & _
        "values('" & lbl_no.Caption & "','" & m_houseno & "','" & m_sum & "')"

        myCon.Execute (strSQL)
    Next
End Sub


Private Sub MSFlexGrid1_EnterCell()


    With MSFlexGrid1

         If .MouseRow = 0 Or .MouseCol = 0 Or .TextMatrix(.MouseRow, 0) = "" Then     '固定行不可编辑

            Text1.Visible = False
            VScroll3.Visible = False

            Exit Sub

         End If

         .Row = .MouseRow                '取要编辑的单元

         .Col = .MouseCol

         Text1.Text = ""             '清空文本框

         Text1.Visible = False
         VScroll3.Visible = False

         Text1.Top = .Top + .CellTop    '确定文本框的位置与网格单元相重合

         Text1.Left = .Left + .CellLeft

         Text1.Width = .CellWidth

         Text1.Height = .CellHeight

         Text1.Text = .TextMatrix(.MouseRow, .MouseCol)
         m_sum = Text1.Text

         VScroll3.Top = .Top + .CellTop   '确定滚动条的位置与网格单元相重合

         VScroll3.Left = Text1.Left + Text1.Width - VScroll3.Width

         VScroll3.Height = Text1.Height

    End With

    Text1.Visible = True       '使文本框可见并可以编辑
    VScroll3.Visible = True
    Text1.SetFocus

End Sub

Private Sub MSFlexGrid1_LeaveCell()

    With MSFlexGrid1
    
        If .Row = 0 Or .Col = 0 Or .TextMatrix(.MouseRow, 0) = "" Then   '固定行不可编辑
            Exit Sub
        Else
            If m_sum < Text1.Text Then
                MsgBox "入住人数不可超过房间所能容纳人数!", vbExclamation
                Text1.Text = m_sum
                Exit Sub
            End If
            MSFlexGrid1.TextMatrix(.Row, .Col) = Text1.Text
        End If
    End With
    
    Text1.Visible = False
    VScroll3.Visible = False
 
End Sub

Private Sub VScroll3_Change()

    Text1.Text = VScroll3.Value

End Sub

Private Function IfOver() As Boolean  '检查入住人数是否超过总人数

    Dim sum As Integer
    Dim n As Integer '循环变量

    For n = 1 To MSFlexGrid1.Rows - 1
        If MSFlexGrid1.TextMatrix(n, 1) = "" Then
            MsgBox "请选择入住房间!", vbExclamation
            IfOver = False
            Exit Function
        Else
            sum = sum + Int(MSFlexGrid1.TextMatrix(n, 1))
        End If
        
    Next
    
    If sum = Int(txt_sum.Text) Then
        IfOver = True
    Else
        MsgBox "入住人数与房间人数安排不符,请调整!", vbExclamation
        IfOver = False
    End If
    
End Function

Private Sub UpdateHouse() '更新房间信息

    Dim m_sum As Integer '当前入住房间人数
    Dim m_name As String '当前入住房间名
    Dim n As Integer '循环变量
    Dim IfFull As Boolean '是否已入住满开关
    IfFull = False
    
    Dim m_sex As String '入住房客性别
    If opsex(0).Value = True Then
        m_sex = 0
    Else
        m_sex = 1
    End If
    
    For n = 1 To MSFlexGrid1.Rows - 1
        
        m_sum = Int(MSFlexGrid1.TextMatrix(n, 1))
        m_name = MSFlexGrid1.TextMatrix(n, 0)
        IfFull = CheckSum(m_name, m_sum)
        
        Dim str1 As String
        str1 = "select * from house where nam='" & m_name & "'"
         
        Dim myrs1 As ADODB.Recordset
        Set myrs1 = New ADODB.Recordset
        
        myrs1.CursorLocation = adUseClient
        myrs1.LockType = adLockOptimistic
        myrs1.CursorType = adOpenDynamic
        myrs1.Open str1, myCon
        myrs1.MoveFirst
        
        Dim m_oldsum As Integer '保存表中原有入住人数
        m_oldsum = Int(myrs1("zhu"))
         
        m_sum = m_sum + m_oldsum
         
        Dim str As String
        If IfFull = True Then
            str = "update house set kong='1', man='1',xingbie='" & m_sex & "',zhu='" & m_sum & "' where nam='" & m_name & "'"
        Else
            str = "update house set kong='1',man='2',xingbie='" & m_sex & "',zhu='" & m_sum & "' where nam='" & m_name & "'"
        End If
        Dim myrs As ADODB.Recordset
        Set myrs = New ADODB.Recordset
        
        myrs.CursorLocation = adUseClient
        myrs.LockType = adLockOptimistic
        myrs.CursorType = adOpenDynamic
        myCon.Execute (str)
        
    Next
    
End Sub

'检查每间客房入住人数是否已满---负责数据库查询

Private Function CheckSum(name As String, sum As Integer) As Boolean
    
    Dim str As String
    str = "select * from house where nam='" & name & "'"
     
    Dim myrs As ADODB.Recordset
    Set myrs = New ADODB.Recordset
    
    myrs.CursorLocation = adUseClient
    myrs.LockType = adLockOptimistic
    myrs.CursorType = adOpenDynamic
    myrs.Open str, myCon
    myrs.MoveFirst
            
    If sum + Int(myrs("zhu")) = Int(myrs("chuang")) Then
        CheckSum = True
    Else
        CheckSum = False
    End If
       
End Function

'检查每间客房入住人数是否已满---负责数据库查询

Private Function CheckSex(name As String) As Integer
    
    Dim str As String
    str = "select * from house where nam='" & name & "'"
     
    Dim myrs As ADODB.Recordset
    Dim m_sex1 As Integer
    
    Set myrs = New ADODB.Recordset
    
    myrs.CursorLocation = adUseClient
    myrs.LockType = adLockOptimistic
    myrs.CursorType = adOpenDynamic
    myrs.Open str, myCon
    
    CheckSex = myrs("xingbie")

       
End Function

'清屏函数
Private Sub CleanScreen()

    txt_name.Text = ""
    comb_zheng.ListIndex = 0
    txt_no.Text = ""
    txt_danwei.Text = ""
    txt_addr.Text = ""
    lbl_time = GetTime
    txt_sum.Text = 1
    txt_days.Text = 1
    txt_money.Text = 0
    Combo1.ListIndex = 0
    Call LoadsNum
    
    Dim m_row As Integer
    m_row = MSFlexGrid1.Rows - 1
    
    MSFlexGrid1.Rows = MSFlexGrid1.Rows - m_row
    
End Sub


'检查房间是否在维修中

Private Function CheckZhuangTai1() As Boolean
    
    Dim str As String
    str = "select * from house where nam='" & m_name & "'"
     
    Dim myrs As ADODB.Recordset
    Dim m_sex1 As Integer
    
    Set myrs = New ADODB.Recordset
    
    myrs.CursorLocation = adUseClient
    myrs.LockType = adLockOptimistic
    myrs.CursorType = adOpenDynamic
    myrs.Open str, myCon
    
    If myrs("weixiu") = 1 Then
        CheckZhuangTai1 = True
    Else
        CheckZhuangTai1 = False
    End If
    
       
End Function


'检查房间是否在清扫中

Private Function CheckZhuangTai2() As Boolean
    
    Dim str As String
    str = "select * from house where nam='" & m_name & "'"
     
    Dim myrs As ADODB.Recordset
    Dim m_sex1 As Integer
    
    Set myrs = New ADODB.Recordset
    
    myrs.CursorLocation = adUseClient
    myrs.LockType = adLockOptimistic
    myrs.CursorType = adOpenDynamic
    myrs.Open str, myCon
    
    If myrs("qingsao") = 1 Then
        CheckZhuangTai2 = True
    Else
        CheckZhuangTai2 = False
    End If
    
       
End Function


'判断是否预订

Private Function IfYuding() As Boolean


    
    Dim str As String
    str = "select * from house where nam='" & m_name & "'"
     
    Dim myrs As ADODB.Recordset
    Set myrs = New ADODB.Recordset
    
    myrs.CursorLocation = adUseClient
    myrs.LockType = adLockOptimistic
    myrs.CursorType = adOpenDynamic
    myrs.Open str, myCon
        
    If myrs("ding") = 1 Then
        
        IfYuding = True
    
    Else
        
        IfYuding = False
    
    End If
       
End Function

⌨️ 快捷键说明

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