home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1998 April B
/
Pcwk4b98.iso
/
Borland
/
Dbase50w
/
CBTSAMP.PAK
/
ORDERS.MNU
< prev
next >
Wrap
Text File
|
1994-08-02
|
9KB
|
278 lines
******************************************************************************
* PROGRAM: Orders.mnu
*
* WRITTEN BY: Borland Samples Group
*
* DATE: 12/93
*
* UPDATED: 7/94
*
* REVISION: $Revision: 1.42 $
*
* VERSION: dBASE FOR WINDOWS 5.0
*
* DESCRIPTION: This is a menu file used by Orders.wfm for
* performing simple tasks. It allows adding and deleting
* records, searching for a value in the order field of the
* current table viewed, and exiting the form in view.
*
* PARAMETERS: FormObj -- the form to which this menu will belong.
*
* CALLS: None
*
* USAGE: form.menuFile = "Orders.mnu"
*
*******************************************************************************
#include <Messdlg.h>
** END HEADER -- do not remove this line*
* Generated on 05/06/94
*
Parameter FormObj
NEW ORDERS(FormObj,"Root")
CLASS ORDERS(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 Orders form."
DEFINE MENU ORDER OF THIS;
PROPERTY;
Text "&Order"
DEFINE MENU VIEWEDIT OF THIS.ORDER;
PROPERTY;
OnClick CLASS::VIEWEDITONCLICK,;
Text "&Edit",;
Shortcut "Ctrl-E",;
StatusMessage "Edit data."
DEFINE MENU SEPARATOR1 OF THIS.ORDER;
PROPERTY;
Separator .T.,;
Text ""
DEFINE MENU ADD OF THIS.ORDER;
PROPERTY;
OnClick CLASS::ADDONCLICK,;
Text "&Add",;
Enabled .T.,;
Shortcut "Ctrl-A",;
StatusMessage "Add a new order."
DEFINE MENU DELETE OF THIS.ORDER;
PROPERTY;
OnClick CLASS::DELETEONCLICK,;
Text "&Delete",;
Enabled .F.,;
Shortcut "Ctrl-D",;
StatusMessage "Delete the current order."
DEFINE MENU SEPARATOR2 OF THIS.ORDER;
PROPERTY;
Separator .T.,;
Text ""
DEFINE MENU SEARCH OF THIS.ORDER;
PROPERTY;
OnClick CLASS::SEARCHONCLICK,;
Text "&Search ...",;
Shortcut "Ctrl-S",;
StatusMessage "Search for an order."
DEFINE MENU SEPARATOR3 OF THIS.ORDER;
PROPERTY;
Separator .T.,;
Text ""
DEFINE MENU CURRENT_CUSTOMER OF THIS.ORDER;
PROPERTY;
OnClick CLASS::CURRENTCUSTOMERONCLICK,;
Text "Custo&mer ...",;
Shortcut "Ctrl-M",;
StatusMessage "View detailed information about the current customer."
DEFINE MENU REPORT OF THIS;
PROPERTY;
Text "&Report"
DEFINE MENU ORDERSREPORT OF THIS.REPORT;
PROPERTY;
OnClick {;report form orders},;
Text "&Invoices",;
Shortcut "Ctrl-I"
****************************************************************************
procedure SearchOnClick
****************************************************************************
private searchForm, searchItem, saveRec, saveFilt
form.CheckChanged(.t.)
set procedure to Search.wfm additive
searchForm = new SearchForm()
searchForm.keyName = "Order Number" && Indicator of key expression
searchForm.formatting = "9999" && format specific to this key
searchForm.mdi = .f.
searchItem = searchForm.Readmodal()
if type("searchItem") = "O" .and. searchItem.id <> 0
&& If search wasn't cancelled
saveRec = recno() && save current record in case seek is unsucessfull
seek ltrim(searchForm.value)
if .not. found()
InformationMessage(FormatStr("Order %1 \n Was not Found.",;
searchForm.value),;
"Info")
go saveRec
endif
endif
searchForm.Release()
close procedure Search.wfm
****************************************************************************
procedure DeleteOnClick
****************************************************************************
if ConfirmationMessage("Are you sure you want to delete this order?",;
"Confirm") = YES
delete && DELETED is ON, so deleted records are still there until
&& a PACK is executed
commit()
form.changesMade = .f.
begintrans()
form.nextOrderButton.OnClick() && Move to next record
endif
****************************************************************************
procedure AddOnClick
****************************************************************************
private addForm, newOrder, saleDateField, orderNoField, custNoField, custNo
form.CheckChanged(.t.)
if ConfirmationMessage("Are you sure you want to add an order?",;
"Confirmation") = YES
orderNoField = field(1) && Customer_n field
custNoField = field(2) && Order_no field
saleDateField = field(3) && Sale_date field
if type("form.parentCustomerForm") <> "U"
custNo = form.customer_n
else
custNo = customer->customer_n && Save customer no
endif
if .not. form.inEditMode
form.ViewEdit() && Make sure record is editable
else
form.childBrowse.setFocus()
endif
form.changesMade = .t.
form.previousRecord = bookmark()
append blank
orderNoField = field(1)
newOrder = str(val(form.maxOrder) + 1,4)
replace &orderNoField with newOrder && Assign new order number
replace &custNoField with custNo && Use the same customer
replace &saleDateField with date() && Default sale date is today
form.maxOrder = newOrder
refresh
select lineitem
append blank
refresh
select orders
endif
****************************************************************************
procedure CurrentCustomerOnclick
****************************************************************************
form.CheckChanged(.t.)
if type("form.parentCustomerForm") = "U"
if type ("form.childCustomerForm") = "U"
form.StartCustomerForm()
form.CallShowCustomer(orders->customer_n)
else
form.CallShowCustomer(orders->customer_n)
form.childCustomerForm.open()
form.childCustomerForm.windowState = 0
form.childCustomerForm.setFocus()
endif
else
form.parentCustomerForm.setFocus()
endif
***************************************************************************
procedure ViewEditOnClick
****************************************************************************
form.ViewEdit()
****************************************************************************
procedure OnExit
****************************************************************************
if type ("form.parentCustomerForm") <> "U"
form.parentCustomerForm.close()
else if type ("form.childCustomerForm") <> "U"
form.childCustomerForm.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: x = FormatStr("Hello \n %1", "World") &&prints Hello World on 2 lines
********************************************************************************
#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