/// <summary> /// Gets Where condition for filtering by the state. When using separated database, materializes the nested query on the other DB. /// </summary> private string GetStateCondition(TextSimpleFilter filter) { string originalQuery = filter.WhereCondition; if (String.IsNullOrEmpty(originalQuery)) { return(string.Empty); } // Query with ContactInfo context has to be used in order to be able to determine DB context of the query (otherwise the materialization would not perform). var query = ContactInfoProvider.GetContacts() .WhereIn("ContactStateID", StateInfoProvider .GetStates() .Where(originalQuery) .Column(StateInfo.TYPEINFO.IDColumn) ); if (filter.FilterOperator == WhereBuilder.NOT_LIKE || filter.FilterOperator == WhereBuilder.NOT_EQUAL) { query = query.Or(new WhereCondition().WhereNull("ContactStateID")); } query.EnsureParameters(); return(query.Parameters.Expand(query.WhereCondition)); }
public IEnumerable <State> GetStates() { return(StateInfoProvider .GetStates() .Columns("StateDisplayName", "StateId", "StateName", "StateCode", "CountryId") .Select <StateInfo, State>(s => _mapper.Map <State>(s))); }
protected void EditForm_OnItemValidation(object sender, ref string errorMessage) { FormEngineUserControl ctrl = sender as FormEngineUserControl; // Checking countryselector if some country was selected if ((ctrl != null) && (ctrl.FieldInfo.Name == "AddressCountryID")) { int countryId = ValidationHelper.GetInteger(ctrl.Value, 0); if (countryId == 0) { errorMessage = GetString("basicform.erroremptyvalue"); } // If country has states, check if some state was selected DataSet states = StateInfoProvider.GetStates("CountryID = " + countryId, "CountryID", 1, "CountryID"); if (!DataHelper.DataSourceIsEmpty(states)) { object[,] stateObj = ctrl.GetOtherValues(); if ((stateObj == null) || (stateObj[0, 1] == null)) { errorMessage = GetString("com.address.nostate"); } } } }
/// <summary> /// Gets target shipping address /// </summary> /// <returns></returns> private static AddressDTO GetBillingAddress() { try { var distributorID = Cart.GetIntegerValue("ShoppingCartDistributorID", default(int)); var distributorAddress = AddressInfoProvider.GetAddresses().WhereEquals("AddressID", distributorID).FirstOrDefault(); var country = CountryInfoProvider.GetCountries().WhereEquals("CountryID", distributorAddress.GetStringValue("AddressCountryID", string.Empty)).FirstOrDefault(); var state = StateInfoProvider.GetStates().WhereEquals("StateID", distributorAddress.GetStringValue("AddressStateID", string.Empty)).FirstOrDefault(); return(new AddressDTO() { KenticoAddressID = distributorAddress.AddressID, AddressLine1 = distributorAddress.AddressLine1, AddressLine2 = distributorAddress.AddressLine2, City = distributorAddress.AddressCity, State = state.StateCode, Zip = distributorAddress.GetStringValue("AddressZip", string.Empty), KenticoCountryID = distributorAddress.AddressCountryID, Country = country.CountryName, isoCountryCode = country.CountryTwoLetterCode, KenticoStateID = distributorAddress.AddressStateID, AddressPersonalName = distributorAddress.AddressPersonalName, AddressCompanyName = distributorAddress.GetStringValue("CompanyName", string.Empty) }); } catch (Exception ex) { EventLogProvider.LogInformation("ShoppingCartHelper", "GetBillingAddress", ex.Message); return(null); } }
/// <summary> /// Returns where condition filtering ShippingAddress, Country and State. /// </summary> private void AddCountryWhereCondition(WhereCondition where) { var addressWhere = new IDQuery <AddressInfo>(); string[] split = ShippingCountry.Split(';'); if ((split.Length >= 1) && (split.Length <= 2)) { // Country filter var country = CountryInfoProvider.GetCountryInfo(split[0]); if (country != null) { addressWhere.WhereEquals("AddressCountryID", country.CountryID); if (split.Length == 2) { // State filter var state = StateInfoProvider.GetStateInfo(split[1]); if (state != null) { addressWhere.WhereEquals("AddressStateID", state.StateID); } } } } where.WhereIn("OrderShippingAddressID", addressWhere); }
/// <summary> /// Gets and bulk updates states. Called when the "Get and bulk update states" button is pressed. /// Expects the CreateState method to be run first. /// </summary> private bool GetAndBulkUpdateStates() { // Get the country CountryInfo country = CountryInfoProvider.GetCountryInfo("MyNewCountry"); if (country != null) { // Get the data DataSet states = StateInfoProvider.GetCountryStates(country.CountryID); if (!DataHelper.DataSourceIsEmpty(states)) { // Loop through the individual items foreach (DataRow stateDr in states.Tables[0].Rows) { // Create object from DataRow StateInfo modifyState = new StateInfo(stateDr); // Update the property modifyState.StateDisplayName = modifyState.StateDisplayName.ToUpper(); // Update the state StateInfoProvider.SetStateInfo(modifyState); } return(true); } } return(false); }
/// <summary> /// Gets target shipping address /// </summary> /// <returns></returns> private static AddressDto GetTargetAddress() { try { var distributorID = Cart.GetIntegerValue("ShoppingCartDistributorID", default(int)); var distributorAddress = AddressInfoProvider.GetAddresses().WhereEquals("AddressID", distributorID).FirstOrDefault(); var addressLines = new[] { distributorAddress.GetStringValue("AddressLine1", string.Empty), distributorAddress.GetStringValue("AddressLine2", string.Empty) }.Where(a => !string.IsNullOrWhiteSpace(a)).ToList(); var country = CountryInfoProvider.GetCountries().WhereEquals("CountryID", distributorAddress.GetStringValue("AddressCountryID", string.Empty)) .Column("CountryTwoLetterCode").FirstOrDefault(); var state = StateInfoProvider.GetStates().WhereEquals("StateID", distributorAddress.GetStringValue("AddressStateID", string.Empty)).Column("StateCode").FirstOrDefault(); return(new AddressDto() { City = distributorAddress.GetStringValue("AddressCity", string.Empty), Country = country?.CountryTwoLetterCode, Postal = distributorAddress.GetStringValue("AddressZip", string.Empty), State = state?.StateCode, StreetLines = addressLines }); } catch (Exception ex) { EventLogProvider.LogInformation("ShoppingCartHelper", "GetTargetAddress", ex.Message); return(null); } }
/// <summary> /// Validates data /// </summary> protected override void ValidateStepData(object sender, StepEventArgs e) { base.ValidateStepData(sender, e); if (!StopProcessing) { if (!addressForm.ValidateData()) { e.CancelEvent = true; return; } // Just set current filed values into EditableObject, saving was canceled in OnBeforeSave addressForm.SaveData(null, false); AddressInfo ai = addressForm.EditedObject as AddressInfo; if (ai != null) { // Validate state if (!DataHelper.DataSourceIsEmpty(StateInfoProvider.GetCountryStates(ai.AddressCountryID))) { if (ai.AddressStateID < 1) { e.CancelEvent = true; addressForm.DisplayErrorLabel("AddressCountryID", ResHelper.GetString("com.address.nostate")); } } } } }
/// <summary> /// Returns true if the contact's country matches one of the specified countries. /// </summary> /// <param name="contact">Contact the activities of which should be checked</param> /// <param name="stateList">State list (separated with semicolon)</param> public static bool IsFromState(object contact, string stateList) { ContactInfo ci = contact as ContactInfo; if (ci == null) { return(false); } StateInfo state = StateInfoProvider.GetStateInfo(ci.ContactStateID); if (state == null) { return(false); } string[] states = stateList.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in states) { if (s.EqualsCSafe(state.StateDisplayName, true) || s.EqualsCSafe(state.StateName, true)) { return(true); } } return(false); }
public BillingAddressViewModel(AddressInfo address, SelectList countries, SelectList addresses = null) { if (address != null) { BillingAddressLine1 = address.AddressLine1; BillingAddressLine2 = address.AddressLine2; BillingAddressCity = address.AddressCity; BillingAddressPostalCode = address.AddressZip; BillingAddressState = StateInfoProvider.GetStateInfo(address.AddressStateID)?.StateDisplayName ?? String.Empty; BillingAddressCountry = CountryInfoProvider.GetCountryInfo(address.AddressCountryID)?.CountryDisplayName ?? String.Empty; Countries = countries; } BillingAddressCountryStateSelector = new CountryStateViewModel { Countries = countries, CountryID = address?.AddressCountryID ?? 0, StateID = address?.AddressStateID ?? 0 }; BillingAddressSelector = new AddressSelectorViewModel { Addresses = addresses, AddressID = address?.AddressID ?? 0 }; }
/// <summary> /// Returns where condition filtering ShippingAddress, Country and State. /// </summary> private string GetCountryWhereCondition() { if (!string.IsNullOrEmpty(ShippingCountry) && ShippingCountry != "0") { string subWhere = "1 == 1"; string[] split = ShippingCountry.Split(';'); if ((split.Length >= 1) && (split.Length <= 2)) { // Country filter CountryInfo country = CountryInfoProvider.GetCountryInfo(split[0]); if (country != null) { int countryID = country.CountryID; subWhere = "(AddressCountryID = " + countryID + ")"; if (split.Length == 2) { // State filter StateInfo state = StateInfoProvider.GetStateInfo(split[1]); if (state != null) { int stateID = state.StateID; subWhere += " AND (AddressStateID = " + stateID + ")"; } } } } return("OrderShippingAddressID IN (SELECT AddressID FROM COM_Address WHERE (" + subWhere + "))"); } return(""); }
public decimal GetUSPSRate(Rates objRates, CurrentUserInfo uinfo, Delivery delivery, string strShippingOptionName) { decimal decRate = 0; try { // Cache the data for 10 minutes with a key using (CachedSection <Rates> cs = new CachedSection <Rates>(ref objRates, 60, true, null, "USPS-" + uinfo.UserID + "-" + delivery.DeliveryAddress.AddressZip + "-" + ValidationHelper.GetString(delivery.Weight, ""))) { if (cs.LoadData) { //Get real-time shipping rates from USPS using dotNETShip Ship objShip = new Ship(); objShip.USPSLogin = strUSPSLogin; objShip.OrigZipPostal = SettingsKeyInfoProvider.GetValue("SourceZip", "90001"); string[] strCountryState = SettingsKeyInfoProvider.GetValue("SourceCountryState", "US").Split(';'); CountryInfo ci = CountryInfoProvider.GetCountryInfo(ValidationHelper.GetString(strCountryState[0], "USA")); objShip.OrigCountry = ci.CountryTwoLetterCode; StateInfo si = StateInfoProvider.GetStateInfo(ValidationHelper.GetString(strCountryState[1], "California")); objShip.OrigStateProvince = si.StateCode; objShip.DestZipPostal = delivery.DeliveryAddress.AddressZip; objShip.DestCountry = delivery.DeliveryAddress.GetCountryTwoLetterCode(); objShip.DestStateProvince = delivery.DeliveryAddress.GetStateCode(); objShip.Length = 12; objShip.Width = 12; objShip.Height = 12; objShip.Weight = (float)delivery.Weight; objShip.Rate("USPS"); cs.Data = objShip.Rates; } objRates = cs.Data; } foreach (Rate rate in objRates) { if (rate.Name.ToLower() == strShippingOptionName.ToLower()) { decRate = ValidationHelper.GetDecimal(rate.Charge, 0); break; } } } catch (Exception ex) { //Log the error EventLogProvider.LogException("MultiCarrier - GetUSPSRate", "EXCEPTION", ex); //Set some base rate for the shipping decRate = 10; } return(decRate); }
/// <summary> /// Deletes state. Called when the "Delete state" button is pressed. /// Expects the CreateState method to be run first. /// </summary> private bool DeleteState() { // Get the state StateInfo deleteState = StateInfoProvider.GetStateInfo("MyNewState"); // Delete the state StateInfoProvider.DeleteStateInfo(deleteState); return(deleteState != null); }
/// <summary> /// Validates the address. /// </summary> /// <remarks> /// The following conditions must be met to pass the validation: /// 1) Country is set. /// 2) Country contains selected state. /// </remarks> public void Validate() { CountryNotSet = (mAddress.CountryID == 0); if (!CountryNotSet) { var state = StateInfoProvider.GetStateInfo(mAddress.StateID); StateNotFromCountry = (state != null) && (state.CountryID != mAddress.CountryID); } }
private void GenerateHaroldLarson() { var haroldLarson = GenerateContact("Harold", "Larson", "*****@*****.**", "(742)-343-5223"); haroldLarson.ContactGender = (int)UserGenderEnum.Male; haroldLarson.ContactCountryID = CountryInfoProvider.GetCountryInfo("USA").CountryID; haroldLarson.ContactCity = "Bedford"; haroldLarson.ContactBounces = 5; haroldLarson.ContactStateID = StateInfoProvider.GetStateInfo("NewHampshire").StateID; ContactInfoProvider.SetContactInfo(haroldLarson); }
public JsonResult CountryStates(int countryId) { // Gets the display names of the country's states var responseModel = StateInfoProvider.GetStates().WhereEquals("CountryID", countryId) .Select(s => new { id = s.StateID, name = HTMLHelper.HTMLEncode(s.StateDisplayName) }); // Returns serialized display names of the states return(Json(responseModel)); }
/// <summary> /// Loads the other fields values to the state of the form control /// </summary> public override void LoadOtherValues() { // Try to set state from dedicated column in form data if (ContainsColumn(StateIDColumnName)) { // Select state in stateSelector in the form if StateIDColumnName was supplied var stateInfo = StateInfoProvider.GetStateInfo(ValidationHelper.GetInteger(GetColumnValue(StateIDColumnName), 0)); if ((stateInfo != null) && (uniSelectorState != null)) { uniSelectorState.Value = stateInfo.StateName; } } }
private void SetFormSpecificData(string formName, ContactInfo contact, BizFormItem formItem) { if (formName == COFFEE_SAMPLE_LIST_FORM_CODE_NAME) { formItem.SetValue("Country", CountryInfoProvider.GetCountryInfo(contact.ContactCountryID).CountryThreeLetterCode); var state = StateInfoProvider.GetStateInfo(contact.ContactStateID); var stateName = state != null ? state.StateDisplayName : string.Empty; formItem.SetValue("State", stateName); } if (formName == CONTACT_US_FORM_CODE_NAME) { formItem.SetValue("UserMessage", "Message"); } }
private void GenerateHaroldLarson() { var contact = GenerateContact("Harold", "Larson", "*****@*****.**", "(742)-343-5223"); contact.ContactGender = 1; contact.ContactCountryID = CountryInfoProvider.GetCountryInfo("USA").CountryID; contact.ContactCity = "Bedford"; contact.ContactBounces = 5; contact.ContactStateID = StateInfoProvider.GetStateInfo("NewHampshire").StateID; ContactInfoProvider.SetContactInfo(contact); GeneratePageVisitActivity(_mPartnershipDocument, contact); CreateFormSubmission(_mPartnershipDocument, TryFreeSampleFormCodeName, contact); CreateFormSubmission(_mPartnershipDocument, ContactUsFormCodeName, contact); }
public OrderAddressViewModel(OrderAddressInfo address) { if (address == null) { return; } AddressLine1 = address.AddressLine1; AddressLine2 = address.AddressLine2; AddressCity = address.AddressCity; AddressPostalCode = address.AddressZip; AddressState = StateInfoProvider.GetStateInfo(address.AddressStateID)?.StateDisplayName ?? String.Empty; AddressCountry = CountryInfoProvider.GetCountryInfo(address.AddressCountryID)?.CountryDisplayName ?? String.Empty; }
/// <summary> /// Returns html code that represents address. Used for generating of invoice. /// </summary> /// <param name="address">Address to be formatted</param> private string GetAddressHTML(IAddress address) { if (address == null) { return(string.Empty); } var sb = new StringBuilder("<table class=\"TextLeft\">"); // Personal name sb.AppendFormat("<tr><td>{0}</td></tr>", HTMLHelper.HTMLEncode(address.AddressPersonalName)); // Line 1 if (address.AddressLine1 != "") { sb.AppendFormat("<tr><td>{0}</td></tr>", HTMLHelper.HTMLEncode(address.AddressLine1)); } // Line 2 if (address.AddressLine2 != "") { sb.AppendFormat("<tr><td>{0}</td></tr>", HTMLHelper.HTMLEncode(address.AddressLine2)); } // City + (State) + Postal Code sb.Append("<tr><td>", HTMLHelper.HTMLEncode(address.AddressCity)); var state = StateInfoProvider.GetStateInfo(address.AddressStateID); if (state != null) { sb.Append(", ", HTMLHelper.HTMLEncode(ResHelper.LocalizeString(state.StateDisplayName))); } sb.AppendFormat(" {0}</td></tr>", HTMLHelper.HTMLEncode(address.AddressZip)); // Country var country = CountryInfoProvider.GetCountryInfo(address.AddressCountryID); if (country != null) { sb.AppendFormat("<tr><td>{0}</td></tr>", HTMLHelper.HTMLEncode(ResHelper.LocalizeString(country.CountryDisplayName))); } // Phone sb.AppendFormat("<tr><td>{0}</td></tr></table>", HTMLHelper.HTMLEncode(address.AddressPhone)); return(sb.ToString()); }
private StateInfo FindState(string state) { if (string.IsNullOrWhiteSpace(state)) { return(null); } var code = state.ToUpper(); return(StateInfoProvider.GetStates() .WhereStartsWith("StateDisplayName", state) .Or() .WhereEquals("StateCode", code) .FirstOrDefault()); }
/// <summary> /// Validates data /// </summary> protected override void ValidateStepData(object sender, StepEventArgs e) { base.ValidateStepData(sender, e); if (!StopProcessing) { if (!addressForm.ValidateData()) { e.CancelEvent = true; return; } // Just set current filed values into EditableObject, saving was canceled in OnBeforeSave addressForm.SaveData(null, false); AddressInfo address = addressForm.EditedObject as AddressInfo; if (address != null) { // Validate state if (!DataHelper.DataSourceIsEmpty(StateInfoProvider.GetCountryStates(address.AddressCountryID))) { if (address.AddressStateID < 1) { e.CancelEvent = true; addressForm.DisplayErrorLabel("AddressCountryID", ResHelper.GetString("com.address.nostate")); return; } } // Clear AddressName and AddressPersonalName to force their update (only if not present on the address form) if (!addressForm.FieldControls.Contains("AddressName")) { address.AddressName = null; } if (!addressForm.FieldControls.Contains("AddressPersonalName")) { address.AddressPersonalName = null; } // Assign validated new address to the current shopping cart // Address will be saved by customer detail web part (existing customer object is needed for the address) CurrentCartAddress = address; } } // Clear shipping address (StopProcessing is true when chkShowAddress is cleared) ClearShippingAddress(); }
/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that throws event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void uniGrid_OnAction(string actionName, object actionArgument) { if (actionName == "delete") { int countryId = ValidationHelper.GetInteger(actionArgument, 0); bool dependent = false; // Get country states DataSet ds = StateInfoProvider.GetCountryStates(countryId); if (!DataHelper.DataSourceIsEmpty(ds)) { // Check dependency of all state at first foreach (DataRow dr in ds.Tables[0].Rows) { int stateId = ValidationHelper.GetInteger(dr["StateID"], 0); if (StateInfoProvider.CheckDependencies(stateId)) { dependent = true; break; } } } // Get country dependency without states DataSet dsCountryDependency = CountryInfoProvider.GetCountries(String.Format("(CountryID IN (SELECT AddressCountryID FROM COM_Address WHERE AddressCountryID={0}) OR CountryID IN (SELECT CustomerCountryID FROM COM_Customer WHERE CustomerCountryID={0}) OR CountryID IN (SELECT CountryID FROM COM_TaxClassCountry WHERE CountryID={0}))", countryId), null, 1, "CountryID"); // Check dependency of country itself dependent |= (!DataHelper.DataSourceIsEmpty(dsCountryDependency)); if (dependent) { ShowError(GetString("ecommerce.deletedisabledwithoutenable")); } else { // Delete all states foreach (DataRow dr in ds.Tables[0].Rows) { int stateId = ValidationHelper.GetInteger(dr["StateID"], 0); StateInfoProvider.DeleteStateInfo(stateId); } // Delete CountryInfo object from database CountryInfoProvider.DeleteCountryInfo(countryId); } } }
private static void SetOrigin(RateRequest request, Delivery delivery) { request.RequestedShipment.Shipper = new Party(); request.RequestedShipment.Shipper.Address = new Address(); request.RequestedShipment.Shipper.Address.StreetLines = new string[1] { SettingsKeyInfoProvider.GetValue("SourceStreet", "123 Street") }; request.RequestedShipment.Shipper.Address.City = SettingsKeyInfoProvider.GetValue("SourceCity", "Los Angeles"); string[] strCountryState = SettingsKeyInfoProvider.GetValue("SourceCountryState", "US").Split(';'); CountryInfo ci = CountryInfoProvider.GetCountryInfo(ValidationHelper.GetString(strCountryState[0], "USA")); request.RequestedShipment.Shipper.Address.CountryCode = ci.CountryTwoLetterCode; StateInfo si = StateInfoProvider.GetStateInfo(ValidationHelper.GetString(strCountryState[1], "California")); request.RequestedShipment.Shipper.Address.StateOrProvinceCode = si.StateCode; request.RequestedShipment.Shipper.Address.PostalCode = SettingsKeyInfoProvider.GetValue("SourceZip", "90001"); }
/// <summary> /// Gets and updates state. Called when the "Get and update state" button is pressed. /// Expects the CreateState method to be run first. /// </summary> private bool GetAndUpdateState() { // Get the state StateInfo updateState = StateInfoProvider.GetStateInfo("MyNewState"); if (updateState != null) { // Update the property updateState.StateDisplayName = updateState.StateDisplayName.ToLower(); // Update the state StateInfoProvider.SetStateInfo(updateState); return(true); } return(false); }
private void SetFormSpecificData(string formName, ContactInfo contact, BizFormItem formItem) { if (formName == TryFreeSampleFormCodeName) { formItem.SetValue("Country", CountryInfoProvider.GetCountryInfo(contact.ContactCountryID).CountryThreeLetterCode); var stateInfo = StateInfoProvider.GetStateInfo(contact.ContactStateID); var str = stateInfo != null ? stateInfo.StateDisplayName : string.Empty; formItem.SetValue("State", str); } if (formName == ContactUsFormCodeName) { formItem.SetValue("UserMessage", "Message"); } if (formName != BusinessCustomerRegistationFormCodeName) { return; } formItem.SetValue("BecomePartner", "Becoming a partner café"); }
/// <summary> /// Creates state. Called when the "Create state" button is pressed. /// </summary> private bool CreateState() { // Get the country CountryInfo country = CountryInfoProvider.GetCountryInfo("MyNewCountry"); if (country != null) { // Create new state object StateInfo newState = new StateInfo(); // Set the properties newState.StateDisplayName = "My new state"; newState.StateName = "MyNewState"; newState.CountryID = country.CountryID; // Create the state StateInfoProvider.SetStateInfo(newState); return(true); } return(false); }
public BillingAddress GetDefaultBillingAddress() { var streets = new[] { estimationSettings.SenderAddressLine1, estimationSettings.SenderAddressLine2, }.Where(i => !string.IsNullOrEmpty(i)).ToList(); string countryName = estimationSettings.SenderCountry; string stateName = estimationSettings.SenderState; int countryId = CountryInfoProvider.GetCountryInfoByCode(countryName).CountryID; int stateId = StateInfoProvider.GetStateInfoByCode(stateName).StateID; return(new BillingAddress() { Street = streets, City = estimationSettings.SenderCity, Country = countryName, CountryId = countryId, Zip = estimationSettings.SenderPostal, State = stateName, StateId = stateId }); }
/// <summary> /// Fills tooltip with appropriate data. /// </summary> private void FillTooltipData(Image image, DataTable dt, string fieldName, string fieldValue, FormFieldDataTypeEnum dataType) { // Insert header into tooltip with parent value if (!String.IsNullOrEmpty(fieldValue)) { // Datetime values if (dataType == FormFieldDataTypeEnum.DateTime) { image.ToolTip += "<em>" + GetString("om.account.parentvalue") + "</em> <strong>" + ValidationHelper.GetDateTime(fieldValue, DateTimeHelper.ZERO_TIME) + "</strong>"; } else { // Country image.ToolTip += "<em>" + GetString("om.account.parentvalue") + "</em> "; if (fieldName == "AccountCountryID") { CountryInfo country = CountryInfoProvider.GetCountryInfo(ValidationHelper.GetInteger(fieldValue, 0)); if (country != null) { image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(country.CountryDisplayName) + "</strong>"; } else { image.ToolTip += GetString("general.na"); } } // State else if (fieldName == "AccountStateID") { StateInfo state = StateInfoProvider.GetStateInfo(ValidationHelper.GetInteger(fieldValue, 0)); if (state != null) { image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(state.StateDisplayName) + "</strong>"; } else { image.ToolTip += GetString("general.na"); } } // Otherwise else { image.ToolTip += "<em>" + GetString("om.account.parentvalue") + "</em> <strong>" + HTMLHelper.HTMLEncode(fieldValue) + "</strong>"; } } } else { image.ToolTip += "<em>" + GetString("om.account.parentvalue") + "</em> " + GetString("general.na"); } image.ToolTip += "<br /><br /><em>" + GetString("om.account.mergedvalues") + "</em><br />"; // Display N/A for empty merged records if (DataHelper.DataSourceIsEmpty(dt)) { image.ToolTip += "<br /> " + GetString("general.na"); } // Display values of merged records else { DataTable accounts; // Loop through all distinct values of given column foreach (DataRow dr in dt.Rows) { image.ToolTip += "<br />"; // Sort accounts by full name mergedAccounts.Tables[0].DefaultView.Sort = "AccountName"; mergedAccounts.CaseSensitive = true; // Need to transform status ID to displayname if (fieldName == "AccountStatusID") { AccountStatusInfo status = AccountStatusInfoProvider.GetAccountStatusInfo((int)dr[fieldName]); image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(status.AccountStatusDisplayName) + "</strong><br />"; mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + status.AccountStatusID.ToString() + "'"; } // Need to transform country ID to displayname else if (fieldName == "AccountCountryID") { CountryInfo country = CountryInfoProvider.GetCountryInfo((int)dr[fieldName]); image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(country.CountryDisplayName) + "</strong><br />"; mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + country.CountryID.ToString() + "'"; } // Need to transform state ID to displayname else if (fieldName == "AccountStateID") { StateInfo state = StateInfoProvider.GetStateInfo((int)dr[fieldName]); image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(state.StateDisplayName) + "</strong><br />"; mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + state.StateID.ToString() + "'"; } // Date time type else if (dataType == FormFieldDataTypeEnum.DateTime) { image.ToolTip += "<strong>" + ValidationHelper.GetDateTime(dr[fieldName], DateTimeHelper.ZERO_TIME) + "</strong><br />"; mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + dr[fieldName] + "'"; } // Integer data type and boolean else if ((dataType == FormFieldDataTypeEnum.Integer) || (dataType == FormFieldDataTypeEnum.Boolean) || (dataType == FormFieldDataTypeEnum.Decimal) || (dataType == FormFieldDataTypeEnum.GUID) || (dataType == FormFieldDataTypeEnum.LongInteger)) { image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr[fieldName], null)) + "</strong><br />"; mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + dr[fieldName] + "'"; } // Get all contacts which have same string value else { image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr[fieldName], null)) + "</strong><br />"; mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " LIKE '" + ContactHelper.EscapeString((string)dr[fieldName]) + "'"; } // Display all accounts accounts = mergedAccounts.Tables[0].DefaultView.ToTable(false, "AccountName"); foreach (DataRow row in accounts.Rows) { image.ToolTip += " - " + HTMLHelper.HTMLEncode(((string)row["AccountName"]).Trim()) + "<br />"; } } } }