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

📄 frmpurchaseorderae.frm

📁 Inventory control system
💻 FRM
📖 第 1 页 / 共 5 页
字号:
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000011D&
      Height          =   240
      Left            =   8310
      TabIndex        =   46
      Top             =   7710
      Width           =   2040
   End
   Begin VB.Shape Shape3 
      BackColor       =   &H80000010&
      BackStyle       =   1  'Opaque
      BorderColor     =   &H80000010&
      Height          =   240
      Left            =   150
      Top             =   3360
      Width           =   11700
   End
   Begin VB.Label Label5 
      Alignment       =   1  'Right Justify
      Caption         =   "Tax Base"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000011D&
      Height          =   240
      Left            =   8310
      TabIndex        =   45
      Top             =   6960
      Visible         =   0   'False
      Width           =   2040
   End
   Begin VB.Label Label8 
      Alignment       =   1  'Right Justify
      Caption         =   "Vat(0.12)"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000011D&
      Height          =   240
      Left            =   8310
      TabIndex        =   44
      Top             =   7260
      Visible         =   0   'False
      Width           =   2040
   End
   Begin VB.Line Line3 
      BorderColor     =   &H80000000&
      BorderWidth     =   2
      X1              =   10080
      X2              =   11790
      Y1              =   7620
      Y2              =   7620
   End
   Begin VB.Label Label10 
      Caption         =   "Label10"
      Height          =   525
      Left            =   5010
      TabIndex        =   42
      Top             =   4050
      Width           =   1245
   End
   Begin VB.Shape Shape2 
      FillColor       =   &H00C0C0C0&
      FillStyle       =   0  'Solid
      Height          =   435
      Left            =   120
      Top             =   120
      Width           =   11805
   End
   Begin VB.Menu mnu_Tasks 
      Caption         =   "Purchase Order Tasks"
      Visible         =   0   'False
      Begin VB.Menu mnu_History 
         Caption         =   "Modification History"
      End
      Begin VB.Menu mnu_ReceiveItem 
         Caption         =   "Receive Items"
      End
      Begin VB.Menu mnu_Vat 
         Caption         =   "Show VAT && Taxbase"
      End
   End
End
Attribute VB_Name = "frmPurchaseOrderAE"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public State                As FormState 'Variable used to determine on how the form used
Public PK                   As Long 'Variable used to get what record is going to edit
Public CloseMe              As Boolean
Public ForCusAcc            As Boolean

Dim cIGross                 As Currency 'Gross Amount
Dim cIAmount                As Currency 'Current Invoice Amount
Dim cDAmount                As Currency 'Current Invoice Discount Amount
Dim cIRowCount              As Integer

Dim HaveAction              As Boolean 'Variable used to detect if the user perform some action
Dim RS                      As New Recordset 'Main recordset for Invoice

Private Sub btnAdd_Click()
    Dim curDiscPerc As Currency
    Dim curExtDiscPerc As Currency

    If nsdStock.Text = "" Then nsdStock.SetFocus: Exit Sub

    If dcUnit.Text = "" Then
        MsgBox "Please select unit", vbInformation
        dcUnit.SetFocus
        Exit Sub
    End If

    If toNumber(txtPrice.Text) <= 0 Then
        MsgBox "Please enter a valid sales price.", vbExclamation
        txtPrice.SetFocus
        Exit Sub
    End If

    Dim CurrRow As Integer
    Dim intStockID As Integer
    
    CurrRow = getFlexPos(Grid, 13, nsdStock.Tag)
    intStockID = nsdStock.Tag

    'Add to grid
    With Grid
        If CurrRow < 0 Then
            'Perform if the record is not exist
            If .Rows = 2 And .TextMatrix(1, 13) = "" Then
                .TextMatrix(1, 1) = nsdStock.getSelValueAt(1)
                .TextMatrix(1, 2) = nsdStock.Text
                .TextMatrix(1, 3) = txtQty.Text
                .TextMatrix(1, 4) = 0
                .TextMatrix(1, 5) = 0
                .TextMatrix(1, 6) = dcUnit.Text
                .TextMatrix(1, 7) = toMoney(txtPrice.Text)
                .TextMatrix(1, 8) = toMoney(txtGross(1).Text)
                .TextMatrix(1, 9) = toMoney(txtDiscPercent.Text)
                .TextMatrix(1, 10) = toNumber(txtExtDiscPerc.Text)
                .TextMatrix(1, 11) = toMoney(txtExtDiscAmt.Text)
                .TextMatrix(1, 12) = toMoney(toNumber(txtNetAmount.Text))
                .TextMatrix(1, 13) = intStockID
            Else
                .Rows = .Rows + 1
                .TextMatrix(.Rows - 1, 1) = nsdStock.getSelValueAt(1)
                .TextMatrix(.Rows - 1, 2) = nsdStock.Text
                .TextMatrix(.Rows - 1, 3) = txtQty.Text
                .TextMatrix(.Rows - 1, 4) = 0
                .TextMatrix(.Rows - 1, 5) = 0
                .TextMatrix(.Rows - 1, 6) = dcUnit.Text
                .TextMatrix(.Rows - 1, 7) = toMoney(txtPrice.Text)
                .TextMatrix(.Rows - 1, 8) = toMoney(txtGross(1).Text)
                .TextMatrix(.Rows - 1, 9) = toMoney(txtDiscPercent.Text)
                .TextMatrix(.Rows - 1, 10) = toNumber(txtExtDiscPerc.Text)
                .TextMatrix(.Rows - 1, 11) = toMoney(txtExtDiscAmt.Text)
                .TextMatrix(.Rows - 1, 12) = toMoney(toNumber(txtNetAmount.Text))
                .TextMatrix(.Rows - 1, 13) = intStockID
                
                .Row = .Rows - 1
            End If
            'Increase the record count
            cIRowCount = cIRowCount + 1
        Else
            If MsgBox("Item already added. Do you want to replace it?", vbQuestion + vbYesNo) = vbYes Then
                .Row = CurrRow
                
                'Restore back the invoice amount and discount
                cIGross = cIGross - toNumber(Grid.TextMatrix(.RowSel, 8))
                txtGross(2).Text = Format$(cIGross, "#,##0.00")
                cIAmount = cIAmount - toNumber(Grid.TextMatrix(.RowSel, 12))
                txtNet.Text = Format$(cIAmount, "#,##0.00")
                
                'Compute discount
                curDiscPerc = .TextMatrix(1, 8) * .TextMatrix(1, 9) / 100
                curExtDiscPerc = .TextMatrix(1, 8) * .TextMatrix(1, 10) / 100
                
                cDAmount = cDAmount - (curDiscPerc + curExtDiscPerc + txtExtDiscAmt.Text)
                
                txtDesc.Text = Format$(cDAmount, "#,##0.00")
                
                .TextMatrix(CurrRow, 1) = nsdStock.getSelValueAt(1)
                .TextMatrix(CurrRow, 2) = nsdStock.Text
                .TextMatrix(CurrRow, 3) = txtQty.Text
                .TextMatrix(CurrRow, 4) = 0
                .TextMatrix(CurrRow, 5) = 0
                .TextMatrix(CurrRow, 6) = dcUnit.Text
                .TextMatrix(CurrRow, 7) = toMoney(txtPrice.Text)
                .TextMatrix(CurrRow, 8) = toMoney(txtGross(1).Text)
                .TextMatrix(CurrRow, 9) = toMoney(txtDiscPercent.Text)
                .TextMatrix(CurrRow, 10) = toNumber(txtExtDiscPerc.Text)
                .TextMatrix(CurrRow, 11) = toMoney(txtExtDiscAmt.Text)
                .TextMatrix(CurrRow, 12) = toMoney(toNumber(txtNetAmount.Text))
                .TextMatrix(CurrRow, 13) = intStockID

            Else
                Exit Sub
            End If
        End If
        'Add the amount to current load amount
        cIGross = cIGross + toNumber(txtGross(1).Text)
        txtGross(2).Text = Format$(cIGross, "#,##0.00")
        
        'Compute discount
        curDiscPerc = txtGross(1).Text * txtDiscPercent.Text / 100
        curExtDiscPerc = txtGross(1).Text * txtExtDiscPerc.Text / 100
        
        cDAmount = curDiscPerc + curExtDiscPerc + txtExtDiscAmt.Text
        
        cIAmount = cIAmount + toNumber(txtNetAmount.Text)
        
        txtDesc.Text = Format$(cDAmount, "#,##0.00")
        txtNet.Text = Format$(cIAmount, "#,##0.00")
        txtTaxBase.Text = toMoney(txtNet.Text / 1.12)
        txtVat.Text = toMoney(txtNet.Text - txtTaxBase.Text)
        
        'Highlight the current row's column
        .ColSel = 12
        'Display a remove button
        Grid_Click
        'Reset the entry fields
        ResetEntry
    End With
End Sub

Private Sub btnRemove_Click()
    Dim curDiscPerc As Currency
    Dim curExtDiscPerc As Currency
    
    'Remove selected load product
    With Grid
        'Update grooss to current purchase amount
        cIGross = cIGross - toNumber(Grid.TextMatrix(.RowSel, 8))
        txtGross(2).Text = Format$(cIGross, "#,##0.00")
        'Update amount to current invoice amount
        cIAmount = cIAmount - toNumber(Grid.TextMatrix(.RowSel, 12))
        txtNet.Text = Format$(cIAmount, "#,##0.00")
        'Update discount to current invoice disc
        curDiscPerc = .TextMatrix(1, 8) * .TextMatrix(1, 9) / 100
        curExtDiscPerc = .TextMatrix(1, 8) * .TextMatrix(1, 10) / 100
        
        cDAmount = cDAmount - (curDiscPerc + curExtDiscPerc + txtExtDiscAmt.Text)
        
        txtDesc.Text = Format$(cDAmount, "#,##0.00")
        txtTaxBase.Text = toMoney(txtNet.Text / 1.12)
        txtVat.Text = toMoney(txtNet.Text - txtTaxBase.Text)
        
        '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 cmdFreightCharges_Click()
    With frmFreightCharges
        .POID = PK
        .VendorPK = nsdVendor.Tag
        
        .show 1
    End With
End Sub

Private Sub mnu_ReceiveItem_Click()
    Dim RSDetails As New Recordset
    
    RSDetails.CursorLocation = adUseClient
    
    If Right(txtLocation.Text, 5) = "Local" Then 'check if local purchase
        RSDetails.CursorLocation = adUseClient
        RSDetails.Open "SELECT * FROM qry_Purchase_Order_Detail WHERE POID=" & PK & " AND QtyDue > 0 ORDER BY Stock ASC", CN, adOpenStatic, adLockOptimistic
        
        If RSDetails.RecordCount > 0 Then
            With frmPOReceiveLocalAE
                .State = adStateAddMode
                .PK = PK
                .show vbModal
            End With
        Else
          MsgBox "All items are already delivered to VT.", vbInformation
        End If
    Else
        RSDetails.Open "SELECT * FROM qry_Purchase_Order_Detail WHERE POID=" & PK & " AND QtyDue > 0 ORDER BY Stock ASC", CN, adOpenStatic, adLockOptimistic
        
        If RSDetails.RecordCount > 0 Then
            With frmForwardersGuideAE
                .State = adStateAddMode
                .PK = PK
                .show vbModal
            End With
        Else
            MsgBox "All items are already forwarded.", vbInformation
        End If
    End If
End Sub

Private Sub CmdTasks_Click()
    PopupMenu mnu_Tasks
End Sub

Private Sub DeleteItems()
    Dim CurrRow As Integer
    Dim RSStocks As New Recordset
    
    If State = adStateAddMode Then Exit Sub
    
    RSStocks.CursorLocation = adUseClient
    RSStocks.Open "SELECT * FROM Purchase_Order_Detail WHERE POID=" & PK, CN, adOpenStatic, adLockOptimistic
    If RSStocks.RecordCount > 0 Then
        RSStocks.MoveFirst
        While Not RSStocks.EOF
            CurrRow = getFlexPos(Grid, 13, RSStocks!StockID)
        
            'Add to grid
            With Grid
                If CurrRow < 0 Then
                    'Delete record if doesnt exist in flexgrid
                    DelRecwSQL "Purchase_Order_Detail", "PODetailID", "", True, RSStocks!PODetailID
                End If
            End With
            RSStocks.MoveNext
        Wend
    End If
End Sub

Private Sub mnu_History_Click()
    On Error Resume Next
    Dim tDate1 As String
    Dim tUser1 As String
    
    tDate1 = Format$(RS.Fields("DateAdded"), "MMM-dd-yyyy HH:MM AMPM")
    
    tUser1 = getValueAt("SELECT PK,CompleteName FROM tbl_SM_Users WHERE PK = " & RS.Fields("AddedByFK"), "CompleteName")
    
    MsgBox "Date Added: " & tDate1 & vbCrLf & _
           "Added By: " & tUser1 & vbCrLf & _
           "" & vbCrLf & _
           "Last Modified: n/a" & vbCrLf & _
           "Modified By: n/a", vbInformation, "Modification History"
           
    tDate1 = vbNullString
    tUser1 = vbNullString
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

⌨️ 快捷键说明

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