/// <summary> /// Code to be run after the deletion process /// </summary> /// <param name="ARowToDelete">the row that was/was to be deleted</param> /// <param name="AAllowDeletion">whether or not the user was permitted to delete</param> /// <param name="ADeletionPerformed">whether or not the deletion was performed successfully</param> /// <param name="ACompletionMessage">if specified, is the deletion completion message</param> private void PostDeleteManual(ARecurringJournalRow ARowToDelete, bool AAllowDeletion, bool ADeletionPerformed, string ACompletionMessage) { /*Code to execute after the delete has occurred*/ TFrmRecurringGLBatch FMyForm = (TFrmRecurringGLBatch)this.ParentForm; try { if (ADeletionPerformed) { UpdateChangeableStatus(); if (!pnlDetails.Enabled) { ClearControls(); } //Always update LastTransactionNumber first before updating totals GLRoutines.UpdateRecurringBatchLastJournal(ref FMainDS, ref FBatchRow); GLRoutines.UpdateRecurringBatchTotals(ref FMainDS, ref FBatchRow); UpdateHeaderTotals(FBatchRow); FMyForm.SaveChangesManual(); MessageBox.Show(ACompletionMessage, Catalog.GetString("Deletion Successful"), MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (!AAllowDeletion && (ACompletionMessage.Length > 0)) { //message to user MessageBox.Show(ACompletionMessage, "Deletion not allowed", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!ADeletionPerformed && (ACompletionMessage.Length > 0)) { //message to user MessageBox.Show(ACompletionMessage, "Deletion failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } finally { FMyForm.FCurrentGLBatchAction = TGLBatchEnums.GLBatchAction.NONE; } //Enable Transaction tab accordingly ((TFrmRecurringGLBatch)ParentForm).EnableTransactions((grdDetails.Rows.Count > 1)); }
/// <summary> /// load the journals into the grid /// </summary> /// <param name="ACurrentBatchRow"></param> public void LoadJournals(ARecurringBatchRow ACurrentBatchRow) { FJournalsLoaded = false; FBatchRow = ACurrentBatchRow; if (FBatchRow == null) { return; } Int32 CurrentLedgerNumber = ACurrentBatchRow.LedgerNumber; Int32 CurrentBatchNumber = ACurrentBatchRow.BatchNumber; bool FirstRun = (FLedgerNumber != CurrentLedgerNumber); bool BatchChanged = (FBatchNumber != CurrentBatchNumber); if (FirstRun) { FLedgerNumber = CurrentLedgerNumber; } if (BatchChanged) { FBatchNumber = CurrentBatchNumber; } //Check if same Journals as previously selected if (!(FirstRun || BatchChanged)) { //Need to reconnect FPrev in some circumstances if (FPreviouslySelectedDetailRow == null) { DataRowView rowView = (DataRowView)grdDetails.Rows.IndexToDataSourceRow(FPrevRowChangedRow); if (rowView != null) { FPreviouslySelectedDetailRow = (GLBatchTDSARecurringJournalRow)(rowView.Row); } } if (GetSelectedRowIndex() > 0) { GetDetailsFromControls(GetSelectedDetailRow()); } } else { // a different journal SetJournalDefaultView(); FPreviouslySelectedDetailRow = null; //Load Journals if (FMainDS.ARecurringJournal.DefaultView.Count == 0) { FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadARecurringJournal(FLedgerNumber, FBatchNumber)); } //Ensure Last Batch Number is correct, needed to correct old Petra data if ((FBatchRow.LastJournal != FMainDS.ARecurringJournal.DefaultView.Count) && GLRoutines.UpdateRecurringBatchLastJournal(ref FMainDS, ref FBatchRow)) { FPetraUtilsObject.SetChangedFlag(); } ShowData(); // Now set up the complete current filter FFilterAndFindObject.FilterPanelControls.SetBaseFilter(FMainDS.ARecurringJournal.DefaultView.RowFilter, true); FFilterAndFindObject.ApplyFilter(); } int nRowToSelect = (BatchChanged || FirstRun) ? 1 : FPrevRowChangedRow; //This will also call UpdateChangeableStatus SelectRowInGrid(nRowToSelect); UpdateRecordNumberDisplay(); FFilterAndFindObject.SetRecordNumberDisplayProperties(); //Check for incorrect Exchange rate to base foreach (DataRowView drv in FMainDS.ARecurringJournal.DefaultView) { ARecurringJournalRow rjr = (ARecurringJournalRow)drv.Row; if (rjr.ExchangeRateToBase == 0) { rjr.ExchangeRateToBase = 1; FPetraUtilsObject.HasChanges = true; } } FJournalsLoaded = true; //Check on batch totals if (GLRoutines.UpdateRecurringBatchTotals(ref FMainDS, ref FBatchRow)) { FPetraUtilsObject.SetChangedFlag(); } }