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

📄 frmreceiptsae.frm

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

Private Sub mnu_Vat_Click()
  If mnu_Vat.Caption = "Show VAT && Taxbase" Then
    Label5.Visible = True
    Label8.Visible = True
    txtTaxBase.Visible = True
    txtVat.Visible = True
    mnu_Vat.Caption = "Hide VAT && Taxbase"
  Else
    Label5.Visible = False
    Label8.Visible = False
    txtTaxBase.Visible = False
    txtVat.Visible = False
    mnu_Vat.Caption = "Show VAT && Taxbase"
  End If
End Sub

Private Sub nsdClient_Change()
    If nsdClient.DisableDropdown = False Then
        txtLocation.Text = nsdClient.getSelValueAt(3)
        txtOwner.Text = nsdClient.getSelValueAt(4)
        txtCreditTerm.Text = nsdClient.getSelValueAt(5)
    End If
End Sub

Private Sub txtCreditTerm2_Validate(Cancel As Boolean)
    txtCreditTerm2.Text = toNumber(txtCreditTerm2.Text)
End Sub

Private Sub txtdisc_Click()
    txtQty_Change
End Sub

Private Sub cmdCancel_Click()
On Error Resume Next

    If blnSave = False Then CN.RollbackTrans
    Unload Me
End Sub

Private Sub txtDisc_GotFocus()
    HLText txtDisc
End Sub

Private Sub txtDisc_LostFocus()
    txtQty_Change
End Sub

Private Sub txtdisc_Validate(Cancel As Boolean)
    txtDisc.Text = toNumber(txtDisc.Text)
End Sub

Private Sub cmdSave_Click()
On Error GoTo err

    'Verify the entries
    If nsdClient.Text = "" Then
        MsgBox "Please select a client.", vbExclamation
        nsdClient.SetFocus
        Exit Sub
    End If
   
    If cIRowCount < 1 Then
        MsgBox "Please enter item to purchase before you can save this record.", vbExclamation
        nsdStock.SetFocus
        Exit Sub
    End If
              
    If MsgBox("This save the record. Do you want to proceed?", vbQuestion + vbYesNo) = vbNo Then Exit Sub

    Dim RSDetails As New Recordset

    RSDetails.CursorLocation = adUseClient
    RSDetails.Open "SELECT * FROM Receipts_Detail WHERE ReceiptID=" & PK, CN, adOpenStatic, adLockOptimistic

    Screen.MousePointer = vbHourglass

    Dim c As Integer

    DeleteItems
    
    'Save the record
    With RS
        If State = adStateAddMode Or State = adStatePopupMode Then
            .AddNew
            ![ReceiptID] = PK
            !ReceiptBatchID = ReceiptBatchPK
            ![ClientID] = nsdClient.BoundText
            
            ![DateAdded] = Now
            ![AddedByFK] = CurrUser.USER_PK
        ElseIf State = adStateEditMode Then
            .Close
            .Open "SELECT * FROM Receipts WHERE ReceiptID=" & PK, CN, adOpenStatic, adLockOptimistic
            
            ![DateModified] = Now
            ![LastUserFK] = CurrUser.USER_PK
        End If
        
        !RouteID = dcRoute.BoundText
        !AgentID = dcAgent.BoundText
        !RefNo = txtRefNo.Text
        !DateIssued = dtpDate.Value
        ![Status] = IIf(cboStatus.Text = "Sold", True, False)
        ![Deducted] = cboDeducted.Text
        ![Notes] = txtNotes.Text

        ![Gross] = toNumber(txtGross(2).Text)
        ![Discount] = txtDesc.Text
        ![TaxBase] = toNumber(txtTaxBase.Text)
        ![Vat] = toNumber(txtVat.Text)
        ![NetAmount] = toNumber(txtNet.Text)

        .Update
    End With
    
    Dim intUnitsOrder As Integer
    Dim intQty As Integer
    
    With Grid
        'Save the details of the records
        For c = 1 To cIRowCount
            .Row = c
            If State = adStateAddMode Or State = adStatePopupMode Then
AddNew:
                'Add qty received in Local Purchase Details
                RSDetails.AddNew

                RSDetails![ReceiptID] = PK
                RSDetails![StockID] = toNumber(.TextMatrix(c, 11))
                RSDetails![Qty] = toNumber(.TextMatrix(c, 3))
                RSDetails![Unit] = getUnitID(.TextMatrix(c, 4))
                RSDetails![Price] = toNumber(.TextMatrix(c, 5))
                RSDetails![ExtPrice] = toNumber(.TextMatrix(c, 6))
                RSDetails![AddCharges] = toNumber(.TextMatrix(c, 7))
                RSDetails![Discount] = toNumber(.TextMatrix(c, 9)) / 100
                RSDetails![Suggested] = .TextMatrix(c, 12)
                RSDetails![CreditTerm] = IIf(.TextMatrix(c, 13) = "", 0, .TextMatrix(c, 13))
                
                RSDetails.Update
                
            ElseIf State = adStateEditMode Then
                RSDetails.Filter = "StockID = " & toNumber(.TextMatrix(c, 11))
            
                If RSDetails.RecordCount = 0 Then GoTo AddNew
                
                RSDetails![ReceiptID] = PK
                RSDetails![StockID] = toNumber(.TextMatrix(c, 11))
                RSDetails![Qty] = toNumber(.TextMatrix(c, 3))
                RSDetails![Unit] = getUnitID(.TextMatrix(c, 4))
                RSDetails![Price] = toNumber(.TextMatrix(c, 5))
                RSDetails![ExtPrice] = toNumber(.TextMatrix(c, 6))
                RSDetails![AddCharges] = toNumber(.TextMatrix(c, 7))
                RSDetails![Discount] = toNumber(.TextMatrix(c, 9)) / 100
                RSDetails![Suggested] = .TextMatrix(c, 12)
                RSDetails![CreditTerm] = IIf(.TextMatrix(c, 13) = "", 0, .TextMatrix(c, 13))
                
                RSDetails.Update
                
            End If
            
        Next c
    End With

    If cboStatus.Text = "Sold" Then
        Dim RSClientsLedger As New Recordset
    
        RSClientsLedger.CursorLocation = adUseClient
        RSClientsLedger.Open "SELECT * FROM Clients_Ledger WHERE LedgerID=" & 0, CN, adOpenStatic, adLockOptimistic
    
        With RSClientsLedger
            .AddNew
            
            !LedgerID = getIndex("Clients_Ledger")
            !ReceiptID = PK
            !ReceiptBatchID = IIf(ReceiptBatchPK <> 0, ReceiptBatchPK, 0)
            !ClientID = IIf(nsdClient.BoundText = "", nsdClient.Tag, nsdClient.BoundText)
            !Date = dtpDeliveryDate.Value
            !RefNo = txtRefNo.Text
            !ChargeAccount = "Credit"
            !Debit = txtNet.Text
            
            .Update
        End With
    End If
    
    If cmdSave.Caption = "&Payment" And cboStatus.Text = "Sold" Then
        With frmPayment
            .PK = PK
            .ClientID = IIf(nsdClient.BoundText = "", nsdClient.Tag, nsdClient.BoundText)
            .strCustomer = nsdClient.Text
            .strRefNo = txtRefNo.Text
            .TotalAmount = txtNet.Text
            
            .show vbModal
        End With
    End If
    
    'Clear variables
    c = 0
    Set RSDetails = Nothing
'    Set RSClientsLedger = Nothing
    CN.CommitTrans
    
    blnSave = True
    
    HaveAction = True
    Screen.MousePointer = vbDefault

    If State = adStateAddMode Then
        MsgBox "New record has been successfully saved.", vbInformation
               
        If MsgBox("Do you want to add another new record?", vbQuestion + vbYesNo) = vbYes Then
            ResetFields
            GeneratePK
            
            CN.BeginTrans
        Else
            Unload Me
        End If
    Else
        MsgBox "Changes in record has been successfully saved.", vbInformation
        Unload Me
    End If

    Exit Sub
err:
    blnSave = False
    
    prompt_err err, Name, "cmdSave_Click"
    Screen.MousePointer = vbDefault
End Sub

Private Sub Form_Activate()
    On Error Resume Next
    If CloseMe = True Then
        Unload Me
    Else
        nsdClient.SetFocus
    End If
End Sub

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

Private Sub Form_Load()
    Dim strRoute As String
    
    InitGrid
    
    bind_dc "SELECT * FROM Routes", "Desc", dcRoute, "RouteID", True
    bind_dc "SELECT * FROM Agents", "AgentName", dcAgent, "AgentID", True
    
    'zero means walk-in customer
    If ReceiptBatchPK = 0 Then _
        dcRoute.BoundText = 21
        
    'Check the form state
    If State = adStateAddMode Or State = adStatePopupMode Then
    InitNSD
    
    'Set the recordset
    RS.CursorLocation = adUseClient
    If RS.State = 1 Then RS.Close
        RS.Open "SELECT * FROM Receipts WHERE ReceiptID=" & PK, CN, adOpenStatic, adLockOptimistic
        dtpDate.Value = Date
        mnu_Return.Enabled = False
        
        GeneratePK
        CN.BeginTrans

        If strRouteDesc <> "" Then _
            dcRoute.Text = strRouteDesc
        
        strRoute = getValueAt("SELECT Route, RouteID FROM Routes WHERE RouteID=" & dcRoute.BoundText, "Route")
        txtRefNo.Text = strRoute & Format(Date, "yy") & Format(PK, "000000")
    Else
        Screen.MousePointer = vbHourglass
        'Set the recordset
        RS.Open "SELECT * FROM qry_Receipts WHERE ReceiptID=" & PK, CN, adOpenStatic, adLockOptimistic
        
        cmdPrint.Visible = True
        
        If State = adStateViewMode Then
            cmdCancel.Caption = "Close"
            DisplayForViewing
        Else
            mnu_Return.Enabled = False
            InitNSD
            
            CN.BeginTrans
            
            DisplayForEditing
        End If
    
        If ForCusAcc = True Then
            Me.Icon = frmSalesReceipts.Icon
        End If

        Screen.MousePointer = vbDefault
    End If
    
    'Initialize Graphics
    With MAIN
        'cmdGenerate.Picture = .i16x16.ListImages(14).Picture
        'cmdNew.Picture = .i16x16.ListImages(10).Picture
        'cmdReset.Picture = .i16x16.ListImages(15).Picture
    End With
End Sub

'Procedure used to generate PK
Private Sub GeneratePK()
    PK = getIndex("Receipts")
End Sub

'Procedure used to initialize the grid
Private Sub InitGrid()
    cIRowCount = 0
    With Grid
        .Clear
        .ClearStructure
        .Rows = 2
        .FixedRows = 1
        .FixedCols = 1
        .Cols = 15
        .ColSel = 14
        'Initialize the column size
        .ColWidth(0) = 315
        .ColWidth(1) = 0
        .ColWidth(2) = 2505
        .ColWidth(3) = 1000
        .ColWidth(4) = 900
        .ColWidth(5) = 900
        .ColWidth(6) = 900
        .ColWidth(7) = 1200
        .ColWidth(8) = 900
        .ColWidth(9) = 1200
        .ColWidth(10) = 1200
        .ColWidth(11) = 0
        'Initialize the column name
        .TextMatrix(0, 0) = ""
        .TextMatrix(0, 1) = "Barcode"
        .TextMatrix(0, 2) = "Description"
        .TextMatrix(0, 3) = "Qty"
        .TextMatrix(0, 4) = "Unit"
        .TextMatrix(0, 5) = "Sales Price"
        .TextMatrix(0, 6) = "Ext Price"
        .TextMatrix(0, 7) = "Add. Charges"
        .TextMatrix(0, 8) = "Gross"
        .TextMatrix(0, 9) = "Discount(%)"
        .TextMatrix(0, 10) = "Net Amount"
        .TextMatrix(0, 11) = "Stock ID"
        .TextMatrix(0, 12) = "Suggested"
        .TextMatrix(0, 13) = "Credit Term"
        .TextMatrix(0, 14) = "Free"
        'Set the column alignment
'        .ColAlignment(0) = vbLeftJustify
'        .ColAlignment(1) = vbLeftJustify
        .ColAlignment(2) = vbLeftJustify
'        .ColAlignment(3) = vbLeftJustify
'        .ColAlignment(4) = vbRightJustify
'        .ColAlignment(5) = vbLeftJustify
'        .ColAlignment(6) = vbRightJustify
'        .ColAlignment(7) = vbRightJustify
'        .ColAlignment(8) = vbRightJustify
'        .ColAlignment(9) = vbRightJustify
'        .ColAlignment(11) = vbLeftJustify
'        .ColAlignment(12) = vbRightJustify
    End With
End Sub

Private Sub ResetEntry()
    nsdStock.ResetValue
    txtPrice.Tag = 0
    txtPrice.Text = "0.00"
    txtQty.Text = 0
    txtExtPrice.Text = "0.00"
End Sub

Private Sub Form_Unload(Cancel As Integer)
'    If HaveAction = True Then
'        'frmSalesReceipts.RefreshRecords
'    End If
    
    Set frmSalesReceiptsAE = Nothing
End Sub

Private Sub 

⌨️ 快捷键说明

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