📄 frmsalesorderae.frm
字号:
Height = 225
Left = 5790
TabIndex = 53
Top = 750
Width = 1275
End
Begin VB.Label Label11
BackStyle = 0 'Transparent
Caption = "Local Purchase 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 = 32
Top = 3600
Width = 4365
End
Begin VB.Label lblTitle
BackStyle = 0 'Transparent
Caption = "Sales Order"
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 = 30
Top = 150
Width = 4905
End
Begin VB.Label Label16
Alignment = 1 'Right Justify
Caption = "Salesman:"
Height = 225
Left = 210
TabIndex = 49
Top = 2100
Width = 1275
End
Begin VB.Label Labels
Alignment = 1 'Right Justify
Caption = "Date:"
Height = 225
Index = 1
Left = 210
TabIndex = 48
Top = 1755
Width = 1275
End
Begin VB.Label Labels
Alignment = 1 'Right Justify
Caption = "Client:"
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 = 210
TabIndex = 47
Top = 1080
Width = 1275
End
Begin VB.Label Label15
Alignment = 1 'Right Justify
Caption = "Address:"
Height = 225
Left = 210
TabIndex = 46
Top = 1440
Width = 1275
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
Caption = "SO No.:"
Height = 225
Left = 210
TabIndex = 45
Top = 720
Width = 1275
End
Begin VB.Shape Shape4
BorderColor = &H80000006&
BorderWidth = 2
Height = 8895
Left = 60
Top = 60
Width = 11085
End
Begin VB.Shape Shape1
Height = 8235
Left = 120
Top = 630
Width = 10935
End
Begin VB.Label Label4
Alignment = 1 'Right Justify
Caption = "Discount"
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 = 7440
TabIndex = 38
Top = 6930
Width = 2040
End
Begin VB.Label Labels
Caption = "Remarks"
Height = 240
Index = 4
Left = 240
TabIndex = 37
Top = 6600
Width = 990
End
Begin VB.Label Label3
Alignment = 1 'Right Justify
Caption = "Gross"
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 = 7440
TabIndex = 36
Top = 6630
Width = 2040
End
Begin VB.Line Line2
BorderColor = &H80000014&
Index = 1
X1 = 210
X2 = 10935
Y1 = 2790
Y2 = 2790
End
Begin VB.Line Line1
BorderColor = &H80000010&
BorderWidth = 2
Index = 1
X1 = 210
X2 = 10935
Y1 = 2790
Y2 = 2790
End
Begin VB.Label Label9
Alignment = 1 'Right Justify
Caption = "Net"
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 = 7440
TabIndex = 35
Top = 7980
Width = 2040
End
Begin VB.Shape Shape3
BackColor = &H80000010&
BackStyle = 1 'Opaque
BorderColor = &H80000010&
Height = 240
Left = 240
Top = 3600
Width = 10740
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 = 7440
TabIndex = 34
Top = 7230
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 = 7440
TabIndex = 33
Top = 7530
Width = 2040
End
Begin VB.Line Line3
BorderColor = &H80000000&
BorderWidth = 2
X1 = 9210
X2 = 10920
Y1 = 7890
Y2 = 7890
End
Begin VB.Label Label10
Caption = "Label10"
Height = 525
Left = 5100
TabIndex = 31
Top = 4290
Width = 1245
End
Begin VB.Shape Shape2
FillColor = &H00C0C0C0&
FillStyle = 0 'Solid
Height = 435
Left = 120
Top = 120
Width = 10935
End
End
Attribute VB_Name = "frmSalesOrderAE"
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()
If nsdStock.Text = "" Then nsdStock.SetFocus: Exit Sub
If toNumber(txtUnitPrice.Text) <= 0 Then
MsgBox "Please enter a valid sales price.", vbExclamation
txtUnitPrice.SetFocus
Exit Sub
End If
Dim CurrRow As Integer
CurrRow = getFlexPos(Grid, 9, nsdStock.BoundText)
'Add to grid
With Grid
If CurrRow < 0 Then
'Perform if the record is not exist
If .Rows = 2 And .TextMatrix(1, 9) = "" Then
.TextMatrix(1, 1) = nsdStock.getSelValueAt(1)
.TextMatrix(1, 2) = nsdStock.Text
.TextMatrix(1, 3) = txtQty.Text
.TextMatrix(1, 4) = dcUnit.Text
.TextMatrix(1, 5) = toMoney(txtUnitPrice.Text)
.TextMatrix(1, 6) = toMoney(txtGross(1).Text)
.TextMatrix(1, 7) = toNumber(txtDisc.Text)
.TextMatrix(1, 8) = toMoney(toNumber(txtNetAmount.Text))
.TextMatrix(1, 9) = nsdStock.BoundText
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) = dcUnit.Text
.TextMatrix(.Rows - 1, 5) = toMoney(txtUnitPrice.Text)
.TextMatrix(.Rows - 1, 6) = toMoney(txtGross(1).Text)
.TextMatrix(.Rows - 1, 7) = toNumber(txtDisc.Text)
.TextMatrix(.Rows - 1, 8) = toMoney(toNumber(txtNetAmount.Text))
.TextMatrix(.Rows - 1, 9) = nsdStock.BoundText
.Row = .Rows - 1
End If
'Increase the record count
cIRowCount = cIRowCount + 1
Else
If MsgBox("Invoice payment 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, 6))
txtGross(2).Text = Format$(cIGross, "#,##0.00")
cIAmount = cIAmount - toNumber(Grid.TextMatrix(.RowSel, 8))
txtNet.Text = Format$(cIAmount, "#,##0.00")
cDAmount = cDAmount - toNumber(toNumber(txtDisc.Text) / 100) * (toNumber(toNumber(Grid.TextMatrix(.RowSel, 3)) * toNumber(txtUnitPrice.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) = dcUnit.Text
.TextMatrix(CurrRow, 5) = toMoney(txtUnitPrice.Text)
.TextMatrix(CurrRow, 6) = toMoney(txtGross(1).Text)
.TextMatrix(CurrRow, 7) = toNumber(txtDisc.Text)
.TextMatrix(CurrRow, 8) = toMoney(toNumber(txtNetAmount.Text))
.TextMatrix(CurrRow, 9) = nsdStock.BoundText
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")
cIAmount = cIAmount + toNumber(txtNetAmount.Text)
cDAmount = cDAmount + toNumber(toNumber(txtDisc.Text) / 100) * (toNumber(toNumber(txtQty.Text) * toNumber(txtUnitPrice.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 = 9
'Display a remove button
Grid_Click
'Reset the entry fields
ResetEntry
End With
End Sub
Private Sub btnRemove_Click()
'Remove selected load product
With Grid
'Update grooss to current purchase amount
cIGross = cIGross - toNumber(Grid.TextMatrix(.RowSel, 6))
txtGross(2).Text = Format$(cIGross, "#,##0.00")
'Update amount to current invoice amount
cIAmount = cIAmount - toNumber(Grid.TextMatrix(.RowSel, 8))
txtNet.Text = Format$(cIAmount, "#,##0.00")
'Update discount to current invoice disc
cDAmount = cDAmount - toNumber(toNumber(txtDisc.Text) / 100) * (toNumber(toNumber(Grid.TextMatrix(.RowSel, 3)) * toNumber(Grid.TextMatrix(.RowSel, 5))))
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 CmdReceiveItem_Click()
'Display the details
Dim RSDetails As New Recordset
RSDetails.CursorLocation = adUseClient
RSDetails.Open "SELECT * FROM qry_Sales_Order_Detail WHERE SalesOrderID=" & PK & " AND QtyDue > 0 ORDER BY Stock ASC", CN, adOpenStatic, adLockOptimistic
If RSDetails.RecordCount > 0 Then
With frmSalesOrderDeliveryAE
.State = adStateAddMode
.PK = PK
.show vbModal
End With
Else
MsgBox "All items are already received.", vbInformation
End If
End Sub
Private Sub nsdClient_Change()
If nsdClient.DisableDropdown = False Then
txtAddress.Text = nsdClient.getSelValueAt(3)
End If
End Sub
Private Sub txtdisc_Change()
txtQty_Change
End Sub
Private Sub txtdisc_Click()
txtQty_Change
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub txtDisc_GotFocus()
HLText txtDisc
End Sub
Private Sub txtdisc_Validate(Cancel As Boolean)
txtDisc.Text = toNumber(txtDisc.Text)
End Sub
Private Sub cmdPH_Click()
'frmInvoiceViewerPH.INV_PK = PK
'frmInvoiceViewerPH.Caption = "Payment History Viewer"
'frmInvoiceViewerPH.lblTitle.Caption = "Payment History Viewer"
'frmInvoiceViewerPH.show vbModal
End Sub
Private Sub cmdSave_Click()
'Verify the entries
If nsdClient.BoundText = "" 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 Sales_Order_Detail WHERE SalesOrderID=" & PK, CN, adOpenStatic, adLockOptimistic
Screen.MousePointer = vbHourglass
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -