/// <summary> /// Determines the 'Best Address' of the PERSON and its Phone Number and Email Address. /// </summary> /// <param name="APhoneNumberOfPerson">Phone Number of the PERSON in international format.</param> /// <param name="AEmailAddressOfPerson">Email Address of the PERSON.</param> /// <returns><see cref="Ict.Petra.Shared.MPartner.TLocationPK" /> pointing to the 'Best Address' of the PERSON.</returns> private TLocationPK DetermineAddressComponents(out string APhoneNumberOfPerson, out string AEmailAddressOfPerson) { TLocationPK ReturnValue = Ict.Petra.Shared.MPartner.Calculations.DetermineBestAddress( FMainDS.Tables[PartnerEditTDSPPartnerLocationTable.GetTableName()]); DataRow BestPartnerLocationDR; DataRow BestLocationDR; string TelephoneNumber; string Extension; string CountryCode; // Initialise out Arguments APhoneNumberOfPerson = null; AEmailAddressOfPerson = null; BestPartnerLocationDR = FMainDS.Tables[PartnerEditTDSPPartnerLocationTable.GetTableName()].Rows.Find(new object[] { FMainDS.PPerson[0].PartnerKey, ReturnValue.SiteKey, ReturnValue.LocationKey }); if (BestPartnerLocationDR != null) { BestLocationDR = FMainDS.Tables[PLocationTable.GetTableName()].Rows.Find(new object[] { ReturnValue.SiteKey, ReturnValue.LocationKey }); if (!BestPartnerLocationDR.IsNull(PPartnerLocationTable.GetTelephoneNumberDBName())) { TelephoneNumber = (string)BestPartnerLocationDR[PPartnerLocationTable.GetTelephoneNumberDBName()]; } else { TelephoneNumber = String.Empty; } if (!BestPartnerLocationDR.IsNull(PPartnerLocationTable.GetExtensionDBName())) { Extension = ((int)BestPartnerLocationDR[PPartnerLocationTable.GetExtensionDBName()]).ToString(); } else { Extension = String.Empty; } if (!BestLocationDR.IsNull(PLocationTable.GetCountryCodeDBName())) { CountryCode = (string)BestLocationDR[PLocationTable.GetCountryCodeDBName()]; } else { CountryCode = String.Empty; } APhoneNumberOfPerson = Ict.Petra.Shared.MPartner.Calculations.FormatIntlPhoneNumber( TelephoneNumber, Extension, CountryCode, @TDataCache.GetCacheableDataTableFromCache); if (!BestPartnerLocationDR.IsNull(PPartnerLocationTable.GetEmailAddressDBName())) { AEmailAddressOfPerson = (string)BestPartnerLocationDR[PPartnerLocationTable.GetEmailAddressDBName()]; } else { AEmailAddressOfPerson = String.Empty; } } else { MessageBox.Show("Unexpected condition: 'Best Address of PERSON is null'", DEV_FIX); } return(ReturnValue); }