コード例 #1
0
        /// <summary>
        /// Looks for gifts where the donor is anoymous but the gift is not marked as confidential 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="AMainDS"></param>
        public static bool CanContinueWithAnyAnonymousDonors(GiftBatchTDS AMainDS)
        {
            GiftBatchTDSAGiftDetailTable UnConfidentialGiftsWithAnonymousDonors = new GiftBatchTDSAGiftDetailTable();

            foreach (GiftBatchTDSAGiftDetailRow Row in AMainDS.AGiftDetail.Rows)
            {
                if (!Row.ConfidentialGiftFlag)
                {
                    PPartnerRow PartnerRow = (PPartnerRow)AMainDS.DonorPartners.Rows.Find(Row.DonorKey);

                    if ((PartnerRow != null) && PartnerRow.AnonymousDonor)
                    {
                        UnConfidentialGiftsWithAnonymousDonors.Rows.Add((object[])Row.ItemArray.Clone());
                    }
                }
            }

            if (UnConfidentialGiftsWithAnonymousDonors.Rows.Count > 0)
            {
                string Message = string.Empty;

                DataView dv = UnConfidentialGiftsWithAnonymousDonors.DefaultView;
                dv.Sort = GiftBatchTDSAGiftDetailTable.GetGiftTransactionNumberDBName() + " ASC";
                DataTable sortedDT = dv.ToTable();

                if (UnConfidentialGiftsWithAnonymousDonors.Rows.Count == 1)
                {
                    Message = Catalog.GetString(
                        "The gift listed below in this batch is not marked as confidential but the donor has asked to remain anonymous.");
                }
                else
                {
                    Message = Catalog.GetString(
                        "The gifts listed below in this batch are not marked as confidential but the donors have asked to remain anonymous.");
                }

                Message += "\n\n";

                foreach (DataRow UnConfidentialGifts in sortedDT.Rows)
                {
                    Message += Catalog.GetString("Batch: ") + UnConfidentialGifts[GiftBatchTDSAGiftDetailTable.GetBatchNumberDBName()] + "; " +
                               Catalog.GetString("Gift: ") + UnConfidentialGifts[GiftBatchTDSAGiftDetailTable.GetGiftTransactionNumberDBName()] +
                               "; " +
                               Catalog.GetString("Donor: ") + UnConfidentialGifts[GiftBatchTDSAGiftDetailTable.GetDonorNameDBName()] + " (" +
                               UnConfidentialGifts[GiftBatchTDSAGiftDetailTable.GetDonorKeyDBName()] + ")\n";
                }

                Message += "\n" + Catalog.GetString("Do you want to continue with posting anyway?");

                if (MessageBox.Show(
                        Message, Catalog.GetString("Anonymous Donor Warning"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
                    == DialogResult.No)
                {
                    return(false);
                }
            }

            return(true);
        }