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

📄 frmpurchaseorderreceiveae.frm

📁 Inventory control system
💻 FRM
📖 第 1 页 / 共 5 页
字号:
End Sub

Private Sub txtQty_Change()
    If toNumber(txtQty.Text) < 1 Then
        btnUpdate.Enabled = False
    Else
        btnUpdate.Enabled = True
    End If
    
    ComputeGrossNet
'    txtGross(1).Text = toMoney((toNumber(txtQty.Text) * toNumber(txtPrice.Text)))
'    txtNetAmount.Text = toMoney((toNumber(txtQty.Text) * toNumber(txtPrice.Text)) - ((toNumber(txtDiscPercent.Text) / 100) * toNumber(toNumber(txtQty.Text) * toNumber(txtPrice.Text))))
End Sub

Private Sub txtQty_GotFocus()
    HLText txtQty
    
'    intQtyOld = txtQty.Text
End Sub

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

'Used to edit record
Private Sub DisplayForAdding()
    On Error GoTo err
    nsdVendor.DisableDropdown = True
    nsdVendor.TextReadOnly = True
    nsdVendor.Text = RS!Company
    txtPONo.Tag = RS!POID
    txtPONo.Text = RS!PONo
    
    txtGross(2).Text = toMoney(toNumber(RS![Gross]))
    txtDesc.Text = toMoney(toNumber(RS![Discount]))
    txtTaxBase.Text = toMoney(RS![TaxBase])
    txtVat.Text = toMoney(RS![Vat])
    txtNet.Text = toMoney(RS![NetAmount])
    txtNotes.Text = RS![Notes]
    
    cIGross = txtGross(2).Text
    cIAmount = txtNet.Text
    cDAmount = txtDesc.Text
    
    'Display the details
    Dim RSDetails As New Recordset

    RSDetails.CursorLocation = adUseClient
    RSDetails.Open "SELECT * FROM qry_Purchase_Order_Detail WHERE POID=" & PK & " AND QtyDue > 0 ORDER BY Stock ASC", CN, adOpenStatic, adLockOptimistic
    
    'Save to Purchase Order Details
'    Dim RSPODetails As New Recordset
'
'    RSPODetails.CursorLocation = adUseClient
'    RSPODetails.Open "SELECT * From Purchase_Order_Detail Where POID = " & PK, CN, adOpenStatic, adLockOptimistic
    
    If RSDetails.RecordCount > 0 Then
        RSDetails.MoveFirst
        While Not RSDetails.EOF
            With Grid
                If .Rows = 2 And .TextMatrix(1, 12) = "" Then
                    .TextMatrix(1, 1) = RSDetails![Barcode]
                    .TextMatrix(1, 2) = RSDetails![Stock]
                    .TextMatrix(1, 3) = RSDetails![QtyDue]
                    .TextMatrix(1, 4) = RSDetails![Unit]
                    .TextMatrix(1, 5) = toMoney(RSDetails![Price])
                    .TextMatrix(1, 6) = toMoney(RSDetails![Gross])
                    .TextMatrix(1, 7) = RSDetails![DiscPercent] * 100
                    .TextMatrix(1, 8) = RSDetails![ExtDiscPercent] * 100
                    .TextMatrix(1, 9) = toMoney(RSDetails![ExtDiscAmt])
                    .TextMatrix(1, 10) = toMoney(RSDetails![NetAmount])
                    .TextMatrix(1, 11) = "MV1"
                    .TextMatrix(1, 12) = RSDetails![StockID]
                    
                    'add qty received in Purchase Order Details
                    RSDetails!QtyReceived = toNumber(RSDetails!QtyReceived) + toNumber(RSDetails![QtyDue])
                    
                    RSDetails.Update
                    '-----------------
                Else
                    .Rows = .Rows + 1
                    .TextMatrix(.Rows - 1, 1) = RSDetails![Barcode]
                    .TextMatrix(.Rows - 1, 2) = RSDetails![Stock]
                    .TextMatrix(.Rows - 1, 3) = RSDetails![QtyDue]
                    .TextMatrix(.Rows - 1, 4) = RSDetails![Unit]
                    .TextMatrix(.Rows - 1, 5) = RSDetails![Price]
                    .TextMatrix(.Rows - 1, 6) = RSDetails![Gross]
                    .TextMatrix(.Rows - 1, 7) = RSDetails![DiscPercent] * 100
                    .TextMatrix(.Rows - 1, 8) = RSDetails![ExtDiscPercent] * 100
                    .TextMatrix(.Rows - 1, 9) = toMoney(RSDetails![ExtDiscAmt])
                    .TextMatrix(.Rows - 1, 10) = toMoney(RSDetails![NetAmount])
                    .TextMatrix(.Rows - 1, 11) = "MV1"
                    .TextMatrix(.Rows - 1, 12) = RSDetails![StockID]
                    
                    'add qty received in Purchase Order Details
                    RSDetails!QtyReceived = toNumber(RSDetails!QtyReceived) + toNumber(RSDetails![QtyDue])
                    
                    RSDetails.Update
                    '-----------------
                End If
                cIRowCount = cIRowCount + 1
            End With
            RSDetails.MoveNext
        Wend
        
        Grid.Row = 1
        Grid.ColSel = 11
        'Set fixed cols
        If State = adStateEditMode Then
            Grid.FixedRows = Grid.Row: 'Grid.SelectionMode = flexSelectionFree
            Grid.FixedCols = 2
        End If
    End If

    RSDetails.Close
    'Clear variables
    Set RSDetails = Nothing
  
    dtpDRDate.Visible = True
    txtDRDate.Visible = False
    lblStatus.Visible = False
    cboStatus.Visible = False
    Exit Sub
err:
    'Error if encounter a null value
    If err.Number = 94 Then
        Resume Next
    Else
        MsgBox err.Description
    End If
End Sub

'Used to edit record
Private Sub DisplayForEditing()
    On Error GoTo err
    nsdVendor.DisableDropdown = True
    nsdVendor.TextReadOnly = True
    nsdVendor.Text = RS!Company
    txtPONo.Tag = RS!POID
    txtPONo.Text = RS!PONo
    PK = RS!POID 'get POID to be make a reference for QtyDue, etc.
    txtDRNo.Text = RS!DRNo
    
    txtDRNo.Text = RS![DRNo]
    dtpDRDate.Value = RS![DRDate]
    txtDeliveryNo.Text = RS![DeliveryNo]
    dtpDeliveryDate.Value = RS![DeliveryDate]
    txtNotes.Text = RS![Notes]
    optReceived.Value = IIf(RS![Remarks] = "R", True, False)
    txtNotes.Text = IIf(IsNull(RS![Notes]), "", RS![Notes])
    cboStatus.Text = RS!Status_Alias
    
    txtGross(2).Text = toMoney(toNumber(RS![Gross]))
    txtDesc.Text = toMoney(toNumber(RS![Discount]))
    txtTaxBase.Text = toMoney(RS![TaxBase])
    txtVat.Text = toMoney(RS![Vat])
    txtNet.Text = toMoney(RS![NetAmount])
    
    cIGross = txtGross(2).Text
    cIAmount = txtNet.Text
    cDAmount = txtDesc.Text
    cIRowCount = 0
    
    'Display the details
    Dim RSDetails As New Recordset

    RSDetails.CursorLocation = adUseClient
    RSDetails.Open "SELECT * FROM qry_Purchase_Order_Receive_Local_Detail WHERE InvoiceID=" & InvoicePK & " ORDER BY Stock ASC", CN, adOpenStatic, adLockOptimistic
    If RSDetails.RecordCount > 0 Then
        RSDetails.MoveFirst
        While Not RSDetails.EOF
            cIRowCount = cIRowCount + 1     'increment
            With Grid
                If .Rows = 2 And .TextMatrix(1, 12) = "" Then
                    .TextMatrix(1, 1) = RSDetails![Barcode]
                    .TextMatrix(1, 2) = RSDetails![Stock]
                    .TextMatrix(1, 3) = RSDetails![Qty]
                    .TextMatrix(1, 4) = RSDetails![Unit]
                    .TextMatrix(1, 5) = toMoney(RSDetails![Price])
                    .TextMatrix(1, 6) = toMoney(RSDetails![Gross])
                    .TextMatrix(1, 7) = RSDetails![DiscPercent] * 100
                    .TextMatrix(1, 8) = RSDetails![ExtDiscPercent] * 100
                    .TextMatrix(1, 9) = toMoney(RSDetails![ExtDiscAmt])
                    .TextMatrix(1, 10) = toMoney(RSDetails![NetAmount])
                    .TextMatrix(1, 11) = toMoney(RSDetails![Warehouse])
                    .TextMatrix(1, 12) = RSDetails![StockID]
                Else
                    .Rows = .Rows + 1
                    .TextMatrix(.Rows - 1, 1) = RSDetails![Barcode]
                    .TextMatrix(.Rows - 1, 2) = RSDetails![Stock]
                    .TextMatrix(.Rows - 1, 3) = RSDetails![Qty]
                    .TextMatrix(.Rows - 1, 4) = RSDetails![Unit]
                    .TextMatrix(.Rows - 1, 5) = toMoney(RSDetails![Price])
                    .TextMatrix(.Rows - 1, 6) = toMoney(RSDetails![Gross])
                    .TextMatrix(.Rows - 1, 7) = RSDetails![DiscPercent] * 100
                    .TextMatrix(.Rows - 1, 8) = RSDetails![ExtDiscPercent] * 100
                    .TextMatrix(.Rows - 1, 9) = toMoney(RSDetails![ExtDiscAmt])
                    .TextMatrix(.Rows - 1, 10) = toMoney(RSDetails![NetAmount])
                    .TextMatrix(.Rows - 1, 11) = toMoney(RSDetails![Warehouse])
                    .TextMatrix(.Rows - 1, 12) = RSDetails![StockID]
                End If
            End With
            RSDetails.MoveNext
        Wend
        Grid.Row = 1
        Grid.ColSel = 11
        'Set fixed cols
        If State = adStateEditMode Then
            Grid.FixedRows = Grid.Row: 'Grid.SelectionMode = flexSelectionFree
            Grid.FixedCols = 2
        End If
    End If

    RSDetails.Close
    'Clear variables
    Set RSDetails = Nothing
  
    dtpDRDate.Visible = True
    txtDRDate.Visible = False
    lblStatus.Visible = True
    cboStatus.Visible = True

    Exit Sub
err:
    'Error if encounter a null value
    If err.Number = 94 Then
        Resume Next
    Else
        MsgBox err.Description
    End If
End Sub

'Used to display record
Private Sub DisplayForViewing()
    On Error GoTo err
    nsdVendor.DisableDropdown = True
    nsdVendor.TextReadOnly = True
    nsdVendor.Text = RS!Company
    txtPONo.Text = RS!PONo
    txtDRNo.Text = RS!DRNo
    
    txtDRNo.Text = RS![DRNo]
    dtpDRDate.Value = RS![DRDate]
    txtDeliveryNo.Text = RS![DeliveryNo]
    dtpDeliveryDate.Value = RS![DeliveryDate]
    txtNotes.Text = RS![Notes]
    optReceived.Value = IIf(RS![Remarks] = "R", True, False)
    cboStatus.Text = RS!Status_Alias
    
    txtGross(2).Text = toMoney(toNumber(RS![Gross]))
    txtDesc.Text = toMoney(toNumber(RS![Discount]))
    txtTaxBase.Text = toMoney(RS![TaxBase])
    txtVat.Text = toMoney(RS![Vat])
    txtNet.Text = toMoney(RS![NetAmount])
    txtNotes.Text = IIf(IsNull(RS![Notes]), "", RS![Notes])
       
    'Display the details
    Dim RSDetails As New Recordset

    RSDetails.CursorLocation = adUseClient
    RSDetails.Open "SELECT * FROM qry_Purchase_Order_Receive_Local_Detail WHERE InvoiceID=" & InvoicePK & " ORDER BY Stock ASC", CN, adOpenStatic, adLockOptimistic
    If RSDetails.RecordCount > 0 Then
        RSDetails.MoveFirst
        While Not RSDetails.EOF
            With Grid
                If .Rows = 2 And .TextMatrix(1, 12) = "" Then
                    .TextMatrix(1, 1) = RSDetails![Barcode]
                    .TextMatrix(1, 2) = RSDetails![Stock]
                    .TextMatrix(1, 3) = RSDetails![Qty]
                    .TextMatrix(1, 4) = RSDetails![Unit]
                    .TextMatrix(1, 5) = toMoney(RSDetails![Price])
                    .TextMatrix(1, 6) = toMoney(RSDetails![Gross])
                    .TextMatrix(1, 7) = RSDetails![DiscPercent] * 100
                    .TextMatrix(1, 8) = RSDetails![ExtDiscPercent] * 100
                    .TextMatrix(1, 9) = toMoney(RSDetails![ExtDiscAmt])
                    .TextMatrix(1, 10) = toMoney(RSDetails![NetAmount])
                    .TextMatrix(1, 11) = toMoney(RSDetails![Warehouse])
                    .TextMatrix(1, 12) = RSDetails![StockID]
                Else
                    .Rows = .Rows + 1
                    .TextMatrix(.Rows - 1, 1) = RSDetails![Barcode]
                    .TextMatrix(.Rows - 1, 2) = RSDetails![Stock]
                    .TextMatrix(.Rows - 1, 3) = RSDetails![Qty]
                    .TextMatrix(.Rows - 1, 4) = RSDetails![Unit]
                    .TextMatrix(.Rows - 1, 5) = toMoney(RSDetails![Price])
                    .TextMatrix(.Rows - 1, 6) = toMoney(RSDetails![Gross])
                    .TextMatrix(.Rows - 1, 7) = RSDetails![DiscPercent] * 100
                    .TextMatrix(.Rows - 1, 8) = RSDetails![ExtDiscPercent] * 100
                    .TextMatrix(.Rows - 1, 9) = toMoney(RSDetails![ExtDiscAmt])
                    .TextMatrix(.Rows - 1, 10) = toMoney(RSDetails![NetAmount])
                    .TextMatrix(.Rows - 1, 11) = toMoney(RSDetails![Warehouse])
                    .TextMatrix(.Rows - 1, 12) = RSDetails![StockID]
                End If
            End With
            RSDetails.MoveNext
        Wend
        Grid.Row = 1
        Grid.ColSel = 10
        'Set fixed cols
        If State = adStateEditMode Then
            Grid.FixedRows = Grid.Row: 'Grid.SelectionMode = flexSelectionFree
            Grid.FixedCols = 2
        End If
    End If

    RSDetails.Close
    'Clear variables
    Set RSDetails = Nothing
  
    'Disable commands
    LockInput Me, True

    dtpDRDate.Visible = True
    txtDRDate.Visible = False
    picPurchase.Visible = False
    cmdSave.Visible = False
    btnUpdate.Visible = False

'    CmdReturn.Left = cmdSave.Left
'    CmdReturn.Visible = True
    
    'Resize and reposition the controls
    'Shape3.Top = 4800
    'Label11.Top = 4800
    'Line1(1).Visible = False
    'Line2(1).Visible = False
    Grid.Top = 3460
    Grid.Height = 3050
    
    Exit Sub
err:
    'Error if encounter a null value
    If err.Number = 94 Then
        Resume Next
    Else
        MsgBox err.Description
    End If
End Sub

Private Sub txtPrice_GotFocus()
    HLText txtPrice
End Sub

Private Sub ComputeGrossNet()
    Dim curDiscPerc As Currency
    Dim curExtDiscPerc As Currency
    
    If toNumber(txtQty.Text) < 1 Or toMoney(txtPrice.Text) < 1 Then Exit Sub
    
    txtGross(1).Text = toMoney(toNumber(txtQty.Text) * toNumber(txtPrice.Text))
    
    curDiscPerc = txtGross(1).Text * txtDiscPercent.Text / 100
    curExtDiscPerc = txtGross(1).Text * txtExtDiscPerc.Text / 100
    
    txtNetAmount.Text = txtGross(1).Text - (curDiscPerc + curExtDiscPerc + txtExtDiscAmt.Text)

    If toNumber(txtQty.Text) < 1 Then
        btnUpdate.Enabled = False
    Else
        btnUpdate.Enabled = True
    End If
End Sub

Private Sub DeleteItems()
    Dim CurrRow As Integer
    Dim RSStocks As New Recordset
'    Dim intStockID As Integer
    
    If State = adStateAddMode Then Exit Sub
    
    RSStocks.CursorLocation = adUseClient
    RSStocks.Open "SELECT * FROM Purchase_Order_Receive_Local_Detail WHERE InvoiceID=" & InvoicePK, CN, adOpenStatic, adLockOptimistic
    If RSStocks.RecordCount > 0 Then
        RSStocks.MoveFirst
        While Not RSStocks.EOF
            CurrRow = ge

⌨️ 快捷键说明

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