savepoint; initial support for deleting selected records
This commit is contained in:
		
							parent
							
								
									c512466fc0
								
							
						
					
					
						commit
						8822d6cd45
					
				
					 3 changed files with 532 additions and 163 deletions
				
			
		| 
						 | 
					@ -14,39 +14,34 @@
 | 
				
			||||||
	</ALERT_RESOURCE>
 | 
						</ALERT_RESOURCE>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	<ALERT_RESOURCE RESOURCE_ID="1100">
 | 
						<ALERT_RESOURCE RESOURCE_ID="1100">
 | 
				
			||||||
		<ALERT_TYPE> ERROR_ALERT </ALERT_TYPE>
 | 
							<ALERT_TYPE> CONFIRMATION_ALERT </ALERT_TYPE>
 | 
				
			||||||
		<HELP_ID> 0 </HELP_ID>
 | 
							<HELP_ID> 0 </HELP_ID>
 | 
				
			||||||
		<DEFAULT_BUTTON> 0 </DEFAULT_BUTTON>
 | 
							<DEFAULT_BUTTON> 1 </DEFAULT_BUTTON>
 | 
				
			||||||
		<TITLE> "Scanner Error" </TITLE>
 | 
							<TITLE> "Are You Sure?" </TITLE>
 | 
				
			||||||
		<MESSAGE>
 | 
							<MESSAGE> "^1" </MESSAGE>
 | 
				
			||||||
			"There was an error closing the scanner.\n\nYou may need to reset the device."
 | 
					 | 
				
			||||||
		</MESSAGE>
 | 
					 | 
				
			||||||
		<BUTTONS>
 | 
							<BUTTONS>
 | 
				
			||||||
			<TEXT> "OK" </TEXT>
 | 
								<TEXT> "OK" </TEXT>
 | 
				
			||||||
 | 
								<TEXT> "Cancel" </TEXT>
 | 
				
			||||||
		</BUTTONS>
 | 
							</BUTTONS>
 | 
				
			||||||
	</ALERT_RESOURCE>
 | 
						</ALERT_RESOURCE>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	<ALERT_RESOURCE RESOURCE_ID="1200">
 | 
						<ALERT_RESOURCE RESOURCE_ID="1200">
 | 
				
			||||||
		<ALERT_TYPE> ERROR_ALERT </ALERT_TYPE>
 | 
							<ALERT_TYPE> INFORMATION_ALERT </ALERT_TYPE>
 | 
				
			||||||
		<HELP_ID> 0 </HELP_ID>
 | 
							<HELP_ID> 0 </HELP_ID>
 | 
				
			||||||
		<DEFAULT_BUTTON> 0 </DEFAULT_BUTTON>
 | 
							<DEFAULT_BUTTON> 0 </DEFAULT_BUTTON>
 | 
				
			||||||
		<TITLE> "Scanner Error" </TITLE>
 | 
							<TITLE> "FYI" </TITLE>
 | 
				
			||||||
		<MESSAGE>
 | 
							<MESSAGE> "^1" </MESSAGE>
 | 
				
			||||||
			"There was an error enabling the scanner.\n\nYou may need to reset the device."
 | 
					 | 
				
			||||||
		</MESSAGE>
 | 
					 | 
				
			||||||
		<BUTTONS>
 | 
							<BUTTONS>
 | 
				
			||||||
			<TEXT> "OK" </TEXT>
 | 
								<TEXT> "OK" </TEXT>
 | 
				
			||||||
		</BUTTONS>
 | 
							</BUTTONS>
 | 
				
			||||||
	</ALERT_RESOURCE>
 | 
						</ALERT_RESOURCE>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	<ALERT_RESOURCE RESOURCE_ID="1300">
 | 
						<ALERT_RESOURCE RESOURCE_ID="1400">
 | 
				
			||||||
		<ALERT_TYPE> ERROR_ALERT </ALERT_TYPE>
 | 
							<ALERT_TYPE> ERROR_ALERT </ALERT_TYPE>
 | 
				
			||||||
		<HELP_ID> 0 </HELP_ID>
 | 
							<HELP_ID> 0 </HELP_ID>
 | 
				
			||||||
		<DEFAULT_BUTTON> 0 </DEFAULT_BUTTON>
 | 
							<DEFAULT_BUTTON> 0 </DEFAULT_BUTTON>
 | 
				
			||||||
		<TITLE> "Scanner Error" </TITLE>
 | 
							<TITLE> "Scanner Error" </TITLE>
 | 
				
			||||||
		<MESSAGE>
 | 
							<MESSAGE> "^1\n\nYou may need to reset the device." </MESSAGE>
 | 
				
			||||||
			"There was an error opening the scanner.\n\nYou may need to reset the device."
 | 
					 | 
				
			||||||
		</MESSAGE>
 | 
					 | 
				
			||||||
		<BUTTONS>
 | 
							<BUTTONS>
 | 
				
			||||||
			<TEXT> "OK" </TEXT>
 | 
								<TEXT> "OK" </TEXT>
 | 
				
			||||||
		</BUTTONS>
 | 
							</BUTTONS>
 | 
				
			||||||
| 
						 | 
					@ -611,6 +606,30 @@
 | 
				
			||||||
	<MENU_BAR_RESOURCE RESOURCE_ID="1000" LOCALE="enUS" COMMENT="Main Form">
 | 
						<MENU_BAR_RESOURCE RESOURCE_ID="1000" LOCALE="enUS" COMMENT="Main Form">
 | 
				
			||||||
		<VISIBLE> TRUE </VISIBLE>
 | 
							<VISIBLE> TRUE </VISIBLE>
 | 
				
			||||||
		<MENUS>
 | 
							<MENUS>
 | 
				
			||||||
 | 
								<MENU>
 | 
				
			||||||
 | 
									<TITLE> "Edit" </TITLE>
 | 
				
			||||||
 | 
									<HIDDEN> FALSE </HIDDEN>
 | 
				
			||||||
 | 
									<BOUNDS>
 | 
				
			||||||
 | 
										<LEFT> 0 </LEFT>
 | 
				
			||||||
 | 
										<TOP> 0 </TOP>
 | 
				
			||||||
 | 
										<WIDTH> 0 </WIDTH>
 | 
				
			||||||
 | 
										<HEIGHT> 0 </HEIGHT>
 | 
				
			||||||
 | 
									</BOUNDS>
 | 
				
			||||||
 | 
									<TITLE_BOUNDS>
 | 
				
			||||||
 | 
										<LEFT> 0 </LEFT>
 | 
				
			||||||
 | 
										<TOP> 0 </TOP>
 | 
				
			||||||
 | 
										<WIDTH> 0 </WIDTH>
 | 
				
			||||||
 | 
										<HEIGHT> 0 </HEIGHT>
 | 
				
			||||||
 | 
									</TITLE_BOUNDS>
 | 
				
			||||||
 | 
									<MENU_ITEMS>
 | 
				
			||||||
 | 
										<MENU_ITEM>
 | 
				
			||||||
 | 
											<ID> 1001 </ID>
 | 
				
			||||||
 | 
											<TITLE> "Delete Record(s)" </TITLE>
 | 
				
			||||||
 | 
											<COMMAND> "" </COMMAND>
 | 
				
			||||||
 | 
											<HIDDEN> FALSE </HIDDEN>
 | 
				
			||||||
 | 
										</MENU_ITEM>
 | 
				
			||||||
 | 
									</MENU_ITEMS>
 | 
				
			||||||
 | 
								</MENU>
 | 
				
			||||||
			<MENU COMMENT="MainOptions">
 | 
								<MENU COMMENT="MainOptions">
 | 
				
			||||||
				<TITLE> "Options" </TITLE>
 | 
									<TITLE> "Options" </TITLE>
 | 
				
			||||||
				<HIDDEN> FALSE </HIDDEN>
 | 
									<HIDDEN> FALSE </HIDDEN>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										613
									
								
								src/AppMain.c
									
										
									
									
									
								
							
							
						
						
									
										613
									
								
								src/AppMain.c
									
										
									
									
									
								
							| 
						 | 
					@ -110,6 +110,8 @@ Boolean         gBabbo = false;
 | 
				
			||||||
//UInt16        gNumRows = 11;
 | 
					//UInt16        gNumRows = 11;
 | 
				
			||||||
//MemHandle     gHandles[11][3];
 | 
					//MemHandle     gHandles[11][3];
 | 
				
			||||||
Int16           gTopVisibleRecord = -1;
 | 
					Int16           gTopVisibleRecord = -1;
 | 
				
			||||||
 | 
					Boolean         scanRecordsSelected[12];
 | 
				
			||||||
 | 
					Int16           eventEnteredRow = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// This handle serves the barcode field.
 | 
					// This handle serves the barcode field.
 | 
				
			||||||
/* MemHandle       hBarcode; */
 | 
					/* MemHandle       hBarcode; */
 | 
				
			||||||
| 
						 | 
					@ -148,11 +150,17 @@ Boolean         gQuantityTouched;
 | 
				
			||||||
 * Type Definitions
 | 
					 * Type Definitions
 | 
				
			||||||
 ************************************************************/
 | 
					 ************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* typedef struct { */
 | 
				
			||||||
 | 
					/*     Char        barcode[15]; */
 | 
				
			||||||
 | 
					/*     Char        cases[4]; */
 | 
				
			||||||
 | 
					/*     Char        units[4]; */
 | 
				
			||||||
 | 
					/* } RatScanDbRecord; */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
    Char        barcode[15];
 | 
					    Char        barcode[15];
 | 
				
			||||||
    Char        cases[4];
 | 
					    UInt16      cases;
 | 
				
			||||||
    Char        units[4];
 | 
					    UInt16      units;
 | 
				
			||||||
} RatScanDbRecord;
 | 
					} RattailScanRecord;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/************************************************************
 | 
					/************************************************************
 | 
				
			||||||
| 
						 | 
					@ -180,6 +188,10 @@ static Boolean MainFormDoCommand(UInt16 command);
 | 
				
			||||||
// Main Form Table
 | 
					// Main Form Table
 | 
				
			||||||
static void MainFormLoadTable(TablePtr table, Boolean updateScroll);
 | 
					static void MainFormLoadTable(TablePtr table, Boolean updateScroll);
 | 
				
			||||||
static void DrawCustomTableItem(void* table, Int16 row, Int16 col, RectangleType* bounds);
 | 
					static void DrawCustomTableItem(void* table, Int16 row, Int16 col, RectangleType* bounds);
 | 
				
			||||||
 | 
					/* static void BarcodeSelectItem(Int16 row); */
 | 
				
			||||||
 | 
					static Boolean TableHitTest(TablePtr table, Int16 screenX, Int16 screenY);
 | 
				
			||||||
 | 
					static Int16 TableRowHitTest(TablePtr table, Int16 screenX, Int16 screenY);
 | 
				
			||||||
 | 
					static void ClearScanRecordSelection();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void FocusBarcode();
 | 
					static void FocusBarcode();
 | 
				
			||||||
#ifdef SCANLIB_SYMBOL
 | 
					#ifdef SCANLIB_SYMBOL
 | 
				
			||||||
| 
						 | 
					@ -295,7 +307,7 @@ static Err AppStart()
 | 
				
			||||||
    if (ScanOpenDecoder() == STATUS_OK) {
 | 
					    if (ScanOpenDecoder() == STATUS_OK) {
 | 
				
			||||||
        bHaveScanner = true;
 | 
					        bHaveScanner = true;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        FrmAlert(AlertScannerOpenError);
 | 
					        FrmCustomAlert(AlertScannerError, "There was an error opening the scanner.", "", "");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -332,7 +344,7 @@ static void AppStop()
 | 
				
			||||||
#ifdef SCANLIB_SYMBOL
 | 
					#ifdef SCANLIB_SYMBOL
 | 
				
			||||||
    if (bHaveScanner) {
 | 
					    if (bHaveScanner) {
 | 
				
			||||||
        if (ScanCloseDecoder() != 0) {
 | 
					        if (ScanCloseDecoder() != 0) {
 | 
				
			||||||
            FrmAlert(AlertScannerCloseError);
 | 
					            FrmCustomAlert(AlertScannerError, "There was an error closing the scanner.", "", "");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -434,10 +446,12 @@ static Boolean AppHandleEvent(EventPtr event)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static Boolean MainFormHandleEvent(EventPtr event)
 | 
					static Boolean MainFormHandleEvent(EventPtr event)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Boolean     handled = false;
 | 
					    Boolean             handled = false;
 | 
				
			||||||
    FormPtr     form;
 | 
					    FormPtr             form;
 | 
				
			||||||
    TablePtr    table;
 | 
					    TablePtr            table;
 | 
				
			||||||
    //UInt16      objId;
 | 
					    //UInt16      objId;
 | 
				
			||||||
 | 
					    /* Int16               row, r; */
 | 
				
			||||||
 | 
					    Int16               row;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    form = FrmGetFormPtr(MainForm);
 | 
					    form = FrmGetFormPtr(MainForm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -474,6 +488,63 @@ static Boolean MainFormHandleEvent(EventPtr event)
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    case penDownEvent:
 | 
				
			||||||
 | 
					        eventEnteredRow = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        table = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScanRecords));
 | 
				
			||||||
 | 
					        if (TableHitTest(table, event->screenX, event->screenY)) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ClearScanRecordSelection();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            row = TableRowHitTest(table, event->screenX, event->screenY);
 | 
				
			||||||
 | 
					            if (row >= 0) {
 | 
				
			||||||
 | 
					                eventEnteredRow = row;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            handled = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    case penMoveEvent:
 | 
				
			||||||
 | 
					        table = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScanRecords));
 | 
				
			||||||
 | 
					        if (TableHitTest(table, event->screenX, event->screenY)) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            row = TableRowHitTest(table, event->screenX, event->screenY);
 | 
				
			||||||
 | 
					            if (row >= 0) {
 | 
				
			||||||
 | 
					                if (! scanRecordsSelected[row]) {
 | 
				
			||||||
 | 
					                    scanRecordsSelected[row] = true;
 | 
				
			||||||
 | 
					                    TblMarkRowInvalid(table, row);
 | 
				
			||||||
 | 
					                    TblRedrawTable(table);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            handled = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    case penUpEvent:
 | 
				
			||||||
 | 
					        if (eventEnteredRow >= 0) {
 | 
				
			||||||
 | 
					            table = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScanRecords));
 | 
				
			||||||
 | 
					            if (TableHitTest(table, event->screenX, event->screenY)) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                row = TableRowHitTest(table, event->screenX, event->screenY);
 | 
				
			||||||
 | 
					                if (row >= 0) {
 | 
				
			||||||
 | 
					                    if (! scanRecordsSelected[row]) {
 | 
				
			||||||
 | 
					                        scanRecordsSelected[row] = true;
 | 
				
			||||||
 | 
					                        TblMarkRowInvalid(table, row);
 | 
				
			||||||
 | 
					                        TblRedrawTable(table);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                handled = true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    case sclEnterEvent:
 | 
				
			||||||
 | 
					        ClearScanRecordSelection();
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
    case sclRepeatEvent:
 | 
					    case sclRepeatEvent:
 | 
				
			||||||
        if (event->data.sclRepeat.newValue > event->data.sclRepeat.value)
 | 
					        if (event->data.sclRepeat.newValue > event->data.sclRepeat.value)
 | 
				
			||||||
            gTopVisibleRecord += (event->data.sclRepeat.newValue - event->data.sclRepeat.value);
 | 
					            gTopVisibleRecord += (event->data.sclRepeat.newValue - event->data.sclRepeat.value);
 | 
				
			||||||
| 
						 | 
					@ -605,6 +676,11 @@ static void MainFormInit(FormPtr form)
 | 
				
			||||||
    TablePtr    table;
 | 
					    TablePtr    table;
 | 
				
			||||||
    Int16       cols, col, rows, row;
 | 
					    Int16       cols, col, rows, row;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Clear row selection state.
 | 
				
			||||||
 | 
					    for (row = 0; row < 12; row++) {
 | 
				
			||||||
 | 
					        scanRecordsSelected[row] = false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    table = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScanRecords));
 | 
					    table = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScanRecords));
 | 
				
			||||||
    TblHasScrollBar(table, true);
 | 
					    TblHasScrollBar(table, true);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
| 
						 | 
					@ -641,17 +717,55 @@ static void MainFormInit(FormPtr form)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static Boolean MainFormDoCommand(UInt16 command)
 | 
					static Boolean MainFormDoCommand(UInt16 command)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Boolean     handled = false;
 | 
					    Boolean     handled;
 | 
				
			||||||
    FormPtr     form;
 | 
					    FormPtr     form;
 | 
				
			||||||
 | 
					    TablePtr    table;
 | 
				
			||||||
 | 
					    DmOpenRef   db;
 | 
				
			||||||
 | 
					    UInt16      row, rowIndex, offset;
 | 
				
			||||||
 | 
					    Boolean     selected;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    handled = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    switch (command) {
 | 
					    switch (command) {
 | 
				
			||||||
    case MainOptionsAboutStarterApp:
 | 
					
 | 
				
			||||||
 | 
					    case MainEditDeleteRecords:
 | 
				
			||||||
 | 
					        selected = false;
 | 
				
			||||||
 | 
					        for (row = 0; row < 12; row++) {
 | 
				
			||||||
 | 
					            if (scanRecordsSelected[row]) {
 | 
				
			||||||
 | 
					                selected = true;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (selected) {
 | 
				
			||||||
 | 
					            if (FrmCustomAlert(AlertConfirmation, "Do you really wish to delete the selected record(s)?", "", "") == 0) {
 | 
				
			||||||
 | 
					                form = FrmGetFormPtr(MainForm);
 | 
				
			||||||
 | 
					                table = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScanRecords));
 | 
				
			||||||
 | 
					                db = OpenScanDatabase();
 | 
				
			||||||
 | 
					                offset = 0;
 | 
				
			||||||
 | 
					                for (row = 0; row < 12; row++) {
 | 
				
			||||||
 | 
					                    if (scanRecordsSelected[row]) {
 | 
				
			||||||
 | 
					                        rowIndex = TblGetRowID(table, row);
 | 
				
			||||||
 | 
					                        DmRemoveRecord(db, rowIndex - offset++);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                DmCloseDatabase(db);
 | 
				
			||||||
 | 
					                MainFormLoadTable(table, true);
 | 
				
			||||||
 | 
					                ClearScanRecordSelection();
 | 
				
			||||||
 | 
					                TblRedrawTable(table);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            FrmCustomAlert(AlertInformation, "You don't have any records selected for deletion.", "", "");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        handled = true;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    case MainOptionsAboutRattail:
 | 
				
			||||||
        form = FrmInitForm(AboutForm);
 | 
					        form = FrmInitForm(AboutForm);
 | 
				
			||||||
        FrmDoDialog(form);
 | 
					        FrmDoDialog(form);
 | 
				
			||||||
        FrmDeleteForm(form);
 | 
					        FrmDeleteForm(form);
 | 
				
			||||||
        handled = true;
 | 
					        handled = true;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    return handled;
 | 
					    return handled;
 | 
				
			||||||
| 
						 | 
					@ -666,29 +780,141 @@ static Boolean MainFormDoCommand(UInt16 command)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void DrawCustomTableItem(void* table, Int16 row, Int16 col, RectangleType* bounds)
 | 
					static void DrawCustomTableItem(void* table, Int16 row, Int16 col, RectangleType* bounds)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    Char *      text;
 | 
					    Char*       barcode;
 | 
				
			||||||
    UInt16      size;
 | 
					    Char        quantity[4];
 | 
				
			||||||
    Coord       x;
 | 
					    Coord       x;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    text = (Char *) TblGetItemPtr(table, row, col);
 | 
					    if (col == 0) {
 | 
				
			||||||
    if (*text != 0) {
 | 
					        barcode = (Char*) TblGetItemPtr(table, row, col);
 | 
				
			||||||
        size = StrLen(text);
 | 
					        WinDrawChars(barcode, StrLen(barcode), bounds->topLeft.x, bounds->topLeft.y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (col == 0) { // barcode
 | 
					    } else {
 | 
				
			||||||
            WinDrawChars(text, size, bounds->topLeft.x, bounds->topLeft.y);
 | 
					        StrIToA(quantity, TblGetItemInt(table, row, col));
 | 
				
			||||||
 | 
					        x = bounds->topLeft.x + bounds->extent.x - FntCharsWidth(quantity, StrLen(quantity));
 | 
				
			||||||
 | 
					        WinDrawChars(quantity, StrLen(quantity), x, bounds->topLeft.y);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } else { // cases or units
 | 
					    if (scanRecordsSelected[row]) {
 | 
				
			||||||
 | 
					        WinInvertRectangle(bounds, 0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Only draw value if nonzero.
 | 
					/* static void DrawCustomTableItem(void* table, Int16 row, Int16 col, RectangleType* bounds) */
 | 
				
			||||||
            if (StrCompareAscii(text, "0") != 0) {
 | 
					/* { */
 | 
				
			||||||
 | 
					/*     Char*       text; */
 | 
				
			||||||
 | 
					/*     UInt16      size; */
 | 
				
			||||||
 | 
					/*     Coord       x; */
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
                // Draw value right-aligned.
 | 
					/*     text = (Char*) TblGetItemPtr(table, row, col); */
 | 
				
			||||||
                x = bounds->topLeft.x + bounds->extent.x - FntCharsWidth(text, size);
 | 
					/*     if (*text != 0) { */
 | 
				
			||||||
                WinDrawChars(text, size, x, bounds->topLeft.y);
 | 
					/*         size = StrLen(text); */
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					/*         if (col == 0) { // barcode */
 | 
				
			||||||
 | 
					/*             WinDrawChars(text, size, bounds->topLeft.x, bounds->topLeft.y); */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*         } else { // cases or units */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*             /\* // Only draw value if nonzero. *\/ */
 | 
				
			||||||
 | 
					/*             /\* if (StrCompareAscii(text, "0") != 0) { *\/ */
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					/*             /\*     // Draw value right-aligned. *\/ */
 | 
				
			||||||
 | 
					/*             /\*     x = bounds->topLeft.x + bounds->extent.x - FntCharsWidth(text, size); *\/ */
 | 
				
			||||||
 | 
					/*             /\*     WinDrawChars(text, size, x, bounds->topLeft.y); *\/ */
 | 
				
			||||||
 | 
					/*             /\* } *\/ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*             /\* if (StrCompareAscii(text, "0") == 0) { *\/ */
 | 
				
			||||||
 | 
					/*             /\*     WinDrawChars(" ", 1, bounds->topLeft.x, bounds->topLeft.y); *\/ */
 | 
				
			||||||
 | 
					/*             /\* } else { *\/ */
 | 
				
			||||||
 | 
					/*                 x = bounds->topLeft.x + bounds->extent.x - FntCharsWidth(text, size); */
 | 
				
			||||||
 | 
					/*                 WinDrawChars(text, size, x, bounds->topLeft.y); */
 | 
				
			||||||
 | 
					/*             /\* } *\/ */
 | 
				
			||||||
 | 
					/*         } */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*         // Invert item if row is selected. */
 | 
				
			||||||
 | 
					/*         if (scanRecordsSelected[row]) { */
 | 
				
			||||||
 | 
					/*             WinInvertRectangle(bounds, 0); */
 | 
				
			||||||
 | 
					/*         } */
 | 
				
			||||||
 | 
					/*     } */
 | 
				
			||||||
 | 
					/* } */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/************************************************************
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * FUNCTION:    ClearScanRecordSelection
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 ************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void ClearScanRecordSelection()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    FormPtr     form;
 | 
				
			||||||
 | 
					    TablePtr    table;
 | 
				
			||||||
 | 
					    Int16       row;
 | 
				
			||||||
 | 
					    Boolean     dirty = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    form = FrmGetFormPtr(MainForm);
 | 
				
			||||||
 | 
					    table = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScanRecords));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (row = 0; row < 12; row++) {
 | 
				
			||||||
 | 
					        if (scanRecordsSelected[row]) {
 | 
				
			||||||
 | 
					            scanRecordsSelected[row] = false;
 | 
				
			||||||
 | 
					            TblMarkRowInvalid(table, row);
 | 
				
			||||||
 | 
					            dirty = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (dirty) {
 | 
				
			||||||
 | 
					        TblRedrawTable(table);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/************************************************************
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * FUNCTION:    TableHitTest
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 ************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static Boolean TableHitTest(TablePtr table, Int16 screenX, Int16 screenY)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    RectangleType       bounds;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    TblGetBounds(table, &bounds);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ((screenX >= bounds.topLeft.x) && (screenX <= (bounds.topLeft.x + bounds.extent.x))
 | 
				
			||||||
 | 
					        && (screenY >= bounds.topLeft.y) && (screenY <= (bounds.topLeft.y + bounds.extent.y))) {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/************************************************************
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * FUNCTION:    TableRowHitTest
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 ************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static Int16 TableRowHitTest(TablePtr table, Int16 screenX, Int16 screenY)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    RectangleType       bounds;
 | 
				
			||||||
 | 
					    Int16               row, col;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (row = 0; row < 12; row++) {
 | 
				
			||||||
 | 
					        if (! TblRowUsable(table, row))
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (col = 0; col < 3; col++) {
 | 
				
			||||||
 | 
					            TblGetItemBounds(table, row, col, &bounds);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if ((screenX >= bounds.topLeft.x) && (screenX <= (bounds.topLeft.x + bounds.extent.x))
 | 
				
			||||||
 | 
					                && (screenY >= bounds.topLeft.y) && (screenY <= (bounds.topLeft.y + bounds.extent.y))) {
 | 
				
			||||||
 | 
					                return row;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
            
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return -1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -701,57 +927,132 @@ static void DrawCustomTableItem(void* table, Int16 row, Int16 col, RectangleType
 | 
				
			||||||
static void MainFormLoadTable(TablePtr table, Boolean updateScroll)
 | 
					static void MainFormLoadTable(TablePtr table, Boolean updateScroll)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    DmOpenRef           db;
 | 
					    DmOpenRef           db;
 | 
				
			||||||
    UInt16              numRecords;
 | 
					    UInt16              records, recordIndex;
 | 
				
			||||||
 | 
					    Int16               rows, row;
 | 
				
			||||||
 | 
					    RattailScanRecord*  recordP;
 | 
				
			||||||
    MemHandle           recordH;
 | 
					    MemHandle           recordH;
 | 
				
			||||||
    RatScanDbRecord*    recordP;
 | 
					 | 
				
			||||||
    UInt16              rows, row, rowId;
 | 
					 | 
				
			||||||
    FormPtr             form;
 | 
					    FormPtr             form;
 | 
				
			||||||
    ScrollBarPtr        scroll;
 | 
					    ScrollBarPtr        scroll;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    db = OpenScanDatabase();
 | 
					    db = OpenScanDatabase();
 | 
				
			||||||
    if (db == NULL)
 | 
					    records = DmNumRecords(db);
 | 
				
			||||||
        return;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    numRecords = DmNumRecords(db);
 | 
					    if (gTopVisibleRecord < 0) {
 | 
				
			||||||
    rows = (numRecords < 12) ? numRecords : 12;
 | 
					        gTopVisibleRecord = (records > 12) ? (records - 12) : 0;
 | 
				
			||||||
    if (gTopVisibleRecord < 0)
 | 
					    }
 | 
				
			||||||
        gTopVisibleRecord = (numRecords > 12) ? (numRecords - 12) : 0;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    rows = (records < 12) ? records : 12;
 | 
				
			||||||
    for (row = 0; row < rows; row++) {
 | 
					    for (row = 0; row < rows; row++) {
 | 
				
			||||||
        rowId = gTopVisibleRecord + row;
 | 
					        recordIndex = gTopVisibleRecord + row;
 | 
				
			||||||
        recordH = DmGetRecord(db, rowId);
 | 
					        recordH = DmGetRecord(db, recordIndex);
 | 
				
			||||||
        recordP = (MemPtr) MemHandleLock(recordH);
 | 
					        recordP = MemHandleLock(recordH);
 | 
				
			||||||
        TblSetItemPtr(table, row, 0, &recordP->barcode);
 | 
					
 | 
				
			||||||
        if (StrCompareAscii(recordP->cases, "0") != 0) {
 | 
					        TblSetItemPtr(table, row, 0, recordP->barcode);
 | 
				
			||||||
            TblSetItemPtr(table, row, 1, &recordP->cases);
 | 
					        TblSetItemInt(table, row, 1, recordP->cases);
 | 
				
			||||||
        } else {
 | 
					        TblSetItemInt(table, row, 2, recordP->units);
 | 
				
			||||||
            TblSetItemPtr(table, row, 1, "");
 | 
					
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if (StrCompareAscii(recordP->units, "0") != 0) {
 | 
					 | 
				
			||||||
            TblSetItemPtr(table, row, 2, &recordP->units);
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            TblSetItemPtr(table, row, 2, "");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        MemHandleUnlock(recordH);
 | 
					        MemHandleUnlock(recordH);
 | 
				
			||||||
        DmReleaseRecord(db, rowId, false);
 | 
					        DmReleaseRecord(db, recordIndex, false);
 | 
				
			||||||
        TblSetRowID(table, row, rowId);
 | 
					
 | 
				
			||||||
 | 
					        TblSetRowID(table, row, recordIndex);
 | 
				
			||||||
        TblSetRowUsable(table, row, true);
 | 
					        TblSetRowUsable(table, row, true);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DmCloseDatabase(db);
 | 
					    DmCloseDatabase(db);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (row = 11; row >= rows; row--) {
 | 
				
			||||||
 | 
					        if (TblRowUsable(table, row)) {
 | 
				
			||||||
 | 
					            TblSetRowUsable(table, row, false);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    TblMarkTableInvalid(table);
 | 
					    TblMarkTableInvalid(table);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (updateScroll) {
 | 
					    if (updateScroll) {
 | 
				
			||||||
        form = FrmGetFormPtr(MainForm);
 | 
					        form = FrmGetFormPtr(MainForm);
 | 
				
			||||||
        scroll = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScroller));
 | 
					        scroll = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScroller));
 | 
				
			||||||
        if (numRecords <= 12) {
 | 
					        if (records <= 12) {
 | 
				
			||||||
            SclSetScrollBar(scroll, 0, 0, 0, 0);
 | 
					            SclSetScrollBar(scroll, 0, 0, 0, 0);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            SclSetScrollBar(scroll, gTopVisibleRecord, 0, numRecords - 12, 11);
 | 
					            SclSetScrollBar(scroll, gTopVisibleRecord, 0, records - 12, 11);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* static void MainFormLoadTable(TablePtr table, Boolean updateScroll) */
 | 
				
			||||||
 | 
					/* { */
 | 
				
			||||||
 | 
					/*     DmOpenRef           db; */
 | 
				
			||||||
 | 
					/*     UInt16              numRecords; */
 | 
				
			||||||
 | 
					/*     MemHandle           recordH; */
 | 
				
			||||||
 | 
					/*     /\* RatScanDbRecord*    recordP; *\/ */
 | 
				
			||||||
 | 
					/*     RattailScanRecord*  recordP; */
 | 
				
			||||||
 | 
					/*     UInt16              rows, row, rowId; */
 | 
				
			||||||
 | 
					/*     FormPtr             form; */
 | 
				
			||||||
 | 
					/*     ScrollBarPtr        scroll; */
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					/*     db = OpenScanDatabase(); */
 | 
				
			||||||
 | 
					/*     if (db == NULL) */
 | 
				
			||||||
 | 
					/*         return; */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*     numRecords = DmNumRecords(db); */
 | 
				
			||||||
 | 
					/*     rows = (numRecords < 12) ? numRecords : 12; */
 | 
				
			||||||
 | 
					/*     if (gTopVisibleRecord < 0) */
 | 
				
			||||||
 | 
					/*         gTopVisibleRecord = (numRecords > 12) ? (numRecords - 12) : 0; */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*     for (row = 0; row < rows; row++) { */
 | 
				
			||||||
 | 
					/*         rowId = gTopVisibleRecord + row; */
 | 
				
			||||||
 | 
					/*         recordH = DmGetRecord(db, rowId); */
 | 
				
			||||||
 | 
					/*         recordP = (MemPtr) MemHandleLock(recordH); */
 | 
				
			||||||
 | 
					/*         TblSetItemPtr(table, row, 0, &recordP->barcode); */
 | 
				
			||||||
 | 
					/*         /\* if (StrCompareAscii(recordP->cases, "0") != 0) { *\/ */
 | 
				
			||||||
 | 
					/*         /\*     TblSetItemPtr(table, row, 1, &recordP->cases); *\/ */
 | 
				
			||||||
 | 
					/*         /\* } else { *\/ */
 | 
				
			||||||
 | 
					/*         /\*     TblSetItemPtr(table, row, 1, ""); *\/ */
 | 
				
			||||||
 | 
					/*         /\* } *\/ */
 | 
				
			||||||
 | 
					/*         /\* if (StrCompareAscii(recordP->units, "0") != 0) { *\/ */
 | 
				
			||||||
 | 
					/*         /\*     TblSetItemPtr(table, row, 2, &recordP->units); *\/ */
 | 
				
			||||||
 | 
					/*         /\* } else { *\/ */
 | 
				
			||||||
 | 
					/*         /\*     TblSetItemPtr(table, row, 2, ""); *\/ */
 | 
				
			||||||
 | 
					/*         /\* } *\/ */
 | 
				
			||||||
 | 
					/*         MemHandleUnlock(recordH); */
 | 
				
			||||||
 | 
					/*         DmReleaseRecord(db, rowId, false); */
 | 
				
			||||||
 | 
					/*         TblSetRowID(table, row, rowId); */
 | 
				
			||||||
 | 
					/*         TblSetRowUsable(table, row, true); */
 | 
				
			||||||
 | 
					/*     } */
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					/*     DmCloseDatabase(db); */
 | 
				
			||||||
 | 
					/*     TblMarkTableInvalid(table); */
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					/*     if (updateScroll) { */
 | 
				
			||||||
 | 
					/*         form = FrmGetFormPtr(MainForm); */
 | 
				
			||||||
 | 
					/*         scroll = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScroller)); */
 | 
				
			||||||
 | 
					/*         if (numRecords <= 12) { */
 | 
				
			||||||
 | 
					/*             SclSetScrollBar(scroll, 0, 0, 0, 0); */
 | 
				
			||||||
 | 
					/*         } else { */
 | 
				
			||||||
 | 
					/*             SclSetScrollBar(scroll, gTopVisibleRecord, 0, numRecords - 12, 11); */
 | 
				
			||||||
 | 
					/*         } */
 | 
				
			||||||
 | 
					/*     } */
 | 
				
			||||||
 | 
					/* } */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/************************************************************
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * FUNCTION:    BarcodeSelectItem
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 ************************************************************/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* static void BarcodeSelectItem(Int16 row) */
 | 
				
			||||||
 | 
					/* { */
 | 
				
			||||||
 | 
					/*     FormPtr     form; */
 | 
				
			||||||
 | 
					/*     TablePtr    table; */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*     form = FrmGetFormPtr(MainForm); */
 | 
				
			||||||
 | 
					/*     table = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScanRecords)); */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*     scanRecordsSelected[row] = true; */
 | 
				
			||||||
 | 
					/*     TblRedrawTable(table); */
 | 
				
			||||||
 | 
					/* } */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/************************************************************
 | 
					/************************************************************
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					@ -902,7 +1203,7 @@ static void EnableScanner(Boolean enable)
 | 
				
			||||||
        if (enable) {
 | 
					        if (enable) {
 | 
				
			||||||
            if (ScanGetScanEnabled() == 0) {
 | 
					            if (ScanGetScanEnabled() == 0) {
 | 
				
			||||||
                if (ScanCmdScanEnable() != STATUS_OK) {
 | 
					                if (ScanCmdScanEnable() != STATUS_OK) {
 | 
				
			||||||
                    FrmAlert(AlertScannerEnableError);
 | 
					                    FrmCustomAlert(AlertScannerError, "There was an error enabling the scanner.", "", "");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
| 
						 | 
					@ -989,6 +1290,7 @@ static void ProcessScan()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    FormPtr     form;
 | 
					    FormPtr     form;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ClearScanRecordSelection();
 | 
				
			||||||
    form = FrmGetFormPtr(MainForm);
 | 
					    form = FrmGetFormPtr(MainForm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (IsChecked(form, MainFormStopOnCases)) {
 | 
					    if (IsChecked(form, MainFormStopOnCases)) {
 | 
				
			||||||
| 
						 | 
					@ -1011,96 +1313,36 @@ static void ProcessScan()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void StoreScanData()
 | 
					static void StoreScanData()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    FormPtr     form;
 | 
					    FormPtr             form;
 | 
				
			||||||
    FieldPtr    barcode;
 | 
					    ControlPtr          ctrl;
 | 
				
			||||||
    ControlPtr  cases, units;
 | 
					    DmOpenRef           db;
 | 
				
			||||||
    /* Char*       quantity; */
 | 
					    RattailScanRecord   record;
 | 
				
			||||||
    UInt32      size, offset;
 | 
					    UInt16              recordIndex;
 | 
				
			||||||
    DmOpenRef   db;
 | 
					    MemHandle           recordH;
 | 
				
			||||||
    UInt16      recordIndex;
 | 
					    MemPtr              recordP;
 | 
				
			||||||
    MemHandle   recordH;
 | 
					    TablePtr            table;
 | 
				
			||||||
    MemPtr      recordP;
 | 
					    UInt16              row;
 | 
				
			||||||
    TablePtr    table;
 | 
					 | 
				
			||||||
    UInt16      row;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Get form and barcode field pointers.
 | 
					 | 
				
			||||||
    form = FrmGetFormPtr(MainForm);
 | 
					    form = FrmGetFormPtr(MainForm);
 | 
				
			||||||
    barcode = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormBarcode));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Set focus to barcode field if empty.
 | 
					    ctrl = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormBarcode));
 | 
				
			||||||
    if (FldGetTextLength(barcode) == 0) {
 | 
					    StrCopy(record.barcode, FldGetTextPtr((FieldPtr) ctrl));
 | 
				
			||||||
        FocusBarcode();
 | 
					 | 
				
			||||||
        return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Get case and unit field pointers.
 | 
					    ctrl = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormCases));
 | 
				
			||||||
    cases = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormCases));
 | 
					    record.cases = StrAToI(CtlGetLabel(ctrl));
 | 
				
			||||||
    units = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormUnits));
 | 
					
 | 
				
			||||||
 | 
					    ctrl = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormUnits));
 | 
				
			||||||
 | 
					    record.units = StrAToI(CtlGetLabel(ctrl));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Open the database and create a new record.
 | 
					 | 
				
			||||||
    db = OpenScanDatabase();
 | 
					    db = OpenScanDatabase();
 | 
				
			||||||
    if (db == NULL) {
 | 
					 | 
				
			||||||
        return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    recordIndex = dmMaxRecordIndex;
 | 
					    recordIndex = dmMaxRecordIndex;
 | 
				
			||||||
    recordH = DmNewRecord(db, &recordIndex, sizeof(RatScanDbRecord));
 | 
					    recordH = DmNewRecord(db, &recordIndex, sizeof(RattailScanRecord));
 | 
				
			||||||
    if (recordH == 0) {
 | 
					 | 
				
			||||||
        DmCloseDatabase(db);
 | 
					 | 
				
			||||||
        return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    // Write scan data to the record...
 | 
					 | 
				
			||||||
    recordP = MemHandleLock(recordH);
 | 
					    recordP = MemHandleLock(recordH);
 | 
				
			||||||
    offset = 0;
 | 
					    DmWrite(recordP, 0, &record, sizeof(RattailScanRecord));
 | 
				
			||||||
 | 
					 | 
				
			||||||
    size = FldGetTextLength(barcode);
 | 
					 | 
				
			||||||
    DmWrite(recordP, offset, FldGetTextPtr(barcode), size);
 | 
					 | 
				
			||||||
    offset += size;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    size = 15 - size;
 | 
					 | 
				
			||||||
    DmSet(recordP, offset, size, 0);
 | 
					 | 
				
			||||||
    offset += size;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /*
 | 
					 | 
				
			||||||
          size = FldGetTextLength(cases);
 | 
					 | 
				
			||||||
          DmWrite(recordP, offset, FldGetTextPtr(cases), size);
 | 
					 | 
				
			||||||
          offset += size;
 | 
					 | 
				
			||||||
    */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /* size = 2; */
 | 
					 | 
				
			||||||
    /* DmWrite(recordP, offset, "0", 2); */
 | 
					 | 
				
			||||||
    /* offset += size; */
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    /* quantity = CtlGetLabel(cases); */
 | 
					 | 
				
			||||||
    /* size = StrLen(quantity); */
 | 
					 | 
				
			||||||
    /* DmWrite(recordP, offset, quantity, size); */
 | 
					 | 
				
			||||||
    /* offset += size; */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    size = StrLen(CtlGetLabel(cases));
 | 
					 | 
				
			||||||
    DmWrite(recordP, offset, CtlGetLabel(cases), size);
 | 
					 | 
				
			||||||
    offset += size;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    size = 4 - size;
 | 
					 | 
				
			||||||
    DmSet(recordP, offset, size, 0);
 | 
					 | 
				
			||||||
    offset += size;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    /* size = FldGetTextLength(units); */
 | 
					 | 
				
			||||||
    /* DmWrite(recordP, offset, FldGetTextPtr(units), size); */
 | 
					 | 
				
			||||||
    /* offset += size; */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    size = StrLen(CtlGetLabel(units));
 | 
					 | 
				
			||||||
    DmWrite(recordP, offset, CtlGetLabel(units), size);
 | 
					 | 
				
			||||||
    offset += size;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    size = 4 - size;
 | 
					 | 
				
			||||||
    DmSet(recordP, offset, size, 0);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    // ...then close the record and database.
 | 
					 | 
				
			||||||
    MemHandleUnlock(recordH);
 | 
					    MemHandleUnlock(recordH);
 | 
				
			||||||
    DmReleaseRecord(db, recordIndex, false);
 | 
					    DmReleaseRecord(db, recordIndex, false);
 | 
				
			||||||
    DmCloseDatabase(db);
 | 
					    DmCloseDatabase(db);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Redraw the table.
 | 
					 | 
				
			||||||
    table = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScanRecords));
 | 
					    table = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScanRecords));
 | 
				
			||||||
    row = TblGetLastUsableRow(table);
 | 
					    row = TblGetLastUsableRow(table);
 | 
				
			||||||
    if (row == tblUnusableRow) {
 | 
					    if (row == tblUnusableRow) {
 | 
				
			||||||
| 
						 | 
					@ -1114,6 +1356,115 @@ static void StoreScanData()
 | 
				
			||||||
    FocusBarcode();
 | 
					    FocusBarcode();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* static void StoreScanData() */
 | 
				
			||||||
 | 
					/* { */
 | 
				
			||||||
 | 
					/*     FormPtr     form; */
 | 
				
			||||||
 | 
					/*     FieldPtr    barcode; */
 | 
				
			||||||
 | 
					/*     /\* ControlPtr  cases, units; *\/ */
 | 
				
			||||||
 | 
					/*     /\* Char*       quantity; *\/ */
 | 
				
			||||||
 | 
					/*     /\* UInt8       quantity; *\/ */
 | 
				
			||||||
 | 
					/*     UInt32      size, offset; */
 | 
				
			||||||
 | 
					/*     DmOpenRef   db; */
 | 
				
			||||||
 | 
					/*     UInt16      recordIndex; */
 | 
				
			||||||
 | 
					/*     MemHandle   recordH; */
 | 
				
			||||||
 | 
					/*     MemPtr      recordP; */
 | 
				
			||||||
 | 
					/*     TablePtr    table; */
 | 
				
			||||||
 | 
					/*     UInt16      row; */
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					/*     // Get form and barcode field pointers. */
 | 
				
			||||||
 | 
					/*     form = FrmGetFormPtr(MainForm); */
 | 
				
			||||||
 | 
					/*     barcode = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormBarcode)); */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*     // Set focus to barcode field if empty. */
 | 
				
			||||||
 | 
					/*     if (FldGetTextLength(barcode) == 0) { */
 | 
				
			||||||
 | 
					/*         FocusBarcode(); */
 | 
				
			||||||
 | 
					/*         return; */
 | 
				
			||||||
 | 
					/*     } */
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					/*     // Get case and unit field pointers. */
 | 
				
			||||||
 | 
					/*     /\* cases = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormCases)); *\/ */
 | 
				
			||||||
 | 
					/*     /\* units = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormUnits)); *\/ */
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					/*     // Open the database and create a new record. */
 | 
				
			||||||
 | 
					/*     db = OpenScanDatabase(); */
 | 
				
			||||||
 | 
					/*     if (db == NULL) { */
 | 
				
			||||||
 | 
					/*         return; */
 | 
				
			||||||
 | 
					/*     } */
 | 
				
			||||||
 | 
					/*     recordIndex = dmMaxRecordIndex; */
 | 
				
			||||||
 | 
					/*     /\* recordH = DmNewRecord(db, &recordIndex, sizeof(RatScanDbRecord)); *\/ */
 | 
				
			||||||
 | 
					/*     recordH = DmNewRecord(db, &recordIndex, sizeof(RattailScanRecord)); */
 | 
				
			||||||
 | 
					/*     if (recordH == 0) { */
 | 
				
			||||||
 | 
					/*         DmCloseDatabase(db); */
 | 
				
			||||||
 | 
					/*         return; */
 | 
				
			||||||
 | 
					/*     } */
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					/*     // Write scan data to the record... */
 | 
				
			||||||
 | 
					/*     recordP = MemHandleLock(recordH); */
 | 
				
			||||||
 | 
					/*     offset = 0; */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*     size = FldGetTextLength(barcode); */
 | 
				
			||||||
 | 
					/*     DmWrite(recordP, offset, FldGetTextPtr(barcode), size); */
 | 
				
			||||||
 | 
					/*     offset += size; */
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					/*     size = 15 - size; */
 | 
				
			||||||
 | 
					/*     DmSet(recordP, offset, size, 0); */
 | 
				
			||||||
 | 
					/*     offset += size; */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*     /\* */
 | 
				
			||||||
 | 
					/*           size = FldGetTextLength(cases); */
 | 
				
			||||||
 | 
					/*           DmWrite(recordP, offset, FldGetTextPtr(cases), size); */
 | 
				
			||||||
 | 
					/*           offset += size; */
 | 
				
			||||||
 | 
					/*     *\/ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*     /\* size = 2; *\/ */
 | 
				
			||||||
 | 
					/*     /\* DmWrite(recordP, offset, "0", 2); *\/ */
 | 
				
			||||||
 | 
					/*     /\* offset += size; *\/ */
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					/*     /\* quantity = CtlGetLabel(cases); *\/ */
 | 
				
			||||||
 | 
					/*     /\* size = StrLen(quantity); *\/ */
 | 
				
			||||||
 | 
					/*     /\* DmWrite(recordP, offset, quantity, size); *\/ */
 | 
				
			||||||
 | 
					/*     /\* offset += size; *\/ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*     /\* */
 | 
				
			||||||
 | 
					/*     size = StrLen(CtlGetLabel(cases)); */
 | 
				
			||||||
 | 
					/*     DmWrite(recordP, offset, CtlGetLabel(cases), size); */
 | 
				
			||||||
 | 
					/*     offset += size; */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*     size = 4 - size; */
 | 
				
			||||||
 | 
					/*     DmSet(recordP, offset, size, 0); */
 | 
				
			||||||
 | 
					/*     offset += size; */
 | 
				
			||||||
 | 
					/*     *\/ */
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					/*     /\* size = FldGetTextLength(units); *\/ */
 | 
				
			||||||
 | 
					/*     /\* DmWrite(recordP, offset, FldGetTextPtr(units), size); *\/ */
 | 
				
			||||||
 | 
					/*     /\* offset += size; *\/ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*     size = StrLen(CtlGetLabel(units)); */
 | 
				
			||||||
 | 
					/*     DmWrite(recordP, offset, CtlGetLabel(units), size); */
 | 
				
			||||||
 | 
					/*     offset += size; */
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					/*     size = 4 - size; */
 | 
				
			||||||
 | 
					/*     DmSet(recordP, offset, size, 0); */
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					/*     // ...then close the record and database. */
 | 
				
			||||||
 | 
					/*     MemHandleUnlock(recordH); */
 | 
				
			||||||
 | 
					/*     DmReleaseRecord(db, recordIndex, false); */
 | 
				
			||||||
 | 
					/*     DmCloseDatabase(db); */
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					/*     // Redraw the table. */
 | 
				
			||||||
 | 
					/*     table = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScanRecords)); */
 | 
				
			||||||
 | 
					/*     row = TblGetLastUsableRow(table); */
 | 
				
			||||||
 | 
					/*     if (row == tblUnusableRow) { */
 | 
				
			||||||
 | 
					/*         gTopVisibleRecord = 0; */
 | 
				
			||||||
 | 
					/*     } else if (row == 11) { */
 | 
				
			||||||
 | 
					/*         gTopVisibleRecord = TblGetRowID(table, 1); */
 | 
				
			||||||
 | 
					/*     } */
 | 
				
			||||||
 | 
					/*     MainFormLoadTable(table, true); */
 | 
				
			||||||
 | 
					/*     TblRedrawTable(table); */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*     FocusBarcode(); */
 | 
				
			||||||
 | 
					/* } */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef SCANLIB_JANAM
 | 
					#ifdef SCANLIB_JANAM
 | 
				
			||||||
/************************************************************
 | 
					/************************************************************
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,9 +16,9 @@
 | 
				
			||||||
#define MainFormUnits							1001
 | 
					#define MainFormUnits							1001
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define AlertTest								1000
 | 
					#define AlertTest								1000
 | 
				
			||||||
#define AlertScannerOpenError                   1300
 | 
					#define AlertInformation                        1200
 | 
				
			||||||
#define AlertScannerEnableError                 1200
 | 
					#define AlertConfirmation                       1100
 | 
				
			||||||
#define AlertScannerCloseError                  1100
 | 
					#define AlertScannerError                       1400
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//	Resource: tFRM 1100
 | 
					//	Resource: tFRM 1100
 | 
				
			||||||
#define AboutForm                                 1100	//(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0)
 | 
					#define AboutForm                                 1100	//(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0)
 | 
				
			||||||
| 
						 | 
					@ -50,12 +50,11 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//	Resource: MBAR 1000
 | 
					//	Resource: MBAR 1000
 | 
				
			||||||
#define MainFormMenuBar                           1000
 | 
					#define MainFormMenuBar                         1000
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
//	Resource: MENU 1000
 | 
					//	Resource: MENU 1000
 | 
				
			||||||
#define MainOptionsMenu                           1000
 | 
					#define MainEditDeleteRecords                   1001
 | 
				
			||||||
#define MainOptionsAboutStarterApp                1000
 | 
					#define MainOptionsAboutRattail                 1000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//	Resource: PICT 1001
 | 
					//	Resource: PICT 1001
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue