/// <summary> /// Adds available E-Mail Addresses to a ComboBox. If <paramref name="ANewEmailAddressValue"/> is specified /// then this value gets selected in the ComboBox. /// </summary> /// <remarks>Method is similar to Method <see cref="UpdatePhoneComboItems"/>.</remarks> /// <param name="AComboBox">The ComboBox Control whose Items should get updated.</param> /// <param name="ASuppressMessages">If set to false: Messages will be shown to the user in certain circumstances. /// However, this will only be done in case <paramref name="AComboBox"/> is cmbPrimaryEMail!</param> /// <param name="ANewEmailAddressValue">Pass a new E-Mail Address to get it selected in the ComboBox. (Default=null)</param> /// <param name="APreviousValue">The Previous Value. Only needed for cmbSecondaryEMail!</param> private void UpdateEmailComboItems(TCmbAutoComplete AComboBox, bool ASuppressMessages, string ANewEmailAddressValue = null, string APreviousValue = null) { object[] EligibleEmailAddresses; string ThePrimaryEmailAddress = String.Empty; string TheSecondaryEmailAddress = String.Empty; string TheWithinOrganisationEmailAddress = String.Empty; string PrimaryContactMethod; // Ignored, but needed as this is an out Argument of GetSystemCategoryOvrlContSettgsValues... DataView EligibleEmailAddrsDV; DataView AllEmailAddrsDV; string CurrentlySelectedEmailAddr = AComboBox.GetSelectedString(-1); // Determine all Partner Attributes that have a Partner Attribute Type that constitutes an E-Mail // and that are Current. EligibleEmailAddrsDV = GetDataViewForContactCombo(TOverallContactComboType.occtPrimaryEmail, true); EligibleEmailAddresses = new object[EligibleEmailAddrsDV.Count + 1]; EligibleEmailAddresses[0] = String.Empty; if (AComboBox == cmbSecondaryEMail) { GetSystemCategoryOvrlContSettgsValues(out PrimaryContactMethod, out TheSecondaryEmailAddress); } for (int Counter = 0; Counter < EligibleEmailAddrsDV.Count; Counter++) { var TheEmailRow = ((PPartnerAttributeRow)EligibleEmailAddrsDV[Counter].Row); EligibleEmailAddresses[Counter + 1] = TheEmailRow.Value; if (AComboBox != cmbSecondaryEMail) { if (TheEmailRow.Primary) { ThePrimaryEmailAddress = TheEmailRow.Value; } if (TheEmailRow.WithinOrganisation) { TheWithinOrganisationEmailAddress = TheEmailRow.Value; } } } if (!AreComboBoxItemsIdenticalToArgument(AComboBox, EligibleEmailAddresses)) { // Add the available E-Mail Addresses to the ComboBox AComboBox.Items.Clear(); AComboBox.Items.AddRange(EligibleEmailAddresses); } if ((AComboBox == cmbPrimaryEMail) && (ThePrimaryEmailAddress != String.Empty)) { if (AComboBox.GetSelectedString() != ThePrimaryEmailAddress) { // Select the Primary E-mail Address in the ComboBox FEmailSelectedValueChangedEvent = true; AComboBox.SetSelectedString(ThePrimaryEmailAddress); FEmailSelectedValueChangedEvent = false; } } else if ((AComboBox == cmbEMailWithinTheOrganisation) && (TheWithinOrganisationEmailAddress != String.Empty)) { if (AComboBox.GetSelectedString() != TheWithinOrganisationEmailAddress) { // Select the Within Organisation E-mail Address in the ComboBox FEmailSelectedValueChangedEvent = true; AComboBox.SetSelectedString(TheWithinOrganisationEmailAddress); FEmailSelectedValueChangedEvent = false; } } else if ((AComboBox == cmbSecondaryEMail) && (ANewEmailAddressValue != null) && (ANewEmailAddressValue != String.Empty)) { if (APreviousValue == TheSecondaryEmailAddress) { if ((APreviousValue != ANewEmailAddressValue) && (CurrentlySelectedEmailAddr == APreviousValue) && (AComboBox.GetSelectedString() != ANewEmailAddressValue)) { // Select the Secondary E-mail Address in the ComboBox FEmailSelectedValueChangedEvent = true; AComboBox.SetSelectedString(ANewEmailAddressValue); FEmailSelectedValueChangedEvent = false; } } else { // Select the Secondary E-mail Address in the ComboBox FEmailSelectedValueChangedEvent = true; AComboBox.SetSelectedString(TheSecondaryEmailAddress); FEmailSelectedValueChangedEvent = false; } } else { CurrentlySelectedEmailAddr = ANewEmailAddressValue ?? CurrentlySelectedEmailAddr; AComboBox.SetSelectedString(CurrentlySelectedEmailAddr); if ((AComboBox == cmbPrimaryEMail) && (!ASuppressMessages)) { if (EligibleEmailAddrsDV.Count > 0) { FTimerDrivenMessageBoxKind = TTimerDrivenMessageBoxKind.tdmbkNoPrimaryEmailAsNoCurrentAvailable; ShowMessageBoxTimer.Start(); } else { AllEmailAddrsDV = GetDataViewForContactCombo(TOverallContactComboType.occtPrimaryEmail, false); if (AllEmailAddrsDV.Count > 0) { FTimerDrivenMessageBoxKind = TTimerDrivenMessageBoxKind.tdmbkNoPrimaryEmailButNonCurrentAvailable; ShowMessageBoxTimer.Start(); } } } } }
/// <summary> /// Performs actions that need to happen once the user changes the value of the 'Charge Option' ComboBox. /// </summary> /// <param name="AAChargeOptionComboBox">'Charge Option' ComboBox Control</param> /// <param name="ADetailChargeAmountLabel">'Charge Amount' Label Control</param> /// <param name="ADetailChargeAmountTextBox">'Charge Amount' TextBox Control</param> /// <param name="ADetailChargePercentageTextBox">'Charge Percentage' TextBox Control</param> public static void ChargeOptionComboChanged(TCmbAutoComplete AAChargeOptionComboBox, Label ADetailChargeAmountLabel, TTxtNumericTextBox ADetailChargeAmountTextBox, TTxtNumericTextBox ADetailChargePercentageTextBox) { ADetailChargeAmountLabel.Text = AAChargeOptionComboBox.GetSelectedString() + Catalog.GetString(" Amount:"); ADetailChargeAmountTextBox.Enabled = true; ADetailChargePercentageTextBox.Enabled = true; switch (AAChargeOptionComboBox.SelectedIndex) { case 2: ADetailChargePercentageTextBox.Enabled = false; ADetailChargePercentageTextBox.NumberValueDecimal = (decimal)0.0; break; case 3: ADetailChargeAmountLabel.Text = Catalog.GetString("Amount:"); // overwrite what was assigned earlier on ADetailChargeAmountTextBox.Enabled = false; // overwrite what was assigned earlier on ADetailChargeAmountTextBox.NumberValueDecimal = (decimal)0.0; break; } }
/// <summary> /// Adds available Phone Numbers to a ComboBox. If <paramref name="ANewPhoneNumberValue"/> is specified /// then this value gets selected in the ComboBox. /// </summary> /// <remarks>Method is similar to Method <see cref="UpdateEmailComboItems"/>.</remarks> /// <param name="AComboBox">The ComboBox Control whose Items should get updated.</param> /// <param name="ANewPhoneNumberValue">Pass a new Phone Number to get it selected in the ComboBox. (Default=null)</param> private void UpdatePhoneComboItems(TCmbAutoComplete AComboBox, string ANewPhoneNumberValue = null) { object[] EligiblePhoneNumbers; string ThePrimaryPhoneNumber = String.Empty; string TheWithinOrganisationPhoneNumber = String.Empty; DataView EligiblePhoneNrsDV; string CurrentlySelectedPhoneNr = AComboBox.GetSelectedString(-1); // Determine all Partner Attributes that have a Partner Attribute Type that constitutes a Phone Number // and that are Current (Fax Numbers are excluded from this!). EligiblePhoneNrsDV = Calculations.DeterminePartnerPhoneNumbers(FMainDS.PPartnerAttribute, true, false); EligiblePhoneNumbers = new object[EligiblePhoneNrsDV.Count + 1]; EligiblePhoneNumbers[0] = String.Empty; for (int Counter = 0; Counter < EligiblePhoneNrsDV.Count; Counter++) { var ThePhoneRow = ((PPartnerAttributeRow)EligiblePhoneNrsDV[Counter].Row); EligiblePhoneNumbers[Counter + 1] = ThePhoneRow.Value; if (ThePhoneRow.Primary) { ThePrimaryPhoneNumber = ThePhoneRow.Value; } if (ThePhoneRow.WithinOrganisation) { TheWithinOrganisationPhoneNumber = ThePhoneRow.Value; } } if (!AreComboBoxItemsIdenticalToArgument(AComboBox, EligiblePhoneNumbers)) { // Add the available Phone Numbers to the ComboBox AComboBox.Items.Clear(); AComboBox.Items.AddRange(EligiblePhoneNumbers); } if ((AComboBox == cmbPrimaryPhoneForContacting) && (ThePrimaryPhoneNumber != String.Empty)) { if (AComboBox.GetSelectedString() != ThePrimaryPhoneNumber) { // Select the Primary Phone Number in the ComboBox FPhoneSelectedValueChangedEvent = true; AComboBox.SetSelectedString(ThePrimaryPhoneNumber); FPhoneSelectedValueChangedEvent = false; } } else if ((AComboBox == cmbPhoneWithinTheOrganisation) && (TheWithinOrganisationPhoneNumber != String.Empty)) { if (AComboBox.GetSelectedString() != TheWithinOrganisationPhoneNumber) { // Select the Within Organisation Phone Number in the ComboBox FPhoneSelectedValueChangedEvent = true; AComboBox.SetSelectedString(TheWithinOrganisationPhoneNumber); FPhoneSelectedValueChangedEvent = false; } } else { CurrentlySelectedPhoneNr = ANewPhoneNumberValue ?? CurrentlySelectedPhoneNr; AComboBox.SetSelectedString(CurrentlySelectedPhoneNr); } }