📄 frmpurchaseorderreturnae.frm
字号:
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 txtPrice_Change()
txtQty_Change
End Sub
Private Sub txtPrice_Validate(Cancel As Boolean)
txtPrice.Text = toMoney(toNumber(txtPrice.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(txtPrice.Text)))
txtNetAmount.Text = toMoney((toNumber(txtQty.Text) * toNumber(txtPrice.Text)) - ((toNumber(txtDisc.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 Add record
Private Sub DisplayForAdding()
On Error GoTo erR
nsdVendor.Tag = rs!VendorID
nsdVendor.DisableDropdown = True
nsdVendor.TextReadOnly = True
nsdVendor.Text = rs!Company
txtLocation.Text = rs!Location
cboReturnType.Text = "Bad"
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.Tag = rs!VendorID
nsdVendor.Text = rs!Company
txtLocation.Text = rs!Location
txtReturnSlipNo.Text = rs!ReturnSlipNo
dtpDate.Value = rs!Date
cboStatus.Text = rs!Status_Alias
txtGross(2).Text = toMoney(toNumber(rs![Gross]))
txtDesc.Text = toMoney(toNumber(rs![Discount]))
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_Return_Detail WHERE POReturnID=" & 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![Qty]
.TextMatrix(1, 4) = RSDetails![Unit]
.TextMatrix(1, 5) = toMoney(RSDetails![Price])
.TextMatrix(1, 6) = toMoney(RSDetails![Gross])
.TextMatrix(1, 7) = RSDetails![Discount] * 100
.TextMatrix(1, 8) = toMoney(RSDetails![NetAmount])
.TextMatrix(1, 9) = RSDetails![ReturnType]
.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![Qty]
.TextMatrix(.Rows - 1, 4) = RSDetails![Unit]
.TextMatrix(.Rows - 1, 5) = RSDetails![Price]
.TextMatrix(.Rows - 1, 6) = RSDetails![Gross]
.TextMatrix(.Rows - 1, 7) = RSDetails![Discount] * 100
.TextMatrix(.Rows - 1, 8) = toMoney(RSDetails![NetAmount])
.TextMatrix(.Rows - 1, 9) = RSDetails![ReturnType]
.TextMatrix(.Rows - 1, 10) = RSDetails![StockID]
End If
cIRowCount = cIRowCount + 1
End With
RSDetails.MoveNext
Wend
Grid.Row = 1
Grid.ColSel = 9
'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
dtpDate.Visible = True
txtDate.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 display record
Private Sub DisplayForViewing()
On Error GoTo erR
nsdVendor.DisableDropdown = True
nsdVendor.TextReadOnly = True
nsdVendor.Text = rs!Company
txtLocation.Text = rs!Location
txtReturnSlipNo.Text = rs!ReturnSlipNo
txtDate.Text = rs![Date]
cboStatus.Text = rs!Status_Alias
txtGross(2).Text = toMoney(toNumber(rs![Gross]))
txtDesc.Text = toMoney(toNumber(rs![Discount]))
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_Return_Detail WHERE POReturnID=" & 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![Qty]
.TextMatrix(1, 4) = RSDetails![Unit]
.TextMatrix(1, 5) = toMoney(RSDetails![Price])
.TextMatrix(1, 6) = toMoney(RSDetails![Gross])
.TextMatrix(1, 7) = RSDetails![Discount] * 100
.TextMatrix(1, 8) = toMoney(RSDetails![NetAmount])
.TextMatrix(1, 9) = RSDetails![ReturnType]
.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![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![Discount] * 100
.TextMatrix(.Rows - 1, 8) = toMoney(RSDetails![NetAmount])
.TextMatrix(.Rows - 1, 9) = RSDetails![ReturnType]
.TextMatrix(.Rows - 1, 10) = RSDetails![StockID]
End If
End With
RSDetails.MoveNext
Wend
Grid.Row = 1
Grid.ColSel = 8
'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
'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 InitNSD()
'For Vendor
With nsdVendor
.ClearColumn
.AddColumn "Supplier ID", 1794.89
.AddColumn "Supplier", 2264.88
.AddColumn "Location", 2670.23
.AddColumn "Gen Disc (%)", 0
.AddColumn "Credit Term", 0
.Connection = CN.ConnectionString
.sqlFields = "VendorID, Company, Location, GenDiscPercent, CreditTerm"
.sqlTables = "qry_Vendors1"
.sqlSortOrder = "Company ASC"
.BoundField = "VendorID"
.PageBy = 25
.DisplayCol = 2
.setDropWindowSize 7000, 4000
.TextReadOnly = True
.SetDropDownTitle = "Vendors Record"
End With
'For Stock
With nsdStock
.ClearColumn
.AddColumn "Barcode", 2064.882
.AddColumn "Product", 4085.26
.AddColumn "Supplier Price", 1500
.AddColumn "Disc (%)", 1500
.AddColumn "Ext Disc (%)", 0
.AddColumn "Ext Disc (Amt)", 0
.Connection = CN.ConnectionString
.sqlFields = "Barcode,Stock,SupplierPrice,DiscPercent,ExtDiscPercent,ExtDiscAmount,StockID"
'.sqlTables = "Stocks"
.sqlTables = "qry_Vendors_Stocks"
.sqlSortOrder = "Stock ASC"
.BoundField = "StockID"
.PageBy = 25
.DisplayCol = 2
.setDropWindowSize 6800, 4000
.TextReadOnly = True
.SetDropDownTitle = "Stocks"
End With
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) = 1000
.ColWidth(2) = 2505
.ColWidth(3) = 1000
.ColWidth(4) = 900
.ColWidth(5) = 900
.ColWidth(6) = 900
.ColWidth(7) = 1100
.ColWidth(8) = 1200
.ColWidth(9) = 1200
.ColWidth(10) = 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) = "Price"
.TextMatrix(0, 6) = "Gross"
.TextMatrix(0, 7) = "Discount(%)"
.TextMatrix(0, 8) = "Net Amount"
.TextMatrix(0, 9) = "Type of Return"
.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
End With
End Sub
Private Sub DeleteItems()
Dim CurrRow As Integer
Dim RSPOReturn As New Recordset
If State = adStateAddMode Then Exit Sub
RSPOReturn.CursorLocation = adUseClient
RSPOReturn.Open "SELECT * FROM Purchase_Order_Return_Detail WHERE POReturnID=" & PK, CN, adOpenStatic, adLockOptimistic
If RSPOReturn.RecordCount > 0 Then
RSPOReturn.MoveFirst
While Not RSPOReturn.EOF
CurrRow = getFlexPos(Grid, 10, RSPOReturn!StockID)
'Add to grid
With Grid
If CurrRow < 0 Then
'Delete record if doesnt exist in flexgrid
DelRecwSQL "Purchase_Order_Return_Detail", "POReturnDetailID", "", True, RSPOReturn!POReturnDetailID
End If
End With
RSPOReturn.MoveNext
Wend
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -