/// <summary> /// Re-show the specified row /// </summary> /// <param name="AModifiedBatchRow"></param> /// <param name="ARedisplay"></param> public void UndoModifiedBatchRow(ABatchRow AModifiedBatchRow, bool ARedisplay) { //Check if new row or not if (AModifiedBatchRow.RowState == DataRowState.Added) { return; } AModifiedBatchRow.RejectChanges(); if (ARedisplay) { ShowDetails(AModifiedBatchRow); } }
/// <summary> /// Undo all changes to the specified batch ready to cancel it. /// This avoids unecessary validation errors when cancelling. /// </summary> /// <param name="ABatchToCancel"></param> /// <param name="ARedisplay"></param> public void PrepareBatchDataForCancelling(Int32 ABatchToCancel, Boolean ARedisplay) { //This code will only be called when the Batch tab is active. DataView GLBatchDV = new DataView(FMainDS.ABatch); DataView JournalDV = new DataView(FMainDS.AJournal); DataView TransDV = new DataView(FMainDS.ATransaction); DataView TransAnalDV = new DataView(FMainDS.ATransAnalAttrib); GLBatchDV.RowFilter = String.Format("{0}={1}", ABatchTable.GetBatchNumberDBName(), ABatchToCancel); JournalDV.RowFilter = String.Format("{0}={1}", AJournalTable.GetBatchNumberDBName(), ABatchToCancel); TransDV.RowFilter = String.Format("{0}={1}", ATransactionTable.GetBatchNumberDBName(), ABatchToCancel); TransAnalDV.RowFilter = String.Format("{0}={1}", ATransAnalAttribTable.GetBatchNumberDBName(), ABatchToCancel); //Work from lowest level up if (TransAnalDV.Count > 0) { TransAnalDV.Sort = String.Format("{0}, {1}, {2}", ATransAnalAttribTable.GetJournalNumberDBName(), ATransAnalAttribTable.GetTransactionNumberDBName(), ATransAnalAttribTable.GetAnalysisTypeCodeDBName()); foreach (DataRowView drv in TransAnalDV) { ATransAnalAttribRow transAnalRow = (ATransAnalAttribRow)drv.Row; if (transAnalRow.RowState == DataRowState.Added) { //Do nothing } else if (transAnalRow.RowState != DataRowState.Unchanged) { transAnalRow.RejectChanges(); } } } if (TransDV.Count > 0) { TransDV.Sort = String.Format("{0}, {1}", ATransactionTable.GetJournalNumberDBName(), ATransactionTable.GetTransactionNumberDBName()); foreach (DataRowView drv in TransDV) { ATransactionRow transRow = (ATransactionRow)drv.Row; if (transRow.RowState == DataRowState.Added) { //Do nothing } else if (transRow.RowState != DataRowState.Unchanged) { transRow.RejectChanges(); } } } if (JournalDV.Count > 0) { JournalDV.Sort = String.Format("{0}", AJournalTable.GetJournalNumberDBName()); foreach (DataRowView drv in JournalDV) { AJournalRow journalRow = (AJournalRow)drv.Row; if (journalRow.RowState == DataRowState.Added) { //Do nothing } else if (journalRow.RowState != DataRowState.Unchanged) { journalRow.RejectChanges(); } } } if (GLBatchDV.Count > 0) { ABatchRow batchRow = (ABatchRow)GLBatchDV[0].Row; //No need to check for Added state as new batches are always saved // on creation if (batchRow.RowState != DataRowState.Unchanged) { batchRow.RejectChanges(); } if (ARedisplay) { ShowDetails(batchRow); } } if (TransDV.Count == 0) { //Load all related data for batch ready to delete/cancel FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadAJournalAndRelatedTablesForBatch(FLedgerNumber, ABatchToCancel)); } }