Code: Select all
#INCLUDE "dcdialog.CH"
#INCLUDE "appevent.CH"
#xTranslate SetFocus(<cId>) => PostAppEvent(xbeP_User+1,,,DC_GetObject(GetList,<cId>))
FUNCTION Main()
RETURN NewQuantity()
* ------------
FUNCTION NewQuantity()
local cItem, nOldQty, nNewQty, bSayQty, oFrame, getlist:={}, GetOptions
cItem := SPACE(20)
nOldQty := 0
nNewQty := 0
DCUSEREVENT xbeP_User+1 ACTION {|a,b,o|SetAppFocus(o),DC_ClearEvents()}
@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_RAISEDBOX ;
OBJECT oFrame ;
SIZE 70,15
@ 2,2 DCSAY "Item" GET cItem ; // enter inventory item
PICTURE "@!" ;
PARENT oFrame ;
GETID 'GetItem' ;
VALID {|| nOldQty:=GetOldQty(cItem) ;
, DC_GetRefresh(getlist) ;
, SetFocus('GetNewQty') ;
, .T. }
bSayQty := {|| "Old Quantity" + STR(nOldQty,5,0) } // show existing qty
@ 4,2 DCSAY bSayQty ;
PARENT oFrame
@ 6,2 DCSAY "New Quantity" GET nNewQty ; // get new quantity
PICTURE "99999" ;
PARENT oFrame ;
GETID 'GetNewQty' ;
VALID {|| SetFocus('YesButton') ;
, .T. }
@ 9, 2 DCPUSHBUTTON ; // write new quantity to file
CAPTION "Yes" ;
PARENT oFrame ;
SIZE 13,1.5 ;
ID 'YesButton' ;
ACTION {|| UpdateQty(cItem,nNewQty) ;
, cItem := SPACE(20) ;
, nOldQty := 0 ;
, nNewQty := 0 ;
, DC_GetRefresh(getlist) ;
, SetFocus('GetItem') }
@ 9,22 DCPUSHBUTTON ; // no write, clear gets
CAPTION "No" ;
PARENT oFrame ;
SIZE 13,1.5 ;
ACTION {|| cItem := SPACE(20) ;
, nOldQty := 0 ;
, nNewQty := 0 ;
, DC_GetRefresh(getlist) ;
, SetFocus('GetItem') }
@ 9,42 DCPUSHBUTTON ; // exit this routine
CAPTION "Exit" ;
PARENT oFrame ;
SIZE 13,1.5 ;
ACTION {|| DC_ReadguiEvent(DCGUI_EXIT_OK,Getlist) ;
, DC_GetRefresh(getlist) }
DCREAD GUI FIT MODAL
RETURN NIL //////////////////////////////////////////////////////////////
STATIC FUNCTION GetOldQty(cItem)
// locate item in dbf file and return quantity
RETURN 99
STATIC FUNCTION UpdateQty(cItem,nNewQty)
// update dbf with new quantity
RETURN NIL