add support for deleting all records in batch
This commit is contained in:
		
							parent
							
								
									8822d6cd45
								
							
						
					
					
						commit
						8f10956bae
					
				
					 3 changed files with 36 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -721,14 +721,15 @@ static Boolean MainFormDoCommand(UInt16 command)
 | 
			
		|||
    FormPtr     form;
 | 
			
		||||
    TablePtr    table;
 | 
			
		||||
    DmOpenRef   db;
 | 
			
		||||
    UInt16      row, rowIndex, offset;
 | 
			
		||||
    UInt16      row, offset, records;
 | 
			
		||||
    Int16       rowIndex;
 | 
			
		||||
    Boolean     selected;
 | 
			
		||||
 | 
			
		||||
    handled = false;
 | 
			
		||||
 | 
			
		||||
    switch (command) {
 | 
			
		||||
 | 
			
		||||
    case MainEditDeleteRecords:
 | 
			
		||||
    case MainEditDeleteSelected:
 | 
			
		||||
        selected = false;
 | 
			
		||||
        for (row = 0; row < 12; row++) {
 | 
			
		||||
            if (scanRecordsSelected[row]) {
 | 
			
		||||
| 
						 | 
				
			
			@ -760,6 +761,30 @@ static Boolean MainFormDoCommand(UInt16 command)
 | 
			
		|||
        handled = true;
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case MainEditDeleteAll:
 | 
			
		||||
        db = OpenScanDatabase();
 | 
			
		||||
        records = DmNumRecords(db);
 | 
			
		||||
        DmCloseDatabase(db);
 | 
			
		||||
        if (records) {
 | 
			
		||||
            if (FrmCustomAlert(AlertConfirmation,
 | 
			
		||||
                               "This will delete ALL records in the batch.\n\nDo you really wish to do this?", "", "") == 0) {
 | 
			
		||||
                db = OpenScanDatabase();
 | 
			
		||||
                for (rowIndex = records - 1; rowIndex >= 0; rowIndex--) {
 | 
			
		||||
                    DmRemoveRecord(db, rowIndex);
 | 
			
		||||
                }
 | 
			
		||||
                DmCloseDatabase(db);
 | 
			
		||||
                form = FrmGetFormPtr(MainForm);
 | 
			
		||||
                table = FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainFormScanRecords));
 | 
			
		||||
                MainFormLoadTable(table, true);
 | 
			
		||||
                ClearScanRecordSelection();
 | 
			
		||||
                TblRedrawTable(table);
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            FrmCustomAlert(AlertInformation, "The batch is already empty.", "", "");
 | 
			
		||||
        }
 | 
			
		||||
        handled = true;
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case MainOptionsAboutRattail:
 | 
			
		||||
        form = FrmInitForm(AboutForm);
 | 
			
		||||
        FrmDoDialog(form);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,7 +53,8 @@
 | 
			
		|||
#define MainFormMenuBar                         1000
 | 
			
		||||
 | 
			
		||||
//	Resource: MENU 1000
 | 
			
		||||
#define MainEditDeleteRecords                   1001
 | 
			
		||||
#define MainEditDeleteSelected                  1001
 | 
			
		||||
#define MainEditDeleteAll                       1002
 | 
			
		||||
#define MainOptionsAboutRattail                 1000
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue