rem 'Set the option on to display the insert confirm dialog after an insert is
rem 'attempted in a data aware BBjGrid object
rem 'Obtain the instance of the BBjAPI object
let myAPI!=BBjAPI()
rem 'Open the SysGui device
SYSGUI=UNT
OPEN (SYSGUI) "X0"
rem 'Obtain the instance of the BBjSysGui object
let mySysGui!=myAPI!.getSysGui()
rem 'Template for the customer data
TMPL$="CUST_NUMBER:C(6),FIRST_NAME:C(10),LAST_NAME:C(10),COMPANY:C(20),ADDRESS:C(20),CITY:C(15),STATE:C(2),ZIP_CODE:C(5)"
rem 'Create the customer data file
GOSUB CreateDataFile
rem 'Create the main window, initially invisible
myWindow! = mySysGui!.addWindow(100,100,650,275,"Data Aware Grid",$00000012$)
rem 'Create the grid
BBjGrid!=MyWindow!.addDataAwareGrid(500,10,10,600,190,DATACHAN,TMPL$,$$)
rem 'Add INSERT and DELETE buttons
Insert! = myWindow!.addButton(101,10,210,90,30,"&Insert",$0800$)
Delete! = myWindow!.addButton(102,110,210,90,30,"&Delete",$0800$)
rem 'Setup the grid
GOSUB SetupGrid
rem 'Set the option on to display the insert confirm dialog after an insert is
rem 'attempted in a data aware BBjGrid object
BBjGrid!.setShowInsertMessage(mySysGui!.FALSE)
INSERT_CONFIRM_MSG=BBjGrid!.getShowInsertMessage()
rem 'Print out if the confirm dialog will be displayed, this will print out false (0)
PRINT "SHOW INSERT CONFIRM MESSAGE = " + STR(INSERT_CONFIRM_MSG)
rem 'Make the window visible
myWindow!.setVisible(mySysGui!.TRUE)
rem 'Register callback routines
CONTEXT=MySysGui!.getContext(),GRID=BBjGrid!.getID()
CALLBACK(ON_BUTTON_PUSH,InsertRow,CONTEXT,Insert!.getID())
CALLBACK(ON_BUTTON_PUSH,DeleteRow,CONTEXT,Delete!.getID())
CALLBACK(ON_GRID_ROW_INSERT,SynchData,CONTEXT,GRID)
CALLBACK(ON_GRID_ROW_INSERT_CANCEL,SynchData,CONTEXT,GRID)
CALLBACK(ON_GRID_ROW_UPDATE,SynchData,CONTEXT,GRID)
CALLBACK(ON_GRID_ROW_DELETE,SynchData,CONTEXT,GRID)
CALLBACK(ON_CLOSE,EXIT_PROGRAM,CONTEXT)
rem 'Process Events
process_events
rem 'Callback routine that is called upon user exit
EXIT_PROGRAM:
release
InsertRow:
BBjGrid!.insertRow()
return
DeleteRow:
ROW=BBjGrid!.getSelectedRow()
if ROW<0 then return
REC$=BBjGrid!.getRecord(ROW)
if (msgbox("Delete customer "+rec.cust_number$+"?",1,"Confirm Deletion")=1) then BBjGrid!.deleteRow(ROW)
return
rem 'Callback to synchronize the data-aware customer grid to its data file
SynchData:
BBjGrid!.synchData()
return
rem 'Routine to create the customer data file
CreateDataFile:
rem 'Create array to hold customer information
NUM_OF_CUSTOMERS=10
NUM_OF_FIELDS=8
DIM CUST_ARRAY$[NUM_OF_CUSTOMERS,NUM_OF_FIELDS]
CUST_ARRAY$[0,0]="000001",CUST_ARRAY$[0,1]="Brian",CUST_ARRAY$[0,2]="Johnson"
CUST_ARRAY$[0,3]="Basis International",CUST_ARRAY$[0,4]="5901 Jefferson"
CUST_ARRAY$[0,5]="Albuquerque",CUST_ARRAY$[0,6]="NM",CUST_ARRAY$[0,7]="87109"
CUST_ARRAY$[1,0]="000002",CUST_ARRAY$[1,1]="Rosalie",CUST_ARRAY$[1,2]="Ortega"
CUST_ARRAY$[1,3]="MOPS",CUST_ARRAY$[1,4]="103 Main Street"
CUST_ARRAY$[1,5]="Las Cruces",CUST_ARRAY$[1,6]="NM",CUST_ARRAY$[1,7]="88113"
CUST_ARRAY$[2,0]="000003",CUST_ARRAY$[2,1]="Neal",CUST_ARRAY$[2,2]="Smith"
CUST_ARRAY$[2,3]="Intel",CUST_ARRAY$[2,4]="6750 Wyoming"
CUST_ARRAY$[2,5]="Albuquerque",CUST_ARRAY$[2,6]="NM",CUST_ARRAY$[2,7]="87114"
CUST_ARRAY$[3,0]="000004",CUST_ARRAY$[3,1]="Pat",CUST_ARRAY$[3,2]="Correl"
CUST_ARRAY$[3,3]="R&J Construction",CUST_ARRAY$[3,4]="5466 Corrales"
CUST_ARRAY$[3,5]="Albuquerque",CUST_ARRAY$[3,6]="NM",CUST_ARRAY$[3,7]="87110"
CUST_ARRAY$[4,0]="000005",CUST_ARRAY$[4,1]="Laura",CUST_ARRAY$[4,2]="Thompson"
CUST_ARRAY$[4,3]="B&F Associates",CUST_ARRAY$[4,4]="23211 Greene"
CUST_ARRAY$[4,5]="Las Vegas",CUST_ARRAY$[4,6]="NV",CUST_ARRAY$[4,7]="87670"
CUST_ARRAY$[5,0]="000006",CUST_ARRAY$[5,1]="Kevin",CUST_ARRAY$[5,2]="Brown"
CUST_ARRAY$[5,3]="High Finance",CUST_ARRAY$[5,4]="12311 Money Way"
CUST_ARRAY$[5,5]="Portland",CUST_ARRAY$[5,6]="OR",CUST_ARRAY$[5,7]="23490"
CUST_ARRAY$[6,0]="000007",CUST_ARRAY$[6,1]="Jeff",CUST_ARRAY$[6,2]="Carson"
CUST_ARRAY$[6,3]="CMGI",CUST_ARRAY$[6,4]="3212 Charger Trail"
CUST_ARRAY$[6,5]="West Palm Beach",CUST_ARRAY$[6,6]="FL",CUST_ARRAY$[6,7]="43651"
CUST_ARRAY$[7,0]="000008",CUST_ARRAY$[7,1]="Jane",CUST_ARRAY$[7,2]="Kytel"
CUST_ARRAY$[7,3]="BEOS",CUST_ARRAY$[7,4]="6634 Dogwood"
CUST_ARRAY$[7,5]="Springdale",CUST_ARRAY$[7,6]="AK",CUST_ARRAY$[7,7]="65211"
CUST_ARRAY$[8,0]="000009",CUST_ARRAY$[8,1]="Laurence",CUST_ARRAY$[8,2]="Olivia"
CUST_ARRAY$[8,3]="Old Timers",CUST_ARRAY$[8,4]="1245 Golf Course"
CUST_ARRAY$[8,5]="Tulsa",CUST_ARRAY$[8,6]="OK",CUST_ARRAY$[8,7]="35213"
CUST_ARRAY$[9,0]="000010",CUST_ARRAY$[9,1]="Paul",CUST_ARRAY$[9,2]="Talbot"
CUST_ARRAY$[9,3]="Courier",CUST_ARRAY$[9,4]="3433 Font Way"
CUST_ARRAY$[9,5]="Dayton",CUST_ARRAY$[9,6]="OH",CUST_ARRAY$[9,7]="98812"
rem 'Create the data file
ERASE "BBjDAGrid.dat",ERR=CREATE_FILE
CREATE_FILE:
MKEYED "BBjDAGrid.dat",[1:1:6],20,150
let DATACHAN=UNT
OPEN (DATACHAN) "BBjDAGrid.dat"
DIM REC$:TMPL$
FOR CUST_NUM = 0 TO NUM_OF_CUSTOMERS - 1
FOR FIELD_NUM = 0 TO NUM_OF_FIELDS - 1
SWITCH FIELD_NUM
CASE 0
REC.CUST_NUMBER$=CUST_ARRAY$[CUST_NUM,FIELD_NUM]
break
CASE 1
REC.FIRST_NAME$=CUST_ARRAY$[CUST_NUM,FIELD_NUM]
break
CASE 2
REC.LAST_NAME$=CUST_ARRAY$[CUST_NUM,FIELD_NUM]
break
CASE 3
REC.COMPANY$=CUST_ARRAY$[CUST_NUM,FIELD_NUM]
break
CASE 4
REC.ADDRESS$=CUST_ARRAY$[CUST_NUM,FIELD_NUM]
break
CASE 5
REC.CITY$=CUST_ARRAY$[CUST_NUM,FIELD_NUM]
break
CASE 6
REC.STATE$=CUST_ARRAY$[CUST_NUM,FIELD_NUM]
break
CASE 7
REC.ZIP_CODE$=CUST_ARRAY$[CUST_NUM,FIELD_NUM]
break
SWEND
NEXT FIELD_NUM
WRITE RECORD (DATACHAN) REC$
NEXT CUST_NUM
rem 'CLOSE (DATACHAN); SELECT (DATACHAN) REC$ FROM "BBjDAGrid.dat"
return
rem 'Routine to setup the grid
SetupGrid:
rem 'Set the grid attributes
BBjGrid!.setHorizontalScrollable(mySysGui!.TRUE)
BBjGrid!.setVerticalScrollable(mySysGui!.TRUE)
BBjGrid!.setDefaultColumnWidth(110)
BBjGrid!.setScrollUpdate(mySysGui!.TRUE)
BBjGrid!.setDefaultAlignment(mySysGui!.GRID_ALIGN_LEFT)
BBjGrid!.setHasColumnHeader(mySysGui!.TRUE)
BBjGrid!.setDefaultAlignment(mySysGui!.GRID_ALIGN_LEFT)
BBjGrid!.setGridEditable(mySysGui!.TRUE)
BBjGrid!.setShowUpdateMessage(mySysGui!.TRUE)
print BBjGrid!.getShowUpdateMessage()
BBjGrid!.setShowInsertMessage(mySysGui!.TRUE)
print BBjGrid!.getShowInsertMessage()
return
|