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

📄 frmrateperperiod.frm

📁 hotel mnagement system
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         Width           =   750
      End
      Begin VB.Label lblRM 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   6.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   165
         Left            =   9450
         TabIndex        =   10
         Top             =   3030
         Width           =   45
      End
   End
End
Attribute VB_Name = "frmRatePerPeriod"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public FolioNumber      As String
Dim cIRowCount          As Integer

Private Sub cmdClose_Click()
    Unload Me
End Sub

Private Sub cmdSave_Click()
    Dim rsRatePerPeriod As New Recordset

    rsRatePerPeriod.CursorLocation = adUseClient
    rsRatePerPeriod.Open "SELECT * FROM [Rate Per Period] WHERE FolioNumber='" & FolioNumber & "'", CN, adOpenStatic, adLockOptimistic
    
    Dim c As Integer
    
    With Grid
        'Save the details of the records
        For c = 1 To cIRowCount
            .Row = c
            
            rsRatePerPeriod.Filter = "[Date] = " & .TextMatrix(c, 1)
            
            If rsRatePerPeriod.RecordCount = 1 Then
                rsRatePerPeriod![RateTypeID] = .TextMatrix(c, 3)
                rsRatePerPeriod![Rate] = .TextMatrix(c, 5)
                rsRatePerPeriod![Adults] = .TextMatrix(c, 6)
                rsRatePerPeriod![Childrens] = .TextMatrix(c, 7)
    
                rsRatePerPeriod.Update
            End If
        Next c
    End With

    'Clear variables
    c = 0
    Set rsRatePerPeriod = Nothing
    
    Unload frmRatePerPeriod
End Sub

Private Sub cmdUpdate_Click()
    With Grid
        .TextMatrix(.RowSel, 3) = dcRateType.BoundText
        .TextMatrix(.RowSel, 4) = dcRateType.Text
        .TextMatrix(.RowSel, 5) = toMoney(txtRate.Text)
        .TextMatrix(.RowSel, 6) = toMoney(txtAdults.Text)
        .TextMatrix(.RowSel, 7) = toMoney(txtChildrens.Text)
    End With
End Sub

Private Sub dcRateType_Click(Area As Integer)
    Dim rsRoomRates As New ADODB.Recordset
    
    If dcRateType.BoundText = "" Then Exit Sub
    
    With rsRoomRates
        .Open "SELECT * FROM [Room Rates] WHERE RoomNumber = " & Grid.TextMatrix(Grid.RowSel, 2) & " AND RateTypeID = " & dcRateType.BoundText, CN, adOpenStatic, adLockOptimistic
    
        If .RecordCount > 0 Then
            txtRate.Text = toMoney(!RoomRate)
        End If
    End With
    
    rsRoomRates.Close
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        SendKeys "{TAB}"
    End If
End Sub

Private Sub Form_Load()
    Call InitGrid
    
    bind_dc "SELECT * FROM [Rate Type]", "RateType", dcRateType, "RateTypeID", False

    DisplayForEditing
    
    DoEvents
End Sub

Private Sub DisplayForEditing()
    On Error GoTo err
    
    'Display the details
    Dim rsRatePerPeriod As New Recordset

    cIRowCount = 0
    
    rsRatePerPeriod.CursorLocation = adUseClient
    rsRatePerPeriod.Open "SELECT * FROM qry_Rate_Per_Period WHERE FolioNumber='" & FolioNumber & "' ORDER BY [Date]", CN, adOpenStatic, adLockOptimistic
    
    If rsRatePerPeriod.RecordCount > 0 Then
        rsRatePerPeriod.MoveFirst
        While Not rsRatePerPeriod.EOF
          cIRowCount = cIRowCount + 1     'increment
            With Grid
                If .Rows = 2 And .TextMatrix(1, 1) = "" Then
                    .TextMatrix(1, 1) = rsRatePerPeriod!Date
                    .TextMatrix(1, 2) = rsRatePerPeriod!RoomNumber
                    .TextMatrix(1, 3) = rsRatePerPeriod!RateTypeID
                    .TextMatrix(1, 4) = rsRatePerPeriod!RateType
                    .TextMatrix(1, 5) = toMoney(rsRatePerPeriod!Rate)
                    .TextMatrix(1, 6) = toMoney(rsRatePerPeriod!Adults)
                    .TextMatrix(1, 7) = toMoney(rsRatePerPeriod!Childrens)
                Else
                    .Rows = .Rows + 1
                    .TextMatrix(.Rows - 1, 1) = rsRatePerPeriod!Date
                    .TextMatrix(.Rows - 1, 2) = rsRatePerPeriod!RoomNumber
                    .TextMatrix(.Rows - 1, 3) = rsRatePerPeriod!RateTypeID
                    .TextMatrix(.Rows - 1, 4) = rsRatePerPeriod!RateType
                    .TextMatrix(.Rows - 1, 5) = toMoney(rsRatePerPeriod!Rate)
                    .TextMatrix(.Rows - 1, 6) = toMoney(rsRatePerPeriod!Adults)
                    .TextMatrix(.Rows - 1, 7) = toMoney(rsRatePerPeriod!Childrens)
                End If
            End With
            
            rsRatePerPeriod.MoveNext
        Wend
        Grid.Row = 1
        Grid.ColSel = 7
        'Set fixed cols
'        If State = adStateEditMode Then
            Grid.FixedRows = Grid.Row: 'Grid.SelectionMode = flexSelectionFree
            Grid.FixedCols = 1
'        End If
    End If

    rsRatePerPeriod.Close
    'Clear variables
    Set rsRatePerPeriod = Nothing

    Exit Sub
err:
    If err.Number = 94 Then Resume Next
    
    prompt_err err, Name, "DisplayForEditing"
    Screen.MousePointer = vbDefault
End Sub

'Procedure used to initialize the grid
Private Sub InitGrid()
    cIRowCount = 0
    With Grid
        .Clear
        .ClearStructure
        .Rows = 2
        .FixedRows = 1
        .FixedCols = 1
        .Cols = 8
        .ColSel = 7
        'Initialize the column size
        .ColWidth(0) = 315
        .ColWidth(1) = 1200
        .ColWidth(2) = 1200
        .ColWidth(3) = 0
        .ColWidth(4) = 1200
        .ColWidth(5) = 900
        .ColWidth(6) = 1200
        .ColWidth(7) = 1200
        
        'Initialize the column name
        .TextMatrix(0, 0) = ""
        .TextMatrix(0, 1) = "Date"
        .TextMatrix(0, 2) = "Room Number"
        .TextMatrix(0, 3) = "Rate Type ID"
        .TextMatrix(0, 4) = "Rate Type"
        .TextMatrix(0, 5) = "Rate"
        .TextMatrix(0, 6) = "Adult's Rate"
        .TextMatrix(0, 7) = "Children's Rate"
        
        'Set the column alignment
'        .ColAlignment(0) = vbLeftJustify
'        .ColAlignment(1) = vbLeftJustify
'        .ColAlignment(2) = vbLeftJustify
'        .ColAlignment(3) = flexAlignGeneral
'        .ColAlignment(4) = flexAlignGeneral
'        .ColAlignment(5) = vbRightJustify
'        .ColAlignment(6) = vbRightJustify
'        .ColAlignment(7) = vbRightJustify
'        .ColAlignment(8) = vbRightJustify
    End With
End Sub

Private Sub Grid_Click()
    With Grid
        dcRateType.BoundText = .TextMatrix(.RowSel, 3)
        txtRate.Text = .TextMatrix(.RowSel, 5)
        txtAdults.Text = .TextMatrix(.RowSel, 6)
        txtChildrens.Text = .TextMatrix(.RowSel, 7)
    End With
End Sub

Private Sub txtAdults_GotFocus()
    HLText txtAdults
End Sub

Private Sub txtAdults_KeyPress(KeyAscii As Integer)
    KeyAscii = isNumber(KeyAscii)
End Sub

Private Sub txtAdults_Validate(Cancel As Boolean)
    txtAdults.Text = toMoney(txtAdults.Text)
End Sub

Private Sub txtChildrens_GotFocus()
    HLText txtChildrens
End Sub

Private Sub txtChildrens_KeyPress(KeyAscii As Integer)
    KeyAscii = isNumber(KeyAscii)
End Sub

Private Sub txtChildrens_Validate(Cancel As Boolean)
    txtChildrens.Text = toMoney(txtChildrens.Text)
End Sub

Private Sub txtRate_GotFocus()
    HLText txtRate
End Sub

Private Sub txtRate_KeyPress(KeyAscii As Integer)
    KeyAscii = isNumber(KeyAscii)
End Sub

Private Sub txtRate_Validate(Cancel As Boolean)
    txtRate.Text = toMoney(txtRate.Text)
End Sub

⌨️ 快捷键说明

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