add support for deleting all records in batch

This commit is contained in:
Lance Edgar 2013-01-13 04:11:46 -08:00
parent 8822d6cd45
commit 8f10956bae
3 changed files with 36 additions and 4 deletions

View file

@ -624,7 +624,13 @@
<MENU_ITEMS>
<MENU_ITEM>
<ID> 1001 </ID>
<TITLE> "Delete Record(s)" </TITLE>
<TITLE> "Delete Selected" </TITLE>
<COMMAND> "" </COMMAND>
<HIDDEN> FALSE </HIDDEN>
</MENU_ITEM>
<MENU_ITEM>
<ID> 1002 </ID>
<TITLE> "Delete All" </TITLE>
<COMMAND> "" </COMMAND>
<HIDDEN> FALSE </HIDDEN>
</MENU_ITEM>

View file

@ -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);

View file

@ -53,7 +53,8 @@
#define MainFormMenuBar 1000
// Resource: MENU 1000
#define MainEditDeleteRecords 1001
#define MainEditDeleteSelected 1001
#define MainEditDeleteAll 1002
#define MainOptionsAboutRattail 1000