📄 frmcustomersae.frm
字号:
End Sub
Private Sub ResetFields()
clearText Me
txtEntry(15).Text = "0.00"
txtEntry(1).SetFocus
End Sub
Private Sub cmdPH_Click()
'frmInvoiceViewer.CUS_PK = PK
'frmInvoiceViewer.Caption = "Purchase History Viewer"
'frmInvoiceViewer.lblTitle.Caption = "Purchase History Viewer"
'frmInvoiceViewer.show vbModal
End Sub
Private Sub cmdSave_Click()
On Error GoTo err
If Trim(txtEntry(1).Text) = "" Then Exit Sub
CN.BeginTrans
If State = adStateAddMode Or State = adStatePopupMode Then
rs.AddNew
rs.Fields("ClientID") = PK
rs.Fields("AddedByFK") = CurrUser.USER_PK
Else
rs.Fields("DateModified") = Now
rs.Fields("LastUserFK") = CurrUser.USER_PK
End If
With rs
.Fields("Company") = txtEntry(1).Text
.Fields("CategoryID") = dcCategory.BoundText
.Fields("Tin") = txtEntry(2).Text
.Fields("OwnersName") = txtEntry(3).Text
.Fields("Address") = txtEntry(4).Text
.Fields("CityID") = dcCity.BoundText
.Fields("PurchaserName") = txtEntry(6).Text
.Fields("Mobile") = txtEntry(7).Text
.Fields("Landline") = txtEntry(8).Text
.Fields("Fax") = txtEntry(9).Text
.Fields("CreditTerm") = toNumber(txtEntry(14).Text)
.Fields("CreditLimit") = toNumber(txtEntry(15).Text)
.Fields("BlackListed") = IIf(chkBlackListed.Value = 1, True, False)
.Fields("Remarks") = txtEntry(16).Text
.Update
End With
Dim rsClientBank As New Recordset
rsClientBank.CursorLocation = adUseClient
rsClientBank.Open "SELECT * FROM Clients_Bank WHERE ClientID=" & PK, CN, adOpenStatic, adLockOptimistic
DeleteItems
Dim c As Integer
With Grid
'Save the details of the records
For c = 1 To cIRowCount
.Row = c
If State = adStateAddMode Or State = adStatePopupMode Then
AddNew:
'Add qty received in Local Purchase Details
rsClientBank.AddNew
rsClientBank![ClientID] = PK
rsClientBank![BankID] = toNumber(.TextMatrix(c, 5))
rsClientBank![AccountNo] = .TextMatrix(c, 3)
rsClientBank![AccountName] = .TextMatrix(c, 4)
rsClientBank.Update
ElseIf State = adStateEditMode Then
rsClientBank.Filter = "BankID = " & toNumber(.TextMatrix(c, 5))
If rsClientBank.RecordCount = 0 Then GoTo AddNew
rsClientBank![ClientID] = PK
rsClientBank![BankID] = toNumber(.TextMatrix(c, 5))
rsClientBank![AccountNo] = .TextMatrix(c, 3)
rsClientBank![AccountName] = .TextMatrix(c, 4)
rsClientBank.Update
End If
Next c
End With
'Clear variables
c = 0
Set rsClientBank = Nothing
CN.CommitTrans
HaveAction = True
If State = adStateAddMode Then
MsgBox "New record has been successfully saved.", vbInformation
If MsgBox("Do you want to add another new record?", vbQuestion + vbYesNo) = vbYes Then
ResetFields
Else
Unload Me
End If
ElseIf State = adStatePopupMode Then
MsgBox "New record has been successfully saved.", vbInformation
Unload Me
Else
MsgBox "Changes in record has been successfully saved.", vbInformation
Unload Me
End If
Exit Sub
err:
CN.RollbackTrans
prompt_err err, Name, "cmdSave_Click"
Screen.MousePointer = vbDefault
End Sub
Private Sub cmdUsrHistory_Click()
On Error Resume Next
Dim tDate1 As String
Dim tDate2 As String
Dim tUser1 As String
Dim tUser2 As String
tDate1 = Format$(rs.Fields("DateAdded"), "MMM-dd-yyyy HH:MM AMPM")
tDate2 = Format$(rs.Fields("DateModified"), "MMM-dd-yyyy HH:MM AMPM")
tUser1 = getValueAt("SELECT PK,CompleteName FROM tbl_SM_Users WHERE PK = " & rs.Fields("AddedByFK"), "CompleteName")
tUser2 = getValueAt("SELECT PK,CompleteName FROM tbl_SM_Users WHERE PK = " & rs.Fields("LastUserFK"), "CompleteName")
MsgBox "Date Added: " & tDate1 & vbCrLf & _
"Added By: " & tUser1 & vbCrLf & _
"" & vbCrLf & _
"Last Modified: " & tDate2 & vbCrLf & _
"Modified By: " & tUser2, vbInformation, "Modification History"
tDate1 = vbNullString
tDate2 = vbNullString
tUser1 = vbNullString
tUser2 = vbNullString
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And blnRemarks = False Then
SendKeys "{TAB}"
End If
End Sub
Private Sub Form_Load()
InitGrid
InitNSD
rs.CursorLocation = adUseClient
rs.Open "SELECT * FROM Clients WHERE ClientID = " & PK, CN, adOpenStatic, adLockOptimistic
rsClientBank.CursorLocation = adUseClient
rsClientBank.Open "SELECT * FROM qry_Clients_Bank WHERE ClientID = " & PK, CN, adOpenStatic, adLockOptimistic
bind_dc "SELECT * FROM Clients_Category", "Category", dcCategory, "CategoryID", True
bind_dc "SELECT * FROM Cities", "City", dcCity, "CityID", True
'Check the form state
If State = adStateAddMode Or State = adStatePopupMode Then
Caption = "Create New Entry"
cmdUsrHistory.Enabled = False
GeneratePK
Else
Caption = "Edit Entry"
DisplayForEditing
cmdPH.Enabled = True
End If
End Sub
'Procedure used to generate PK
Private Sub GeneratePK()
PK = getIndex("Clients")
End Sub
Private Sub Form_Unload(Cancel As Integer)
If HaveAction = True Then
If State = adStateAddMode Or State = adStateEditMode Then
frmCustomers.RefreshRecords
ElseIf State = adStatePopupMode Then
srcText.Text = txtEntry(0).Text
srcText.Tag = PK
On Error Resume Next
srcTextAdd.Text = rs![DisplayAddr]
srcTextCP.Text = txtEntry(6).Text
'srcTextDisc.Text = toNumber(cmdDisc.Text)
End If
End If
Set frmCustomersAE = Nothing
End Sub
Private Sub ResetEntry()
txtBranch.Text = ""
txtAcctNo.Text = ""
txtAcctName.Text = ""
End Sub
Private Sub Grid_Click()
With Grid
nsdBank.Text = .TextMatrix(.RowSel, 1)
nsdBank.Tag = .TextMatrix(.RowSel, 5) 'Add tag coz boundtext is empty
txtBranch.Text = .TextMatrix(.RowSel, 2)
txtAcctNo.Text = .TextMatrix(.RowSel, 3)
txtAcctName.Text = .TextMatrix(.RowSel, 4)
If Grid.Rows = 2 And Grid.TextMatrix(1, 5) = "" Then '10 = StockID
btnRemove.Visible = False
Else
btnRemove.Visible = True
btnRemove.Top = (Grid.CellTop + Grid.Top) - 20
btnRemove.Left = Grid.Left + 50
End If
End With
End Sub
Private Sub nsdBank_Change()
txtBranch.Text = nsdBank.getSelValueAt(3)
End Sub
Private Sub txtEntry_GotFocus(Index As Integer)
If Index = 16 Then
blnRemarks = True
Exit Sub
Else
blnRemarks = False
End If
HLText txtEntry(Index)
End Sub
Private Sub txtEntry_KeyPress(Index As Integer, KeyAscii As Integer)
If Index = 15 Then KeyAscii = isNumber(KeyAscii)
End Sub
'Procedure used to initialize the grid
Private Sub InitGrid()
cIRowCount = 0
With Grid
.Clear
.ClearStructure
.Rows = 2
.FixedRows = 1
.FixedCols = 1
.Cols = 6
.ColSel = 5
'Initialize the column size
.ColWidth(0) = 315
.ColWidth(1) = 1400
.ColWidth(2) = 1500
.ColWidth(3) = 1400
.ColWidth(4) = 1500
.ColWidth(5) = 0
'Initialize the column name
.TextMatrix(0, 0) = ""
.TextMatrix(0, 1) = "Bank"
.TextMatrix(0, 2) = "Branch"
.TextMatrix(0, 3) = "Acct. No."
.TextMatrix(0, 4) = "Acct. Name"
.TextMatrix(0, 5) = "Bank ID"
'Set the column alignment
.ColAlignment(0) = vbLeftJustify
.ColAlignment(1) = vbLeftJustify
.ColAlignment(2) = vbLeftJustify
.ColAlignment(3) = vbLeftJustify
.ColAlignment(4) = vbRightJustify
End With
End Sub
Private Sub InitNSD()
'For Bank
With nsdBank
.ClearColumn
.AddColumn "Bank ID", 1794.89
.AddColumn "Bank", 2264.88
.AddColumn "Branch", 2670.23
.Connection = CN.ConnectionString
'.sqlFields = "VendorID, Company, Location"
.sqlFields = "BankID, Bank, Branch"
.sqlTables = "Banks"
.sqlSortOrder = "Bank ASC"
.BoundField = "BankID"
.PageBy = 25
.DisplayCol = 2
.setDropWindowSize 7000, 4000
.TextReadOnly = True
.SetDropDownTitle = "Banks Record"
End With
End Sub
Private Sub DeleteItems()
Dim CurrRow As Integer
Dim RSBank As New Recordset
If State = adStateAddMode Then Exit Sub
RSBank.CursorLocation = adUseClient
RSBank.Open "SELECT * FROM Clients_Bank WHERE ClientID=" & PK, CN, adOpenStatic, adLockOptimistic
If RSBank.RecordCount > 0 Then
RSBank.MoveFirst
While Not RSBank.EOF
CurrRow = getFlexPos(Grid, 5, RSBank!BankID)
'Add to grid
With Grid
If CurrRow < 0 Then
'Delete record if doesnt exist in flexgrid
DelRecwSQL "Clients_Bank", "PK", "", True, RSBank!PK
End If
End With
RSBank.MoveNext
Wend
End If
End Sub
Private Sub txtEntry_Validate(Index As Integer, Cancel As Boolean)
txtEntry(14).Text = toNumber(txtEntry(14).Text)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -