コード例 #1
0
        /// <summary>
        /// Check if batch columns have actually changed
        /// </summary>
        /// <param name="ARecurringBatchRow"></param>
        /// <returns></returns>
        public bool BatchColumnsHaveChanged(ARecurringGiftBatchRow ARecurringBatchRow)
        {
            bool RetVal = false;

            if (ARecurringBatchRow.RowState != DataRowState.Unchanged)
            {
                bool columnValueChanged = false;

                for (int i = 0; i < FMainDS.ARecurringGiftBatch.Columns.Count; i++)
                {
                    string originalValue = ARecurringBatchRow[i, DataRowVersion.Original].ToString();
                    string currentValue  = ARecurringBatchRow[i, DataRowVersion.Current].ToString();

                    if (originalValue != currentValue)
                    {
                        columnValueChanged = true;
                        break;
                    }
                }

                if (!columnValueChanged)
                {
                    ARecurringBatchRow.RejectChanges();
                }

                RetVal = columnValueChanged;
            }

            return(RetVal);
        }
コード例 #2
0
        /// <summary>
        /// Re-show the specified row
        /// </summary>
        /// <param name="AModifiedBatchRow"></param>
        /// <param name="ARedisplay"></param>
        public void UndoModifiedBatchRow(ARecurringGiftBatchRow AModifiedBatchRow, bool ARedisplay)
        {
            //Check if new row or not
            if (AModifiedBatchRow.RowState == DataRowState.Added)
            {
                return;
            }

            AModifiedBatchRow.RejectChanges();

            if (ARedisplay)
            {
                ShowDetails(AModifiedBatchRow);
            }
        }
コード例 #3
0
        /// <summary>
        /// Deletes the current row and optionally populates a completion message
        /// </summary>
        /// <param name="ARowToDelete">the currently selected row to delete</param>
        /// <param name="ACompletionMessage">if specified, is the deletion completion message</param>
        /// <returns>true if row deletion is successful</returns>
        private bool DeleteRowManual(ARecurringGiftBatchRow ARowToDelete, ref string ACompletionMessage)
        {
            bool DeletionSuccessful = false;

            if (ARowToDelete == null)
            {
                return(DeletionSuccessful);
            }

            int BatchNumber = ARowToDelete.BatchNumber;

            ACompletionMessage = string.Empty;

            bool RowToDeleteIsNew = (ARowToDelete.RowState == DataRowState.Added);

            //Backup the Dataset for reversion purposes
            GiftBatchTDS BackupMainDS = (GiftBatchTDS)FMainDS.Copy();

            BackupMainDS.Merge(FMainDS);

            if (!RowToDeleteIsNew)
            {
                //Return modified row to last saved state to avoid validation failures
                ARowToDelete.RejectChanges();
                ShowDetails(ARowToDelete);

                if (!((TFrmRecurringGiftBatch)FPetraUtilsObject.GetForm()).SaveChangesManual(TExtraGiftBatchChecks.GiftBatchAction.DELETING))
                {
                    MessageBox.Show(Catalog.GetString("Error in trying to save prior to deleting current recurring gift batch!"),
                                    Catalog.GetString("Deletion Error"),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);

                    return(DeletionSuccessful);
                }
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;

                ACompletionMessage = String.Format(Catalog.GetString("Batch no.: {0} deleted successfully."),
                                                   BatchNumber);

                //clear any transactions currently being editied in the Transaction Tab
                ((TFrmRecurringGiftBatch)ParentForm).GetTransactionsControl().ClearCurrentSelection();

                if (!RowToDeleteIsNew)
                {
                    //Load tables afresh
                    FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadRecurringGiftTransactionsForBatch(FLedgerNumber, BatchNumber));
                }

                ((TFrmRecurringGiftBatch)ParentForm).GetTransactionsControl().DeleteCurrentRecurringBatchGiftData(BatchNumber);

                // Delete the recurring batch row.
                ARowToDelete.Delete();

                FPreviouslySelectedDetailRow = null;

                DeletionSuccessful = true;
            }
            catch (Exception ex)
            {
                ACompletionMessage = ex.Message;
                MessageBox.Show(ACompletionMessage,
                                "Deletion Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                //Revert to previous state
                FMainDS.Merge(BackupMainDS);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }

            UpdateRecordNumberDisplay();

            return(DeletionSuccessful);
        }
コード例 #4
0
        /// <summary>
        /// Deletes the current row and optionally populates a completion message
        /// </summary>
        /// <param name="ARowToDelete">the currently selected row to delete</param>
        /// <param name="ACompletionMessage">if specified, is the deletion completion message</param>
        /// <returns>true if row deletion is successful</returns>
        private bool DeleteRowManual(ARecurringGiftBatchRow ARowToDelete, ref string ACompletionMessage)
        {
            bool DeletionSuccessful = false;

            if (ARowToDelete == null)
            {
                return DeletionSuccessful;
            }

            int BatchNumber = ARowToDelete.BatchNumber;

            ACompletionMessage = string.Empty;

            bool RowToDeleteIsNew = (ARowToDelete.RowState == DataRowState.Added);

            //Backup the Dataset for reversion purposes
            GiftBatchTDS BackupMainDS = (GiftBatchTDS)FMainDS.Copy();
            BackupMainDS.Merge(FMainDS);

            if (!RowToDeleteIsNew)
            {
                //Return modified row to last saved state to avoid validation failures
                ARowToDelete.RejectChanges();
                ShowDetails(ARowToDelete);

                if (!((TFrmRecurringGiftBatch)FPetraUtilsObject.GetForm()).SaveChangesManual(TExtraGiftBatchChecks.GiftBatchAction.DELETING))
                {
                    MessageBox.Show(Catalog.GetString("Error in trying to save prior to deleting current recurring gift batch!"),
                        Catalog.GetString("Deletion Error"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);

                    return DeletionSuccessful;
                }
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;

                ACompletionMessage = String.Format(Catalog.GetString("Batch no.: {0} deleted successfully."),
                    BatchNumber);

                //clear any transactions currently being editied in the Transaction Tab
                ((TFrmRecurringGiftBatch)ParentForm).GetTransactionsControl().ClearCurrentSelection();

                if (!RowToDeleteIsNew)
                {
                    //Load tables afresh
                    FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadRecurringGiftTransactionsForBatch(FLedgerNumber, BatchNumber));
                }

                ((TFrmRecurringGiftBatch)ParentForm).GetTransactionsControl().DeleteCurrentRecurringBatchGiftData(BatchNumber);

                // Delete the recurring batch row.
                ARowToDelete.Delete();

                FPreviouslySelectedDetailRow = null;

                DeletionSuccessful = true;
            }
            catch (Exception ex)
            {
                ACompletionMessage = ex.Message;
                MessageBox.Show(ACompletionMessage,
                    "Deletion Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);

                //Revert to previous state
                FMainDS.Merge(BackupMainDS);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }

            UpdateRecordNumberDisplay();

            return DeletionSuccessful;
        }
コード例 #5
0
        /// <summary>
        /// Check if batch columns have actually changed
        /// </summary>
        /// <param name="ARecurringBatchRow"></param>
        /// <returns></returns>
        public bool BatchColumnsHaveChanged(ARecurringGiftBatchRow ARecurringBatchRow)
        {
            bool RetVal = false;

            if (ARecurringBatchRow.RowState != DataRowState.Unchanged)
            {
                bool columnValueChanged = false;

                for (int i = 0; i < FMainDS.ARecurringGiftBatch.Columns.Count; i++)
                {
                    string originalValue = ARecurringBatchRow[i, DataRowVersion.Original].ToString();
                    string currentValue = ARecurringBatchRow[i, DataRowVersion.Current].ToString();

                    if (originalValue != currentValue)
                    {
                        columnValueChanged = true;
                        break;
                    }
                }

                if (!columnValueChanged)
                {
                    ARecurringBatchRow.RejectChanges();
                }

                RetVal = columnValueChanged;
            }

            return RetVal;
        }
コード例 #6
0
        /// <summary>
        /// Undo all changes to the specified batch ready to delete it.
        ///  This avoids unecessary validation errors when deleting.
        /// </summary>
        /// <param name="ABatchToDelete"></param>
        /// <param name="ARedisplay"></param>
        public void PrepareBatchDataForDeleting(Int32 ABatchToDelete, bool ARedisplay)
        {
            //This code will only be called when the Batch tab is active.

            DataView GiftBatchDV  = new DataView(FMainDS.ARecurringGiftBatch);
            DataView GiftDV       = new DataView(FMainDS.ARecurringGift);
            DataView GiftDetailDV = new DataView(FMainDS.ARecurringGiftDetail);

            GiftBatchDV.RowFilter = String.Format("{0}={1}",
                                                  ARecurringGiftBatchTable.GetBatchNumberDBName(),
                                                  ABatchToDelete);

            GiftDV.RowFilter = String.Format("{0}={1}",
                                             AGiftTable.GetBatchNumberDBName(),
                                             ABatchToDelete);

            GiftDetailDV.RowFilter = String.Format("{0}={1}",
                                                   AGiftDetailTable.GetBatchNumberDBName(),
                                                   ABatchToDelete);

            //Work from lowest level up
            if (GiftDetailDV.Count > 0)
            {
                GiftDetailDV.Sort = String.Format("{0}, {1}",
                                                  ARecurringGiftDetailTable.GetGiftTransactionNumberDBName(),
                                                  ARecurringGiftDetailTable.GetDetailNumberDBName());

                foreach (DataRowView drv in GiftDetailDV)
                {
                    ARecurringGiftDetailRow gDR = (ARecurringGiftDetailRow)drv.Row;

                    if (gDR.RowState == DataRowState.Added)
                    {
                        //Do nothing
                    }
                    else if (gDR.RowState != DataRowState.Unchanged)
                    {
                        gDR.RejectChanges();
                    }
                }
            }

            if (GiftDV.Count > 0)
            {
                GiftDV.Sort = String.Format("{0}", ARecurringGiftTable.GetGiftTransactionNumberDBName());

                foreach (DataRowView drv in GiftDV)
                {
                    ARecurringGiftRow gR = (ARecurringGiftRow)drv.Row;

                    if (gR.RowState == DataRowState.Added)
                    {
                        //Do nothing
                    }
                    else if (gR.RowState != DataRowState.Unchanged)
                    {
                        gR.RejectChanges();
                    }
                }
            }

            if (GiftBatchDV.Count > 0)
            {
                ARecurringGiftBatchRow gB = (ARecurringGiftBatchRow)GiftBatchDV[0].Row;

                //No need to check for Added state as new batches are always saved
                // on creation

                if (gB.RowState != DataRowState.Unchanged)
                {
                    gB.RejectChanges();
                }

                if (ARedisplay)
                {
                    ShowDetails(gB);
                }
            }

            if (GiftDetailDV.Count == 0)
            {
                //Load all related data for batch ready to delete
                FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadRecurringGiftTransactionsForBatch(FLedgerNumber, ABatchToDelete));
            }
        }