private void DeleteAllGifts(System.Object sender, EventArgs e) { string completionMessage = string.Empty; int BatchNumberToClear = FBatchNumber; if ((FPreviouslySelectedDetailRow == null) || (FBatchRow.BatchStatus != MFinanceConstants.BATCH_UNPOSTED)) { return; } else if (!FFilterAndFindObject.IsActiveFilterEqualToBase) { MessageBox.Show(Catalog.GetString("Please remove the filter before attempting to delete all gifts in this batch."), Catalog.GetString("Delete All Gifts")); return; } if (MessageBox.Show(String.Format(Catalog.GetString( "You have chosen to delete all gifts from batch ({0}).{1}{1}Are you sure you want to delete all?"), BatchNumberToClear, Environment.NewLine), Catalog.GetString("Confirm Delete All"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { try { //Normally need to set the message parameters before the delete is performed if requiring any of the row values completionMessage = String.Format(Catalog.GetString("All gifts and details deleted successfully."), FPreviouslySelectedDetailRow.BatchNumber); //clear any transactions currently being editied in the Transaction Tab ClearCurrentSelection(false); //Clear out the gift data for the current batch without marking the records for deletion // and then reload from server RefreshCurrentBatchGiftData(BatchNumberToClear); //Now delete all gift data for current batch DeleteCurrentBatchGiftData(BatchNumberToClear); FBatchRow.BatchTotal = 0; // Be sure to set the last gift number in the parent table before saving all the changes SetBatchLastGiftNumber(); FPetraUtilsObject.SetChangedFlag(); // save first, then post if (!((TFrmGiftBatch)ParentForm).SaveChangesManual()) { SelectRowInGrid(1); // saving failed, therefore do not try to cancel MessageBox.Show(Catalog.GetString("The emptied batch failed to save!")); } else { MessageBox.Show(completionMessage, "All Gifts Deleted.", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { completionMessage = ex.Message; MessageBox.Show(ex.Message, "Deletion Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //Return FMainDS to original state FMainDS.RejectChanges(); } } if (grdDetails.Rows.Count < 2) { ShowDetails(null); UpdateControlsProtection(); } UpdateRecordNumberDisplay(); }