/// <summary> /// Checks the entire gift batch for inactive values and informs the user /// </summary> /// <param name="AAction"></param> /// <param name="AMainDS"></param> /// <param name="APetraUtilsObject"></param> /// <param name="AIsRecurringGift"></param> /// <returns></returns> public static bool CheckForConsistentFieldValues(GiftBatchAction AAction, GiftBatchTDS AMainDS, TFrmPetraEditUtils APetraUtilsObject, Boolean AIsRecurringGift = false) { bool RetVal = false; //TODO: check for field value consistency before saving //TODO: Check Batch, Gift and Detail key field consistency // e.g. consecutive numbers, last number values etc if (!AIsRecurringGift) { } else { } //TODO: Check Method of Payment between Batch and Gift level if (!AIsRecurringGift) { } else { } //TODO: Check for Tax value correctness at Gift Detail level if (!AIsRecurringGift) { } //Nothing to do for recurring return(RetVal); }
/// <summary> /// Looks for gifts where the recipient is an ExWorker and asks the user if they want to continue. /// (Make sure GetDataFromControls is called before this method so that AMainDS is up-to-date.) /// </summary> /// <param name="AAction">Why this method is being called</param> /// <param name="AMainDS"></param> /// <param name="APetraUtilsObject"></param> /// <param name="APostingGiftDetails">Only used when being called in order to carry out a batch posting</param> /// <returns>Returns true if saving/posting can continue</returns> public static bool CanContinueWithAnyExWorkers(GiftBatchAction AAction, GiftBatchTDS AMainDS, TFrmPetraEditUtils APetraUtilsObject, DataTable APostingGiftDetails = null) { DataTable ExWorkers = null; string Msg = string.Empty; int BatchNumber = -1; int ExWorkerGifts = 0; string ExWorkerSpecialType = TSystemDefaults.GetSystemDefault(SharedConstants.SYSDEFAULT_EXWORKERSPECIALTYPE, "EX-WORKER"); // first check for Ex-Workers in the batch that is being posted/submitted (if a batch is being posted/submitted) if ((APostingGiftDetails != null) && (APostingGiftDetails.Rows.Count > 0)) { ExWorkers = TRemote.MFinance.Gift.WebConnectors.FindGiftRecipientExWorker(APostingGiftDetails, BatchNumber); ExWorkerGifts += ExWorkers.Rows.Count; Msg = GetExWorkersString(AAction, ExWorkerSpecialType, ExWorkers); if (ExWorkers.Rows.Count > 0) { BatchNumber = (int)APostingGiftDetails.Rows[0][GiftBatchTDSAGiftDetailTable.GetBatchNumberDBName()]; } } // check for Ex-Workers in all added and modified data if (APetraUtilsObject.HasChanges) { DataTable Changes = new DataTable(); if (AMainDS.AGiftDetail.GetChangesTyped() != null) { Changes.Merge(AMainDS.AGiftDetail.GetChangesTyped()); } else if (AMainDS.ARecurringGiftDetail.GetChangesTyped() != null) { Changes.Merge(AMainDS.ARecurringGiftDetail.GetChangesTyped()); } if ((Changes != null) && (Changes.Rows.Count > 0)) { ExWorkers = TRemote.MFinance.Gift.WebConnectors.FindGiftRecipientExWorker(Changes, BatchNumber); ExWorkerGifts += ExWorkers.Rows.Count; Msg += GetExWorkersString(null, ExWorkerSpecialType, ExWorkers); } } // alert the user to any recipients who are Ex-Workers if (Msg != string.Empty) { if (AAction == GiftBatchAction.SAVING) { Msg += Catalog.GetString("Do you want to continue with saving anyway?"); } else { // singular if (ExWorkerGifts == 1) { if (AAction == GiftBatchAction.POSTING) { Msg += Catalog.GetString("This gift will need to be saved before this batch can be posted."); } else if (AAction == GiftBatchAction.NEWBATCH) { Msg += Catalog.GetString("This gift will need to be saved before a new batch can be created."); } else if (AAction == GiftBatchAction.CANCELLING) { Msg += Catalog.GetString("This gift will need to be saved before this batch can be cancelled."); } else if (AAction == GiftBatchAction.SUBMITTING) { Msg += Catalog.GetString("This gift will need to be saved before this batch can be submitted."); } else if (AAction == GiftBatchAction.DELETING) { Msg += Catalog.GetString("This gift will need to be saved before this batch can be deleted."); } } // plural else { if (AAction == GiftBatchAction.POSTING) { Msg += Catalog.GetString("These gifts will need to be saved before this batch can be posted."); } else if (AAction == GiftBatchAction.NEWBATCH) { Msg += Catalog.GetString("These gifts will need to be saved before a new batch can be created."); } else if (AAction == GiftBatchAction.CANCELLING) { Msg += Catalog.GetString("These gifts will need to be saved before this batch can be cancelled."); } else if (AAction == GiftBatchAction.SUBMITTING) { Msg += Catalog.GetString("These gifts will need to be saved before this batch can be submitted."); } else if (AAction == GiftBatchAction.DELETING) { Msg += Catalog.GetString("These gifts will need to be saved before this batch can be deleted."); } } Msg += " " + Catalog.GetString("Do you want to continue?"); } if (MessageBox.Show( Msg, string.Format(Catalog.GetString("{0} Warning"), ExWorkerSpecialType), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return false; } } return true; }
private static string GetExWorkersString(GiftBatchAction? AAction, string AExWorkerSpecialType, DataTable AExWorkers) { string ReturnValue = string.Empty; if (AExWorkers.Rows.Count == 0) { return ReturnValue; } DataView dv = AExWorkers.DefaultView; dv.Sort = GiftBatchTDSAGiftDetailTable.GetGiftTransactionNumberDBName() + " ASC"; DataTable sortedDT = dv.ToTable(); if ((AAction == GiftBatchAction.POSTING) || (AAction == GiftBatchAction.SUBMITTING)) { if (AExWorkers.Rows.Count == 1) { ReturnValue = string.Format(Catalog.GetString( "The gift listed below has a recipient who has a Special Type beginning with {0}:"), AExWorkerSpecialType); } else { ReturnValue = string.Format(Catalog.GetString( "The gifts listed below have recipients who have a Special Type beginning with {0}:"), AExWorkerSpecialType); } } else { if (AExWorkers.Rows.Count == 1) { ReturnValue = string.Format(Catalog.GetString( "The unsaved gift listed below is for a recipient who has Special Type beginning with {0}:"), AExWorkerSpecialType); } else { ReturnValue = string.Format(Catalog.GetString( "The unsaved gifts listed below are for recipients who have Special Type beginning with {0}:"), AExWorkerSpecialType); } } ReturnValue += "\n\n"; foreach (DataRow Row in sortedDT.Rows) { ReturnValue += Catalog.GetString("Batch: ") + Row[GiftBatchTDSAGiftDetailTable.GetBatchNumberDBName()] + "; " + Catalog.GetString("Gift: ") + Row[GiftBatchTDSAGiftDetailTable.GetGiftTransactionNumberDBName()] + "; " + Catalog.GetString("Recipient: ") + Row[GiftBatchTDSAGiftDetailTable.GetRecipientDescriptionDBName()] + " (" + Row[GiftBatchTDSAGiftDetailTable.GetRecipientKeyDBName()] + ")\n"; } return ReturnValue += "\n"; }
/// <summary> /// Looks for gifts where the recipient is an ExWorker and asks the user if they want to continue. /// (Make sure GetDataFromControls is called before this method so that AMainDS is up-to-date.) /// </summary> /// <param name="AAction">Why this method is being called</param> /// <param name="AMainDS"></param> /// <param name="APetraUtilsObject"></param> /// <param name="APostingGiftDetails">Only used when being called in order to carry out a batch posting</param> /// <returns>Returns true if saving/posting can continue</returns> public static bool CanContinueWithAnyExWorkers(GiftBatchAction AAction, GiftBatchTDS AMainDS, TFrmPetraEditUtils APetraUtilsObject, DataTable APostingGiftDetails = null) { DataTable ExWorkers = null; string Msg = string.Empty; int BatchNumber = -1; int ExWorkerGifts = 0; string ExWorkerSpecialType = TSystemDefaults.GetStringDefault(SharedConstants.SYSDEFAULT_EXWORKERSPECIALTYPE, "EX-WORKER"); // first check for Ex-Workers in the batch that is being posted/submitted (if a batch is being posted/submitted) if ((APostingGiftDetails != null) && (APostingGiftDetails.Rows.Count > 0)) { ExWorkers = TRemote.MFinance.Gift.WebConnectors.FindGiftRecipientExWorker(APostingGiftDetails, BatchNumber); ExWorkerGifts += ExWorkers.Rows.Count; Msg = GetExWorkersString(AAction, ExWorkerSpecialType, ExWorkers); if (ExWorkers.Rows.Count > 0) { BatchNumber = (int)APostingGiftDetails.Rows[0][GiftBatchTDSAGiftDetailTable.GetBatchNumberDBName()]; } } // check for Ex-Workers in all added and modified data if (APetraUtilsObject.HasChanges) { DataTable Changes = new DataTable(); if (AMainDS.AGiftDetail.GetChangesTyped() != null) { Changes.Merge(AMainDS.AGiftDetail.GetChangesTyped()); } else if (AMainDS.ARecurringGiftDetail.GetChangesTyped() != null) { Changes.Merge(AMainDS.ARecurringGiftDetail.GetChangesTyped()); } if ((Changes != null) && (Changes.Rows.Count > 0)) { ExWorkers = TRemote.MFinance.Gift.WebConnectors.FindGiftRecipientExWorker(Changes, BatchNumber); ExWorkerGifts += ExWorkers.Rows.Count; Msg += GetExWorkersString(null, ExWorkerSpecialType, ExWorkers); } } // alert the user to any recipients who are Ex-Workers if (Msg != string.Empty) { if (AAction == GiftBatchAction.SAVING) { Msg += Environment.NewLine + Environment.NewLine; Msg += Catalog.GetString("Do you want to continue with saving anyway?"); } else { Msg += Environment.NewLine + Environment.NewLine; Msg += Catalog.GetString("(any changes will also need to be saved before "); if (AAction == GiftBatchAction.NEWBATCH) { Msg += Catalog.GetString("a new batch can be created"); } else //POSTING, CANCELLING, SUBMITTING, DELETING { Msg += Catalog.GetString("this batch continues with " + AAction.ToString().ToLower()); } Msg += ")" + Environment.NewLine + Environment.NewLine; Msg += Catalog.GetString("Do you want to continue?"); } TFrmExtendedMessageBox extendedMessageBox = new TFrmExtendedMessageBox(APetraUtilsObject.GetForm()); if (extendedMessageBox.ShowDialog(Msg, Catalog.GetString("Ex-Workers Found"), string.Empty, TFrmExtendedMessageBox.TButtons.embbYesNo, TFrmExtendedMessageBox.TIcon.embiWarning) == TFrmExtendedMessageBox.TResult.embrNo) { return(false); } } return(true); }
/// <summary> /// Checks the entire gift batch for inactive values and informs the user /// </summary> /// <param name="ALedgerNumber"></param> /// <param name="AAction"></param> /// <param name="AMainDS"></param> /// <param name="APetraUtilsObject"></param> /// <param name="AIsRecurringGift"></param> /// <returns></returns> public static bool CheckForInactiveFieldValues(Int32 ALedgerNumber, GiftBatchAction AAction, GiftBatchTDS AMainDS, TFrmPetraEditUtils APetraUtilsObject, Boolean AIsRecurringGift = false) { #region Validate Arguments if (AMainDS == null) { throw new EFinanceSystemInvalidLedgerNumberException(String.Format(Catalog.GetString( "Function:{0} - The Gift Batch dataset is empty!"), Utilities.GetMethodName(true))); } else if (AMainDS.AGiftBatch.Count == 0) { throw new ArgumentException(String.Format(Catalog.GetString( "Function:{0} - The Gift Batch table contains no batches to validate!"), Utilities.GetMethodName(true))); } #endregion Validate Arguments //TODO: Need to rewrite... bool RetVal = false; bool ChangesAtGiftBatchLevel = false; bool ChangesAtGiftLevel = false; bool ChangesAtGiftDetailLevel = false; string IndentifyRecurring = (AIsRecurringGift ? "ARecurring" : "A"); Type GiftBatchTableType = Type.GetType(IndentifyRecurring + "GiftBatchTable"); bool WarnOfInactiveValuesOnPosting = TUserDefaults.GetBooleanDefault(TUserDefaults.FINANCE_GIFT_WARN_OF_INACTIVE_VALUES_ON_POSTING, true); if ((AAction == GiftBatchAction.POSTING) && !WarnOfInactiveValuesOnPosting) { return(true); } if (APetraUtilsObject.HasChanges) { GiftBatchTDS Changes = new GiftBatchTDS(); //Batch level if (!AIsRecurringGift && (AMainDS.AGiftBatch.GetChangesTyped() != null)) { Changes.Merge(AMainDS.AGiftBatch.GetChangesTyped()); ChangesAtGiftBatchLevel = true; } else if (AIsRecurringGift && (AMainDS.ARecurringGiftBatch.GetChangesTyped() != null)) { Changes.Merge(AMainDS.ARecurringGiftBatch.GetChangesTyped()); ChangesAtGiftBatchLevel = true; } //Gift level if (!AIsRecurringGift && (AMainDS.AGift.GetChangesTyped() != null)) { Changes.Merge(AMainDS.AGift.GetChangesTyped()); ChangesAtGiftLevel = true; } else if (AIsRecurringGift && (AMainDS.ARecurringGift.GetChangesTyped() != null)) { Changes.Merge(AMainDS.ARecurringGift.GetChangesTyped()); ChangesAtGiftLevel = true; } //Detail level if (!AIsRecurringGift && (AMainDS.AGiftDetail.GetChangesTyped() != null)) { Changes.Merge(AMainDS.AGiftDetail.GetChangesTyped()); ChangesAtGiftDetailLevel = true; } else if (AIsRecurringGift && (AMainDS.ARecurringGiftDetail.GetChangesTyped() != null)) { Changes.Merge(AMainDS.ARecurringGiftDetail.GetChangesTyped()); ChangesAtGiftDetailLevel = true; } //Process changes if (ChangesAtGiftBatchLevel) { //***Batch level //TODO: Check for inactive Bank Cost Centre if (!AIsRecurringGift) { } else { //Recurring gift batch changes } //TODO: Check for inactive Bank Account if (!AIsRecurringGift) { } else { //Recurring gift batch changes } //TODO: Check for inactive Currency Code if (!AIsRecurringGift) { } else { //Recurring gift batch changes } //TODO: Check for inactive Method of Payment if (!AIsRecurringGift) { } else { //Recurring gift batch changes } } if (ChangesAtGiftLevel) { //**Gift-level //TODO: Check for inactive Donor if (!AIsRecurringGift) { } else { //Recurring gift batch changes } //TODO: Check for inactive Method of Payment if (!AIsRecurringGift) { } else { //Recurring gift batch changes } //TODO: Check for inactive Method of Giving if (!AIsRecurringGift) { } else { //Recurring gift batch changes } } if (ChangesAtGiftDetailLevel) { //*Detail-level //TODO: Check for inactive Recipient if (!AIsRecurringGift) { } else { //Recurring gift batch changes } //TODO: Check for inactive Key Ministry if (!AIsRecurringGift) { } else { //Recurring gift batch changes } //TODO: Check for inactive Cost Centre if (!AIsRecurringGift) { } else { //Recurring gift batch changes } //TODO: Check for inactive Account if (!AIsRecurringGift) { } else { //Recurring gift batch changes } //TODO: Check for inactive Tax Account if (!AIsRecurringGift) { } else { //Recurring gift batch changes } //TODO: Check for inactive Motivation Group or Detail if (!AIsRecurringGift) { } else { //Recurring gift batch changes } //TODO: Check for inactive MailingCode if (!AIsRecurringGift) { } else { //Recurring gift batch changes } } } return(RetVal); }
/// <summary> /// Looks for gifts where the recipient is an ExWorker and asks the user if they want to continue. /// (Make sure GetDataFromControls is called before this method so that AMainDS is up-to-date.) /// </summary> /// <param name="AAction">Why this method is being called</param> /// <param name="AMainDS"></param> /// <param name="APetraUtilsObject"></param> /// <param name="APostingGiftDetails">Only used when being called in order to carry out a batch posting</param> /// <returns>Returns true if saving/posting can continue</returns> public static bool CanContinueWithAnyExWorkers(GiftBatchAction AAction, GiftBatchTDS AMainDS, TFrmPetraEditUtils APetraUtilsObject, DataTable APostingGiftDetails = null) { DataTable ExWorkers = null; string Msg = string.Empty; int BatchNumber = -1; int ExWorkerGifts = 0; string ExWorkerSpecialType = TSystemDefaults.GetSystemDefault(SharedConstants.SYSDEFAULT_EXWORKERSPECIALTYPE, "EX-WORKER"); // first check for Ex-Workers in the batch that is being posted/submitted (if a batch is being posted/submitted) if ((APostingGiftDetails != null) && (APostingGiftDetails.Rows.Count > 0)) { ExWorkers = TRemote.MFinance.Gift.WebConnectors.FindGiftRecipientExWorker(APostingGiftDetails, BatchNumber); ExWorkerGifts += ExWorkers.Rows.Count; Msg = GetExWorkersString(AAction, ExWorkerSpecialType, ExWorkers); if (ExWorkers.Rows.Count > 0) { BatchNumber = (int)APostingGiftDetails.Rows[0][GiftBatchTDSAGiftDetailTable.GetBatchNumberDBName()]; } } // check for Ex-Workers in all added and modified data if (APetraUtilsObject.HasChanges) { DataTable Changes = new DataTable(); if (AMainDS.AGiftDetail.GetChangesTyped() != null) { Changes.Merge(AMainDS.AGiftDetail.GetChangesTyped()); } else if (AMainDS.ARecurringGiftDetail.GetChangesTyped() != null) { Changes.Merge(AMainDS.ARecurringGiftDetail.GetChangesTyped()); } if ((Changes != null) && (Changes.Rows.Count > 0)) { ExWorkers = TRemote.MFinance.Gift.WebConnectors.FindGiftRecipientExWorker(Changes, BatchNumber); ExWorkerGifts += ExWorkers.Rows.Count; Msg += GetExWorkersString(null, ExWorkerSpecialType, ExWorkers); } } // alert the user to any recipients who are Ex-Workers if (Msg != string.Empty) { if (AAction == GiftBatchAction.SAVING) { Msg += Catalog.GetString("Do you want to continue with saving anyway?"); } else { // singular if (ExWorkerGifts == 1) { if (AAction == GiftBatchAction.POSTING) { Msg += Catalog.GetString("This gift will need to be saved before this batch can be posted."); } else if (AAction == GiftBatchAction.NEWBATCH) { Msg += Catalog.GetString("This gift will need to be saved before a new batch can be created."); } else if (AAction == GiftBatchAction.CANCELLING) { Msg += Catalog.GetString("This gift will need to be saved before this batch can be cancelled."); } else if (AAction == GiftBatchAction.SUBMITTING) { Msg += Catalog.GetString("This gift will need to be saved before this batch can be submitted."); } else if (AAction == GiftBatchAction.DELETING) { Msg += Catalog.GetString("This gift will need to be saved before this batch can be deleted."); } } // plural else { if (AAction == GiftBatchAction.POSTING) { Msg += Catalog.GetString("These gifts will need to be saved before this batch can be posted."); } else if (AAction == GiftBatchAction.NEWBATCH) { Msg += Catalog.GetString("These gifts will need to be saved before a new batch can be created."); } else if (AAction == GiftBatchAction.CANCELLING) { Msg += Catalog.GetString("These gifts will need to be saved before this batch can be cancelled."); } else if (AAction == GiftBatchAction.SUBMITTING) { Msg += Catalog.GetString("These gifts will need to be saved before this batch can be submitted."); } else if (AAction == GiftBatchAction.DELETING) { Msg += Catalog.GetString("These gifts will need to be saved before this batch can be deleted."); } } Msg += " " + Catalog.GetString("Do you want to continue?"); } if (MessageBox.Show( Msg, string.Format(Catalog.GetString("{0} Warning"), ExWorkerSpecialType), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return(false); } } return(true); }