예제 #1
0
        /// <summary>
        /// Processes the result of a data submission to the Server where the result of that operation is
        /// <see cref="TSubmitChangesResult.scrOK" />. (Overload for DataTables.)
        /// </summary>
        /// <param name="ACallingFormOrUserControl"></param>
        /// <param name="ALocalDT"></param>
        /// <param name="ASubmitDT"></param>
        /// <param name="APetraUtilsObject"></param>
        /// <param name="AVerificationResults"></param>
        /// <param name="ASetPrimaryKeyOnlyMethod"></param>
        /// <param name="AMasterDataTableSaveCall"></param>
        /// <param name="ACalledFromUserControl"></param>
        /// <param name="ACallAcceptChangesOnReturnedDataBeforeMerge"></param>
        public static void ProcessSubmitChangesResultOK(IFrmPetra ACallingFormOrUserControl, DataTable ALocalDT,
                                                        DataTable ASubmitDT, TFrmPetraEditUtils APetraUtilsObject, TVerificationResultCollection AVerificationResults,
                                                        Action <bool> ASetPrimaryKeyOnlyMethod, bool AMasterDataTableSaveCall, bool ACalledFromUserControl,
                                                        bool ACallAcceptChangesOnReturnedDataBeforeMerge = false)
        {
            if (AMasterDataTableSaveCall)
            {
                // Call AcceptChanges to get rid now of any deleted columns before we Merge with the result from the Server
                ALocalDT.AcceptChanges();

                // Merge back with data from the Server (eg. for getting Sequence values)
                if (ACallAcceptChangesOnReturnedDataBeforeMerge)
                {
                    ASubmitDT.AcceptChanges();
                }

                ALocalDT.Merge(ASubmitDT, false);

                // Need to accept any new modification ID's
                ALocalDT.AcceptChanges();

                if (ASetPrimaryKeyOnlyMethod != null)
                {
                    // Ensure the Primary-Key(s)-containing Controls are disabled to prevent further modification of Primary Key values
                    ASetPrimaryKeyOnlyMethod(true);
                }
            }

            CommonPostMergeOperations(ACallingFormOrUserControl, APetraUtilsObject,
                                      AVerificationResults, ACalledFromUserControl);
        }
        /// <summary>
        /// Processes the result of a data submission to the Server where the result of that operation is
        /// <see cref="TSubmitChangesResult.scrOK" />. (Overload for DataTables.)
        /// </summary>
        /// <param name="ACallingFormOrUserControl"></param>
        /// <param name="ALocalDT"></param>
        /// <param name="ASubmitDT"></param>
        /// <param name="APetraUtilsObject"></param>
        /// <param name="AVerificationResults"></param>
        /// <param name="ASetPrimaryKeyOnlyMethod"></param>
        /// <param name="AMasterDataTableSaveCall"></param>
        /// <param name="ACalledFromUserControl"></param>
        /// <param name="ACallAcceptChangesOnReturnedDataBeforeMerge"></param>
        public static void ProcessSubmitChangesResultOK(IFrmPetra ACallingFormOrUserControl, DataTable ALocalDT,
            DataTable ASubmitDT, TFrmPetraEditUtils APetraUtilsObject, TVerificationResultCollection AVerificationResults,
            Action <bool>ASetPrimaryKeyOnlyMethod, bool AMasterDataTableSaveCall, bool ACalledFromUserControl,
            bool ACallAcceptChangesOnReturnedDataBeforeMerge = false)
        {
            if (AMasterDataTableSaveCall)
            {
                // Call AcceptChanges to get rid now of any deleted columns before we Merge with the result from the Server
                ALocalDT.AcceptChanges();

                // Merge back with data from the Server (eg. for getting Sequence values)
                if (ACallAcceptChangesOnReturnedDataBeforeMerge)
                {
                    ASubmitDT.AcceptChanges();
                }

                ALocalDT.Merge(ASubmitDT, false);

                // Need to accept any new modification ID's
                ALocalDT.AcceptChanges();

                if (ASetPrimaryKeyOnlyMethod != null)
                {
                    // Ensure the Primary-Key(s)-containing Controls are disabled to prevent further modification of Primary Key values
                    ASetPrimaryKeyOnlyMethod(true);
                }
            }

            CommonPostMergeOperations(ACallingFormOrUserControl, APetraUtilsObject,
                AVerificationResults, ACalledFromUserControl);
        }
예제 #3
0
 /// <summary>
 /// Processes the result of a data submission to the Server where the result of that operation is
 /// <see cref="TSubmitChangesResult.scrNothingToBeSaved" />.
 /// </summary>
 /// <param name="ACallingFormOrUserControl"></param>
 /// <param name="APetraUtilsObject"></param>
 /// <param name="ACalledFromUserControl"></param>
 public static void ProcessSubmitChangesResultNothingToBeSaved(IFrmPetra ACallingFormOrUserControl,
                                                               TFrmPetraEditUtils APetraUtilsObject,
                                                               bool ACalledFromUserControl = false)
 {
     CommonUIUpdatesNoChangesAnymore(ACallingFormOrUserControl, APetraUtilsObject,
                                     MCommonResourcestrings.StrSavingDataNothingToSave, ACalledFromUserControl);
 }
        /// <summary>
        /// Constructor
        /// </summary>
        public TUC_GiftBatches_Cancel(TFrmPetraEditUtils APetraUtilsObject, Int32 ALedgerNumber, GiftBatchTDS AMainDS)
        {
            FPetraUtilsObject = APetraUtilsObject;
            FLedgerNumber = ALedgerNumber;
            FMainDS = AMainDS;

            FMyForm = (TFrmGiftBatch)FPetraUtilsObject.GetForm();
        }
예제 #5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="AParentForm">Parent Form.</param>
        public TPetraShepherdConcreteForm(Form AParentForm)
        {
            TLogging.Log("Entering TPetraShepherdConcreteForm Constructor...");

            FPetraUtilsObject = new TFrmPetraEditUtils(AParentForm, this, ShepherdStatusBar);

            TLogging.Log("TPetraShepherdConcreteForm Constructor ran.");
        }
        /// <summary>
        /// Constructor
        /// </summary>
        public TUC_GLBatches_Post(TFrmPetraEditUtils APetraUtilsObject, Int32 ALedgerNumber, GLBatchTDS AMainDS, IUC_GLBatches AUserControl)
        {
            FPetraUtilsObject = APetraUtilsObject;
            FLedgerNumber = ALedgerNumber;
            FMainDS = AMainDS;
            FMyUserControl = AUserControl;

            FMyForm = (TFrmGLBatch)FPetraUtilsObject.GetForm();
        }
 /// <summary>
 /// Constructor
 /// </summary>
 public MaintainBudget_Import(TFrmPetraEditUtils APetraUtilsObject,
     Int32 ALedgerNumber,
     Int32 ANumberOfPeriods,
     TFrmMaintainBudget AUserControl)
 {
     FPetraUtilsObject = APetraUtilsObject;
     FLedgerNumber = ALedgerNumber;
     FNumberOfPeriods = ANumberOfPeriods;
     FUserControl = AUserControl;
     FParentForm = AUserControl;
 }
        /// <summary>
        /// The main method to run a reference check on a single item of data
        /// </summary>
        /// <param name="APetraUtilsObject">The calling forms PetraUtils Object</param>
        /// <param name="AVerificationResults">The results collection to check</param>
        /// <param name="ALimitedCount">Will be true if the reference count call was a limited check</param>
        /// <returns>A message box result.  Yes implies doing a new unlimited count, Undefined implies there are no references so deletion can proceed.
        /// Any other value implies that references exist</returns>
        public TFrmExtendedMessageBox.TResult HandleReferences(TFrmPetraEditUtils APetraUtilsObject,
                                                               TVerificationResultCollection AVerificationResults,
                                                               bool ALimitedCount)
        {
            Form MyForm = APetraUtilsObject.GetForm();

            // There were reference(s)
            TRowReferenceInfo info = (TRowReferenceInfo)AVerificationResults[0].ResultContext;
            bool bIncomplete       = info.CascadingCountEndedEarly;

            // Build up a message string
            string msgContent = Messages.BuildMessageFromVerificationResult(
                MCommonResourcestrings.StrRecordCannotBeDeleted +
                Environment.NewLine +
                Catalog.GetPluralString(MCommonResourcestrings.StrReasonColon, MCommonResourcestrings.StrReasonsColon, AVerificationResults.Count),
                AVerificationResults);

            TFrmExtendedMessageBox.TButtons       buttons   = TFrmExtendedMessageBox.TButtons.embbOK;
            TFrmExtendedMessageBox.TDefaultButton defButton = TFrmExtendedMessageBox.TDefaultButton.embdDefButton1;

            if (bIncomplete && ALimitedCount)
            {
                msgContent += String.Format(MCommonResourcestrings.StrCountTerminatedEarly1,
                                            Environment.NewLine,
                                            APetraUtilsObject.MaxReferenceCountOnDelete);
                msgContent += MCommonResourcestrings.StrCountTerminatedEarly2;
                msgContent += MCommonResourcestrings.StrCountTerminatedEarly3;
                msgContent += String.Format(MCommonResourcestrings.StrCountTerminatedEarly4,
                                            Environment.NewLine,
                                            MyForm.Text);
                buttons   = TFrmExtendedMessageBox.TButtons.embbYesNo;
                defButton = TFrmExtendedMessageBox.TDefaultButton.embdDefButton2;
            }
            else
            {
                if (bIncomplete)
                {
                    // We should never get an incomplete count on an unlimited check
                }

                msgContent += String.Format(MCommonResourcestrings.StrCountTerminatedEarlyOK, Environment.NewLine);
            }

            // Show an Extended Message Box and return the value
            TFrmExtendedMessageBox extendedMsgBox = new TFrmExtendedMessageBox(MyForm);

            return(extendedMsgBox.ShowDialog(
                       msgContent,
                       MCommonResourcestrings.StrRecordDeletionTitle,
                       String.Empty,
                       buttons,
                       defButton,
                       TFrmExtendedMessageBox.TIcon.embiInformation));
        }
        /// <summary>
        /// The main method to run a reference check on a single item of data
        /// </summary>
        /// <param name="APetraUtilsObject">The calling forms PetraUtils Object</param>
        /// <param name="AVerificationResults">The results collection to check</param>
        /// <param name="ALimitedCount">Will be true if the reference count call was a limited check</param>
        /// <returns>A message box result.  Yes implies doing a new unlimited count, Undefined implies there are no references so deletion can proceed.
        /// Any other value implies that references exist</returns>
        public TFrmExtendedMessageBox.TResult HandleReferences(TFrmPetraEditUtils APetraUtilsObject,
            TVerificationResultCollection AVerificationResults,
            bool ALimitedCount)
        {
            Form MyForm = APetraUtilsObject.GetForm();

            // There were reference(s)
            TRowReferenceInfo info = (TRowReferenceInfo)AVerificationResults[0].ResultContext;
            bool bIncomplete = info.CascadingCountEndedEarly;

            // Build up a message string
            string msgContent = Messages.BuildMessageFromVerificationResult(
                MCommonResourcestrings.StrRecordCannotBeDeleted +
                Environment.NewLine +
                Catalog.GetPluralString(MCommonResourcestrings.StrReasonColon, MCommonResourcestrings.StrReasonsColon, AVerificationResults.Count),
                AVerificationResults);

            TFrmExtendedMessageBox.TButtons buttons = TFrmExtendedMessageBox.TButtons.embbOK;
            TFrmExtendedMessageBox.TDefaultButton defButton = TFrmExtendedMessageBox.TDefaultButton.embdDefButton1;

            if (bIncomplete && ALimitedCount)
            {
                msgContent += String.Format(MCommonResourcestrings.StrCountTerminatedEarly1,
                    Environment.NewLine,
                    APetraUtilsObject.MaxReferenceCountOnDelete);
                msgContent += MCommonResourcestrings.StrCountTerminatedEarly2;
                msgContent += MCommonResourcestrings.StrCountTerminatedEarly3;
                msgContent += String.Format(MCommonResourcestrings.StrCountTerminatedEarly4,
                    Environment.NewLine,
                    MyForm.Text);
                buttons = TFrmExtendedMessageBox.TButtons.embbYesNo;
                defButton = TFrmExtendedMessageBox.TDefaultButton.embdDefButton2;
            }
            else
            {
                if (bIncomplete)
                {
                    // We should never get an incomplete count on an unlimited check
                }

                msgContent += String.Format(MCommonResourcestrings.StrCountTerminatedEarlyOK, Environment.NewLine);
            }

            // Show an Extended Message Box and return the value
            TFrmExtendedMessageBox extendedMsgBox = new TFrmExtendedMessageBox(MyForm);

            return extendedMsgBox.ShowDialog(
                msgContent,
                MCommonResourcestrings.StrRecordDeletionTitle,
                String.Empty,
                buttons,
                defButton,
                TFrmExtendedMessageBox.TIcon.embiInformation);
        }
예제 #10
0
        private static void CommonPostMergeOperations(IFrmPetra ACallingFormOrUserControl,
                                                      TFrmPetraEditUtils APetraUtilsObject,
                                                      TVerificationResultCollection AVerificationResults,
                                                      bool ACalledFromUserControl = false)
        {
            CommonUIUpdatesSavingSuccessful(ACallingFormOrUserControl, APetraUtilsObject, ACalledFromUserControl);

            if ((AVerificationResults != null) &&
                (AVerificationResults.HasCriticalOrNonCriticalErrors))
            {
                TDataValidation.ProcessAnyDataValidationErrors(false, AVerificationResults, ACallingFormOrUserControl.GetType(), null);
            }
        }
예제 #11
0
        private static void CommonUIUpdatesNoChangesAnymore(IFrmPetra ACallingFormOrUserControl,
                                                            TFrmPetraEditUtils APetraUtilsObject,
                                                            string AStatusBarMessage,
                                                            bool ACalledFromUserControl = false)
        {
            APetraUtilsObject.WriteToStatusBar(AStatusBarMessage);
            APetraUtilsObject.ShowDefaultCursor();

            // We don't have unsaved changes anymore
            APetraUtilsObject.DisableSaveButton();

            if (!ACalledFromUserControl)
            {
                APetraUtilsObject.OnDataSaved(ACallingFormOrUserControl, new TDataSavedEventArgs(true));
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 public TUC_GiftBatches_Import(TFrmPetraEditUtils APetraUtilsObject, Int32 ALedgerNumber, IUC_GiftBatches AUserControl)
 {
     FPetraUtilsObject = APetraUtilsObject;
     FLedgerNumber = ALedgerNumber;
     FMyUserControl = AUserControl;
 }
        private static void CommonUIUpdatesNoChangesAnymore(IFrmPetra ACallingFormOrUserControl,
            TFrmPetraEditUtils APetraUtilsObject,
            string AStatusBarMessage,
            bool ACalledFromUserControl = false)
        {
            APetraUtilsObject.WriteToStatusBar(AStatusBarMessage);
            APetraUtilsObject.ShowDefaultCursor();

            // We don't have unsaved changes anymore
            APetraUtilsObject.DisableSaveButton();

            if (!ACalledFromUserControl)
            {
                APetraUtilsObject.OnDataSaved(ACallingFormOrUserControl, new TDataSavedEventArgs(true));
            }
        }
 private static void CommonUIUpdatesSavingSuccessful(IFrmPetra ACallingFormOrUserControl, TFrmPetraEditUtils APetraUtilsObject,
     bool ACalledFromUserControl = false)
 {
     CommonUIUpdatesNoChangesAnymore(ACallingFormOrUserControl, APetraUtilsObject,
         MCommonResourcestrings.StrSavingDataSuccessful, ACalledFromUserControl);
 }
        private static void CommonPostMergeOperations(IFrmPetra ACallingFormOrUserControl,
            TFrmPetraEditUtils APetraUtilsObject,
            TVerificationResultCollection AVerificationResults,
            bool ACalledFromUserControl = false)
        {
            CommonUIUpdatesSavingSuccessful(ACallingFormOrUserControl, APetraUtilsObject, ACalledFromUserControl);

            if ((AVerificationResults != null)
                && (AVerificationResults.HasCriticalOrNonCriticalErrors))
            {
                TDataValidation.ProcessAnyDataValidationErrors(false, AVerificationResults, ACallingFormOrUserControl.GetType(), null);
            }
        }
예제 #16
0
        /// <summary>
        /// Method to create and show the controls required for a particular code on the specified panel.
        /// Currently we support the following controls:
        ///    txt -> TextBox,
        ///    txt -> TTxtNumericTextBox with Format=Integer as the attribute,
        ///    cmb -> TCmbAutoComplete: content is defined in OptionalValues column: Format=yes/no turns the combo into a tri-state choice
        ///                where the OptionalValues do not have to be False and True because the result is yes or no based on SelectedIndex.
        ///    dtp -> TtxtPetraDate
        /// </summary>
        /// <param name="AControlCode">The code that is a primary key into the controls table</param>
        /// <param name="AHostPanel">The panel onto which the GUI controls will be placed</param>
        /// <param name="AInitialValue">The initial value for this 'setting'.  The value may be a comma separated list of values.</param>
        /// <param name="AReadOnly">Set to true to disable the control(s) or make them read-only as appropriate.</param>
        /// <param name="AValidationEventHandler">An event handler that will be called on validation</param>
        public void ShowControls(string AControlCode, Panel AHostPanel, string AInitialValue, bool AReadOnly, EventHandler AValidationEventHandler)
        {
            // Work out the PetraUtilsObject for the form that called us
            TFrmPetraUtils petraBase = ((IFrmPetra)AHostPanel.TopLevelControl).GetPetraUtilsObject();

            FPetraUtilsObject = (petraBase is TFrmPetraEditUtils) ? (TFrmPetraEditUtils)petraBase : null;

            // Set up a default view on the controls table that will tell us the controls we need for this code
            FDataTable.DefaultView.RowFilter = string.Format("{0}='{1}'", FCodeColumn, AControlCode);
            FDataTable.DefaultView.Sort      = string.Format("{0} ASC, {1} ASC", FCodeColumn, FControlIndexColumn);

            AHostPanel.AutoScroll = (FDataTable.DefaultView.Count > 1);
            AHostPanel.Controls.Clear();

            // Work out the value(s) that have been passed in as a comma separated list
            StringCollection values = StringHelper.GetCSVList(AInitialValue, ",", true);

            if (values.Count != FDataTable.DefaultView.Count)
            {
                return;
            }

            FCurrentHostPanel = AHostPanel;
            int id       = 0;
            int vPos     = 5;
            int tabIndex = 10;

            foreach (DataRowView drv in FDataTable.DefaultView)
            {
                // get the attributes as a dictionary
                Dictionary <string, string> attributes = new Dictionary <string, string>();
                object rowValue = drv.Row[FAttributesColumn];

                if ((rowValue != null) && rowValue.ToString().Contains("="))
                {
                    string[] attPairs = drv.Row[FAttributesColumn].ToString().Split(',');

                    foreach (string attPair in attPairs)
                    {
                        string[] att = attPair.Split('=');

                        if (att.Length == 2)
                        {
                            attributes.Add(att[0].Trim(), att[1].Trim());
                        }
                    }
                }

                // See if some of the popular attributes are defined and store their values in local variables
                string formatAttribute     = string.Empty;
                string allowBlankAttribute = string.Empty;
                string stretchAttribute    = string.Empty;
                int    widthAttribute      = -1;
                int    labelWidthAttribute = -1;

                if (attributes.ContainsKey("Format"))
                {
                    // Use lower case
                    formatAttribute = attributes["Format"].ToString().ToLower();
                }

                if (attributes.ContainsKey("Width"))
                {
                    widthAttribute = Convert.ToInt32(attributes["Width"]);
                }

                if (attributes.ContainsKey("LabelWidth"))
                {
                    labelWidthAttribute = Convert.ToInt32(attributes["LabelWidth"]);
                }

                if (attributes.ContainsKey("AllowBlankValue"))
                {
                    allowBlankAttribute = attributes["AllowBlankValue"].ToString().ToLower();
                }

                if (attributes.ContainsKey("Stretch"))
                {
                    stretchAttribute = attributes["Stretch"].ToString().ToLower();
                }

                // create the control label
                Label label = new Label();
                label.Name      = "cLabel_" + id.ToString();
                label.Text      = drv.Row[FLabelColumn].ToString() + ":";
                label.Location  = new Point(5, vPos);
                label.Size      = new Size((labelWidthAttribute > 0) ? labelWidthAttribute : (AHostPanel.Width / 2) - 10, 17);
                label.TextAlign = ContentAlignment.MiddleRight;
                label.Anchor    = AnchorStyles.Top | AnchorStyles.Left;

                AHostPanel.Controls.Add(label);

                // Create the control
                // We support text boxes, numeric (integer) text boxes, combo boxes and date boxes
                switch (drv.Row[FControlTypeColumn].ToString().Substring(0, 3))
                {
                case "txt":

                    if (formatAttribute == "integer")
                    {
                        TTxtNumericTextBox txt = new TTxtNumericTextBox();
                        txt.Context     = AHostPanel;
                        txt.ControlMode = TTxtNumericTextBox.TNumericTextBoxMode.Integer;
                        txt.Name        = "cValue_" + id.ToString();
                        txt.Location    = new Point(label.Right + 10, vPos);
                        txt.Size        = new Size((widthAttribute > 0) ? widthAttribute : 100, 22);
                        txt.TabStop     = true;
                        txt.TabIndex    = tabIndex;

                        int iValue;

                        if (int.TryParse(values[id], out iValue))
                        {
                            txt.NumberValueInt = iValue;
                        }

                        txt.ReadOnly = AReadOnly;

                        txt.Validated   += AValidationEventHandler;
                        txt.TextChanged += new EventHandler(MultiChangeEventHandler);

                        AHostPanel.Controls.Add(txt);
                    }
                    else
                    {
                        TextBox txt = new TextBox();
                        txt.Name     = "cValue_" + id.ToString();
                        txt.Location = new Point(label.Right + 10, vPos);
                        txt.Size     = new Size((widthAttribute > 0) ? widthAttribute : AHostPanel.Width - label.Width - 25, 22);
                        txt.TabStop  = true;
                        txt.TabIndex = tabIndex;
                        txt.Text     = values[id];
                        txt.ReadOnly = AReadOnly;

                        if (stretchAttribute == "horizontally")
                        {
                            txt.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                        }

                        txt.Validated   += AValidationEventHandler;
                        txt.TextChanged += new EventHandler(MultiChangeEventHandler);

                        AHostPanel.Controls.Add(txt);
                    }

                    break;

                case "cmb":

                    if (attributes.ContainsKey("List"))
                    {
                        TCmbAutoPopulated cmb = new TCmbAutoPopulated();
                        cmb.Name      = "cValue_" + id.ToString();
                        cmb.Location  = new Point(label.Right + 10, vPos);
                        cmb.Size      = new Size((widthAttribute > 0) ? widthAttribute : AHostPanel.Width - label.Width - 25, 22);
                        cmb.TabStop   = true;
                        cmb.TabIndex  = tabIndex;
                        cmb.ListTable = (TCmbAutoPopulated.TListTableEnum)Enum.Parse(typeof(TCmbAutoPopulated.TListTableEnum),
                                                                                     attributes["List"].ToString(),
                                                                                     true);
                        cmb.InitialiseUserControl();
                        cmb.SetSelectedString(values[id], -1);

                        cmb.Enabled = !AReadOnly;

                        cmb.Validated            += AValidationEventHandler;
                        cmb.SelectedValueChanged += new EventHandler(MultiChangeEventHandler);

                        AHostPanel.Controls.Add(cmb);
                    }
                    else
                    {
                        TCmbAutoComplete cmb = new TCmbAutoComplete();
                        cmb.Name     = "cValue_" + id.ToString();
                        cmb.Location = new Point(label.Right + 10, vPos);
                        cmb.Size     = new Size((widthAttribute > 0) ? widthAttribute : AHostPanel.Width - label.Width - 25, 22);
                        cmb.TabStop  = true;
                        cmb.TabIndex = tabIndex;

                        if (drv.Row[FOptionalValuesColumn] != null)
                        {
                            string[] optValues = drv.Row[FOptionalValuesColumn].ToString().Split(',');

                            for (int i = 0; i < optValues.Length; i++)
                            {
                                cmb.Items.Add(optValues[i].ToString().Trim());
                            }
                        }

                        if (formatAttribute == "yes/no")
                        {
                            cmb.SetSelectedYesNo(values[id]);
                            cmb.Tag = "yes/no";
                        }
                        else
                        {
                            cmb.Text = values[id];
                        }

                        if (stretchAttribute == "horizontally")
                        {
                            cmb.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                        }

                        cmb.AllowBlankValue = (allowBlankAttribute == "true");
                        cmb.Enabled         = !AReadOnly;

                        cmb.Validated            += AValidationEventHandler;
                        cmb.SelectedIndexChanged += new EventHandler(MultiChangeEventHandler);
                        cmb.TextChanged          += new EventHandler(ComboBoxTextChangeEventHandler);

                        AHostPanel.Controls.Add(cmb);
                    }

                    break;

                case "dtp":
                    TtxtPetraDate dtp = new TtxtPetraDate();
                    dtp.Name     = "cValue_" + id.ToString();
                    dtp.Location = new Point(label.Right + 10, vPos);
                    dtp.Size     = new Size(94, 22);
                    dtp.TabStop  = true;
                    dtp.TabIndex = tabIndex;

                    DateTime dt;

                    if (DateTime.TryParse(values[id], out dt))
                    {
                        dtp.Date = Convert.ToDateTime(values[id]);
                    }
                    else
                    {
                        dtp.Date = null;
                    }

                    dtp.ReadOnly = AReadOnly;

                    dtp.Validated   += AValidationEventHandler;
                    dtp.DateChanged += new TPetraDateChangedEventHandler(MultiChangeEventHandler);

                    AHostPanel.Controls.Add(dtp);
                    break;

                default:
                    break;
                }

                id++;
                tabIndex += 10;
                vPos     += 30;
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="APetraUtilsObject">Reference to the PetraUtilsObject for the form</param>
        /// <param name="ALedgerNumber">Ledger number</param>
        /// <param name="AMainDS">The main data set</param>
        /// <param name="AFilterFindPanelObject">The filter panel control object</param>
        public TUC_GLBatches_LoadAndFilter(TFrmPetraEditUtils APetraUtilsObject,
            int ALedgerNumber,
            GLBatchTDS AMainDS,
            TFilterAndFindPanel AFilterFindPanelObject)
        {
            FPetraUtilsObject = APetraUtilsObject;
            FFilterFindPanelObject = AFilterFindPanelObject;
            FMainDS = AMainDS;
            FLedgerNumber = ALedgerNumber;

            FcmbYearEnding = (TCmbAutoComplete)AFilterFindPanelObject.FilterPanelControls.FindControlByName("cmbYearEnding");
            FcmbPeriod = (TCmbAutoComplete)AFilterFindPanelObject.FilterPanelControls.FindControlByName("cmbPeriod");
            FrbtEditing = (RadioButton)AFilterFindPanelObject.FilterPanelControls.FindControlByName("rbtEditing");
            FrbtPosting = (RadioButton)AFilterFindPanelObject.FilterPanelControls.FindControlByName("rbtPosting");
            FrbtAll = (RadioButton)AFilterFindPanelObject.FilterPanelControls.FindControlByName("rbtAll");

            TFinanceControls.InitialiseAvailableFinancialYearsList(ref FcmbYearEnding, FLedgerNumber, false, true);
            //TLogging.Log("GL Financial Years completed");
            FrbtEditing.Checked = true;
            //TLogging.Log("Editing checkbox selected");
        }
        /// <summary>
        /// ApplyMotivationDetailCodeFilter
        /// </summary>
        private static void ApplyMotivationDetailCodeFilter(GiftBatchTDSAGiftDetailRow ACurrentDetailRow,
            GiftBatchTDS AMainDS,
            Int32 ALedgerNumber,
            TFrmPetraEditUtils APetraUtilsObject,
            TCmbAutoPopulated ACmbKeyMinistries,
            ref TCmbAutoPopulated ACmbMotivationDetailCode,
            TtxtAutoPopulatedButtonLabel ATxtDetailRecipientKey,
            Int64 ARecipientKey,
            TtxtAutoPopulatedButtonLabel AtxtDetailRecipientLedgerNumber,
            TextBox ATxtDetailCostCentreCode,
            TextBox ATxtDetailAccountCode,
            TextBox ATxtDetailRecipientKeyMinistry,
            CheckBox AChkDetailTaxDeductible,
            TextBox ATxtDeductibleAccount,
            string AMotivationGroup,
            ref string AMotivationDetail,
            ref bool AMotivationDetailChangedFlag,
            bool AActiveOnly,
            bool ARecipientKeyChangingFlag,
            bool ACreatingNewGiftFlag,
            bool AInEditModeFlag,
            bool ABatchUnpostedFlag,
            bool ATaxDeductiblePercentageEnabledFlag,
            out bool ADoTaxUpdate)
        {
            //FMotivationbDetail will change by next process
            string motivationDetail = AMotivationDetail;

            string AutoPopComment;

            TFinanceControls.ChangeFilterMotivationDetailList(ref ACmbMotivationDetailCode, AMotivationGroup);
            AMotivationDetail = motivationDetail;

            if (AMotivationDetail.Length > 0)
            {
                ACmbMotivationDetailCode.SetSelectedString(AMotivationDetail);
                ACmbMotivationDetailCode.Text = AMotivationDetail;
                ADoTaxUpdate = false;
            }
            else if (ACmbMotivationDetailCode.Count > 0)
            {
                ACmbMotivationDetailCode.SelectedIndex = 0;

                //Force refresh of label
                OnMotivationDetailChanged(ACurrentDetailRow,
                    AMainDS,
                    ALedgerNumber,
                    APetraUtilsObject,
                    ACmbKeyMinistries,
                    ACmbMotivationDetailCode,
                    ATxtDetailRecipientKey,
                    ARecipientKey,
                    AtxtDetailRecipientLedgerNumber,
                    ATxtDetailCostCentreCode,
                    ATxtDetailAccountCode,
                    ATxtDetailRecipientKeyMinistry,
                    AChkDetailTaxDeductible,
                    ATxtDeductibleAccount,
                    AMotivationGroup,
                    ref AMotivationDetail,
                    ref AMotivationDetailChangedFlag,
                    ARecipientKeyChangingFlag,
                    ACreatingNewGiftFlag,
                    AInEditModeFlag,
                    ABatchUnpostedFlag,
                    ATaxDeductiblePercentageEnabledFlag,
                    false,
                    out ADoTaxUpdate,
                    out AutoPopComment);
            }
            else
            {
                ACmbMotivationDetailCode.SelectedIndex = -1;
                //Force refresh of label
                OnMotivationDetailChanged(ACurrentDetailRow,
                    AMainDS,
                    ALedgerNumber,
                    APetraUtilsObject,
                    ACmbKeyMinistries,
                    ACmbMotivationDetailCode,
                    ATxtDetailRecipientKey,
                    ARecipientKey,
                    AtxtDetailRecipientLedgerNumber,
                    ATxtDetailCostCentreCode,
                    ATxtDetailAccountCode,
                    ATxtDetailRecipientKeyMinistry,
                    AChkDetailTaxDeductible,
                    ATxtDeductibleAccount,
                    AMotivationGroup,
                    ref AMotivationDetail,
                    ref AMotivationDetailChangedFlag,
                    ARecipientKeyChangingFlag,
                    ACreatingNewGiftFlag,
                    AInEditModeFlag,
                    ABatchUnpostedFlag,
                    ATaxDeductiblePercentageEnabledFlag,
                    false,
                    out ADoTaxUpdate,
                    out AutoPopComment);
            }

            RetrieveMotivationDetailAccountCode(AMainDS, ALedgerNumber, ATxtDetailAccountCode, ATxtDeductibleAccount,
                AMotivationGroup, AMotivationDetail, ATaxDeductiblePercentageEnabledFlag);

            if ((ATxtDetailRecipientKey.Text == string.Empty) || (Convert.ToInt64(ATxtDetailRecipientKey.Text) == 0))
            {
                ATxtDetailRecipientKey.Text = String.Format("{0:0000000000}", 0);
                RetrieveMotivationDetailCostCentreCode(AMainDS, ALedgerNumber, ATxtDetailCostCentreCode, AMotivationGroup, AMotivationDetail);
            }
        }
        /// <summary>
        /// SetKeyMinistryTextBoxInvisible
        /// </summary>
        public static void SetKeyMinistryTextBoxInvisible(GiftBatchTDSAGiftDetailRow ACurrentDetailRow,
            GiftBatchTDS AMainDS,
            Int32 ALedgerNumber,
            TFrmPetraEditUtils APetraUtilsObject,
            TCmbAutoPopulated ACmbKeyMinistries,
            ref TCmbAutoPopulated ACmbMotivationDetailCode,
            TtxtAutoPopulatedButtonLabel ATxtDetailRecipientKey,
            Int64 ARecipientKey,
            TtxtAutoPopulatedButtonLabel AtxtDetailRecipientLedgerNumber,
            TextBox ATxtDetailCostCentreCode,
            TextBox ATxtDetailAccountCode,
            TextBox ATxtDetailRecipientKeyMinistry,
            CheckBox AChkDetailTaxDeductible,
            TextBox ATxtDeductibleAccount,
            string AMotivationGroup,
            ref string AMotivationDetail,
            ref bool AMotivationDetailChangedFlag,
            bool AActiveOnly,
            bool ARecipientKeyChangingFlag,
            bool ACreatingNewGiftFlag,
            bool AInEditModeFlag,
            bool ABatchUnpostedFlag,
            bool ATaxDeductiblePercentageEnabledFlag,
            out bool ADoTaxUpdate)
        {
            if (ATxtDetailRecipientKeyMinistry.Visible)
            {
                ApplyMotivationDetailCodeFilter(ACurrentDetailRow,
                    AMainDS,
                    ALedgerNumber,
                    APetraUtilsObject,
                    ACmbKeyMinistries,
                    ref ACmbMotivationDetailCode,
                    ATxtDetailRecipientKey,
                    ARecipientKey,
                    AtxtDetailRecipientLedgerNumber,
                    ATxtDetailCostCentreCode,
                    ATxtDetailAccountCode,
                    ATxtDetailRecipientKeyMinistry,
                    AChkDetailTaxDeductible,
                    ATxtDeductibleAccount,
                    AMotivationGroup,
                    ref AMotivationDetail,
                    ref AMotivationDetailChangedFlag,
                    AActiveOnly,
                    ARecipientKeyChangingFlag,
                    ACreatingNewGiftFlag,
                    AInEditModeFlag,
                    ABatchUnpostedFlag,
                    ATaxDeductiblePercentageEnabledFlag,
                    out ADoTaxUpdate);

                PopulateKeyMinistry(ACurrentDetailRow, ACmbKeyMinistries, ATxtDetailRecipientKey, AtxtDetailRecipientLedgerNumber, false);

                ReconcileKeyMinistryFromTextbox(ACurrentDetailRow,
                    ACmbKeyMinistries,
                    ATxtDetailRecipientKeyMinistry,
                    AInEditModeFlag,
                    ABatchUnpostedFlag);

                //hide the overlay box during editing
                ATxtDetailRecipientKeyMinistry.Visible = false;
            }
            else
            {
                ADoTaxUpdate = false;
            }
        }
예제 #20
0
        /// <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;
        }
        /// <summary>
        /// Call when the recipient ledger number changes
        /// </summary>
        public static void OnRecipientLedgerNumberChanged(Int32 ALedgerNumber,
            GiftBatchTDSAGiftDetailRow ACurrentDetailRow,
            TFrmPetraEditUtils APetraUtilsObject,
            TextBox ATxtDetailCostCentreCode,
            bool ABatchUnpostedFlag,
            bool ARecipientKeyChangingFlag,
            bool AShowingDetailsFlag)
        {
            if (APetraUtilsObject.SuppressChangeDetection || AShowingDetailsFlag || ARecipientKeyChangingFlag || !ABatchUnpostedFlag)
            {
                return;
            }

            string NewCCCode = TRemote.MFinance.Gift.WebConnectors.RetrieveCostCentreCodeForRecipient(ALedgerNumber,
                ACurrentDetailRow.RecipientKey,
                ACurrentDetailRow.RecipientLedgerNumber,
                ACurrentDetailRow.DateEntered,
                ACurrentDetailRow.MotivationGroupCode,
                ACurrentDetailRow.MotivationDetailCode);

            if (ATxtDetailCostCentreCode.Text != NewCCCode)
            {
                ATxtDetailCostCentreCode.Text = NewCCCode;
            }
        }
        /// <summary>
        /// Call when the recipient key changes
        /// </summary>
        public static void OnRecipientKeyChanged(Int64 APartnerKey,
            String APartnerShortName,
            bool AValidSelection,
            GiftBatchTDSAGiftDetailRow ACurrentDetailRow,
            GiftBatchTDS AMainDS,
            Int32 ALedgerNumber,
            TFrmPetraEditUtils APetraUtilsObject,
            ref TCmbAutoPopulated ACmbKeyMinistries,
            TCmbAutoPopulated ACmbMotivationGroupCode,
            TCmbAutoPopulated ACmbMotivationDetailCode,
            TtxtAutoPopulatedButtonLabel ATxtDetailRecipientKey,
            TtxtAutoPopulatedButtonLabel AtxtDetailRecipientLedgerNumber,
            TextBox ATxtDetailCostCentreCode,
            TextBox ATxtDetailAccountCode,
            TextBox ATxtDetailRecipientKeyMinistry,
            CheckBox AChkDetailTaxDeductible,
            TextBox ATxtDeductibleAccount,
            ref string AMotivationGroup,
            ref string AMotivationDetail,
            bool AShowingDetailsFlag,
            ref bool ARecipientKeyChangingFlag,
            bool AInKeyMinistryChangingFlag,
            bool AInEditModeFlag,
            bool ABatchUnpostedFlag,
            bool AMotivationDetailChangedFlag,
            bool ATaxDeductiblePercentageEnabledFlag,
            bool ACreatingNewGiftFlag,
            bool AActiveOnly,
            out bool ADoValidateGiftDestination,
            out bool ADoTaxUpdate)
        {
            ADoValidateGiftDestination = false;
            ADoTaxUpdate = false;

            if (ARecipientKeyChangingFlag || APetraUtilsObject.SuppressChangeDetection || AShowingDetailsFlag)
            {
                return;
            }

            ARecipientKeyChangingFlag = true;
            ATxtDetailRecipientKeyMinistry.Text = string.Empty;

            try
            {
                ACurrentDetailRow.RecipientKey = APartnerKey;
                ACurrentDetailRow.RecipientDescription = APartnerShortName;

                // do not want to update motivation comboboxes if recipient key is being changed due to a new gift or the motivation detail being changed
                if (!AMotivationDetailChangedFlag && !ACreatingNewGiftFlag
                    && TRemote.MFinance.Gift.WebConnectors.GetMotivationGroupAndDetail(APartnerKey, ref AMotivationGroup, ref AMotivationDetail))
                {
                    if (AMotivationGroup != ACmbMotivationGroupCode.GetSelectedString())
                    {
                        // note - this will also update the Motivation Detail
                        ACmbMotivationGroupCode.SetSelectedString(AMotivationGroup);
                    }

                    if (AMotivationDetail != ACmbMotivationDetailCode.GetSelectedString())
                    {
                        ACmbMotivationDetailCode.SetSelectedString(AMotivationDetail);
                    }

                    ACurrentDetailRow.MotivationGroupCode = AMotivationGroup;
                    ACurrentDetailRow.MotivationDetailCode = AMotivationDetail;
                }

                APetraUtilsObject.SuppressChangeDetection = true;

                //Set RecipientLedgerNumber
                if (APartnerKey > 0)
                {
                    ACurrentDetailRow.RecipientLedgerNumber = TRemote.MFinance.Gift.WebConnectors.GetRecipientFundNumber(APartnerKey,
                        ACurrentDetailRow.DateEntered);
                }
                else
                {
                    ACurrentDetailRow.RecipientLedgerNumber = 0;
                }

                if (!AInKeyMinistryChangingFlag)
                {
                    GetRecipientData(ACurrentDetailRow,
                        APartnerKey,
                        ref ACmbKeyMinistries,
                        ATxtDetailRecipientKey,
                        ref AtxtDetailRecipientLedgerNumber,
                        AMotivationDetailChangedFlag);
                    ADoValidateGiftDestination = true;
                }

                if (APartnerKey > 0)
                {
                    RetrieveRecipientCostCentreCode(ACurrentDetailRow, ATxtDetailCostCentreCode);
                }
                else
                {
                    UpdateRecipientKeyText(APartnerKey, ACurrentDetailRow, AMotivationGroup, AMotivationDetail);
                    RetrieveMotivationDetailCostCentreCode(AMainDS, ALedgerNumber, ATxtDetailCostCentreCode, AMotivationGroup, AMotivationDetail);
                }

                if (ATaxDeductiblePercentageEnabledFlag)
                {
                    ADoTaxUpdate = true;
                }
            }
            finally
            {
                ARecipientKeyChangingFlag = false;
                ReconcileKeyMinistryFromCombo(ACurrentDetailRow,
                    ACmbKeyMinistries,
                    ATxtDetailRecipientKeyMinistry,
                    AInEditModeFlag,
                    ABatchUnpostedFlag);

                APetraUtilsObject.SuppressChangeDetection = false;
            }
        }
        /// <summary>
        /// Call when the Motivation Detail changes
        /// </summary>
        public static void OnMotivationDetailChanged(GiftBatchTDSAGiftDetailRow ACurrentDetailRow,
            GiftBatchTDS AMainDS,
            Int32 ALedgerNumber,
            TFrmPetraEditUtils APetraUtilsObject,
            TCmbAutoPopulated ACmbKeyMinistries,
            TCmbAutoPopulated ACmbMotivationDetailCode,
            TtxtAutoPopulatedButtonLabel ATxtDetailRecipientKey,
            Int64 ARecipientKey,
            TtxtAutoPopulatedButtonLabel AtxtDetailRecipientLedgerNumber,
            TextBox ATxtDetailCostCentreCode,
            TextBox ATxtDetailAccountCode,
            TextBox ATxtDetailRecipientKeyMinistry,
            CheckBox AChkDetailTaxDeductible,
            TextBox ATxtDeductibleAccount,
            string AMotivationGroup,
            ref string AMotivationDetail,
            ref bool AMotivationDetailChangedFlag,
            bool ARecipientKeyChangingFlag,
            bool ACreatingNewGiftFlag,
            bool AInEditModeFlag,
            bool ABatchUnpostedFlag,
            bool ATaxDeductiblePercentageEnabledFlag,
            bool AAutoPopulatingGift,
            out bool ADoTaxUpdate,
            out string AAutoPopComment)
        {
            ADoTaxUpdate = false;
            AAutoPopComment = null;

            if (!ABatchUnpostedFlag || !AInEditModeFlag || ATxtDetailRecipientKeyMinistry.Visible)
            {
                return;
            }

            Int64 MotivationRecipientKey = 0;
            AMotivationDetail = ACmbMotivationDetailCode.GetSelectedString();

            if (AMotivationDetail.Length > 0)
            {
                AMotivationDetailRow motivationDetail = (AMotivationDetailRow)AMainDS.AMotivationDetail.Rows.Find(
                    new object[] { ALedgerNumber, AMotivationGroup, AMotivationDetail });

                ACmbMotivationDetailCode.RefreshLabel();

                if (motivationDetail != null)
                {
                    RetrieveMotivationDetailAccountCode(motivationDetail,
                        ATxtDetailAccountCode,
                        ATxtDeductibleAccount,
                        ATaxDeductiblePercentageEnabledFlag);

                    MotivationRecipientKey = motivationDetail.RecipientKey;

                    // if motivation detail autopopulation is set to true
                    if (motivationDetail.Autopopdesc)
                    {
                        AAutoPopComment = motivationDetail.MotivationDetailDesc;
                    }

                    // set tax deductible checkbox if motivation detail has been changed by the user (i.e. not a row change)
                    if (!APetraUtilsObject.SuppressChangeDetection || ARecipientKeyChangingFlag)
                    {
                        AChkDetailTaxDeductible.Checked = motivationDetail.TaxDeductible;
                    }

                    if (ATaxDeductiblePercentageEnabledFlag)
                    {
                        if (string.IsNullOrEmpty(motivationDetail.TaxDeductibleAccount))
                        {
                            MessageBox.Show(Catalog.GetString("This Motivation Detail does not have an associated Tax Deductible Account. " +
                                    "This can be added in Finance / Setup / Motivation Details.\n\n" +
                                    "Unless this is changed it will be impossible to assign a Tax Deductible Percentage to this gift."),
                                Catalog.GetString("Incomplete Motivation Detail"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }

                        ADoTaxUpdate = true;
                    }
                }
                else
                {
                    AChkDetailTaxDeductible.Checked = false;
                }
            }

            if (!ACreatingNewGiftFlag && !AAutoPopulatingGift && (MotivationRecipientKey > 0))
            {
                AMotivationDetailChangedFlag = true;
                PopulateKeyMinistry(ACurrentDetailRow,
                    ACmbKeyMinistries,
                    ATxtDetailRecipientKey,
                    AtxtDetailRecipientLedgerNumber,
                    AMotivationDetailChangedFlag,
                    MotivationRecipientKey);
                AMotivationDetailChangedFlag = false;
            }
            else if (ARecipientKey == 0)
            {
                UpdateRecipientKeyText(0, ACurrentDetailRow, AMotivationGroup, AMotivationDetail);
            }

            if (ARecipientKey == 0)
            {
                RetrieveMotivationDetailCostCentreCode(AMainDS, ALedgerNumber, ATxtDetailCostCentreCode, AMotivationGroup, AMotivationDetail);
            }
            else
            {
                string NewCCCode = TRemote.MFinance.Gift.WebConnectors.RetrieveCostCentreCodeForRecipient(ALedgerNumber,
                    ARecipientKey,
                    ACurrentDetailRow.RecipientLedgerNumber,
                    ACurrentDetailRow.DateEntered,
                    AMotivationGroup,
                    AMotivationDetail);

                if (ATxtDetailCostCentreCode.Text != NewCCCode)
                {
                    ATxtDetailCostCentreCode.Text = NewCCCode;
                }
            }
        }
예제 #24
0
 private static void CommonUIUpdatesSavingSuccessful(IFrmPetra ACallingFormOrUserControl, TFrmPetraEditUtils APetraUtilsObject,
                                                     bool ACalledFromUserControl = false)
 {
     CommonUIUpdatesNoChangesAnymore(ACallingFormOrUserControl, APetraUtilsObject,
                                     MCommonResourcestrings.StrSavingDataSuccessful, ACalledFromUserControl);
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="APetraUtilsObject">Reference to the PetraUtilsObject for the form</param>
        /// <param name="ALedgerNumber">Ledger number</param>
        /// <param name="AMainDS">The main data set</param>
        /// <param name="AFilterFindPanelObject">The filter panel control object</param>
        public TUC_GiftBatches_LoadAndFilter(TFrmPetraEditUtils APetraUtilsObject,
            int ALedgerNumber,
            GiftBatchTDS AMainDS,
            TFilterAndFindPanel AFilterFindPanelObject)
        {
            FPetraUtilsObject = APetraUtilsObject;
            FLedgerNumber = ALedgerNumber;
            FMainDS = AMainDS;
            FFilterFindPanelObject = AFilterFindPanelObject;

            FrbtEditing = (RadioButton)AFilterFindPanelObject.FilterPanelControls.FindControlByName("rbtEditing");
            FrbtPosting = (RadioButton)AFilterFindPanelObject.FilterPanelControls.FindControlByName("rbtPosting");
            FrbtAll = (RadioButton)AFilterFindPanelObject.FilterPanelControls.FindControlByName("rbtAll");
            FcmbYearEnding = (TCmbAutoComplete)AFilterFindPanelObject.FilterPanelControls.FindControlByName("cmbYearEnding");
            FcmbPeriod = (TCmbAutoComplete)AFilterFindPanelObject.FilterPanelControls.FindControlByName("cmbPeriod");

            FMainDS.AGiftBatch.DefaultView.Sort = String.Format("{0}, {1} DESC",
                AGiftBatchTable.GetLedgerNumberDBName(),
                AGiftBatchTable.GetBatchNumberDBName()
                );

            // Populate the Year ComboBox with available years for the specified ledger
            TFinanceControls.InitialiseAvailableGiftYearsList(ref FcmbYearEnding, FLedgerNumber);
            //TLogging.Log("Gift Years completed");

            // Ensure that we start with the status set to 'editing'.
            FrbtEditing.Checked = true;
            //TLogging.Log("Editing checkbox selected");
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="AParentForm">Parent Form.</param>
        public TPetraShepherdConcreteForm(Form AParentForm)
        {
            TLogging.Log("Entering TPetraShepherdConcreteForm Constructor...");

            FPetraUtilsObject = new TFrmPetraEditUtils(AParentForm, this, ShepherdStatusBar);

            TLogging.Log("TPetraShepherdConcreteForm Constructor ran.");
        }
 /// <summary>
 /// Processes the result of a data submission to the Server where the result of that operation is
 /// <see cref="TSubmitChangesResult.scrNothingToBeSaved" />.
 /// </summary>
 /// <param name="ACallingFormOrUserControl"></param>
 /// <param name="APetraUtilsObject"></param>
 /// <param name="ACalledFromUserControl"></param>
 public static void ProcessSubmitChangesResultNothingToBeSaved(IFrmPetra ACallingFormOrUserControl,
     TFrmPetraEditUtils APetraUtilsObject,
     bool ACalledFromUserControl = false)
 {
     CommonUIUpdatesNoChangesAnymore(ACallingFormOrUserControl, APetraUtilsObject,
         MCommonResourcestrings.StrSavingDataNothingToSave, ACalledFromUserControl);
 }
        /// <summary>
        /// Call when the motivation group changes
        /// </summary>
        public static void OnMotivationGroupChanged(GiftBatchTDSAGiftDetailRow AGiftBatchDetail,
            GiftBatchTDS AMainDS,
            Int32 ALedgerNumber,
            TFrmPetraEditUtils APetraUtilsObject,
            TCmbAutoPopulated ACmbKeyMinistries,
            TCmbAutoPopulated ACmbMotivationGroupCode,
            ref TCmbAutoPopulated ACmbMotivationDetailCode,
            TtxtAutoPopulatedButtonLabel ATxtDetailRecipientKey,
            Int64 ARecipientKey,
            TtxtAutoPopulatedButtonLabel AtxtDetailRecipientLedgerNumber,
            TextBox ATxtDetailCostCentreCode,
            TextBox ATxtDetailAccountCode,
            TextBox ATxtDetailRecipientKeyMinistry,
            CheckBox AChkDetailTaxDeductible,
            TextBox ATxtDeductibleAccount,
            ref string AMotivationGroup,
            ref string AMotivationDetail,
            ref bool AMotivationDetailChangedFlag,
            bool AActiveOnly,
            bool ACreatingNewGiftFlag,
            bool ARecipientKeyChangingFlag,
            bool AInEditModeFlag,
            bool ABatchUnpostedFlag,
            bool ATaxDeductiblePercentageEnabledFlag,
            out bool ADoTaxUpdate)
        {
            if (!ABatchUnpostedFlag || APetraUtilsObject.SuppressChangeDetection || !AInEditModeFlag || ATxtDetailRecipientKeyMinistry.Visible)
            {
                ADoTaxUpdate = false;
                return;
            }

            AMotivationGroup = ACmbMotivationGroupCode.GetSelectedString();

            if (!ARecipientKeyChangingFlag)
            {
                AMotivationDetail = string.Empty;
            }

            ApplyMotivationDetailCodeFilter(AGiftBatchDetail,
                AMainDS,
                ALedgerNumber,
                APetraUtilsObject,
                ACmbKeyMinistries,
                ref ACmbMotivationDetailCode,
                ATxtDetailRecipientKey,
                ARecipientKey,
                AtxtDetailRecipientLedgerNumber,
                ATxtDetailCostCentreCode,
                ATxtDetailAccountCode,
                ATxtDetailRecipientKeyMinistry,
                AChkDetailTaxDeductible,
                ATxtDeductibleAccount,
                AMotivationGroup,
                ref AMotivationDetail,
                ref AMotivationDetailChangedFlag,
                AActiveOnly,
                ARecipientKeyChangingFlag,
                ACreatingNewGiftFlag,
                AInEditModeFlag,
                ABatchUnpostedFlag,
                ATaxDeductiblePercentageEnabledFlag,
                out ADoTaxUpdate);
        }
예제 #29
0
        /// <summary>
        /// The main method of this class.  It deletes one or more rows selected in a grid on the caller form
        /// </summary>
        /// <param name="ACallerFormOrControl">The form or user control that is making the call.  The form must implement the IDeleteGridRows interface</param>
        /// <param name="AGrid">A reference to the grid object</param>
        /// <param name="APetraUtilsObject">A reference to the PetraUtilsObject associated with the form or control making the call</param>
        /// <param name="AButtonPanel">A reference a form or control that implements the IButtonPanel interface.  This parameter can be null.</param>
        /// <returns>True if any rows were actually deleted</returns>
        public static bool DeleteRows(IDeleteGridRows ACallerFormOrControl,
            TSgrdDataGrid AGrid,
            TFrmPetraEditUtils APetraUtilsObject,
            IButtonPanel AButtonPanel)
        {
            DataRow currentDataRow = ACallerFormOrControl.GetSelectedDataRow();
            Int32 currentRowIndex = ACallerFormOrControl.GetSelectedRowIndex();

            if ((currentDataRow == null) || (currentRowIndex == -1))
            {
                return false;
            }

            string CompletionMessage = String.Empty;
            DataRowView[] HighlightedRows = AGrid.SelectedDataRowsAsDataRowView;

            if (HighlightedRows.Length == 1)
            {
                // Single row deletion

                TVerificationResultCollection VerificationResults = null;

                if (TVerificationHelper.IsNullOrOnlyNonCritical(APetraUtilsObject.VerificationResultCollection))
                {
                    ACallerFormOrControl.GetReferenceCount(currentDataRow, APetraUtilsObject.MaxReferenceCountOnDelete, out VerificationResults);
                }

                if ((VerificationResults != null)
                    && (VerificationResults.Count > 0))
                {
                    TCascadingReferenceCountHandler countHandler = new TCascadingReferenceCountHandler();
                    TFrmExtendedMessageBox.TResult result = countHandler.HandleReferences(APetraUtilsObject, VerificationResults, true);

                    if (result == TFrmExtendedMessageBox.TResult.embrYes)
                    {
                        // repeat the count but with no limit to the number of references
                        ACallerFormOrControl.GetReferenceCount(currentDataRow, 0, out VerificationResults);
                        countHandler.HandleReferences(APetraUtilsObject, VerificationResults, false);
                    }

                    return false;
                }

                string DeletionQuestion = ACallerFormOrControl.GetDefaultDeletionQuestion();
                bool AllowDeletion = true;
                bool DeletionPerformed = false;

                ACallerFormOrControl.HandlePreDelete(currentDataRow, ref AllowDeletion, ref DeletionQuestion);

                if (AllowDeletion)
                {
                    if ((MessageBox.Show(DeletionQuestion,
                             MCommonResourcestrings.StrConfirmDeleteTitle,
                             MessageBoxButtons.YesNo,
                             MessageBoxIcon.Question,
                             MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes))
                    {
                        try
                        {
                            if (!ACallerFormOrControl.HandleDeleteRow(currentDataRow, ref DeletionPerformed, ref CompletionMessage))
                            {
                                currentDataRow.Delete();
                                DeletionPerformed = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(String.Format(MCommonResourcestrings.StrErrorWhileDeleting,
                                    Environment.NewLine, ex.Message),
                                MCommonResourcestrings.StrGenericError,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                        }

                        if (DeletionPerformed)
                        {
                            APetraUtilsObject.SetChangedFlag();
                        }

                        // Select and display the details of the nearest row to the one previously selected
                        ACallerFormOrControl.SelectRowInGrid(currentRowIndex);
                        // Clear any errors left over from  the deleted row
                        APetraUtilsObject.VerificationResultCollection.Clear();

                        if (AButtonPanel != null)
                        {
                            AButtonPanel.UpdateRecordNumberDisplay();
                        }
                    }
                }

                if (!ACallerFormOrControl.HandlePostDelete(currentDataRow, AllowDeletion, DeletionPerformed, CompletionMessage))
                {
                    if (DeletionPerformed && (CompletionMessage.Length > 0))
                    {
                        MessageBox.Show(CompletionMessage, MCommonResourcestrings.StrDeletionCompletedTitle);
                    }
                }

                return DeletionPerformed;
            }
            else
            {
                // Multi-row deletion

                int recordsDeleted = 0;

                string DeletionQuestion = String.Format(MCommonResourcestrings.StrMultiRowDeletionQuestion,
                    HighlightedRows.Length,
                    Environment.NewLine);
                DeletionQuestion += MCommonResourcestrings.StrMultiRowDeletionCheck;

                if (MessageBox.Show(DeletionQuestion,
                        MCommonResourcestrings.StrConfirmDeleteTitle,
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                {
                    int recordsUndeletable = 0;
                    int recordsDeleteDisallowed = 0;
                    List <TMultiDeleteResult>listConflicts = new List <TMultiDeleteResult>();
                    List <TMultiDeleteResult>listExceptions = new List <TMultiDeleteResult>();

                    APetraUtilsObject.GetForm().Cursor = Cursors.WaitCursor;

                    foreach (DataRowView drv in HighlightedRows)
                    {
                        DataRow rowToDelete = drv.Row;
                        string rowDetails = MakePKValuesString(rowToDelete);

                        if (!ACallerFormOrControl.IsRowDeletable(rowToDelete))
                        {
                            recordsUndeletable++;
                            continue;
                        }

                        TVerificationResultCollection VerificationResults = null;
                        ACallerFormOrControl.GetReferenceCount(rowToDelete, APetraUtilsObject.MaxReferenceCountOnDelete, out VerificationResults);

                        if ((VerificationResults != null) && (VerificationResults.Count > 0))
                        {
                            TMultiDeleteResult result = new TMultiDeleteResult(rowDetails,
                                Messages.BuildMessageFromVerificationResult(String.Empty, VerificationResults));
                            listConflicts.Add(result);
                            continue;
                        }

                        bool AllowDeletion = true;
                        bool DeletionPerformed = false;

                        ACallerFormOrControl.HandlePreDelete(rowToDelete, ref AllowDeletion, ref DeletionQuestion);

                        if (AllowDeletion)
                        {
                            try
                            {
                                if (!ACallerFormOrControl.HandleDeleteRow(rowToDelete, ref DeletionPerformed, ref CompletionMessage))
                                {
                                    rowToDelete.Delete();
                                    DeletionPerformed = true;
                                }
                            }
                            catch (Exception ex)
                            {
                                TMultiDeleteResult result = new TMultiDeleteResult(rowDetails, ex.Message);
                                listExceptions.Add(result);
                            }
                        }
                        else
                        {
                            recordsDeleteDisallowed++;
                        }

                        if (DeletionPerformed)
                        {
                            APetraUtilsObject.SetChangedFlag();
                            recordsDeleted++;
                        }

                        ACallerFormOrControl.HandlePostDelete(rowToDelete, AllowDeletion, DeletionPerformed, String.Empty);
                    }

                    APetraUtilsObject.GetForm().Cursor = Cursors.Default;
                    ACallerFormOrControl.SelectRowInGrid(currentRowIndex);

                    if (AButtonPanel != null)
                    {
                        AButtonPanel.UpdateRecordNumberDisplay();
                    }

                    if ((recordsDeleted > 0) && (CompletionMessage.Length > 0))
                    {
                        MessageBox.Show(CompletionMessage, MCommonResourcestrings.StrDeletionCompletedTitle);
                    }

                    //  Show the results of the multi-deletion
                    string results = null;

                    if (recordsDeleted > 0)
                    {
                        results = String.Format(
                            Catalog.GetPluralString(MCommonResourcestrings.StrRecordSuccessfullyDeleted,
                                MCommonResourcestrings.StrRecordsSuccessfullyDeleted, recordsDeleted),
                            recordsDeleted);
                    }
                    else
                    {
                        results = MCommonResourcestrings.StrNoRecordsWereDeleted;
                    }

                    if (recordsUndeletable > 0)
                    {
                        results += String.Format(
                            Catalog.GetPluralString(MCommonResourcestrings.StrRowNotDeletedBecauseNonDeletable,
                                MCommonResourcestrings.StrRowsNotDeletedBecauseNonDeletable,
                                recordsUndeletable),
                            Environment.NewLine,
                            recordsUndeletable);
                    }

                    if (recordsDeleteDisallowed > 0)
                    {
                        results += String.Format(
                            Catalog.GetPluralString(MCommonResourcestrings.StrRowNotDeletedBecauseDeleteNotAllowed,
                                MCommonResourcestrings.StrRowsNotDeletedBecauseDeleteNotAllowed,
                                recordsDeleteDisallowed),
                            Environment.NewLine,
                            recordsDeleteDisallowed);
                    }

                    bool showCancel = false;

                    if (listConflicts.Count > 0)
                    {
                        showCancel = true;
                        results += String.Format(
                            Catalog.GetPluralString(MCommonResourcestrings.StrRowNotDeletedBecauseReferencedElsewhere,
                                MCommonResourcestrings.StrRowsNotDeletedBecauseReferencedElsewhere,
                                listConflicts.Count),
                            Environment.NewLine,
                            listConflicts.Count);
                    }

                    if (listExceptions.Count > 0)
                    {
                        showCancel = true;
                        results += String.Format(
                            Catalog.GetPluralString(MCommonResourcestrings.StrRowNotDeletedDueToUnexpectedException,
                                MCommonResourcestrings.StrRowNotDeletedDueToUnexpectedException,
                                listExceptions.Count),
                            Environment.NewLine,
                            listExceptions.Count);
                    }

                    if (showCancel)
                    {
                        results += String.Format(MCommonResourcestrings.StrClickToReviewDeletionOrCancel, Environment.NewLine);

                        if (MessageBox.Show(results,
                                MCommonResourcestrings.StrDeleteActionSummaryTitle,
                                MessageBoxButtons.OKCancel,
                                MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK)
                        {
                            ReviewMultiDeleteResults(listConflicts, MCommonResourcestrings.StrRowsReferencedByOtherTables);
                            ReviewMultiDeleteResults(listExceptions, MCommonResourcestrings.StrExceptions);
                        }
                    }
                    else
                    {
                        MessageBox.Show(results,
                            MCommonResourcestrings.StrDeleteActionSummaryTitle,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
                    }
                }

                return recordsDeleted > 0;
            }
        }
예제 #30
0
        /// <summary>
        /// The main method of this class.  It deletes one or more rows selected in a grid on the caller form
        /// </summary>
        /// <param name="ACallerFormOrControl">The form or user control that is making the call.  The form must implement the IDeleteGridRows interface</param>
        /// <param name="AGrid">A reference to the grid object</param>
        /// <param name="APetraUtilsObject">A reference to the PetraUtilsObject associated with the form or control making the call</param>
        /// <param name="AButtonPanel">A reference a form or control that implements the IButtonPanel interface.  This parameter can be null.</param>
        /// <returns>True if any rows were actually deleted</returns>
        public static bool DeleteRows(IDeleteGridRows ACallerFormOrControl,
                                      TSgrdDataGrid AGrid,
                                      TFrmPetraEditUtils APetraUtilsObject,
                                      IButtonPanel AButtonPanel)
        {
            DataRow currentDataRow  = ACallerFormOrControl.GetSelectedDataRow();
            Int32   currentRowIndex = ACallerFormOrControl.GetSelectedRowIndex();

            if ((currentDataRow == null) || (currentRowIndex == -1))
            {
                return(false);
            }

            string CompletionMessage = String.Empty;

            DataRowView[] HighlightedRows = AGrid.SelectedDataRowsAsDataRowView;

            if (HighlightedRows.Length == 1)
            {
                // Single row deletion

                TVerificationResultCollection VerificationResults = null;

                if (TVerificationHelper.IsNullOrOnlyNonCritical(APetraUtilsObject.VerificationResultCollection))
                {
                    ACallerFormOrControl.GetReferenceCount(currentDataRow, APetraUtilsObject.MaxReferenceCountOnDelete, out VerificationResults);
                }

                if ((VerificationResults != null) &&
                    (VerificationResults.Count > 0))
                {
                    TCascadingReferenceCountHandler countHandler = new TCascadingReferenceCountHandler();
                    TFrmExtendedMessageBox.TResult  result       = countHandler.HandleReferences(APetraUtilsObject, VerificationResults, true);

                    if (result == TFrmExtendedMessageBox.TResult.embrYes)
                    {
                        // repeat the count but with no limit to the number of references
                        ACallerFormOrControl.GetReferenceCount(currentDataRow, 0, out VerificationResults);
                        countHandler.HandleReferences(APetraUtilsObject, VerificationResults, false);
                    }

                    return(false);
                }

                string DeletionQuestion  = ACallerFormOrControl.GetDefaultDeletionQuestion();
                bool   AllowDeletion     = true;
                bool   DeletionPerformed = false;

                ACallerFormOrControl.HandlePreDelete(currentDataRow, ref AllowDeletion, ref DeletionQuestion);

                if (AllowDeletion)
                {
                    if ((MessageBox.Show(DeletionQuestion,
                                         MCommonResourcestrings.StrConfirmDeleteTitle,
                                         MessageBoxButtons.YesNo,
                                         MessageBoxIcon.Question,
                                         MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes))
                    {
                        try
                        {
                            if (!ACallerFormOrControl.HandleDeleteRow(currentDataRow, ref DeletionPerformed, ref CompletionMessage))
                            {
                                currentDataRow.Delete();
                                DeletionPerformed = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(String.Format(MCommonResourcestrings.StrErrorWhileDeleting,
                                                          Environment.NewLine, ex.Message),
                                            MCommonResourcestrings.StrGenericError,
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Warning);
                        }

                        if (DeletionPerformed)
                        {
                            APetraUtilsObject.SetChangedFlag();
                        }

                        // Select and display the details of the nearest row to the one previously selected
                        ACallerFormOrControl.SelectRowInGrid(currentRowIndex);
                        // Clear any errors left over from  the deleted row
                        APetraUtilsObject.VerificationResultCollection.Clear();

                        if (AButtonPanel != null)
                        {
                            AButtonPanel.UpdateRecordNumberDisplay();
                        }
                    }
                }

                if (!ACallerFormOrControl.HandlePostDelete(currentDataRow, AllowDeletion, DeletionPerformed, CompletionMessage))
                {
                    if (DeletionPerformed && (CompletionMessage.Length > 0))
                    {
                        MessageBox.Show(CompletionMessage, MCommonResourcestrings.StrDeletionCompletedTitle);
                    }
                }

                return(DeletionPerformed);
            }
            else
            {
                // Multi-row deletion

                int recordsDeleted = 0;

                string DeletionQuestion = String.Format(MCommonResourcestrings.StrMultiRowDeletionQuestion,
                                                        HighlightedRows.Length,
                                                        Environment.NewLine);
                DeletionQuestion += MCommonResourcestrings.StrMultiRowDeletionCheck;

                if (MessageBox.Show(DeletionQuestion,
                                    MCommonResourcestrings.StrConfirmDeleteTitle,
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                {
                    int recordsUndeletable                   = 0;
                    int recordsDeleteDisallowed              = 0;
                    List <TMultiDeleteResult> listConflicts  = new List <TMultiDeleteResult>();
                    List <TMultiDeleteResult> listExceptions = new List <TMultiDeleteResult>();

                    APetraUtilsObject.GetForm().Cursor = Cursors.WaitCursor;

                    foreach (DataRowView drv in HighlightedRows)
                    {
                        DataRow rowToDelete = drv.Row;

                        if (rowToDelete.RowState == DataRowState.Detached)
                        {
                            continue;
                        }

                        string rowDetails = MakePKValuesString(rowToDelete);

                        if (!ACallerFormOrControl.IsRowDeletable(rowToDelete))
                        {
                            recordsUndeletable++;
                            continue;
                        }

                        TVerificationResultCollection VerificationResults = null;
                        ACallerFormOrControl.GetReferenceCount(rowToDelete, APetraUtilsObject.MaxReferenceCountOnDelete, out VerificationResults);

                        if ((VerificationResults != null) && (VerificationResults.Count > 0))
                        {
                            TMultiDeleteResult result = new TMultiDeleteResult(rowDetails,
                                                                               Messages.BuildMessageFromVerificationResult(String.Empty, VerificationResults));
                            listConflicts.Add(result);
                            continue;
                        }

                        bool AllowDeletion     = true;
                        bool DeletionPerformed = false;

                        ACallerFormOrControl.HandlePreDelete(rowToDelete, ref AllowDeletion, ref DeletionQuestion);

                        if (AllowDeletion)
                        {
                            try
                            {
                                if (!ACallerFormOrControl.HandleDeleteRow(rowToDelete, ref DeletionPerformed, ref CompletionMessage))
                                {
                                    rowToDelete.Delete();
                                    DeletionPerformed = true;
                                }
                            }
                            catch (Exception ex)
                            {
                                TMultiDeleteResult result = new TMultiDeleteResult(rowDetails, ex.Message);
                                listExceptions.Add(result);
                            }
                        }
                        else
                        {
                            recordsDeleteDisallowed++;
                        }

                        if (DeletionPerformed)
                        {
                            APetraUtilsObject.SetChangedFlag();
                            recordsDeleted++;
                        }

                        ACallerFormOrControl.HandlePostDelete(rowToDelete, AllowDeletion, DeletionPerformed, String.Empty);
                    }

                    APetraUtilsObject.GetForm().Cursor = Cursors.Default;
                    ACallerFormOrControl.SelectRowInGrid(currentRowIndex);

                    if (AButtonPanel != null)
                    {
                        AButtonPanel.UpdateRecordNumberDisplay();
                    }

                    if ((recordsDeleted > 0) && (CompletionMessage.Length > 0))
                    {
                        MessageBox.Show(CompletionMessage, MCommonResourcestrings.StrDeletionCompletedTitle);
                    }

                    //  Show the results of the multi-deletion
                    string results = null;

                    if (recordsDeleted > 0)
                    {
                        results = String.Format(
                            Catalog.GetPluralString(MCommonResourcestrings.StrRecordSuccessfullyDeleted,
                                                    MCommonResourcestrings.StrRecordsSuccessfullyDeleted, recordsDeleted),
                            recordsDeleted);
                    }
                    else
                    {
                        results = MCommonResourcestrings.StrNoRecordsWereDeleted;
                    }

                    if (recordsUndeletable > 0)
                    {
                        results += String.Format(
                            Catalog.GetPluralString(MCommonResourcestrings.StrRowNotDeletedBecauseNonDeletable,
                                                    MCommonResourcestrings.StrRowsNotDeletedBecauseNonDeletable,
                                                    recordsUndeletable),
                            Environment.NewLine,
                            recordsUndeletable);
                    }

                    if (recordsDeleteDisallowed > 0)
                    {
                        results += String.Format(
                            Catalog.GetPluralString(MCommonResourcestrings.StrRowNotDeletedBecauseDeleteNotAllowed,
                                                    MCommonResourcestrings.StrRowsNotDeletedBecauseDeleteNotAllowed,
                                                    recordsDeleteDisallowed),
                            Environment.NewLine,
                            recordsDeleteDisallowed);
                    }

                    bool showCancel = false;

                    if (listConflicts.Count > 0)
                    {
                        showCancel = true;
                        results   += String.Format(
                            Catalog.GetPluralString(MCommonResourcestrings.StrRowNotDeletedBecauseReferencedElsewhere,
                                                    MCommonResourcestrings.StrRowsNotDeletedBecauseReferencedElsewhere,
                                                    listConflicts.Count),
                            Environment.NewLine,
                            listConflicts.Count);
                    }

                    if (listExceptions.Count > 0)
                    {
                        showCancel = true;
                        results   += String.Format(
                            Catalog.GetPluralString(MCommonResourcestrings.StrRowNotDeletedDueToUnexpectedException,
                                                    MCommonResourcestrings.StrRowNotDeletedDueToUnexpectedException,
                                                    listExceptions.Count),
                            Environment.NewLine,
                            listExceptions.Count);
                    }

                    if (showCancel)
                    {
                        results += String.Format(MCommonResourcestrings.StrClickToReviewDeletionOrCancel, Environment.NewLine);

                        if (MessageBox.Show(results,
                                            MCommonResourcestrings.StrDeleteActionSummaryTitle,
                                            MessageBoxButtons.OKCancel,
                                            MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK)
                        {
                            ReviewMultiDeleteResults(listConflicts, MCommonResourcestrings.StrRowsReferencedByOtherTables);
                            ReviewMultiDeleteResults(listExceptions, MCommonResourcestrings.StrExceptions);
                        }
                    }
                    else
                    {
                        MessageBox.Show(results,
                                        MCommonResourcestrings.StrDeleteActionSummaryTitle,
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                }

                return(recordsDeleted > 0);
            }
        }
        /// <summary>
        /// Call when the key ministry changes
        /// </summary>
        public static void OnKeyMinistryChanged(GiftBatchTDSAGiftDetailRow ACurrentDetailRow, TFrmPetraEditUtils APetraUtilsObject,
            TCmbAutoPopulated ACmbKeyMinistries, TtxtAutoPopulatedButtonLabel ATxtDetailRecipientKey, TextBox ATxtDetailRecipientKeyMinistry,
            bool ARecipientKeyChangingFlag, ref bool AInKeyMinistryChangingFlag)
        {
            if ((ACurrentDetailRow == null) || AInKeyMinistryChangingFlag || ARecipientKeyChangingFlag
                || APetraUtilsObject.SuppressChangeDetection || ATxtDetailRecipientKeyMinistry.Visible)
            {
                return;
            }

            string KeyMinistry = ACmbKeyMinistries.GetSelectedDescription();
            string RecipientKey = ACmbKeyMinistries.GetSelectedInt64().ToString();

            try
            {
                AInKeyMinistryChangingFlag = true;

                if (ACmbKeyMinistries.Count == 0)
                {
                    ACmbKeyMinistries.SelectedIndex = -1;

                    if (ATxtDetailRecipientKeyMinistry.Text != string.Empty)
                    {
                        ATxtDetailRecipientKeyMinistry.Text = string.Empty;
                    }
                }
                else
                {
                    // if key ministry has actually changed
                    if ((ATxtDetailRecipientKeyMinistry.Text != KeyMinistry)
                        || (ACurrentDetailRow.RecipientKeyMinistry != KeyMinistry))
                    {
                        ATxtDetailRecipientKeyMinistry.Text = KeyMinistry;
                        ACurrentDetailRow.RecipientKeyMinistry = KeyMinistry;
                    }

                    if (Convert.ToInt64(ATxtDetailRecipientKey.Text) != Convert.ToInt64(RecipientKey))
                    {
                        ATxtDetailRecipientKey.Text = RecipientKey;
                    }
                }
            }
            finally
            {
                AInKeyMinistryChangingFlag = false;
            }
        }