home *** CD-ROM | disk | FTP | other *** search
- *******************************************************************************
- * PROGRAM: Customer.wfm
- *
- * WRITTEN BY: Borland Samples Group
- *
- * DATE: 12/93
- *
- * UPDATED: 7/94
- *
- * REVISION: $Revision: 1.100 $
- *
- * VERSION: dBASE FOR WINDOWS 5.0
- *
- * DESCRIPTION: This program displays information about the customers of a
- * company. It contains entryfields and radio buttons with
- * various customer information. A browse object displays
- * orders made by this customer. To add, delete, and search
- * for customers, a menu (Customer.mnu) is used. This form
- * also has custom buttons (from Buttons.cc) to allow traversing
- * through customers. Information can be viewed in either
- * View mode or in Edit mode, which is toggled in the menu.
- *
- * PARAMETERS: None
- *
- * CALLS: Customer.mnu (Menu file)
- * Buttons.cc (Custom controls)
- * Orders.wfm (Orders detail form)
- * Customer.qbe (View of tables)
- *
- * USAGE: DO Customer.wfm && Note that you can also DO Orders.wfm
- *
- *******************************************************************************
- #include <Messdlg.h>
- shell(.f.,.t.)
- create session
- set talk off
- set ldCheck off && To avoid language driver conflicts
-
- ** END HEADER -- do not remove this line*
- * Generated on 07/06/94
- *
- local f
- f = NEW CUSTOMERFORM()
- f.Open()
-
- CLASS CUSTOMERFORM OF FORM
- Set Procedure to BUTTONS.CC Additive
- this.OnClose = CLASS::ONCLOSE
- this.MenuFile = "CUSTOMER.MNU"
- this.View = "CUSTOMER.QBE"
- this.Top = 0.00
- this.Width = 88.40
- this.Height = 21.51
- this.Left = 1.53
- this.Text = "Customer -- View Mode"
- this.MousePointer = 1
- this.Maximize = .F.
- this.HelpId = ""
- this.Minimize = .F.
- this.EscExit = .F.
- this.HelpFile = ""
-
- DEFINE PREVBUTTON PREVCUSTBUTTON OF THIS;
- PROPERTY;
- OnClick CLASS::PREVIOUS,;
- Top 19.62,;
- Width 14.11,;
- Default .T.,;
- Height 1.50,;
- Left 1.35,;
- Group .T.
-
- DEFINE NEXTBUTTON NEXTCUSTBUTTON OF THIS;
- PROPERTY;
- OnClick CLASS::NEXT,;
- Top 19.62,;
- Width 14.11,;
- Height 1.50,;
- Left 16.28,;
- Group .F.
-
-
- DEFINE PUSHBUTTON FIRSTCUSTBUTTON OF THIS;
- PROPERTY;
- OnClick {;form.CheckCommit(form.inEditMode);go top},;
- Top 19.62,;
- Width 14.11,;
- Text "F&irst",;
- ColorNormal "N/W",;
- Height 1.50,;
- Left 31.08,;
- StatusMessage "Go to the first record.",;
- Group .F.
-
-
- DEFINE PUSHBUTTON LASTCUSTBUTTON OF THIS;
- PROPERTY;
- OnClick {;form.CheckCommit(form.inEditMode);go bottom},;
- Top 19.62,;
- Width 14.11,;
- Text "&Last",;
- ColorNormal "N/W",;
- Height 1.50,;
- Left 45.95,;
- StatusMessage "Go to the last customer.",;
- Group .F.
-
- DEFINE RECTANGLE NAMEPHONEBOX OF THIS;
- PROPERTY;
- Top 0.26,;
- Width 85.85,;
- Text "Customer Info",;
- ColorNormal "N/W",;
- Border .T.,;
- Height 18.56,;
- Left 1.35
-
- DEFINE TEXT NAMETEXT OF THIS;
- PROPERTY;
- Top 1.32,;
- Width 10.81,;
- Text "N&ame:",;
- ColorNormal "B/W",;
- Border .F.,;
- Alignment 5,;
- Height 1.32,;
- Left 2.03
-
- DEFINE ENTRYFIELD NAMEENTRY OF THIS;
- PROPERTY;
- Top 1.32,;
- Width 54.06,;
- OnChange CLASS::CHANGESMADE,;
- Border .T.,;
- Enabled .F.,;
- ColorNormal "N/W",;
- ColorHighLight "B+/W*",;
- Height 1.32,;
- DataLink "CUSTOMER->NAME",;
- Left 13.52
-
- DEFINE TEXT CUSTNOTEXT OF THIS;
- PROPERTY;
- Top 1.32,;
- Width 13.52,;
- Text "Customer #:",;
- ColorNormal "B/W",;
- Border .F.,;
- Alignment 3,;
- Height 1.32,;
- Left 70.28
-
- DEFINE ENTRYFIELD CUSTNOENTRY OF THIS;
- PROPERTY;
- Top 2.66,;
- Width 11.49,;
- OnChange CLASS::CHANGESMADE,;
- Border .T.,;
- Enabled .F.,;
- ColorNormal "N/W",;
- ColorHighLight "B+/W*",;
- Height 1.32,;
- DataLink "CUSTOMER_N",;
- Left 70.28
-
- DEFINE TEXT STREETTEXT OF THIS;
- PROPERTY;
- Top 2.66,;
- Width 10.81,;
- Text "&Street:",;
- ColorNormal "B/W",;
- Border .F.,;
- Alignment 5,;
- Height 1.32,;
- Left 2.03
-
- DEFINE ENTRYFIELD STREETENTRY OF THIS;
- PROPERTY;
- Top 2.66,;
- Width 54.06,;
- OnChange CLASS::CHANGESMADE,;
- Border .T.,;
- Enabled .F.,;
- ColorNormal "N/W",;
- ColorHighLight "B+/W*",;
- Height 1.32,;
- DataLink "STREET",;
- Left 13.52
-
- DEFINE TEXT CITYTEXT OF THIS;
- PROPERTY;
- Top 3.98,;
- Width 10.81,;
- Text "Cit&y:",;
- ColorNormal "B/W",;
- Border .F.,;
- Alignment 5,;
- Height 1.32,;
- Left 2.03
-
- DEFINE ENTRYFIELD CITYENTRY OF THIS;
- PROPERTY;
- Top 3.98,;
- Width 22.30,;
- OnChange CLASS::CHANGESMADE,;
- Border .T.,;
- Enabled .F.,;
- ColorNormal "N/W",;
- ColorHighLight "B+/W*",;
- Height 1.32,;
- DataLink "CITY",;
- Left 13.52
-
- DEFINE TEXT STATETEXT OF THIS;
- PROPERTY;
- Top 3.98,;
- Width 16.22,;
- Text "State/Pro&vince:",;
- ColorNormal "B/W",;
- Border .F.,;
- Alignment 5,;
- Height 1.32,;
- Left 36.49
-
- DEFINE ENTRYFIELD STATEENTRY OF THIS;
- PROPERTY;
- Top 3.98,;
- Width 14.20,;
- OnChange CLASS::CHANGESMADE,;
- Border .T.,;
- Enabled .F.,;
- ColorNormal "N/W",;
- ColorHighLight "B+/W*",;
- Height 1.32,;
- DataLink "STATE_PROV",;
- Left 53.39
-
- DEFINE TEXT ZIPTEXT OF THIS;
- PROPERTY;
- Top 5.30,;
- Width 10.81,;
- Text "&Zip Code:",;
- ColorNormal "B/W",;
- Border .F.,;
- Alignment 5,;
- Height 1.32,;
- Left 2.03
-
- DEFINE ENTRYFIELD ZIPENTRY OF THIS;
- PROPERTY;
- Top 5.30,;
- Width 22.30,;
- OnChange CLASS::CHANGESMADE,;
- Border .T.,;
- Enabled .F.,;
- ColorNormal "N/W",;
- ColorHighLight "B+/W*",;
- Height 1.32,;
- DataLink "ZIP_POSTAL",;
- Left 13.52
-
- DEFINE TEXT COUNTRYTEXT OF THIS;
- PROPERTY;
- Top 5.30,;
- Width 14.87,;
- Text "Count&ry:",;
- ColorNormal "B/W",;
- Border .F.,;
- Alignment 5,;
- Height 1.32,;
- Left 37.84
-
- DEFINE ENTRYFIELD COUNTRYENTRY OF THIS;
- PROPERTY;
- Top 5.30,;
- Width 14.20,;
- OnChange CLASS::CHANGESMADE,;
- Border .T.,;
- Enabled .F.,;
- ColorNormal "N/W",;
- ColorHighLight "B+/W*",;
- Height 1.32,;
- DataLink "COUNTRY",;
- Left 53.39
-
- DEFINE TEXT PHONETEXT OF THIS;
- PROPERTY;
- Top 6.63,;
- Width 10.81,;
- Text "P&hone:",;
- ColorNormal "B/W",;
- Border .F.,;
- Alignment 5,;
- Height 1.32,;
- Left 2.03
-
- DEFINE ENTRYFIELD PHONEENTRY OF THIS;
- PROPERTY;
- Top 6.63,;
- Width 22.30,;
- OnChange CLASS::CHANGESMADE,;
- Border .T.,;
- Enabled .F.,;
- ColorNormal "N/W",;
- ColorHighLight "B+/W*",;
- Height 1.32,;
- DataLink "PHONE",;
- Left 13.52
-
- DEFINE TEXT ORDERSTEXT OF THIS;
- PROPERTY;
- Top 7.95,;
- Width 10.81,;
- Text "&Orders:",;
- ColorNormal "B/W",;
- Border .F.,;
- Alignment 5,;
- Height 1.32,;
- Left 2.03
-
- DEFINE BROWSE CHILDBROWSE OF THIS;
- PROPERTY;
- OnChange CLASS::CHANGESMADE,;
- OnLeftDblClick CLASS::CHILDBROWSEDBLCLICK,;
- OnNavigate CLASS::BROWSEONNAVIGATE,;
- Top 8.22,;
- Width 72.64,;
- ColorNormal "N/W",;
- Modify .F.,;
- ShowRecNo .F.,;
- FontBold .F.,;
- Alias "ORDERS",;
- Fields "ORDERS->ORDER_NO\H='ORDER NO',ORDERS->TOTAL\9\P='9,999,999.99',ORDERS->SALE_DATE\H='SALE DATE',ORDERS->SHIP_DATE\H='SHIP DATE',ORDERS->AMT_PAID\H='AMT PAID'\P='9,999,999.99',ORDERS->TERMS\12",;
- ShowDeleted .F.,;
- TabStop .T.,;
- Modify .F.,;
- Follow .T.,;
- Delete .F.,;
- Toggle .T.,;
- Append .F.,;
- Height 5.57,;
- Left 13.52
-
- DEFINE TEXT SIGNATURETEXT OF THIS;
- PROPERTY;
- Top 14.05,;
- Width 20.27,;
- Text "Signature:",;
- ColorNormal "B/W",;
- Border .F.,;
- Alignment 3,;
- Height 1.32,;
- Left 57.44
-
- DEFINE IMAGE SIGNATUREIMAGE OF THIS;
- PROPERTY;
- Top 15.15,;
- Width 28.38,;
- DataSource "BINARY SIGNATURE",;
- Height 2.53,;
- Left 57.44
-
- DEFINE TEXT NOTESTEXT OF THIS;
- PROPERTY;
- Top 14.05,;
- Width 10.81,;
- Text "No&tes:",;
- ColorNormal "B/W",;
- Border .F.,;
- Alignment 5,;
- Height 1.32,;
- Left 2.03
-
- DEFINE EDITOR NOTESEDITOR OF THIS;
- PROPERTY;
- Top 14.32,;
- Width 43.25,;
- ColorNormal "N/W",;
- OnGotFocus {;if this.Modify;this.colorNormal = "B+/W*";endif},;
- OnLostFocus {;if this.Modify;this.colorNormal = "N/W";endif},;
- OnChange CLASS::CHANGESMADE,;
- Border .T.,;
- Modify .F.,;
- Wrap .T.,;
- Height 4.24,;
- DataLink "CUSTOMER->NOTES",;
- Left 13.52
-
- DEFINE IMAGE LOGOIMAGE OF THIS;
- PROPERTY;
- Top 18.89,;
- Width 14.87,;
- DataSource "FILE DIVESHOP.BMP",;
- Height 2.83,;
- Alignment 1,;
- Left 71.63
-
- ****************************************************************************
- procedure Open
- ****************************************************************************
- private custNoField, orderField
-
- if type("form.init") = "U"
- form.init = .t.
-
- set skip to && Customer.qbe has set skip to orders
- set exact off && Customer.qbe has set exact on
-
- set procedure to SampProc additive
- set procedure to Orders.wfm additive
-
- *** Do calculations in other area, so form doesn't update on record moves
- select select()
- use customer again alias temp
- custNoField = field(1) && Field customer_n
- set order to &custNoField && Tag name is same as field name
- go bottom
- form.maxCustNo = &custNoField && Max value for the key - used for
- && creating new customers
- use
- select customer
-
- *** Other setup work
- form.inEditMode = .f. && Indicate view/edit state
- form.changesMade = .f. && Changes haven't been made yet
- form.previousRecord = .f. && Save record number when appending
- form.nextCustButton.SetFocus() && Since we are at the first
- && customer, can only move forward
- if type("form.parentOrdersForm") <> "U"
- form.EscExit = .t.
- form.prevCustButton.enabled = .f. && Disable navigation buttons if
- form.nextCustButton.enabled = .f. && called from orders.
- form.firstCustButton.enabled = .f.
- form.lastCustButton.enabled = .f.
- form.root.customer.search.enabled = .f.
- form.root.customer.add.enabled = .f.
- endif
- endif
- form::open() && Now the form actually opens
-
- ****************************************************************************
- procedure OnClose
- ****************************************************************************
- if this.inEditMode
- form.ViewEdit()
- endif
- if type("form.parentOrdersForm") = "U" && If called from Orders.wfm, leave shell(.f.)
- shell(.t.)
- close procedure SampProc
- close procedure Orders.wfm
- close procedure Customer.mnu
- endif
-
- ****************************************************************************
- procedure BrowseOnNavigate
- ****************************************************************************
- if eof()
- form.root.customer.viewEdit.enabled = .f.
- else
- form.root.customer.viewEdit.enabled = .t.
- endif
- form.CallShowOrders()
-
- ****************************************************************************
- procedure ChangesMade
- ****************************************************************************
- form.changesMade = .t.
-
- ****************************************************************************
- procedure Next
- ****************************************************************************
- form.CheckCommit(form.inEditMode)
- if .not. eof()
- NEXTBUTTON::OnClick()
- endif
-
- ****************************************************************************
- procedure Previous
- ****************************************************************************
- form.CheckCommit(form.inEditMode)
- PREVBUTTON::OnClick()
-
- ****************************************************************************
- procedure ChildBrowseDblClick
- ****************************************************************************
- form.root.customer.current_orders.OnClick()
-
- ****************************************************************************
- procedure CheckCommit (newInEditMode)
- ****************************************************************************
- private orderField, changesMade
-
- changesMade = form.changesMade
- if form.changesMade .and. form.inEditMode
- orderField = field(1) && Field Customer_n
- if ConfirmationMessage("Commit changes?",;
- FormatStr("Customer %1",&orderField)) = YES
- commit()
- else
- rollback()
- if .not. empty(form.previousRecord)
- go form.previousRecord
- form.previousRecord = .f.
- endif
- endif
- if form.inEditMode .and. newInEditMode
- begintrans()
- endif
- form.changesMade = .f.
- endif
- if form.inEditMode <> newInEditMode
- if newInEditMode && Going to Edit mode
- begintrans()
- else && Going to View mode
- if .not. changesMade
- rollback()
- endif
- endif
- form.inEditMode = newInEditMode
- endif
-
- ****************************************************************************
- procedure ViewEdit
- ****************************************************************************
- local inEditMode, editMenu, control
-
- editMenu = form.root.customer.viewEdit
-
- *** If ending edit mode then close transaction, otherwise open it.
- if form.inEditMode
- form.checkChanged(.f.)
- editMenu.text = "&Edit"
- editMenu.shortcut = "Ctrl-E"
- editMenu.statusMessage = "Edit data."
- form.root.customer.delete.enabled = .f. && disabled in view mode
- form.CheckCommit(.f.) && Check transaction and
- form.text = "Customer -- View Mode" && change mode to View
- form.notesEditor.colorNormal = "N/W"
- form.childBrowse.modify = .f.
- form.notesEditor.modify = .f.
- form.statusmessage = "In View Mode. " + ;
- "Select Customer - Edit menu to " + ;
- "edit/delete data."
- form.nextcustbutton.SetFocus()
- else && Switch to edit mode
- editMenu.text = "Vi&ew"
- editMenu.shortcut = "Ctrl-E"
- editMenu.statusMessage = "View data."
- form.root.customer.delete.enabled = .t. && enabled in edit mode
- form.CheckCommit(.t.) && Check transaction and
- form.text = "Customer -- Edit Mode" && change mode to Edit
- form.childBrowse.modify = .t.
- form.notesEditor.modify = .t.
- form.statusmessage = "In Edit Mode. " + ;
- "Select menu Customer - View to switch " + ;
- "to View mode."
- form.nameEntry.SetFocus() && Move to the name entryfield
- endif
- inEditMode = form.inEditMode && Faster if we don't reference a form
- control = form.first && variable each time through the loop
- do
- if .not. control.className $ "BROWSE,EDITOR,NEXTBUTTON,PREVBUTTON,PUSHBUTTON,IMAGE,TEXT"
- control.enabled = inEditMode
- endif
- control = control.before
- until control.name = form.first.name
- form.custNoEntry.enabled = .f. && Key field is always disabled
- form.nameEntry.SetFocus() && Move to the name entryfield
-
- ****************************************************************************
- procedure CheckChanged(callCommit)
-
- * Check if changes have been made to the current entryfield. This procedure
- * is called from menu routines to make sure the form.changesMade gets
- * updated when a menu is selected while the changed control has focus.
- ****************************************************************************
- private control, fieldValue
-
- if form.inEditMode
- control = form.activeControl
- fieldValue = iif(type("control.datalink") <> "U", control.datalink, .f.)
- if type("fieldValue") <> "L" .and. control.value <> &fieldValue
- form.changesMade = .t.
- endif
- endif
- if form.changesMade .and. callCommit
- form.CheckCommit(form.inEditMode) && Check transactions
- endif
-
- ****************************************************************************
- procedure StartOrdersForm
-
- * Starts the Orders form in it's own session. Note that control returns
- * to the current session when this procedure is returned from. This means
- * that between the create session command and return you cannot access
- * tables in the current session.
- ****************************************************************************
- local custNo
-
- custNo = customer->customer_n && Pass current customer_n into
- && orders form in the new session
- create session
- set talk off && Set these for the new session
- set ldCheck off
-
- form.childOrdersForm = new OrdersForm() && Use Orders.wfm to add, view,
- && edit, or delete an order.
- form.childOrdersForm.top = 2.02
- form.childOrdersForm.left = 4.25
- form.childOrdersForm.customer_n = custNo
- form.childOrdersForm.parentCustomerForm = form && Store a reference to this
- && form so that Orders can
- && call events in this form
- form.childOrdersForm.open()
-
- ****************************************************************************
- procedure CallShowOrders
-
- * Synchronizes the Orders form to the same customer. This is done when
- * Customer is run first (form.parentOrdersForm is undefined), and the Orders
- * form has been opened (form.childOrdersForm is defined).
- ****************************************************************************
- if type("form.parentOrdersForm") = "U" && Customer is the parent form
- if type ("form.childOrdersForm") <> "U" && Orders form has been defined
- form.childOrdersForm.ShowOrders(customer->customer_n, orders->order_no)
- endif
- endif
-
- ****************************************************************************
- procedure ShowCustomer(custNo)
-
- * Called by Orders.wfm when it is the first form run. Used to synchronize
- * this form to the same customer for a given order displayed in Orders.
- ****************************************************************************
- private pCustNo
-
- form.CheckChanged(.t.)
- set order to customer_n
- pCustNo = custNo && Parameters are local so cannot macro
- set key to "&pCustNo" && Only see corresponding customer
- go top
-
- ENDCLASS
-
-
-