home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmCustAccount
- Caption = "Customer Account"
- ClientHeight = 3840
- ClientLeft = 1185
- ClientTop = 1575
- ClientWidth = 7650
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 1
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 4245
- Left = 1125
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 3840
- ScaleWidth = 7650
- Top = 1230
- Width = 7770
- Begin VB.TextBox txtCurrentBalance
- Height = 375
- Left = 4320
- Locked = -1 'True
- TabIndex = 3
- TabStop = 0 'False
- Top = 3240
- Width = 1575
- End
- Begin VB.CommandButton btnPrintStatement
- Caption = "&Print Account Statement"
- Height = 495
- Left = 2520
- TabIndex = 1
- Top = 240
- Width = 2295
- End
- Begin VB.CommandButton btnFindCust
- Caption = "&Close"
- Height = 495
- Left = 6240
- TabIndex = 0
- Top = 3240
- Width = 1095
- End
- Begin VB.Data Orders
- Appearance = 0 'Flat
- Caption = "Orders"
- Connect = ""
- DatabaseName = "C:\VBPROJ\SAMS\VB4DB.MDB"
- Exclusive = 0 'False
- Height = 270
- Left = 120
- Options = 0
- ReadOnly = 0 'False
- RecordsetType = 1 'Dynaset
- RecordSource = "ORDERS"
- Top = 3240
- Visible = 0 'False
- Width = 1935
- End
- Begin Threed.SSPanel SSPanel1
- Height = 375
- Left = 2640
- TabIndex = 2
- Top = 3240
- Width = 1575
- _version = 65536
- _extentx = 2778
- _extenty = 661
- _stockprops = 15
- caption = "Current balance"
- backcolor = 12632256
- End
- Begin Crystal.CrystalReport rptBilling
- Left = 2160
- Top = 3360
- _extentx = 741
- _extenty = 741
- _stockprops = 0
- reportfilename = ""
- destination = 0
- windowleft = 100
- windowtop = 100
- windowwidth = 490
- windowheight = 300
- windowtitle = ""
- windowborderstyle= 2
- windowcontrolbox= -1 'True
- windowmaxbutton = -1 'True
- windowminbutton = -1 'True
- copiestoprinter = 1
- printfilename = ""
- printfiletype = 0
- selectionformula= ""
- groupselectionformula= ""
- connect = ""
- username = ""
- reportsource = 0
- boundreportheading= ""
- boundreportfooter= 0 'False
- End
- Begin MSDBGrid.DBGrid OrdersGrid
- Bindings = "FRMCUSTA.frx":0000
- Height = 2175
- Left = 120
- Negotiate = -1 'True
- OleObjectBlob = "FRMCUSTA.frx":000F
- TabIndex = 4
- Top = 960
- Width = 7335
- End
- Attribute VB_Name = "frmCustAccount"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Private Sub btnPrintStatement_Click()
- Dim Tbl As Table
- response = MsgBox("Really print statement?", 4, "Print Statement")
- If (response = vbNo) Then
- Exit Sub
- End If
- On Error GoTo statement_error
- ' Calculate the current balance one last time and write the amount to
- ' CUSTMAIN. If the balance is zero, prompt the user for deleting all
- ' ORDERS records for the client.
- Call CalculateCurrentBalance
- Set Tbl = CustDB.OpenTable("CustMain")
- Tbl.Index = "PrimaryKey"
- Tbl.Seek "=", Customer_number
- If (Tbl.NoMatch = False) Then
- Tbl.Edit
- Tbl.Fields("Current_Balance") = CurrentBalance
- Tbl.Update
- End If
- Tbl.Close
- rptBilling.ReportFileName = App_location + "statemnt.rpt"
- rptBilling.Destination = 0 ' 1=Output to Printer, 0=Screen
- rptBilling.Action = 1
- Exit Sub
- statement_error:
- MsgBox ("Error printing this statement: " & Err.Description)
- MousePointer = 0
- End Sub
- Private Sub Command3D1_Click()
- End Sub
- Private Sub Form_KeyPress(KeyAscii As Integer)
- ' While not a Windows standard, the client
- ' prefers to use the enter key to move from field to field.
- ' This subroutine should trap the keypress and
- ' and process all "ENTER" keys as "TAB"
- If KeyAscii = 13 Then
- SendKeys "{tab}"
- KeyAscii = 0
- End If
- End Sub
- Private Sub btnFindCust_Click()
- Me.Hide
- 'Unload Me
- End Sub
- Private Sub Form_Activate()
- ' Reset to the default pointer when returning to this form.
- MousePointer = 0
- Dim Tbl As Table
- Dim CreditTbl As Table
- ' Put the customer name in the title bar
- If IsNull(CustmainDynaset.Fields("Last_Name")) <> True Then
- frmCustAccount.Caption = "Account Information for " & CustmainDynaset.Fields("Last_Name")
- Else
- If IsNull(CustmainDynaset.Fields("Company")) <> True Then
- frmCustAccount.Caption = "Account Information for " & CustmainDynaset.Fields("Company")
- Else
- frmCustAccount.Caption = "Account Information"
- End If
- End If
- ' This SQL statement populates the grid. I included an 'Order By'
- ' so the records are displayed in order of date.
- orders.RecordSource = "Select * From Orders Where CustomerNum = " & Str(Customer_number) & " Order By Date DESC;"
- orders.Refresh
- ' Calculate and put the current balance on the screen.
- Call CalculateCurrentBalance
- txtCurrentBalance = CurrentBalance
- End Sub
- Private Sub Form_Load()
- Dim Tbl As Table
- 'Center the form
- Left = (Screen.Width - Width) / 2
- Top = (Screen.Height - Height) / 2
- orders.DatabaseName = Database_name
- End Sub
- Private Sub OrdersGrid_Append()
- orders.Recordset.AddNew
- orders.Recordset.Fields("CustomerNum") = Customer_number
- orders.Recordset.Update
- End Sub
- Private Sub OrdersGrid_AfterDelete()
- On Error GoTo DeleteError
- If (orders.Recordset.RecordCount = 0) Then
- orders.Recordset.AddNew
- orders.Recordset.Fields("CustomerNum") = Customer_number
- CalculateCurrentBalance
- OrdersGrid.SetFocus
- Exit Sub
- End If
- orders.Recordset.MoveFirst
- orders.Refresh
- OrdersGrid.SetFocus
- CalculateCurrentBalance
- txtCurrentBalance = CurrentBalance
- Exit Sub
- DeleteError:
- MsgBox "This record is new and must be saved to the database before it can be deleted", 16, "Delete Record"
- OrdersGrid.SetFocus
- Exit Sub
- End Sub
- Private Sub OrdersGrid_AfterUpdate()
- Call CalculateCurrentBalance
- txtCurrentBalance = CurrentBalance
- End Sub
- Private Sub OrdersGrid_BeforeDelete(Cancel As Integer)
- Dim response As Integer
- response = MsgBox("Delete the current order?", 4, "Delete Record")
- If (response = IDNO) Then
- OrdersGrid.SetFocus
- Exit Sub
- End If
- End Sub
- Private Sub OrdersGrid_BeforeUpdate(Cancel As Integer)
- orders.Recordset.Fields("CustomerNum") = Customer_number
- End Sub
- Private Sub OrdersGrid_GotFocus()
- Dim Tbl As Table
- DoEvents
- If (orders.Recordset.RecordCount = 0) Then
- DoEvents
- orders.Recordset.AddNew
- orders.Recordset.Fields("CustomerNum") = Customer_number
- End If
- End Sub
- Private Sub OrdersGrid_RowChange()
- Call CalculateCurrentBalance
- End Sub
- Private Sub OrdersGrid_Validate(row As Long, Col As Integer, value As String, Cancel As Integer)
- ' If the user has just changed data in the date cell, validate it it.
- On Error GoTo DateError
- If (Col = 1) Then
- RetVal = DateValue(value)
- End If
- Exit Sub
- DateError:
- MsgBox "Date is illegal", 16, "Error"
- Cancel = True
- Exit Sub
- End Sub
- Private Sub OrdersGrid_RowColChange1(ByVal LastRow As String, ByVal LastCol As Integer)
- Call CalculateCurrentBalance
- txtCurrentBalance = CurrentBalance
- End Sub
-