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

📄 frmothercharges.frm

📁 hotel mnagement system
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         Width           =   45
      End
   End
End
Attribute VB_Name = "frmOtherCharges"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public FolioNumber      As String
Public GuestName        As String
Public RefForm          As Form 'Calling form

Dim OtherCharges          As Currency
Dim cIRowCount          As Integer

Private Sub btnRemove_Click()
    'Remove selected load product
    With Grid
        'Update the record count
        cIRowCount = cIRowCount - 1
        
        If .Rows = 2 Then Grid.Rows = Grid.Rows + 1
        .RemoveItem (.RowSel)
    End With

    btnRemove.Visible = False
    
    Grid_Click
End Sub

Private Sub cmdAdd_Click()
    If Trim(txtAmount.Text) = "" Or Trim(txtAmount.Text) = "0.00" Then Exit Sub

    Dim CurrRow As Integer

    'Add to grid
    With Grid

        'Perform if the record is not exist
        If .Rows = 2 And .TextMatrix(1, 2) = "" Then
            .TextMatrix(1, 2) = FolioNumber
            .TextMatrix(1, 3) = dtpDate.Value
            .TextMatrix(1, 4) = dcChargeType.Text
            .TextMatrix(1, 5) = txtDescription.Text
            .TextMatrix(1, 6) = toNumber(toMoney(txtAmount.Text))
        Else
            .Rows = .Rows + 1
            .TextMatrix(.Rows - 1, 2) = FolioNumber
            .TextMatrix(.Rows - 1, 3) = dtpDate.Value
            .TextMatrix(.Rows - 1, 4) = dcChargeType.Text
            .TextMatrix(.Rows - 1, 5) = txtDescription.Text
            .TextMatrix(.Rows - 1, 6) = toNumber(toMoney(txtAmount.Text))

            .Row = .Rows - 1
        End If
        'Increase the record count
        cIRowCount = cIRowCount + 1
        
        'Highlight the current row's column
        .ColSel = 6
        'Display a remove button
        Call Grid_Click
        
        Call ResetFields
    End With
End Sub

Private Sub cmdClose_Click()
    Dim c As Integer
    
    With Grid
        'Save the details of the records
        For c = 1 To cIRowCount
            .Row = c
            
            OtherCharges = OtherCharges + .TextMatrix(c, 6)
        Next c
    End With

    'Clear variables
    c = 0
    RefForm.OtherCharges = OtherCharges
    
    Me.Hide
End Sub

Public Sub cmdSave_Click()
    Dim rsOtherCharges As New Recordset

    rsOtherCharges.CursorLocation = adUseClient
    rsOtherCharges.Open "SELECT * FROM [Other Charges] WHERE FolioNumber='" & FolioNumber & "'", CN, adOpenStatic, adLockOptimistic
    
    DeleteItems
    
    Dim c As Integer
    
    With Grid
        'Save the details of the records
        For c = 1 To cIRowCount
            .Row = c
            
            If .TextMatrix(c, 1) = "" Then
                rsOtherCharges.AddNew
                
                rsOtherCharges![FolioNumber] = FolioNumber
            Else
                rsOtherCharges.Filter = "OtherChargesID = " & toNumber(.TextMatrix(c, 1))
            
                If rsOtherCharges.RecordCount = 0 Then
                    rsOtherCharges.AddNew
                    
                    rsOtherCharges![FolioNumber] = FolioNumber
                End If
            End If

            rsOtherCharges![Date] = .TextMatrix(c, 3)
            rsOtherCharges![ChargeTypeID] = getValueAt("SELECT * FROM [Charge Type] WHERE ChargeType = '" & .TextMatrix(c, 4) & "'", "ChargeTypeID")
            rsOtherCharges![Description] = .TextMatrix(c, 5)
            rsOtherCharges![Amount] = .TextMatrix(c, 6)

            rsOtherCharges.Update

            OtherCharges = OtherCharges + .TextMatrix(c, 6)
        Next c
    End With

    'Clear variables
    c = 0
    Set rsOtherCharges = Nothing
    
    Unload frmOtherCharges
End Sub

Private Sub cmdUpdate_Click()
    With Grid
        .TextMatrix(.RowSel, 3) = dtpDate.Value
        .TextMatrix(.RowSel, 4) = dcChargeType.Text
        .TextMatrix(.RowSel, 5) = txtDescription.Text
        .TextMatrix(.RowSel, 6) = toMoney(txtAmount.Text)
    End With
End Sub

Private Sub Form_Activate()
    OtherCharges = 0
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 [Charge Type]", "ChargeType", dcChargeType, "ChargeTypeID", True

    txtGuestName.Text = GuestName
    
    dtpDate.Value = Date
    
    DisplayForEditing
End Sub

'Procedure used to initialize the grid
Private Sub InitGrid()
    cIRowCount = 0
    With Grid
        .Clear
        .ClearStructure
        .Rows = 2
        .FixedRows = 1
        .FixedCols = 1
        .Cols = 7
        .ColSel = 6
        'Initialize the column size
        .ColWidth(0) = 315
        .ColWidth(1) = 0
        .ColWidth(2) = 0
        .ColWidth(3) = 1200
        .ColWidth(4) = 1500
        .ColWidth(5) = 1700
        .ColWidth(6) = 1200

        'Initialize the column name
        .TextMatrix(0, 0) = ""
        .TextMatrix(0, 1) = "Other Charges ID"
        .TextMatrix(0, 2) = "Folio Number"
        .TextMatrix(0, 3) = "Date"
        .TextMatrix(0, 4) = "Charge Type"
        .TextMatrix(0, 5) = "Description"
        .TextMatrix(0, 6) = "Amount"
    End With
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set frmPayment = Nothing
End Sub

Private Sub Grid_Click()
    With Grid
        If .TextMatrix(.RowSel, 3) = "" Then Exit Sub
        
        dtpDate.Value = .TextMatrix(.RowSel, 3)
        dcChargeType.Text = .TextMatrix(.RowSel, 4)
        txtDescription.Text = .TextMatrix(.RowSel, 5)
        txtAmount.Text = .TextMatrix(.RowSel, 6)
    
        If Grid.Rows = 2 And Grid.TextMatrix(1, 2) = "" Then     '1 = Folio Number
            btnRemove.Visible = False
        Else
            btnRemove.Visible = True
            btnRemove.Top = (Grid.CellTop + Grid.Top) - 20
            btnRemove.Left = Grid.Left + 50
        End If
    End With
End Sub

Private Sub ResetFields()
    txtAmount.Text = ""
   
    dcChargeType.SetFocus
End Sub

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

    cIRowCount = 0
    
    rsOtherCharges.CursorLocation = adUseClient
    rsOtherCharges.Open "SELECT * FROM qry_Other_Charges WHERE FolioNumber='" & FolioNumber & "'", CN, adOpenStatic, adLockOptimistic
    
    If rsOtherCharges.RecordCount > 0 Then
        rsOtherCharges.MoveFirst
        While Not rsOtherCharges.EOF
          cIRowCount = cIRowCount + 1     'increment
            With Grid
                If .Rows = 2 And .TextMatrix(1, 1) = "" Then
                    .TextMatrix(1, 1) = rsOtherCharges!OtherChargesID
                    .TextMatrix(1, 2) = rsOtherCharges!FolioNumber
                    .TextMatrix(1, 3) = rsOtherCharges!Date
                    .TextMatrix(1, 4) = rsOtherCharges!ChargeType
                    .TextMatrix(1, 5) = rsOtherCharges!Description
                    .TextMatrix(1, 6) = toMoney(rsOtherCharges!Amount)
                Else
                    .Rows = .Rows + 1
                    .TextMatrix(.Rows - 1, 1) = rsOtherCharges!OtherChargesID
                    .TextMatrix(.Rows - 1, 2) = rsOtherCharges!FolioNumber
                    .TextMatrix(.Rows - 1, 3) = rsOtherCharges!Date
                    .TextMatrix(.Rows - 1, 4) = rsOtherCharges!ChargeType
                    .TextMatrix(.Rows - 1, 5) = rsOtherCharges!Description
                    .TextMatrix(.Rows - 1, 6) = toMoney(rsOtherCharges!Amount)
                End If
            End With
           
            rsOtherCharges.MoveNext
        Wend
        Grid.Row = 1
        Grid.ColSel = 6
        'Set fixed cols
        If State = adStateEditMode Then
            Grid.FixedRows = Grid.Row: 'Grid.SelectionMode = flexSelectionFree
            Grid.FixedCols = 1
        End If
    End If

    rsOtherCharges.Close
    'Clear variables
    Set rsOtherCharges = Nothing

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

Private Sub DeleteItems()
    Dim CurrRow As Integer
    Dim rsOtherCharges As New Recordset

    rsOtherCharges.CursorLocation = adUseClient
    rsOtherCharges.Open "SELECT * FROM [Other Charges] WHERE FolioNumber='" & FolioNumber & "'", CN, adOpenStatic, adLockOptimistic
    If rsOtherCharges.RecordCount > 0 Then
        rsOtherCharges.MoveFirst
        While Not rsOtherCharges.EOF
            CurrRow = getFlexPos(Grid, 1, rsOtherCharges!OtherChargesID)
        
            'Add to grid
            With Grid
                If CurrRow < 0 Then
                    'Delete record if doesnt exist in flexgrid
                    DelRecwSQL "[Other Charges]", "OtherChargesID", "", True, rsOtherCharges!OtherChargesID
                End If
            End With
            rsOtherCharges.MoveNext
        Wend
    End If
End Sub

Private Sub txtAmount_GotFocus()
    HLText txtAmount
End Sub

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

Private Sub txtAmount_Validate(Cancel As Boolean)
    txtAmount.Text = toMoney(txtAmount.Text)
End Sub

⌨️ 快捷键说明

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