From 8f10956bae09e7aaf575da17f92a9755a05e672c Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 13 Jan 2013 04:11:46 -0800 Subject: [PATCH] add support for deleting all records in batch --- rsc/AppResources.xrd | 8 +++++++- src/AppMain.c | 29 +++++++++++++++++++++++++++-- src/AppResources.h | 3 ++- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/rsc/AppResources.xrd b/rsc/AppResources.xrd index 39758c3..763a3f4 100644 --- a/rsc/AppResources.xrd +++ b/rsc/AppResources.xrd @@ -624,7 +624,13 @@ 1001 - "Delete Record(s)" + "Delete Selected" + "" + FALSE + + + 1002 + "Delete All" "" FALSE diff --git a/src/AppMain.c b/src/AppMain.c index 5352f01..759600c 100644 --- a/src/AppMain.c +++ b/src/AppMain.c @@ -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); diff --git a/src/AppResources.h b/src/AppResources.h index 1f80ad3..27fbbaa 100644 --- a/src/AppResources.h +++ b/src/AppResources.h @@ -53,7 +53,8 @@ #define MainFormMenuBar 1000 // Resource: MENU 1000 -#define MainEditDeleteRecords 1001 +#define MainEditDeleteSelected 1001 +#define MainEditDeleteAll 1002 #define MainOptionsAboutRattail 1000