Ejemplo n.º 1
0
        /// <summary>
        /// Main method to Submit a specified batch
        /// </summary>
        /// <param name="ACurrentRecurringBatchRow">The batch row to Submit</param>
        /// <param name="AWarnOfInactiveValues">True means user is warned if inactive values exist</param>
        /// <param name="ADonorZeroIsValid"></param>
        /// <param name="ARecipientZeroIsValid"></param>
        /// <returns>True if the batch was successfully Submited</returns>
        public bool SubmitBatch(ARecurringGiftBatchRow ACurrentRecurringBatchRow,
                                bool AWarnOfInactiveValues = true,
                                bool ADonorZeroIsValid     = false,
                                bool ARecipientZeroIsValid = false)
        {
            if (ACurrentRecurringBatchRow == null)
            {
                return(false);
            }

            FSelectedBatchNumber = ACurrentRecurringBatchRow.BatchNumber;

            //Make sure that all control data is in dataset
            FMyForm.GetLatestControlData();

            //Copy all batch data to new table
            GiftBatchTDSARecurringGiftDetailTable RecurringBatchGiftDetails = new GiftBatchTDSARecurringGiftDetailTable();

            //Filter ARecurringGiftDetail
            DataView RecurringGiftDetailDV = new DataView(FMainDS.ARecurringGiftDetail);

            RecurringGiftDetailDV.RowFilter = string.Format("{0}={1}",
                                                            ARecurringGiftDetailTable.GetBatchNumberDBName(),
                                                            FSelectedBatchNumber);

            RecurringGiftDetailDV.Sort = string.Format("{0} ASC, {1} ASC, {2} ASC",
                                                       ARecurringGiftDetailTable.GetBatchNumberDBName(),
                                                       ARecurringGiftDetailTable.GetGiftTransactionNumberDBName(),
                                                       ARecurringGiftDetailTable.GetDetailNumberDBName());

            foreach (DataRowView dRV in RecurringGiftDetailDV)
            {
                GiftBatchTDSARecurringGiftDetailRow rGBR = (GiftBatchTDSARecurringGiftDetailRow)dRV.Row;
                RecurringBatchGiftDetails.Rows.Add((object[])rGBR.ItemArray.Clone());
            }

            //Save and check for inactive values and ex-workers and anonymous gifts
            if (FPetraUtilsObject.HasChanges)
            {
                //Keep this conditional check separate from the one above so that it only gets called
                // when necessary and doesn't result in the executon of the same method
                if (!FMyForm.SaveChangesForSubmitting(RecurringBatchGiftDetails))
                {
                    return(false);
                }
            }
            else
            {
                //This has to be called here because if there are no changes then the DataSavingValidating
                // method which calls the method below, will not run.
                if (!FMyForm.GetBatchControl().AllowInactiveFieldValues(TExtraGiftBatchChecks.GiftBatchAction.SUBMITTING) ||
                    FMyForm.GiftHasExWorkerOrAnon(RecurringBatchGiftDetails)
                    )
                {
                    return(false);
                }
            }

            //Check hash total validity
            if ((ACurrentRecurringBatchRow.HashTotal != 0) &&
                (ACurrentRecurringBatchRow.BatchTotal != ACurrentRecurringBatchRow.HashTotal))
            {
                MessageBox.Show(String.Format(Catalog.GetString(
                                                  "The recurring gift batch total ({0}) for batch {1} does not equal the hash total ({2})."),
                                              StringHelper.FormatUsingCurrencyCode(ACurrentRecurringBatchRow.BatchTotal, ACurrentRecurringBatchRow.CurrencyCode),
                                              ACurrentRecurringBatchRow.BatchNumber,
                                              StringHelper.FormatUsingCurrencyCode(ACurrentRecurringBatchRow.HashTotal, ACurrentRecurringBatchRow.CurrencyCode)),
                                "Submit Recurring Gift Batch");

                FMyForm.GetBatchControl().Controls["txtDetailHashTotal"].Focus();
                FMyForm.GetBatchControl().Controls["txtDetailHashTotal"].Select();
                return(false);
            }

            //Check for zero Donors or Recipients
            if (!ADonorZeroIsValid)
            {
                DataView recurringBatchGiftDV = new DataView(FMainDS.ARecurringGift);

                recurringBatchGiftDV.RowFilter = string.Format("{0}={1} And {2}=0",
                                                               ARecurringGiftTable.GetBatchNumberDBName(),
                                                               FSelectedBatchNumber,
                                                               ARecurringGiftTable.GetDonorKeyDBName());

                int numDonorZeros = recurringBatchGiftDV.Count;

                if (numDonorZeros > 0)
                {
                    string messageListOfOffendingGifts =
                        String.Format(Catalog.GetString(
                                          "Recurring Gift Batch {0} contains {1} gift detail(s) with Donor 0000000. Please fix before posting!{2}{2}"),
                                      FSelectedBatchNumber,
                                      numDonorZeros,
                                      Environment.NewLine);

                    string listOfOffendingRows = string.Empty;

                    listOfOffendingRows += "Gift" + Environment.NewLine;
                    listOfOffendingRows += "------------";

                    foreach (DataRowView drv in recurringBatchGiftDV)
                    {
                        ARecurringGiftRow giftRow = (ARecurringGiftRow)drv.Row;

                        listOfOffendingRows += String.Format("{0}{1:0000}",
                                                             Environment.NewLine,
                                                             giftRow.GiftTransactionNumber);
                    }

                    TFrmExtendedMessageBox extendedMessageBox = new TFrmExtendedMessageBox(FMyForm);

                    extendedMessageBox.ShowDialog((messageListOfOffendingGifts + listOfOffendingRows),
                                                  Catalog.GetString("Submit Batch Error"), string.Empty,
                                                  TFrmExtendedMessageBox.TButtons.embbOK,
                                                  TFrmExtendedMessageBox.TIcon.embiWarning);

                    return(false);
                }
            }

            if (!ARecipientZeroIsValid)
            {
                DataView recurringBatchGiftDetailsDV = new DataView(FMainDS.ARecurringGiftDetail);

                recurringBatchGiftDetailsDV.RowFilter = string.Format("{0}={1} And {2}=0",
                                                                      ARecurringGiftDetailTable.GetBatchNumberDBName(),
                                                                      FSelectedBatchNumber,
                                                                      ARecurringGiftDetailTable.GetRecipientKeyDBName());

                int numRecipientZeros = recurringBatchGiftDetailsDV.Count;

                if (numRecipientZeros > 0)
                {
                    string messageListOfOffendingGifts =
                        String.Format(Catalog.GetString(
                                          "Recurring Gift Batch {0} contains {1} gift detail(s) with Recipient 0000000. Please fix before posting!{2}{2}"),
                                      FSelectedBatchNumber,
                                      numRecipientZeros,
                                      Environment.NewLine);

                    string listOfOffendingRows = string.Empty;

                    listOfOffendingRows += "Gift   Detail" + Environment.NewLine;
                    listOfOffendingRows += "-------------------";

                    foreach (DataRowView drv in recurringBatchGiftDetailsDV)
                    {
                        ARecurringGiftDetailRow giftDetailRow = (ARecurringGiftDetailRow)drv.Row;

                        listOfOffendingRows += String.Format("{0}{1:0000}  {2:00}",
                                                             Environment.NewLine,
                                                             giftDetailRow.GiftTransactionNumber,
                                                             giftDetailRow.DetailNumber);
                    }

                    TFrmExtendedMessageBox extendedMessageBox = new TFrmExtendedMessageBox(FMyForm);

                    extendedMessageBox.ShowDialog((messageListOfOffendingGifts + listOfOffendingRows),
                                                  Catalog.GetString("Submit Batch Error"), string.Empty,
                                                  TFrmExtendedMessageBox.TButtons.embbOK,
                                                  TFrmExtendedMessageBox.TIcon.embiWarning);

                    return(false);
                }
            }

            //Check for inactive KeyMinistries
            DataTable GiftsWithInactiveKeyMinistries;

            if (TRemote.MFinance.Gift.WebConnectors.InactiveKeyMinistriesFoundInBatch(FLedgerNumber, FSelectedBatchNumber,
                                                                                      out GiftsWithInactiveKeyMinistries, true))
            {
                int numInactiveValues = GiftsWithInactiveKeyMinistries.Rows.Count;

                string listOfOffendingRows =
                    String.Format(Catalog.GetString(
                                      "{0} inactive key ministries found in Recurring Gift Batch {1}. Do you still want to submit?{2}{2}"),
                                  numInactiveValues,
                                  FSelectedBatchNumber,
                                  Environment.NewLine);

                listOfOffendingRows += "Gift      Detail   Recipient          KeyMinistry" + Environment.NewLine;
                listOfOffendingRows += "-------------------------------------------------------------------------------";

                foreach (DataRow dr in GiftsWithInactiveKeyMinistries.Rows)
                {
                    listOfOffendingRows += String.Format("{0}{1:0000}    {2:00}        {3:00000000000}    {4}",
                                                         Environment.NewLine,
                                                         dr[0],
                                                         dr[1],
                                                         dr[2],
                                                         dr[3]);
                }

                TFrmExtendedMessageBox extendedMessageBox = new TFrmExtendedMessageBox(FPetraUtilsObject.GetForm());

                if (extendedMessageBox.ShowDialog(listOfOffendingRows.ToString(),
                                                  Catalog.GetString("Submit Batch"), string.Empty,
                                                  TFrmExtendedMessageBox.TButtons.embbYesNo,
                                                  TFrmExtendedMessageBox.TIcon.embiWarning) != TFrmExtendedMessageBox.TResult.embrYes)
                {
                    return(false);
                }
            }

            TFrmRecurringGiftBatchSubmit SubmitForm = new TFrmRecurringGiftBatchSubmit(FPetraUtilsObject.GetForm());

            try
            {
                FMyForm.ShowInTaskbar = false;
                SubmitForm.MainDS     = FMainDS;
                SubmitForm.BatchRow   = ACurrentRecurringBatchRow;
                SubmitForm.ShowDialog();
            }
            finally
            {
                SubmitForm.Dispose();
                FMyForm.ShowInTaskbar = true;
            }

            return(true);
        }
Ejemplo n.º 2
0
        public static SponsorshipTDS GetChildDetails(Int64 APartnerKey,
                                                     Int32 ALedgerNumber,
                                                     bool AWithPhoto,
                                                     out string ASponsorshipStatus)
        {
            SponsorshipTDS MainDS = new SponsorshipTDS();

            TDBTransaction Transaction = new TDBTransaction();

            DBAccess.ReadTransaction(ref Transaction,
                                     delegate
            {
                PPartnerAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                PFamilyAccess.LoadByPrimaryKey(MainDS, APartnerKey, Transaction);
                PPartnerTypeAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                PPartnerCommentAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);
                PPartnerReminderAccess.LoadViaPPartner(MainDS, APartnerKey, Transaction);

                if (!AWithPhoto && (MainDS.PFamily.Rows.Count == 1))
                {
                    MainDS.PFamily[0].Photo = "";
                }

                int SponsorshipBatchNumber = GetRecurringGiftBatchForSponsorship(ALedgerNumber, Transaction);

                if (SponsorshipBatchNumber > -1)
                {
                    ARecurringGiftBatchAccess.LoadByPrimaryKey(MainDS, ALedgerNumber, SponsorshipBatchNumber, Transaction);
                    ARecurringGiftAccess.LoadViaARecurringGiftBatch(MainDS, ALedgerNumber, SponsorshipBatchNumber, Transaction);
                    ARecurringGiftDetailAccess.LoadViaARecurringGiftBatch(MainDS, ALedgerNumber, SponsorshipBatchNumber, Transaction);

                    GiftBatchTDS GiftDS = new GiftBatchTDS();
                    TGiftTransactionWebConnector.LoadGiftDonorRelatedData(GiftDS, true, ALedgerNumber, SponsorshipBatchNumber, Transaction);

                    for (int i = 0; i < MainDS.ARecurringGiftDetail.Count;)
                    {
                        SponsorshipTDSARecurringGiftDetailRow gdr = MainDS.ARecurringGiftDetail[i];
                        // drop all recurring gift details, that are not related to this child (RecipientKey)
                        if (gdr.RecipientKey != APartnerKey)
                        {
                            MainDS.ARecurringGiftDetail.Rows.RemoveAt(i);
                        }
                        else
                        {
                            i++;
                            // set the donor key from the appropriate recurring gift
                            MainDS.ARecurringGift.DefaultView.RowFilter = String.Format("{0} = {1}",
                                                                                        ARecurringGiftTable.GetGiftTransactionNumberDBName(),
                                                                                        gdr.GiftTransactionNumber);

                            // there should be only one row
                            foreach (DataRowView drv in MainDS.ARecurringGift.DefaultView)
                            {
                                ARecurringGiftRow recurrGiftRow = (ARecurringGiftRow)drv.Row;
                                gdr.DonorKey         = recurrGiftRow.DonorKey;
                                PPartnerRow donorRow = (PPartnerRow)GiftDS.DonorPartners.Rows.Find(recurrGiftRow.DonorKey);
                                gdr.DonorName        = donorRow.PartnerShortName;
                                gdr.CurrencyCode     = MainDS.ARecurringGiftBatch[0].CurrencyCode;
                            }
                        }
                    }

                    // drop all unrelated gift rows, that don't have a detail for this child
                    for (int i = 0; i < MainDS.ARecurringGift.Count;)
                    {
                        ARecurringGiftRow gr = MainDS.ARecurringGift[0];
                        MainDS.ARecurringGiftDetail.DefaultView.RowFilter = String.Format("{0} = {1}",
                                                                                          ARecurringGiftDetailTable.GetGiftTransactionNumberDBName(),
                                                                                          gr.GiftTransactionNumber);

                        if (MainDS.ARecurringGiftDetail.DefaultView.Count == 0)
                        {
                            MainDS.ARecurringGift.Rows.RemoveAt(i);
                        }
                        else
                        {
                            i++;
                        }
                    }
                }
            });

            bool isSponsoredChild = false;

            ASponsorshipStatus = "[N/A]";

            foreach (PPartnerTypeRow type in MainDS.PPartnerType.Rows)
            {
                if (type.TypeCode == "CHILDREN_HOME" || type.TypeCode == "HOME_BASED" || type.TypeCode == "BOARDING_SCHOOL" || type.TypeCode == "PREVIOUS_CHILD" || type.TypeCode == "CHILD_DIED")
                {
                    isSponsoredChild = true;
                }
                ASponsorshipStatus = type.TypeCode;
            }

            if (!isSponsoredChild)
            {
                return(new SponsorshipTDS());
            }

            return(MainDS);
        }
Ejemplo n.º 3
0
        private Boolean LoadAllBatchData(int ABatchNumber = 0)
        {
            bool RetVal = false;

            DataView GiftDV        = new DataView(FMainDS.ARecurringGift);
            DataView GiftDetailsDV = new DataView(FMainDS.ARecurringGiftDetail);

            bool NoGiftRows       = true;
            bool NoGiftDetailRows = true;

            if ((ABatchNumber == 0) && (FPreviouslySelectedDetailRow != null))
            {
                ABatchNumber = FPreviouslySelectedDetailRow.BatchNumber;
            }
            else if (ABatchNumber == 0)
            {
                return(RetVal);
            }

            try
            {
                // now load all gift data for this batch
                GiftDV.RowFilter = String.Format("{0}={1}",
                                                 ARecurringGiftTable.GetBatchNumberDBName(),
                                                 FSelectedBatchNumber);
                GiftDetailsDV.RowFilter = String.Format("{0}={1}",
                                                        ARecurringGiftDetailTable.GetBatchNumberDBName(),
                                                        FSelectedBatchNumber);

                if (GiftDV.Count == 0)
                {
                    FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadRecurringGiftTransactionsForBatch(FLedgerNumber, FSelectedBatchNumber));
                }

                NoGiftRows       = (GiftDV.Count == 0);
                NoGiftDetailRows = (GiftDetailsDV.Count == 0);

                if ((NoGiftRows && !NoGiftDetailRows) ||
                    (!NoGiftRows && NoGiftDetailRows))
                {
                    MessageBox.Show(String.Format(Catalog.GetString(
                                                      "The recurring gift batch {0} contains orphaned gift records. PLEASE DELETE THE RECURRING BATCH AND RECREATE!"),
                                                  FPreviouslySelectedDetailRow.BatchNumber),
                                    Catalog.GetString("Orphaned Data"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(RetVal);
                }

                //Restrict now to active gifts only
                GiftDV.RowFilter = String.Format("{0}={1} And {2}=true",
                                                 ARecurringGiftTable.GetBatchNumberDBName(),
                                                 FSelectedBatchNumber,
                                                 ARecurringGiftTable.GetActiveDBName());

                if (GiftDV.Count == 0)
                {
                    if (MessageBox.Show(String.Format(Catalog.GetString(
                                                          "The recurring gift batch {0} has no active gifts. Do you still want to submit?"),
                                                      FPreviouslySelectedDetailRow.BatchNumber),
                                        Catalog.GetString("Submit Empty Batch"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
                                        MessageBoxDefaultButton.Button2) == DialogResult.No)
                    {
                        return(RetVal);
                    }
                }

                RetVal = true;
            }
            catch (Exception)
            {
                throw;
            }

            return(RetVal);
        }
        private bool OnDeleteRowManual(GiftBatchTDSARecurringGiftDetailRow ARowToDelete, ref string ACompletionMessage)
        {
            //TODO: Make this like deleton on GL Transactions form
            // e.g. pass copy to delete method on server...
            //GiftBatchTDS TempDS = (GiftBatchTDS)FMainDS.Copy();
            //TempDS.Merge(FMainDS);

            bool DeletionSuccessful = false;

            ACompletionMessage = string.Empty;

            if (FBatchRow == null)
            {
                FBatchRow = GetRecurringBatchRow();
            }

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

            int  CurrentBatchNo   = ARowToDelete.BatchNumber;
            bool RowToDeleteIsNew = (ARowToDelete.RowState == DataRowState.Added);
            int  CurrentRowIndex  = GetSelectedRowIndex();

            TFrmRecurringGiftBatch FMyForm = (TFrmRecurringGiftBatch)this.ParentForm;

            GiftBatchTDS BackupMainDS = null;

            int    SelectedDetailNumber                 = ARowToDelete.DetailNumber;
            int    RecurringGiftToDeleteTransNo         = 0;
            string FilterAllRecurringGiftsOfBatch       = String.Empty;
            string FilterAllRecurringGiftDetailsOfBatch = String.Empty;

            int DetailRowCount = FGiftDetailView.Count;

            try
            {
                this.Cursor = Cursors.WaitCursor;
                //Specify current action
                FMyForm.FCurrentGiftBatchAction = Logic.TExtraGiftBatchChecks.GiftBatchAction.DELETINGTRANS;
                //Speeds up deletion of larger gift sets
                FMainDS.EnforceConstraints = false;
                // temporarily disable  New Donor Warning
                FMyForm.NewDonorWarning = false;

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

                //Don't run an inactive fields check on this batch
                FMyForm.GetBatchControl().UpdateRecurringBatchDictionary(CurrentBatchNo);

                //Delete current row
                ARowToDelete.RejectChanges();

                if (!RowToDeleteIsNew)
                {
                    ShowDetails(ARowToDelete);
                }

                ARowToDelete.Delete();

                //If there existed (before the delete row above) more than one detail row, then no need to delete Recurring Gift header row
                if (DetailRowCount > 1)
                {
                    ACompletionMessage = Catalog.GetString("Recurring Gift Detail row deleted successfully!");

                    FGiftSelectedForDeletionFlag = false;

                    foreach (DataRowView rv in FGiftDetailView)
                    {
                        GiftBatchTDSARecurringGiftDetailRow row = (GiftBatchTDSARecurringGiftDetailRow)rv.Row;

                        if (row.DetailNumber > SelectedDetailNumber)
                        {
                            row.DetailNumber--;
                        }
                    }

                    FGift.LastDetailNumber--;
                }
                else
                {
                    ACompletionMessage = Catalog.GetString("Recurring Gift deleted successfully!");

                    RecurringGiftToDeleteTransNo = FGift.GiftTransactionNumber;

                    // Reduce all Recurring Gift Detail row Transaction numbers by 1 if they are greater then Recurring Gift to be deleted
                    FilterAllRecurringGiftDetailsOfBatch = String.Format("{0}={1} And {2}>{3}",
                                                                         ARecurringGiftDetailTable.GetBatchNumberDBName(),
                                                                         FBatchNumber,
                                                                         ARecurringGiftDetailTable.GetGiftTransactionNumberDBName(),
                                                                         RecurringGiftToDeleteTransNo);

                    DataView RecurringGiftDetailView = new DataView(FMainDS.ARecurringGiftDetail);
                    RecurringGiftDetailView.RowFilter = FilterAllRecurringGiftDetailsOfBatch;
                    RecurringGiftDetailView.Sort      = String.Format("{0} ASC", ARecurringGiftDetailTable.GetGiftTransactionNumberDBName());

                    foreach (DataRowView rv in RecurringGiftDetailView)
                    {
                        GiftBatchTDSARecurringGiftDetailRow row = (GiftBatchTDSARecurringGiftDetailRow)rv.Row;

                        row.GiftTransactionNumber--;
                    }

                    //Cannot delete the Recurring Gift row, just copy the data of rows above down by 1 row
                    // and then mark the top row for deletion
                    //In other words, bubble the Recurring Gift row to be deleted to the top
                    FilterAllRecurringGiftsOfBatch = String.Format("{0}={1} And {2}>={3}",
                                                                   ARecurringGiftTable.GetBatchNumberDBName(),
                                                                   FBatchNumber,
                                                                   ARecurringGiftTable.GetGiftTransactionNumberDBName(),
                                                                   RecurringGiftToDeleteTransNo);

                    DataView RecurringGiftView = new DataView(FMainDS.ARecurringGift);
                    RecurringGiftView.RowFilter = FilterAllRecurringGiftsOfBatch;
                    RecurringGiftView.Sort      = String.Format("{0} ASC", ARecurringGiftTable.GetGiftTransactionNumberDBName());

                    ARecurringGiftRow RecurringGiftRowToReceive  = null;
                    ARecurringGiftRow RecurringGiftRowToCopyDown = null;
                    ARecurringGiftRow RecurringGiftRowCurrent    = null;

                    int currentRecurringGiftTransNo = 0;

                    foreach (DataRowView gv in RecurringGiftView)
                    {
                        RecurringGiftRowCurrent = (ARecurringGiftRow)gv.Row;

                        currentRecurringGiftTransNo = RecurringGiftRowCurrent.GiftTransactionNumber;

                        if (currentRecurringGiftTransNo > RecurringGiftToDeleteTransNo)
                        {
                            RecurringGiftRowToCopyDown = RecurringGiftRowCurrent;

                            //Copy column values down
                            for (int j = 3; j < RecurringGiftRowToCopyDown.Table.Columns.Count; j++)
                            {
                                //Update all columns except the pk fields that remain the same
                                if (!RecurringGiftRowToCopyDown.Table.Columns[j].ColumnName.EndsWith("_text"))
                                {
                                    RecurringGiftRowToReceive[j] = RecurringGiftRowToCopyDown[j];
                                }
                            }
                        }

                        if (currentRecurringGiftTransNo == FBatchRow.LastGiftNumber)
                        {
                            //Mark last record for deletion
                            RecurringGiftRowCurrent.ChargeStatus = MFinanceConstants.MARKED_FOR_DELETION;
                        }

                        //Will always be previous row
                        RecurringGiftRowToReceive = RecurringGiftRowCurrent;
                    }

                    FPreviouslySelectedDetailRow = null;
                    FGiftSelectedForDeletionFlag = true;
                    FBatchRow.LastGiftNumber--;
                }

                //Save and check for inactive values and ex-workers and anonymous gifts
                //  in other unsaved Batches
                FPetraUtilsObject.SetChangedFlag();

                if (!FMyForm.SaveChangesManual(Logic.TExtraGiftBatchChecks.GiftBatchAction.DELETINGTRANS, false, false))
                {
                    FMyForm.GetBatchControl().UpdateRecurringBatchDictionary();

                    MessageBox.Show(Catalog.GetString("The gift detail has been deleted but the changes are not saved!"),
                                    Catalog.GetString("Deletion Warning"),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);

                    ACompletionMessage = string.Empty;

                    if (FGiftSelectedForDeletionFlag)
                    {
                        FGiftSelectedForDeletionFlag = false;
                        SetBatchLastGiftNumber();
                        UpdateControlsProtection();
                    }

                    UpdateTotals();

                    return(false);
                }

                //Clear current batch's gift data and reload from server
                RefreshRecurringBatchGiftData(FBatchNumber, true);

                DeletionSuccessful = true;
            }
            catch (Exception ex)
            {
                //Revert to previous state
                RevertDataSet(FMainDS, BackupMainDS, CurrentRowIndex);

                TLogging.LogException(ex, Utilities.GetMethodSignature());
                throw;
            }
            finally
            {
                FMyForm.NewDonorWarning         = true;
                FMainDS.EnforceConstraints      = true;
                FMyForm.FCurrentGiftBatchAction = Logic.TExtraGiftBatchChecks.GiftBatchAction.NONE;
                this.Cursor = Cursors.Default;
            }

            SetGiftDetailDefaultView();
            FFilterAndFindObject.ApplyFilter();
            UpdateRecordNumberDisplay();

            return(DeletionSuccessful);
        }
        private int GetChangedRecordCountManual(out string AMessage)
        {
            //For Gift Batch we will get a mix of some batches, gifts and gift details.
            // Only check relevant tables.
            List <string> TablesToCheck = new List <string>();

            TablesToCheck.Add(FMainDS.ARecurringGiftBatch.TableName);
            TablesToCheck.Add(FMainDS.ARecurringGift.TableName);
            TablesToCheck.Add(FMainDS.ARecurringGiftDetail.TableName);

            List <Tuple <string, int> > TableAndCountList = new List <Tuple <string, int> >();
            int AllChangesCount = 0;

            if (FMainDS.HasChanges())
            {
                foreach (DataTable dt in FMainDS.GetChanges().Tables)
                {
                    string currentTableName = dt.TableName;

                    if ((dt != null) &&
                        TablesToCheck.Contains(currentTableName) &&
                        (dt.Rows.Count > 0))
                    {
                        int tableChangesCount = 0;

                        DataTable dtChanges = dt.GetChanges();

                        foreach (DataRow dr in dtChanges.Rows)
                        {
                            if (DataUtilities.DataRowColumnsHaveChanged(dr))
                            {
                                tableChangesCount++;
                                AllChangesCount++;
                            }
                        }

                        if (tableChangesCount > 0)
                        {
                            TableAndCountList.Add(new Tuple <string, int>(currentTableName, tableChangesCount));
                        }
                    }
                }
            }

            // Now build up a sensible message
            AMessage = String.Empty;

            if (TableAndCountList.Count > 0)
            {
                if (TableAndCountList.Count == 1)
                {
                    Tuple <string, int> TableAndCount = TableAndCountList[0];

                    string tableName = TableAndCount.Item1;

                    if (TableAndCount.Item1.Equals(ARecurringGiftBatchTable.GetTableName()))
                    {
                        AMessage = String.Format(Catalog.GetString("    You have made changes to {0} recurring {1}.{2}"),
                                                 TableAndCount.Item2,
                                                 Catalog.GetPluralString("batch", "batches", TableAndCount.Item2),
                                                 Environment.NewLine);
                    }
                    else if (TableAndCount.Item1.Equals(ARecurringGiftTable.GetTableName()))
                    {
                        AMessage = String.Format(Catalog.GetString("    You have made changes to {0} {1}.{2}"),
                                                 TableAndCount.Item2,
                                                 Catalog.GetPluralString("gift", "gifts", TableAndCount.Item2),
                                                 Environment.NewLine);
                    }
                    else //if (TableAndCount.Item1.Equals(ARecurringGiftDetailTable.GetTableName()))
                    {
                        AMessage = String.Format(Catalog.GetString("    You have made changes to {0} {1}.{2}"),
                                                 TableAndCount.Item2,
                                                 Catalog.GetPluralString("gift detail", "gift details", TableAndCount.Item2),
                                                 Environment.NewLine);
                    }
                }
                else
                {
                    int nBatches     = 0;
                    int nGifts       = 0;
                    int nGiftDetails = 0;

                    foreach (Tuple <string, int> TableAndCount in TableAndCountList)
                    {
                        if (TableAndCount.Item1.Equals(ARecurringGiftBatchTable.GetTableName()))
                        {
                            nBatches = TableAndCount.Item2;
                        }
                        else if (TableAndCount.Item1.Equals(ARecurringGiftTable.GetTableName()))
                        {
                            nGifts = TableAndCount.Item2;
                        }
                        else //if (TableAndCount.Item1.Equals(ARecurringGiftDetailTable.GetTableName()))
                        {
                            nGiftDetails = TableAndCount.Item2;
                        }
                    }

                    if ((nBatches > 0) && (nGifts > 0) && (nGiftDetails > 0))
                    {
                        AMessage = String.Format(Catalog.GetString("    You have made changes to {0} recurring {1}, {2} {3} and {4} {5}.{6}"),
                                                 nBatches,
                                                 Catalog.GetPluralString("batch", "batches", nBatches),
                                                 nGifts,
                                                 Catalog.GetPluralString("gift", "gifts", nGifts),
                                                 nGiftDetails,
                                                 Catalog.GetPluralString("gift detail", "gift details", nGiftDetails),
                                                 Environment.NewLine);
                    }
                    else if ((nBatches > 0) && (nGifts > 0) && (nGiftDetails == 0))
                    {
                        AMessage = String.Format(Catalog.GetString("    You have made changes to {0} recurring {1} and {2} {3}.{4}"),
                                                 nBatches,
                                                 Catalog.GetPluralString("batch", "batches", nBatches),
                                                 nGifts,
                                                 Catalog.GetPluralString("gift", "gifts", nGifts),
                                                 Environment.NewLine);
                    }
                    else if ((nBatches > 0) && (nGifts == 0) && (nGiftDetails > 0))
                    {
                        AMessage = String.Format(Catalog.GetString("    You have made changes to {0} recurring {1} and {2} {3}.{4}"),
                                                 nBatches,
                                                 Catalog.GetPluralString("batch", "batches", nBatches),
                                                 nGiftDetails,
                                                 Catalog.GetPluralString("gift detail", "gift details", nGiftDetails),
                                                 Environment.NewLine);
                    }
                    else if ((nBatches > 0) && (nGifts == 0) && (nGiftDetails == 0))
                    {
                        AMessage = String.Format(Catalog.GetString("    You have made changes to {0} recurring {1}.{2}"),
                                                 nBatches,
                                                 Catalog.GetPluralString("batch", "batches", nBatches),
                                                 Environment.NewLine);
                    }
                    else if ((nBatches == 0) && (nGifts > 0) && (nGiftDetails > 0))
                    {
                        AMessage = String.Format(Catalog.GetString("    You have made changes to {0} {1} and {2} {3}.{4}"),
                                                 nGifts,
                                                 Catalog.GetPluralString("gift", "gifts", nGifts),
                                                 nGiftDetails,
                                                 Catalog.GetPluralString("gift detail", "gift details", nGiftDetails),
                                                 Environment.NewLine);
                    }
                    else if ((nBatches == 0) && (nGifts > 0) && (nGiftDetails == 0))
                    {
                        AMessage = String.Format(Catalog.GetString("    You have made changes to {0} {1}.{2}"),
                                                 nGifts,
                                                 Catalog.GetPluralString("gift", "gifts", nGiftDetails),
                                                 Environment.NewLine);
                    }
                    else if ((nBatches == 0) && (nGifts == 0) && (nGiftDetails > 0))
                    {
                        AMessage = String.Format(Catalog.GetString("    You have made changes to {0} {1}.{2}"),
                                                 nGiftDetails,
                                                 Catalog.GetPluralString("gift detail", "gift details", nGiftDetails),
                                                 Environment.NewLine);
                    }
                }

                AMessage += Catalog.GetString("(some of the changes may include related background items)");
                AMessage += Environment.NewLine;
                AMessage += String.Format(TFrmPetraEditUtils.StrConsequenceIfNotSaved, Environment.NewLine);
            }

            return(AllChangesCount);
        }
        private bool OnDeleteRowManual(GiftBatchTDSARecurringGiftDetailRow ARowToDelete, ref string ACompletionMessage)
        {
            bool DeletionSuccessful = false;

            ACompletionMessage = string.Empty;

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

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

            if (!RowToDeleteIsNew)
            {
                try
                {
                    // temporarily disable  New Donor Warning
                    ((TFrmRecurringGiftBatch)this.ParentForm).NewDonorWarning = false;

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

                    if (!((TFrmRecurringGiftBatch)this.ParentForm).SaveChanges())
                    {
                        MessageBox.Show(Catalog.GetString("Error in trying to save prior to deleting current Gift detail!"),
                                        Catalog.GetString("Deletion Error"),
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);

                        return(DeletionSuccessful);
                    }
                }
                finally
                {
                    ((TFrmRecurringGiftBatch)this.ParentForm).NewDonorWarning = true;
                }
            }

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

            BackupMainDS.Merge(FMainDS);

            //To be used later....Pass copy to delete method.
            //RecurringGiftBatchTDS TempDS = (RecurringGiftBatchTDS)FMainDS.Copy();
            //TempDS.Merge(FMainDS);

            int    SelectedDetailNumber                 = ARowToDelete.DetailNumber;
            int    RecurringGiftToDeleteTransNo         = 0;
            string FilterAllRecurringGiftsOfBatch       = String.Empty;
            string FilterAllRecurringGiftDetailsOfBatch = String.Empty;

            int DetailRowCount = FGiftDetailView.Count;

            try
            {
                this.Cursor = Cursors.WaitCursor;

                //Speeds up deletion of larger Recurring Gift sets
                FMainDS.EnforceConstraints = false;

                //Delete current detail row
                ARowToDelete.Delete();

                //If there existed (before the delete row above) more than one detail row, then no need to delete Recurring Gift header row
                if (DetailRowCount > 1)
                {
                    ACompletionMessage = Catalog.GetString("Recurring Gift Detail row deleted successfully!");

                    FGiftSelectedForDeletion = false;

                    foreach (DataRowView rv in FGiftDetailView)
                    {
                        GiftBatchTDSARecurringGiftDetailRow row = (GiftBatchTDSARecurringGiftDetailRow)rv.Row;

                        if (row.DetailNumber > SelectedDetailNumber)
                        {
                            row.DetailNumber--;
                        }
                    }

                    FGift.LastDetailNumber--;

                    FPetraUtilsObject.SetChangedFlag();
                }
                else
                {
                    ACompletionMessage = Catalog.GetString("Recurring Gift deleted successfully!");

                    RecurringGiftToDeleteTransNo = FGift.GiftTransactionNumber;

                    // Reduce all Recurring Gift Detail row Transaction numbers by 1 if they are greater then Recurring Gift to be deleted
                    FilterAllRecurringGiftDetailsOfBatch = String.Format("{0}={1} And {2}>{3}",
                                                                         ARecurringGiftDetailTable.GetBatchNumberDBName(),
                                                                         FBatchNumber,
                                                                         ARecurringGiftDetailTable.GetGiftTransactionNumberDBName(),
                                                                         RecurringGiftToDeleteTransNo);

                    DataView RecurringGiftDetailView = new DataView(FMainDS.ARecurringGiftDetail);
                    RecurringGiftDetailView.RowFilter = FilterAllRecurringGiftDetailsOfBatch;
                    RecurringGiftDetailView.Sort      = String.Format("{0} ASC", ARecurringGiftDetailTable.GetGiftTransactionNumberDBName());

                    foreach (DataRowView rv in RecurringGiftDetailView)
                    {
                        GiftBatchTDSARecurringGiftDetailRow row = (GiftBatchTDSARecurringGiftDetailRow)rv.Row;

                        row.GiftTransactionNumber--;
                    }

                    //Cannot delete the Recurring Gift row, just copy the data of rows above down by 1 row
                    // and then mark the top row for deletion
                    //In other words, bubble the Recurring Gift row to be deleted to the top
                    FilterAllRecurringGiftsOfBatch = String.Format("{0}={1} And {2}>={3}",
                                                                   ARecurringGiftTable.GetBatchNumberDBName(),
                                                                   FBatchNumber,
                                                                   ARecurringGiftTable.GetGiftTransactionNumberDBName(),
                                                                   RecurringGiftToDeleteTransNo);

                    DataView RecurringGiftView = new DataView(FMainDS.ARecurringGift);
                    RecurringGiftView.RowFilter = FilterAllRecurringGiftsOfBatch;
                    RecurringGiftView.Sort      = String.Format("{0} ASC", ARecurringGiftTable.GetGiftTransactionNumberDBName());

                    ARecurringGiftRow RecurringGiftRowToReceive  = null;
                    ARecurringGiftRow RecurringGiftRowToCopyDown = null;
                    ARecurringGiftRow RecurringGiftRowCurrent    = null;

                    int currentRecurringGiftTransNo = 0;

                    foreach (DataRowView gv in RecurringGiftView)
                    {
                        RecurringGiftRowCurrent = (ARecurringGiftRow)gv.Row;

                        currentRecurringGiftTransNo = RecurringGiftRowCurrent.GiftTransactionNumber;

                        if (currentRecurringGiftTransNo > RecurringGiftToDeleteTransNo)
                        {
                            RecurringGiftRowToCopyDown = RecurringGiftRowCurrent;

                            //Copy column values down
                            for (int j = 3; j < RecurringGiftRowToCopyDown.Table.Columns.Count; j++)
                            {
                                //Update all columns except the pk fields that remain the same
                                if (!RecurringGiftRowToCopyDown.Table.Columns[j].ColumnName.EndsWith("_text"))
                                {
                                    RecurringGiftRowToReceive[j] = RecurringGiftRowToCopyDown[j];
                                }
                            }
                        }

                        if (currentRecurringGiftTransNo == FBatchRow.LastGiftNumber)
                        {
                            //Mark last record for deletion
                            RecurringGiftRowCurrent.ChargeStatus = MFinanceConstants.MARKED_FOR_DELETION;
                        }

                        //Will always be previous row
                        RecurringGiftRowToReceive = RecurringGiftRowCurrent;
                    }

                    FPreviouslySelectedDetailRow = null;

                    FPetraUtilsObject.SetChangedFlag();

                    FGiftSelectedForDeletion = true;

                    FBatchRow.LastGiftNumber--;
                }

                //Try to save changes
                if (((TFrmRecurringGiftBatch)this.ParentForm).SaveChangesManual())
                {
                    //Clear current batch's Recurring Gift data and reload from server
                    RefreshCurrentRecurringBatchGiftData(FBatchNumber, true);
                }
                else
                {
                    throw new Exception("Unable to save after deleting a Recurring Gift!");
                }

                DeletionSuccessful = true;
            }
            catch (Exception ex)
            {
                //Revert to previous state
                RevertDataSet(FMainDS, BackupMainDS);

                TLogging.LogException(ex, Utilities.GetMethodSignature());
                throw;
            }
            finally
            {
                FMainDS.EnforceConstraints = true;
                SetGiftDetailDefaultView();
                FFilterAndFindObject.ApplyFilter();
                this.Cursor = Cursors.Default;
            }

            UpdateRecordNumberDisplay();

            return(DeletionSuccessful);
        }
        /// <summary>
        /// Get Unsaved Recurring Batch Rows in a list
        /// </summary>
        /// <param name="ABatchToInclude">If > 0 then include in list even if unchanged</param>
        /// <returns></returns>
        public List <ARecurringGiftBatchRow> GetUnsavedBatchRowsList(int ABatchToInclude = 0)
        {
            List <ARecurringGiftBatchRow> RetVal = new List <ARecurringGiftBatchRow>();
            List <int> BatchesWithChangesList    = new List <int>();
            string     BatchesWithChangesString  = string.Empty;

            DataView GiftBatchesDV = new DataView(FMainDS.ARecurringGiftBatch);

            GiftBatchesDV.Sort = ARecurringGiftBatchTable.GetBatchNumberDBName() + " ASC";

            DataView GiftDV        = new DataView(FMainDS.ARecurringGift);
            DataView GiftDetailsDV = new DataView(FMainDS.ARecurringGiftDetail);

            GiftDV.Sort = String.Format("{0} ASC, {1} ASC",
                                        ARecurringGiftTable.GetBatchNumberDBName(),
                                        ARecurringGiftTable.GetGiftTransactionNumberDBName());

            GiftDetailsDV.Sort = String.Format("{0} ASC, {1} ASC, {2} ASC",
                                               ARecurringGiftDetailTable.GetBatchNumberDBName(),
                                               ARecurringGiftDetailTable.GetGiftTransactionNumberDBName(),
                                               ARecurringGiftDetailTable.GetDetailNumberDBName());

            //Add the batch number(s) of changed gift rows
            foreach (DataRowView dRV in GiftDV)
            {
                ARecurringGiftRow gR = (ARecurringGiftRow)dRV.Row;

                if (!BatchesWithChangesList.Contains(gR.BatchNumber) &&
                    (gR.RowState != DataRowState.Unchanged))
                {
                    BatchesWithChangesList.Add(gR.BatchNumber);
                }
            }

            //Generate string of all batches found with changes
            if (BatchesWithChangesList.Count > 0)
            {
                BatchesWithChangesString = String.Join(",", BatchesWithChangesList);

                //Add any other batch number(s) of changed gift details
                GiftDetailsDV.RowFilter = String.Format("{0} NOT IN ({1})",
                                                        ARecurringGiftDetailTable.GetBatchNumberDBName(),
                                                        BatchesWithChangesString);
            }

            foreach (DataRowView dRV in GiftDetailsDV)
            {
                ARecurringGiftDetailRow gDR = (ARecurringGiftDetailRow)dRV.Row;

                if (!BatchesWithChangesList.Contains(gDR.BatchNumber) &&
                    (gDR.RowState != DataRowState.Unchanged))
                {
                    BatchesWithChangesList.Add(gDR.BatchNumber);
                }
            }

            BatchesWithChangesList.Sort();

            //Get batch rows
            foreach (DataRowView dRV in GiftBatchesDV)
            {
                ARecurringGiftBatchRow giftBatchRow = (ARecurringGiftBatchRow)dRV.Row;

                if ((giftBatchRow.BatchNumber == ABatchToInclude) ||
                    BatchesWithChangesList.Contains(giftBatchRow.BatchNumber) ||
                    (giftBatchRow.RowState != DataRowState.Unchanged))
                {
                    RetVal.Add(giftBatchRow);
                }
            }

            return(RetVal);
        }
Ejemplo n.º 8
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));
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Update the transaction method payment from outside
        /// </summary>
        public void UpdateMethodOfPayment()
        {
            Int32 LedgerNumber;
            Int32 BatchNumber;

            if (!((TFrmRecurringGiftBatch)this.ParentForm).GetBatchControl().FBatchLoaded)
            {
                return;
            }

            FBatchRow = GetRecurringBatchRow();

            if (FBatchRow == null)
            {
                FBatchRow = ((TFrmRecurringGiftBatch)this.ParentForm).GetBatchControl().GetSelectedDetailRow();
            }

            FBatchMethodOfPayment = ((TFrmRecurringGiftBatch)this.ParentForm).GetBatchControl().MethodOfPaymentCode;

            LedgerNumber = FBatchRow.LedgerNumber;
            BatchNumber  = FBatchRow.BatchNumber;

            if (!LoadGiftDataForBatch(LedgerNumber, BatchNumber))
            {
                //No transactions exist to process or corporate exchange rate not found
                return;
            }

            if ((FLedgerNumber == LedgerNumber) && (FBatchNumber == BatchNumber))
            {
                //Rows already active in transaction tab. Need to set current row ac code below will not update selected row
                if (FPreviouslySelectedDetailRow != null)
                {
                    FPreviouslySelectedDetailRow.MethodOfPaymentCode = FBatchMethodOfPayment;
                    cmbDetailMethodOfPaymentCode.SetSelectedString(FBatchMethodOfPayment);
                }
            }

            //Update all transactions
            DataView GiftView = new DataView(FMainDS.ARecurringGift);

            GiftView.RowStateFilter = DataViewRowState.CurrentRows;
            GiftView.RowFilter      = String.Format("{0}={1}",
                                                    ARecurringGiftTable.GetBatchNumberDBName(),
                                                    BatchNumber);

            foreach (DataRowView drv in GiftView)
            {
                ARecurringGiftRow giftRow = (ARecurringGiftRow)drv.Row;
                giftRow.MethodOfPaymentCode = FBatchMethodOfPayment;
            }

            //Do same at detail level to update the grid
            DataView GiftDetailView = new DataView(FMainDS.ARecurringGiftDetail);

            GiftDetailView.RowStateFilter = DataViewRowState.CurrentRows;
            GiftDetailView.RowFilter      = String.Format("{0}={1}",
                                                          ARecurringGiftDetailTable.GetBatchNumberDBName(),
                                                          BatchNumber);

            foreach (DataRowView drv in GiftDetailView)
            {
                GiftBatchTDSARecurringGiftDetailRow giftDetailRow = (GiftBatchTDSARecurringGiftDetailRow)drv.Row;
                giftDetailRow.MethodOfPaymentCode = FBatchMethodOfPayment;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Clear the gift data of the current batch without marking records for delete
        /// </summary>
        private bool RefreshRecurringBatchGiftData(Int32 ABatchNumber,
                                                   bool AAcceptChanges       = false,
                                                   bool AHandleDataSetBackup = false)
        {
            bool RetVal = false;

            //Copy and backup the current dataset
            GiftBatchTDS BackupDS = null;
            GiftBatchTDS TempDS   = (GiftBatchTDS)FMainDS.Copy();

            TempDS.Merge(FMainDS);

            if (AHandleDataSetBackup)
            {
                BackupDS = (GiftBatchTDS)FMainDS.GetChangesTyped(false);
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;

                //Remove current batch gift data
                DataView giftDetailView = new DataView(TempDS.ARecurringGiftDetail);

                giftDetailView.RowFilter = String.Format("{0}={1}",
                                                         ARecurringGiftDetailTable.GetBatchNumberDBName(),
                                                         ABatchNumber);

                giftDetailView.Sort = String.Format("{0} DESC, {1} DESC",
                                                    ARecurringGiftDetailTable.GetGiftTransactionNumberDBName(),
                                                    ARecurringGiftDetailTable.GetDetailNumberDBName());

                foreach (DataRowView dr in giftDetailView)
                {
                    dr.Delete();
                }

                DataView giftView = new DataView(TempDS.ARecurringGift);

                giftView.RowFilter = String.Format("{0}={1}",
                                                   ARecurringGiftTable.GetBatchNumberDBName(),
                                                   ABatchNumber);

                giftView.Sort = String.Format("{0} DESC",
                                              ARecurringGiftTable.GetGiftTransactionNumberDBName());

                foreach (DataRowView dr in giftView)
                {
                    dr.Delete();
                }

                TempDS.AcceptChanges();

                //Clear all gift data from Main dataset gift tables
                FMainDS.ARecurringGiftDetail.Clear();
                FMainDS.ARecurringGift.Clear();

                //Bring data back in from other batches if it exists
                if (TempDS.ARecurringGift.Count > 0)
                {
                    FMainDS.ARecurringGift.Merge(TempDS.ARecurringGift);
                    FMainDS.ARecurringGiftDetail.Merge(TempDS.ARecurringGiftDetail);
                }

                FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadRecurringGiftTransactionsForBatch(FLedgerNumber, ABatchNumber));

                if (AAcceptChanges)
                {
                    FMainDS.AcceptChanges();
                }

                RetVal = true;
            }
            catch (Exception ex)
            {
                //If not revert on error then calling method will
                if (AHandleDataSetBackup)
                {
                    RevertDataSet(FMainDS, BackupDS);
                }

                TLogging.LogException(ex, Utilities.GetMethodSignature());
                throw;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }

            return(RetVal);
        }