📄 frmlocalpurchaseae.frm
字号:
Screen.MousePointer = vbDefault
End Sub
Private Sub cmdUsrHistory_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 Form_Activate()
On Error Resume Next
If CloseMe = True Then
Unload Me
Else
txtPurchaseFrom.SetFocus
End If
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys ("{tab}")
End Sub
Private Sub Form_Load()
InitGrid
frmPayment.Visible = False
bind_dc "SELECT * FROM Unit", "Unit", dcUnit, "UnitID", True
'Check the form state
If State = adStateAddMode Or State = adStatePopupMode Then
InitNSD
'Set the recordset
rs.Open "SELECT * FROM Local_Purchase WHERE LocalPurchaseID=" & PK, CN, adOpenStatic, adLockOptimistic
dtpDate.Value = Date
dtpBankDate.Value = Date
Caption = "Create New Entry"
cmdUsrHistory.Enabled = False
GeneratePK
Else
Screen.MousePointer = vbHourglass
'Set the recordset
rs.Open "SELECT * FROM Local_Purchase WHERE LocalPurchaseID=" & PK, CN, adOpenStatic, adLockOptimistic
cmdCancel.Caption = "Close"
cmdUsrHistory.Enabled = True
DisplayForViewing
If ForCusAcc = True Then
Me.Icon = frmLocalPurchase.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("Local_Purchase")
End Sub
'Procedure used to initialize the grid
Private Sub InitGrid()
cIRowCount = 0
With Grid
.Clear
.ClearStructure
.Rows = 2
.FixedRows = 1
.FixedCols = 1
.Cols = 11
.ColSel = 10
'Initialize the column size
.ColWidth(0) = 315
.ColWidth(1) = 2025
.ColWidth(2) = 2505
.ColWidth(3) = 1545
.ColWidth(4) = 900
.ColWidth(5) = 900
.ColWidth(6) = 900
.ColWidth(7) = 900
.ColWidth(8) = 900
.ColWidth(9) = 1545
.ColWidth(10) = 0
'Initialize the column name
.TextMatrix(0, 0) = ""
.TextMatrix(0, 1) = "Barcode"
.TextMatrix(0, 2) = "Description"
.TextMatrix(0, 3) = "ICode"
.TextMatrix(0, 4) = "Unit Qty"
.TextMatrix(0, 5) = "Unit"
.TextMatrix(0, 6) = "Sales Price"
.TextMatrix(0, 7) = "Gross"
.TextMatrix(0, 8) = "Discount(%)"
.TextMatrix(0, 9) = "Net Amount"
.TextMatrix(0, 10) = "Stock ID"
'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
End With
End Sub
Private Sub ResetEntry()
nsdStock.ResetValue
txtUnitPrice.Tag = 0
txtUnitPrice.Text = "0.00"
txtQty.Text = 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
If HaveAction = True Then
frmLocalPurchase.RefreshRecords
End If
Set frmLocalPurchaseAE = Nothing
End Sub
Private Sub Grid_Click()
If State = adStateEditMode Then Exit Sub
If Grid.Rows = 2 And Grid.TextMatrix(1, 10) = "" Then
btnRemove.Visible = False
Else
btnRemove.Visible = True
btnRemove.Top = (Grid.CellTop + Grid.Top) - 20
btnRemove.Left = Grid.Left + 50
End If
End Sub
Private Sub Grid_Scroll()
btnRemove.Visible = False
End Sub
Private Sub Grid_SelChange()
Grid_Click
End Sub
Private Sub nsdStock_Change()
txtQty.Text = "0"
'txtUnitPrice.Tag = nsdStock.getSelValueAt(3) 'Unit Cost
txtUnitPrice.Text = toMoney(nsdStock.getSelValueAt(3)) 'Selling Price
End Sub
Private Sub txtDate_GotFocus()
HLText txtDate
End Sub
Private Sub txtDesc_GotFocus()
HLText txtDesc
End Sub
Private Sub txtQty_Validate(Cancel As Boolean)
txtQty.Text = toNumber(txtQty.Text)
End Sub
Private Sub txtUnitPrice_Change()
txtQty_Change
End Sub
Private Sub txtUnitPrice_Validate(Cancel As Boolean)
txtUnitPrice.Text = toMoney(toNumber(txtUnitPrice.Text))
End Sub
Private Sub txtQty_Change()
If toNumber(txtQty.Text) < 1 Then
btnAdd.Enabled = False
Else
btnAdd.Enabled = True
End If
txtGross(1).Text = toMoney((toNumber(txtQty.Text) * toNumber(txtUnitPrice.Text)))
txtNetAmount.Text = toMoney((toNumber(txtQty.Text) * toNumber(txtUnitPrice.Text)) - ((toNumber(txtDisc.Text) / 100) * toNumber(toNumber(txtQty.Text) * toNumber(txtUnitPrice.Text))))
'If toNumber(txtQty.Text) < 1 Then txtNetPrice.Text = 0: Exit Sub
'txtNetPrice.Text = toMoney(toNumber(txtUnitPrice.Text)) - ((toNumber(txtUnitPrice.Text) * (toNumber(txtdisc.Text) / 100)))
End Sub
Private Sub txtQty_GotFocus()
HLText txtQty
End Sub
Private Sub txtUnitPrice_KeyPress(KeyAscii As Integer)
KeyAscii = isNumber(KeyAscii)
End Sub
'Procedure used to reset fields
Private Sub ResetFields()
InitGrid
ResetEntry
txtPurchaseFrom.Text = ""
txtInvoiceNo.Text = ""
dtpDate.Value = Date
txtPurchaseRequest.Text = ""
txtCanvass.Text = ""
txtCash.Text = ""
txtBank.Text = ""
txtCheck.Text = ""
txtCheckAmount.Text = ""
txtRemarks.Text = ""
txtGross(2).Text = "0.00"
txtDesc.Text = "0.00"
txtTaxBase.Text = "0.00"
txtVat.Text = "0.00"
txtNet.Text = "0.00"
cIAmount = 0
cDAmount = 0
txtPurchaseFrom.SetFocus
End Sub
'Used to display record
Private Sub DisplayForViewing()
On Error GoTo err
txtPurchaseFrom.Text = rs![PurchaseFrom]
txtInvoiceNo.Text = rs![InvoiceNo]
txtDate.Text = Format$(rs![Date], "MMM-dd-yyyy")
txtPurchaseRequest.Text = rs![PurchaseRequestNo]
txtCanvass.Text = rs![CanvasSheetNo]
'Display payment type
If rs![PaymentType] = "Cash" Then
cmbPaymentType.ListIndex = 0
txtCash.Text = rs!Cash
ElseIf rs![PaymentType] = "Bank" Then
cmbPaymentType.ListIndex = 1
Dim RSChecks As New Recordset
RSChecks.CursorLocation = adUseClient
RSChecks.Open "SELECT * FROM Local_Purchase_Checks WHERE LocalPurchaseID=" & PK, CN, adOpenStatic, adLockOptimistic
With RSChecks
txtBank.Text = ![Bank]
dtpBankDate.Visible = False
txtBankDate.Visible = True
txtBankDate.Text = ![Checkdate]
txtCheck.Text = ![CheckNo]
txtCheckAmount.Text = ![CheckAmount]
End With
End If
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])
txtRemarks.Text = rs![Remarks]
'Display the details
Dim RSDetails As New Recordset
RSDetails.CursorLocation = adUseClient
RSDetails.Open "SELECT * FROM qry_Local_Purchase_Detail WHERE LocalPurchaseID=" & PK & " 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, 10) = "" Then
.TextMatrix(1, 1) = RSDetails![Barcode]
.TextMatrix(1, 2) = RSDetails![Stock]
.TextMatrix(1, 3) = RSDetails![ICode]
.TextMatrix(1, 4) = RSDetails![Qty]
.TextMatrix(1, 5) = RSDetails![Unit]
.TextMatrix(1, 6) = toMoney(RSDetails![Price])
.TextMatrix(1, 7) = toMoney(RSDetails![Gross])
.TextMatrix(1, 8) = RSDetails![Discount] * 100
.TextMatrix(1, 9) = toMoney(RSDetails![NetAmount])
.TextMatrix(1, 10) = RSDetails![StockID]
Else
.Rows = .Rows + 1
.TextMatrix(.Rows - 1, 1) = RSDetails![Barcode]
.TextMatrix(.Rows - 1, 2) = RSDetails![Stock]
.TextMatrix(.Rows - 1, 3) = RSDetails![ICode]
.TextMatrix(.Rows - 1, 4) = RSDetails![Qty]
.TextMatrix(.Rows - 1, 5) = RSDetails![Unit]
.TextMatrix(.Rows - 1, 6) = RSDetails![Price]
.TextMatrix(.Rows - 1, 7) = RSDetails![Gross]
.TextMatrix(.Rows - 1, 8) = RSDetails![Discount] * 100
.TextMatrix(.Rows - 1, 9) = toMoney(RSDetails![NetAmount])
.TextMatrix(.Rows - 1, 10) = 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
dtpDate.Visible = False
txtDate.Visible = True
picPurchase.Visible = False
cmdSave.Visible = False
btnAdd.Visible = False
CmdReturn.Left = cmdSave.Left
CmdReturn.Visible = True
'Resize and reposition the controls
Shape3.Top = 2800
Label11.Top = 2800
Line1(1).Visible = False
Line2(1).Visible = False
Grid.Top = 3100
Grid.Height = 3380
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 InitNSD()
'For Product
With nsdStock
.ClearColumn
.AddColumn "Barcode", 2064.882
.AddColumn "Stock", 4085.26
.AddColumn "Cost", 1500
.AddColumn "Sales Price", 1500
.AddColumn "ICode", 1500
.Connection = CN.ConnectionString
.sqlFields = "Barcode,Stock,Cost,SalesPrice,ICode,StockID"
.sqlTables = "Stocks"
.sqlSortOrder = "Stock ASC"
.BoundField = "StockID"
.PageBy = 25
.DisplayCol = 2
.setDropWindowSize 6800, 4000
.TextReadOnly = True
.SetDropDownTitle = "Stocks"
End With
End Sub
Private Sub txtUnitPrice_GotFocus()
HLText txtUnitPrice
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -