home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 April B
/
Pcwk4b98.iso
/
Borland
/
Dbase50w
/
CBTSAMP.PAK
/
CUSTOMER.MNU
< prev
next >
Wrap
Text File
|
1994-08-02
|
9KB
|
264 lines
******************************************************************************
* PROGRAM: Customer.mnu
*
* WRITTEN BY: Borland Samples Group
*
* DATE: 12/93
*
* UPDATED: 7/94
*
* REVISION: $Revision: 1.41 $
*
* VERSION: dBASE FOR WINDOWS 5.0
*
* DESCRIPTION: This menu file is used by Customer.wfm for performing simple
* tasks. It allows adding, deleting, and searching for
* customers, brings up the orders form for a customer,
* and runs reports.
*
* PARAMETERS: FormObj -- the form to which this menu is attached.
*
* CALLS: None
*
* USAGE: form.menuFile = "Customer.mnu"
*
*******************************************************************************
#include <Messdlg.h>
** END HEADER -- do not remove this line*
* Generated on 06/21/94
*
Parameter FormObj
NEW CUSTOMERMENU(FormObj,"Root")
CLASS CUSTOMERMENU(FormObj,Name) OF MENU(FormObj,Name)
this.Text = ""
DEFINE MENU FILE OF THIS;
PROPERTY;
Text "&File"
DEFINE MENU EXIT OF THIS.FILE;
PROPERTY;
OnClick CLASS::ONEXIT,;
Text "E&xit",;
StatusMessage "Leave Customer form."
DEFINE MENU CUSTOMER OF THIS;
PROPERTY;
Text "&Customer"
DEFINE MENU VIEWEDIT OF THIS.CUSTOMER;
PROPERTY;
OnClick CLASS::VIEWEDITONCLICK,;
Text "&Edit",;
Shortcut "Ctrl-E",;
StatusMessage "Edit data."
DEFINE MENU SEPARATOR1 OF THIS.CUSTOMER;
PROPERTY;
Separator .T.,;
Text ""
DEFINE MENU ADD OF THIS.CUSTOMER;
PROPERTY;
OnClick CLASS::ADDONCLICK,;
Text "&Add",;
Shortcut "Ctrl-A",;
Enabled .T.,;
StatusMessage "Add a new customer."
DEFINE MENU DELETE OF THIS.CUSTOMER;
PROPERTY;
OnClick CLASS::DELETEONCLICK,;
Text "&Delete",;
Shortcut "Ctrl-D",;
Enabled .F.,;
StatusMessage "Delete the current customer."
DEFINE MENU SEPARATOR2 OF THIS.CUSTOMER;
PROPERTY;
Separator .T.,;
Text ""
DEFINE MENU SEARCH OF THIS.CUSTOMER;
PROPERTY;
OnClick CLASS::SEARCHONCLICK,;
Text "&Search ...",;
Shortcut "Ctrl-S",;
StatusMessage "Search for a customer."
DEFINE MENU SEPARATOR3 OF THIS.CUSTOMER;
PROPERTY;
Separator .T.,;
Text ""
DEFINE MENU CURRENT_ORDERS OF THIS.CUSTOMER;
PROPERTY;
OnClick CLASS::CURRENTORDERSONCLICK,;
Text "&Orders ...",;
Shortcut "Ctrl-O",;
StatusMessage "See the orders for the current customer in the Orders form."
DEFINE MENU REPORT OF THIS;
PROPERTY;
Text "&Report"
DEFINE MENU CUSTOMER_REPORT OF THIS.REPORT;
PROPERTY;
OnClick {;report form customer},;
Text "Customer &Report",;
Shortcut "Ctrl-R",;
StatusMessage "Display a report of customer information."
DEFINE MENU CUSTOMER_LABELS OF THIS.REPORT;
PROPERTY;
OnClick {;report form customer.rpl},;
Text "Customer &Labels",;
Shortcut "Ctrl-L",;
StatusMessage "Display labels for all customers."
****************************************************************************
procedure SearchOnClick
****************************************************************************
private searchForm,searchItem,saveRec
form.CheckChanged(.t.)
set procedure to Search.wfm additive
searchForm = new SearchForm()
searchForm.keyName = "Name" && Indicate to user expression to enter
searchForm.formatting = "@X"
searchForm.mdi = .f. && Necessary for a modal form
searchItem = searchForm.Readmodal()
if type("searchItem") = "O" .and. searchItem.id <> 0;
.and. .not. empty(searchForm.value)
*** If Cancel or ESC wasn't used to exit Search.wfm
saveRec = recno()
form.enabled = .f.
seek upper(ltrim(rtrim(searchForm.value)))
if .not. found()
go saveRec
InformationMessage(FormatStr("Customer %1 \n Was not Found.",;
searchForm.value),;
"Info")
endif
form.enabled = .t.
endif
searchForm.Release()
close procedure Search.wfm
****************************************************************************
procedure DeleteOnClick
****************************************************************************
if ConfirmationMessage("Are you sure you want to delete this customer?",;
"Confirm") = YES
delete && Deleted is on, so deleted records are there until you PACK
commit()
form.changesMade = .f.
begintrans()
form.nextCustButton.OnClick() && Move to next record
endif
****************************************************************************
procedure AddOnClick
****************************************************************************
private addForm, custNoField, newCustomer
form.CheckChanged(.t.)
if ConfirmationMessage("Are you sure you want to add a customer?",;
"Confirmation") = YES
if .not. form.inEditMode
form.ViewEdit() && Make sure record is editable
else
form.nameEntry.SetFocus()
endif && and begin a transaction
form.changesMade = .t. && Since we are adding a record
form.previousRecord = bookmark()
append blank && This must be done after begintrans()
custNoField = field(1) && so rollback() could delete if necessary
newCustomer = str(val(form.maxCustNo) + 1, 4)
replace &custNoField with newCustomer && New customer number
form.maxCustNo = newCustomer
endif
****************************************************************************
procedure CurrentOrdersOnclick
****************************************************************************
form.CheckChanged(.t.)
if type ("form.parentOrdersForm") = "U"
if type ("form.childOrdersForm") = "U"
form.StartOrdersForm()
form.CallShowOrders(customer->customer_n)
else
form.CallShowOrders(customer->customer_n)
form.childOrdersForm.open()
form.childOrdersForm.windowState = 0
form.childOrdersForm.windowState = 0
form.childOrdersForm.setFocus()
endif
else
form.parentOrdersForm.setFocus()
endif
****************************************************************************
procedure ViewEditOnClick
****************************************************************************
form.ViewEdit()
****************************************************************************
procedure OnExit
****************************************************************************
if type ("form.parentOrdersForm") <> "U"
form.parentOrdersForm.close()
else if type ("form.childOrdersForm") <> "U"
form.childOrdersForm.close()
endif
form.Close()
ENDCLASS
********************************************************************************
function FormatStr(string)
* Could have 0 or more parameters.
* This function will replace occurrences of "%<n>" with the corresponding
* parameter string. It will also replace all occurrences of "\n" with a
* carriage return, and all occurrences of "\t" with a tab.
*
* Example - This prints Hello World on 2 lines:
* FormatStr("Hello \n %1", "World")
********************************************************************************
#define ENTER chr(13)
#define TAB chr(9)
local i, strPos, strCnt, tmpStr
tmpStr = string
for i = 2 to argc() && While have something to search for
tmpStr = StrTran(tmpStr, "%" + ltrim(str(i - 1)), argv(i))
next
tmpStr = StrTran(tmpStr, "\n", ENTER)
tmpStr = StrTran(tmpStr, "\t", TAB)
return tmpStr
*******************************************************************************
function StrTran(string,curStr,repStr)
*
* Replaces all occurrences of curStr in string with repStr
*******************************************************************************
local strPos, lenCurStr, tmpStr
tmpStr = string
lenCurStr = len(curStr)
strPos = at(curStr,tmpStr)
do while strPos > 0
tmpStr = stuff(tmpStr, strPos, lenCurStr, repStr)
strPos = at(curStr,tmpStr)
enddo
return tmpStr