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

📄 frmreceiptsae.frm

📁 Inventory control system
💻 FRM
📖 第 1 页 / 共 5 页
字号:
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000011D&
      Height          =   240
      Left            =   9960
      TabIndex        =   51
      Top             =   6930
      Width           =   2040
   End
   Begin VB.Shape Shape1 
      Height          =   8295
      Left            =   120
      Top             =   570
      Width           =   13455
   End
   Begin VB.Shape Shape4 
      BorderColor     =   &H80000006&
      BorderWidth     =   2
      Height          =   8895
      Left            =   60
      Top             =   60
      Width           =   13605
   End
   Begin VB.Label Label15 
      Alignment       =   1  'Right Justify
      Caption         =   "Location"
      Height          =   225
      Left            =   270
      TabIndex        =   50
      Top             =   1800
      Width           =   1275
   End
   Begin VB.Label Labels 
      Alignment       =   1  'Right Justify
      Caption         =   "Booking Agent"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   225
      Index           =   0
      Left            =   270
      TabIndex        =   49
      Top             =   1110
      Width           =   1275
   End
   Begin VB.Label Labels 
      Alignment       =   1  'Right Justify
      Caption         =   "Date Issued:"
      Height          =   255
      Index           =   1
      Left            =   5730
      TabIndex        =   48
      Top             =   1380
      Width           =   1305
   End
   Begin VB.Label Label16 
      Alignment       =   1  'Right Justify
      Caption         =   "Owner"
      Height          =   225
      Left            =   270
      TabIndex        =   47
      Top             =   2160
      Width           =   1275
   End
   Begin VB.Label lblTitle 
      BackStyle       =   0  'Transparent
      Caption         =   "Sales Receipts"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   14.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   345
      Left            =   240
      TabIndex        =   46
      Top             =   150
      Width           =   4905
   End
   Begin VB.Label Label11 
      BackStyle       =   0  'Transparent
      Caption         =   "Receipt Details"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000014&
      Height          =   210
      Left            =   300
      TabIndex        =   45
      Top             =   3600
      Width           =   4365
   End
   Begin VB.Label Label6 
      Alignment       =   1  'Right Justify
      Caption         =   "DR#/ OR#"
      Height          =   255
      Left            =   5730
      TabIndex        =   44
      Top             =   1050
      Width           =   1305
   End
   Begin VB.Shape Shape2 
      FillColor       =   &H00C0C0C0&
      FillStyle       =   0  'Solid
      Height          =   435
      Left            =   120
      Top             =   120
      Width           =   13455
   End
   Begin VB.Shape Shape3 
      BackColor       =   &H80000010&
      BackStyle       =   1  'Opaque
      BorderColor     =   &H80000010&
      Height          =   240
      Left            =   240
      Top             =   3600
      Width           =   13245
   End
   Begin VB.Menu mnu_Tasks 
      Caption         =   "Sales Receipts Tasks"
      Visible         =   0   'False
      Begin VB.Menu mnu_History 
         Caption         =   "Modification History"
      End
      Begin VB.Menu mnu_Return 
         Caption         =   "Return"
      End
      Begin VB.Menu mnu_Tally 
         Caption         =   "Tally Forms"
      End
      Begin VB.Menu mnu_Loading 
         Caption         =   "Loading Forms"
      End
      Begin VB.Menu mnu_Disc 
         Caption         =   "Overall Disc"
      End
      Begin VB.Menu mnu_Adjust 
         Caption         =   "Adjust"
      End
      Begin VB.Menu mnu_Prn 
         Caption         =   "Prn Ind/Prn Bat"
      End
      Begin VB.Menu mnu_Vat 
         Caption         =   "Show VAT && Taxbase"
      End
   End
End
Attribute VB_Name = "frmSalesReceiptsAE"
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
Public strRouteDesc         As String
Public ReceiptBatchPK       As Long

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
Dim blnSave                 As Boolean
Dim intQtyOld               As Integer 'Old txtQty Value. Hold when editing qty
Dim cSalesPrice             As Currency

Private Sub btnAdd_Click(Index As Integer)
On Error GoTo err
    
    Dim RSStockUnit As New Recordset
    
    Dim intTotalOnhand          As Long
    Dim intTotalIncoming        As Integer
    Dim intTotalOnhInc          As Long  'Total of Onhand + Incoming
    Dim intExcessQty            As Integer
    
    Dim intSuggestedQty         As Integer
    Dim blnAddIncoming          As Boolean
    Dim intQtyOrdered           As Integer 'hold the value of txtQty
    Dim intCount                As Integer
    
    If nsdStock.Text = "" Then nsdStock.SetFocus: Exit Sub
    
    If dcUnit.Text = "" Then
        MsgBox "Please select unit", vbInformation
        dcUnit.SetFocus
        Exit Sub
    End If
    
    Dim CurrRow As Integer

    Dim intStockID As Integer
    
    CurrRow = getFlexPos(Grid, 11, nsdStock.Tag)
    intStockID = nsdStock.Tag
    
    RSStockUnit.CursorLocation = adUseClient
    RSStockUnit.Open "SELECT * FROM qry_Stock_Unit WHERE StockID =" & intStockID & " ORDER BY Stock_Unit.Order ASC", CN, adOpenStatic, adLockOptimistic
    
    If toNumber(txtPrice.Text) <= 0 Then
        MsgBox "Please enter a valid sales price.", vbExclamation
        txtPrice.SetFocus
        Exit Sub
    End If
    
    intQtyOrdered = txtQty.Text

    RSStockUnit.Find "UnitID = " & dcUnit.BoundText

    If RSStockUnit!Onhand < intQtyOrdered Then GoSub GetOnhand

Continue:
    'Save to stock card
    Dim RSStockCard As New Recordset

    RSStockCard.CursorLocation = adUseClient
    RSStockCard.Open "SELECT * FROM Stock_Card", CN, adOpenStatic, adLockOptimistic

    'Add to grid
    With Grid
        If CurrRow < 0 Then
            'Perform if the record is not exist
            If .Rows = 2 And .TextMatrix(1, 11) = "" Then
                .TextMatrix(1, 1) = nsdStock.getSelValueAt(1)
                .TextMatrix(1, 2) = nsdStock.Text
                .TextMatrix(1, 3) = intQtyOrdered 'txtQty.Text
                .TextMatrix(1, 4) = dcUnit.Text
                .TextMatrix(1, 5) = toMoney(txtPrice.Text)
                .TextMatrix(1, 6) = toMoney(txtExtPrice.Text)
                .TextMatrix(1, 7) = toMoney(txtAddCharges.Text)
                .TextMatrix(1, 8) = toMoney(txtGross(1).Text)
                .TextMatrix(1, 9) = toNumber(txtDisc.Text)
                .TextMatrix(1, 10) = toMoney(toNumber(txtNetAmount.Text))
                .TextMatrix(1, 11) = intStockID
                .TextMatrix(1, 12) = False
                .TextMatrix(1, 13) = txtCreditTerm2.Text
                .TextMatrix(1, 14) = changeYNValue(ckFree.Value)
            Else
AddIncoming:
                .Rows = .Rows + 1
                .TextMatrix(.Rows - 1, 1) = nsdStock.getSelValueAt(1)
                .TextMatrix(.Rows - 1, 2) = nsdStock.Text
                .TextMatrix(.Rows - 1, 3) = intQtyOrdered 'txtQty.Text
                .TextMatrix(.Rows - 1, 4) = dcUnit.Text
                .TextMatrix(.Rows - 1, 5) = toMoney(txtPrice.Text)
                .TextMatrix(.Rows - 1, 6) = toMoney(txtExtPrice.Text)
                .TextMatrix(.Rows - 1, 7) = toMoney(txtAddCharges.Text)
                .TextMatrix(.Rows - 1, 8) = toMoney(txtGross(1).Text)
                .TextMatrix(.Rows - 1, 9) = toNumber(txtDisc.Text)
                .TextMatrix(.Rows - 1, 10) = toMoney(toNumber(txtNetAmount.Text))
                .TextMatrix(.Rows - 1, 11) = intStockID
                .TextMatrix(.Rows - 1, 12) = IIf(blnAddIncoming = True And intCount = 2, True, False)
                .TextMatrix(.Rows - 1, 13) = txtCreditTerm2.Text
                .TextMatrix(.Rows - 1, 14) = changeYNValue(ckFree.Value)
                
                .FillStyle = 1

                .Row = .Rows - 1
                .ColSel = 12
                If blnAddIncoming = True And intCount = 2 Then
                    .CellForeColor = vbBlue
                    
                    blnAddIncoming = False
                End If
            End If
            'Increase the record count
            cIRowCount = cIRowCount + 1
        Else
            If .TextMatrix(CurrRow, 4) <> dcUnit.Text Then GoTo AddIncoming
                
            If MsgBox("Item already exist. 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, 10))
                txtNet.Text = Format$(cIAmount, "#,##0.00")
                'Use ExtPrice instead of Sales Price if ExtPrice is more than zero (0)
                cDAmount = cDAmount - toNumber(toNumber(.TextMatrix(.Rows - 1, 9)) / 100) * _
                        (toNumber(toNumber(Grid.TextMatrix(.RowSel, 3)) * _
                        cSalesPrice))
                txtDesc.Text = Format$(cDAmount, "#,##0.00")

                .TextMatrix(CurrRow, 1) = nsdStock.getSelValueAt(1)
                .TextMatrix(CurrRow, 2) = nsdStock.Text
                .TextMatrix(CurrRow, 3) = intQtyOrdered 'txtQty.Text
                .TextMatrix(CurrRow, 4) = dcUnit.Text
                .TextMatrix(CurrRow, 5) = toMoney(txtPrice.Text)
                .TextMatrix(CurrRow, 6) = toMoney(txtExtPrice.Text)
                .TextMatrix(CurrRow, 7) = toMoney(txtAddCharges.Text)
                .TextMatrix(CurrRow, 8) = toMoney(txtGross(1).Text)
                .TextMatrix(CurrRow, 9) = toNumber(txtDisc.Text)
                .TextMatrix(CurrRow, 10) = toMoney(toNumber(txtNetAmount.Text))
                .TextMatrix(CurrRow, 13) = txtCreditTerm2.Text
                .TextMatrix(CurrRow, 14) = changeYNValue(ckFree.Value)

                'deduct qty from Stock Unit's table
                RSStockUnit.Filter = "UnitID = " & dcUnit.BoundText  'getValueAt("SELECT UnitID,Unit FROM Unit WHERE Unit='" & .TextMatrix(c, 4) & "'", "UnitID")

                RSStockUnit!Onhand = RSStockUnit!Onhand + intQtyOld

                RSStockUnit.Update
            Else
                Exit Sub
            End If
        End If
        
        RSStockCard.Filter = "StockID = " & intStockID & " AND RefNo2 = '" & txtRefNo.Text & "'"

        If RSStockCard.RecordCount = 0 Then RSStockCard.AddNew
        
        'Deduct qty solt to stock card
        RSStockCard!Type = "S"
        RSStockCard!UnitID = dcUnit.BoundText
        RSStockCard!RefNo2 = txtRefNo.Text
        RSStockCard!Pieces2 = intQtyOrdered
        'Use ExtPrice instead of Sales Price if ExtPrice is more than zero (0)
        RSStockCard!SalesPrice = cSalesPrice
        RSStockCard!StockID = intStockID

        RSStockCard.Update
        
        RSStockUnit.Find "UnitID = " & dcUnit.BoundText

        'Deduct qty from highest unit breakdown if Onhand is less than qty ordered
        If RSStockUnit!Onhand < intQtyOrdered Then
            DeductOnhand intQtyOrdered, RSStockUnit!Order, True, RSStockUnit
        End If
        
        'deduct qty from Stock Unit's table
        RSStockUnit.Find "UnitID = " & dcUnit.BoundText
        
        RSStockUnit!Onhand = RSStockUnit!Onhand - intQtyOrdered
        
        RSStockUnit.Update
            
        'Add the amount to current load amount
        cIGross = cIGross + toNumber(txtGross(1).Text)
        txtGross(2).Text = Format$(cIGross, "#,##0.00")
        cIAmount = cIAmount + toNumber(txtNetAmount.Text)
        'Use ExtPrice instead of Sales Price if ExtPrice is more than zero (0)
        cDAmount = cDAmount + toNumber(toNumber(txtDisc.Text) / 100) * _
                (toNumber(intQtyOrdered * _
                cSalesPrice))
        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 = 13
        'Display a remove button
        If blnAddIncoming = True Then
            intQtyOrdered = intSuggestedQty
            intCount = 2
            GoSub AddIncoming
            
'            blnAddIncoming = False
        End If
        
        Grid_Click
        'Reset the entry fields
        ResetEntry
    End With
    
    Exit Sub
    
GetOnhand:
    intTotalOnhInc = GetTotalQty("Total", RSStockUnit!Order, RSStockUnit!TotalQty, RSStockUnit)
    
    If intTotalOnhInc > 0 Then
    

⌨️ 快捷键说明

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