/// <summary>
        /// Creates a Data Validation *Error* for Phone ComboBoxes.
        /// </summary>
        private void ValidationPhoneNrSetButNoPhoneNrAvailable(TOverallContactComboType AContactComboType)
        {
            const string ResCont = "ContactDetails_Phone_Set_But_No_Phone_Nr_Available";
            TScreenVerificationResult VerificationResult;
            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;
            string ErrorCode;
            TCmbAutoComplete ComboBoxForContactComboType;
            string ComboTypeStr;   // Ignored, but needed as this is an out Argument of GetDataAccordingToContactComboType...

            if (AContactComboType == TOverallContactComboType.occtPrimaryPhone)
            {
                ErrorCode = PetraErrorCodes.ERR_PRIMARY_PHONE_NR_SET_DESIPITE_NO_PHONE_NR_AVAIL;
            }
            else if (AContactComboType == TOverallContactComboType.occtPhoneWithinOrganisation)
            {
                ErrorCode = PetraErrorCodes.ERR_OFFICE_PHONE_NR_SET_DESIPITE_NO_PHONE_NR_AVAIL;
            }
            else
            {
                throw new EOPAppException("AContactComboType Argument must designate a Phone ComboBox");
            }

            GetDataAccordingToContactComboType(AContactComboType,
                out ComboBoxForContactComboType, out ComboTypeStr);

            VerificationResult = new TScreenVerificationResult(
                new TVerificationResult((object)ResCont,
                    ErrorCodes.GetErrorInfo(ErrorCode),
                    FPetraUtilsObject.VerificationResultCollection.CurrentDataValidationRunID),
                null, ComboBoxForContactComboType, FPetraUtilsObject.VerificationResultCollection.CurrentDataValidationRunID);

            VerificationResultCollection.Remove(ResCont);

            if (VerificationResult != null)
            {
                VerificationResultCollection.Add(VerificationResult);
            }
        }
        private void GetDataAccordingToContactComboType(TOverallContactComboType AContactComboType,
            out TCmbAutoComplete AComboBoxForContactComboType, out string APhoneComboTypeStr)
        {
            switch (AContactComboType)
            {
                case TOverallContactComboType.occtPrimaryPhone:
                    AComboBoxForContactComboType = cmbPrimaryPhoneForContacting;
                    APhoneComboTypeStr = StrPrimaryPhone;

                    break;

                case TOverallContactComboType.occtPhoneWithinOrganisation:
                    AComboBoxForContactComboType = cmbPhoneWithinTheOrganisation;
                    APhoneComboTypeStr = StrPhoneWithinOrgansiation;

                    break;

                case TOverallContactComboType.occtPrimaryEmail:
                    AComboBoxForContactComboType = cmbPrimaryEMail;
                    APhoneComboTypeStr = StrPrimaryEmail;

                    break;

                case TOverallContactComboType.occtSecondaryEmail:
                    AComboBoxForContactComboType = cmbSecondaryEMail;
                    APhoneComboTypeStr = StrSecondaryEmail;

                    break;

                case TOverallContactComboType.occtEmailWithinOrganisation:
                    AComboBoxForContactComboType = cmbEMailWithinTheOrganisation;
                    APhoneComboTypeStr = StrEmailWithinOrgansiation;

                    break;

                default:
                    AComboBoxForContactComboType = null;
                    APhoneComboTypeStr = String.Empty;

                    break;
            }
        }
        private void GetDataAccordingToContactComboType(TOverallContactComboType AContactComboType,
            out TCmbAutoComplete AComboBoxForContactComboType, out DataColumn ADataColumn)
        {
            string PhoneComboTypeStr;  // Ignored, but needed as this is an out Argument of GetDataAccordingToContactComboType...

            GetDataAccordingToContactComboType(AContactComboType, out AComboBoxForContactComboType, out PhoneComboTypeStr);

            switch (AContactComboType)
            {
                case TOverallContactComboType.occtPrimaryPhone:
                    ADataColumn = new PPartnerAttributeTable().Columns[PPartnerAttributeTable.ColumnPrimaryId];

                    break;

                case TOverallContactComboType.occtPhoneWithinOrganisation:
                    ADataColumn = new PPartnerAttributeTable().Columns[PPartnerAttributeTable.ColumnWithinOrganisationId];

                    break;

                case TOverallContactComboType.occtPrimaryEmail:
                    ADataColumn = new PPartnerAttributeTable().Columns[PPartnerAttributeTable.ColumnPrimaryId];

                    break;

                case TOverallContactComboType.occtEmailWithinOrganisation:
                    ADataColumn = new PPartnerAttributeTable().Columns[PPartnerAttributeTable.ColumnWithinOrganisationId];

                    break;

                default:
                    ADataColumn = null;

                    break;
            }
        }
        private void CheckThatNonCurrentEmailAddressIsntSpecificEmailAddr(TOverallContactComboType AContactComboType,
            bool AEmailAddressInQuestionIsThisRecord)
        {
            TCmbAutoComplete ComboBoxForContactComboType;
            string EmailComboTypeStr;
            bool NoEmailAddressesAvailableAnymore = false;
            string EmailConsequenceStr = StrEmailUnavailableConsequenceSelectNewOne;
            string EmailMessageBoxTitleStr;


            GetDataAccordingToContactComboType(AContactComboType, out ComboBoxForContactComboType, out EmailComboTypeStr);

            EmailMessageBoxTitleStr = String.Format(StrEmailUnavailableConsequenceSelectNewOneTitle, EmailComboTypeStr);

            if (AEmailAddressInQuestionIsThisRecord)
            {
                DataView EligibleEmailAddrsDV = GetDataViewForContactCombo(TOverallContactComboType.occtPrimaryEmail, true);

                if (EligibleEmailAddrsDV.Count == 0)
                {
                    NoEmailAddressesAvailableAnymore = true;

                    EmailConsequenceStr = String.Format(StrEmailUnavailableConsequenceCleared, EmailComboTypeStr);
                    EmailMessageBoxTitleStr = String.Format(StrEmailUnavailableConsequenceClearedTitle, EmailComboTypeStr);
                }

                // Select the 'empty' ComboBox Item
                ComboBoxForContactComboType.SelectedIndex = 0;

                MessageBox.Show(
                    String.Format(
                        Catalog.GetString(
                            "You have made the E-mail Address no longer current, but up till now it was set to be the {0}.\r\n\r\n{1}"),
                        EmailComboTypeStr,
                        EmailConsequenceStr),
                    EmailMessageBoxTitleStr,
                    MessageBoxButtons.OK, NoEmailAddressesAvailableAnymore ? MessageBoxIcon.Warning : MessageBoxIcon.Information);

                if (!NoEmailAddressesAvailableAnymore)
                {
                    // Show the other current e-mail-Address(es) to the user
                    ComboBoxForContactComboType.DroppedDown = true;
                }
            }
        }
        private bool ValidateOvrlContSettgsCombos(TOverallContactComboType AContactComboType, TCmbAutoComplete AComboBoxForContactComboType,
            string AComboBoxSelectedString, DataView AEligibleValuesDV)
        {
            bool ReturnValue = true;
            DataView CurrentValuesDV;
            PPartnerAttributeRow ThePartnerAttributeRow;
            bool ChoiceFoundAmongEligibleValues = false;

            CurrentValuesDV = GetDataViewForContactCombo(AContactComboType, true);

            if (CurrentValuesDV.Count != 0)
            {
                if ((AContactComboType == TOverallContactComboType.occtPrimaryEmail)
                    && (AComboBoxSelectedString == String.Empty))
                {
                    // Generate a Validation *Warning*, not an error. The user can ignore this if (s)he chooses to do so!
                    ValidationPrimaryEmailAddrNotSet();
                }
                else if ((AContactComboType == TOverallContactComboType.occtSecondaryEmail)
                         && (AComboBoxSelectedString != String.Empty)
                         && (AComboBoxSelectedString == cmbPrimaryEMail.GetSelectedString()))
                {
                    // Generate a Validation *Warning*, not an error. The user can ignore this if (s)he chooses to do so!
                    ValidationSecondaryEmailAddrEqualsPrimaryEmailAddr();
                }
                else
                {
                    if (AComboBoxSelectedString != String.Empty)
                    {
                        for (int Counter3 = 0; Counter3 < AEligibleValuesDV.Count; Counter3++)
                        {
                            ThePartnerAttributeRow = ((PPartnerAttributeRow)AEligibleValuesDV[Counter3].Row);

                            if (ThePartnerAttributeRow.Value == AComboBoxSelectedString)
                            {
                                ChoiceFoundAmongEligibleValues = true;

                                if (!ThePartnerAttributeRow.Current)
                                {
                                    // This condition should not occur, unless the program code that runs when the 'Valid'
                                    // CheckBox is disabled and which should clear all the Items from the ComboBox is somehow
                                    // not working correctly, or not run at all. This condition is therefore a 'back-stop'
                                    // that will prevent invalid data going to the DB!

                                    // Generate a Validation *Error*. The user cannot ignore this.
                                    if ((AContactComboType == TOverallContactComboType.occtPrimaryPhone)
                                        || (AContactComboType == TOverallContactComboType.occtPhoneWithinOrganisation))
                                    {
                                        ValidationPhoneNrSetButItIsntCurrent(AContactComboType);
                                    }
                                    else
                                    {
                                        ValidationEmailAddrSetButItIsntCurrent(AContactComboType);
                                    }

                                    UpdateItemsOfOvrlContSettgsCombo(AComboBoxForContactComboType, false);

                                    ReturnValue = false;
                                }
                            }
                        }

                        if (!ChoiceFoundAmongEligibleValues)
                        {
                            // This condition should not occur, unless various bits of program code are somehow
                            // not working correctly, or not run at all. This condition is therefore a 'back-stop'
                            // that will prevent invalid data going to the DB!

                            // Generate a Validation *Error*. The user cannot ignore this.
                            if ((AContactComboType == TOverallContactComboType.occtPrimaryPhone)
                                || (AContactComboType == TOverallContactComboType.occtPhoneWithinOrganisation))
                            {
                                ValidationPhoneNrSetButNotAmongPhoneNrs(AContactComboType);
                            }
                            else
                            {
                                ValidationEmailAddrSetButNotAmongEmailAddrs(AContactComboType);
                            }

                            UpdateItemsOfOvrlContSettgsCombo(AComboBoxForContactComboType, true);

                            ReturnValue = false;
                        }
                    }
                }
            }
            else
            {
                if (AComboBoxSelectedString != String.Empty)
                {
                    // This condition should not occur, unless various bits of program code are somehow
                    // not working correctly, or not run at all. This condition is therefore a 'back-stop'
                    // that will prevent invalid data going to the DB!

                    // Generate a Validation *Error*. The user cannot ignore this.
                    if ((AContactComboType == TOverallContactComboType.occtPrimaryPhone)
                        || (AContactComboType == TOverallContactComboType.occtPhoneWithinOrganisation))
                    {
                        ValidationPhoneNrSetButNoPhoneNrAvailable(AContactComboType);
                    }
                    else
                    {
                        ValidationEmailAddrSetButNoEmailAddrAvailable(AContactComboType);
                    }

                    UpdateItemsOfOvrlContSettgsCombo(AComboBoxForContactComboType, true);

                    ReturnValue = false;
                }
            }

            return ReturnValue;
        }
        /// <summary>
        /// Updates the DataRows that pertain to a ComboBox from the 'Overall Contact Settings Group' to reflect the
        /// current ComboBox setting.
        /// </summary>
        /// <param name="AContactComboType">The Contact ComboBox Type that designates which Records' data should get
        /// updated.</param>
        /// <param name="ARunValidation">If set to true, various validations are run against the ComboBox setting.</param>
        /// <returns>True if <paramref name="ARunValidation"/> is false, or when <paramref name="ARunValidation"/>
        /// is true and validation succeeds, otherwise false.</returns>
        private bool UpdateDataRowsPertainingToOvrlContSettgsCombo(TOverallContactComboType AContactComboType, bool ARunValidation)
        {
            bool ReturnValue = true;
            TCmbAutoComplete ComboBoxForContactComboType;
            DataColumn UpdateDataColumn;
            PPartnerAttributeRow ThePartnerAttributeRow;
            string ComboBoxSelectedString;
            DataView EligibleValuesDV = GetDataViewForContactCombo(AContactComboType, false);

            GetDataAccordingToContactComboType(AContactComboType, out ComboBoxForContactComboType, out UpdateDataColumn);

            ComboBoxSelectedString = ComboBoxForContactComboType.GetSelectedString();

            if (ComboBoxSelectedString != String.Empty)
            {
                for (int Counter = 0; Counter < EligibleValuesDV.Count; Counter++)
                {
                    ThePartnerAttributeRow = ((PPartnerAttributeRow)EligibleValuesDV[Counter].Row);

                    // Modify Rows only as necessary
                    if ((bool)ThePartnerAttributeRow[UpdateDataColumn.Ordinal])
                    {
                        if (ThePartnerAttributeRow.Value != ComboBoxSelectedString)
                        {
                            ThePartnerAttributeRow[UpdateDataColumn.Ordinal] = (object)false;
                        }
                    }
                    else
                    {
                        if (ThePartnerAttributeRow.Value == ComboBoxSelectedString)
                        {
                            ThePartnerAttributeRow[UpdateDataColumn.Ordinal] = (object)true;
                        }
                    }
                }
            }
            else
            {
                for (int Counter2 = 0; Counter2 < EligibleValuesDV.Count; Counter2++)
                {
                    ThePartnerAttributeRow = ((PPartnerAttributeRow)EligibleValuesDV[Counter2].Row);

                    // Modify Rows only as necessary
                    if ((bool)ThePartnerAttributeRow[UpdateDataColumn.Ordinal])
                    {
                        ThePartnerAttributeRow[UpdateDataColumn.Ordinal] = (object)false;
                    }
                }
            }

            if (ARunValidation)
            {
                ReturnValue = ValidateOvrlContSettgsCombos(AContactComboType, ComboBoxForContactComboType, ComboBoxSelectedString, EligibleValuesDV);
            }

            return ReturnValue;
        }
        private DataView GetDataViewForContactCombo(TOverallContactComboType AContactComboType,
            bool AOnlyCurrentValues)
        {
            DataView ReturnValue;

            if ((AContactComboType == TOverallContactComboType.occtPrimaryPhone)
                || (AContactComboType == TOverallContactComboType.occtPhoneWithinOrganisation))
            {
                ReturnValue = Calculations.DeterminePartnerPhoneNumbers(FMainDS.PPartnerAttribute, AOnlyCurrentValues, false);
            }
            else
            {
                ReturnValue = Calculations.DeterminePartnerEmailAddresses(FMainDS.PPartnerAttribute, AOnlyCurrentValues);
            }

            return ReturnValue;
        }
        /// <summary>
        /// Creates a Data Validation *Error* for E-Mail ComboBoxes.
        /// </summary>
        private void ValidationEmailAddrSetButNotAmongEmailAddrs(TOverallContactComboType AContactComboType)
        {
            const string ResCont = "ContactDetails_EmailAddress_Set_But_Not_Among_Email_Addrs";
            TScreenVerificationResult VerificationResult;
            TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection;
            string ErrorCode;
            TCmbAutoComplete ComboBoxForContactComboType;
            string ComboTypeStr;   // Ignored, but needed as this is an out Argument of GetDataAccordingToContactComboType...

            if (AContactComboType == TOverallContactComboType.occtPrimaryEmail)
            {
                ErrorCode = PetraErrorCodes.ERR_PRIMARY_EMAIL_ADDR_SET_BUT_NOT_AMONG_EMAIL_ADDR;
            }
            else if (AContactComboType == TOverallContactComboType.occtSecondaryEmail)
            {
                ErrorCode = PetraErrorCodes.ERR_SECONDARY_EMAIL_ADDR_SET_BUT_NOT_AMONG_EMAIL_ADDR;
            }
            else if (AContactComboType == TOverallContactComboType.occtEmailWithinOrganisation)
            {
                ErrorCode = PetraErrorCodes.ERR_OFFICE_EMAIL_ADDR_SET_BUT_NOT_AMONG_EMAIL_ADDR;
            }
            else
            {
                throw new EOPAppException("AContactComboType Argument must designate an E-Mail ComboBox");
            }

            GetDataAccordingToContactComboType(AContactComboType,
                out ComboBoxForContactComboType, out ComboTypeStr);

            VerificationResult = new TScreenVerificationResult(
                new TVerificationResult((object)ResCont,
                    ErrorCodes.GetErrorInfo(ErrorCode),
                    FPetraUtilsObject.VerificationResultCollection.CurrentDataValidationRunID),
                null, ComboBoxForContactComboType, FPetraUtilsObject.VerificationResultCollection.CurrentDataValidationRunID);

            VerificationResultCollection.Remove(ResCont);

            if (VerificationResult != null)
            {
                VerificationResultCollection.Add(VerificationResult);
            }
        }