/// <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);
    }
Exemplo n.º 2
0
    /// <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);
    }
Exemplo n.º 3
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 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
            };
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
    /// <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);
        }
Exemplo n.º 9
0
 /// <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;
         }
     }
 }
        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;
        }
Exemplo n.º 11
0
        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);
        }
 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");
     }
 }
Exemplo n.º 13
0
    /// <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());
    }
Exemplo n.º 14
0
        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");
        }
Exemplo n.º 15
0
    /// <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);
    }
Exemplo n.º 16
0
        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é");
        }
Exemplo n.º 17
0
    /// <summary>
    /// Fills tooltip with appropriate data.
    /// </summary>
    private string FillTooltipData(DataTable dt, string fieldName, string fieldValue, string dataType)
    {
        var output = String.Empty;

        // Insert header into tooltip with parent value
        if (!String.IsNullOrEmpty(fieldValue))
        {
            // Display birthday
            if (fieldName == "ContactBirthday")
            {
                output += "<em>" + GetString("om.contact.parentvalue") + "</em> <strong>" + HTMLHelper.HTMLEncode(ValidationHelper.GetDateTime(fieldValue, DateTimeHelper.ZERO_TIME).ToShortDateString()) + "</strong>";
            }
            // Display gender
            else if (fieldName == "ContactGender")
            {
                int gender = ValidationHelper.GetInteger(fieldValue, 0);
                if (gender == (int)UserGenderEnum.Male)
                {
                    output += "<em>" + GetString("om.contact.parentvalue") + "</em> <strong>" + GetString("general.male") + "</strong>";
                }
                else if (gender == (int)UserGenderEnum.Female)
                {
                    output += "<em>" + GetString("om.contact.parentvalue") + "</em> <strong>" + GetString("general.female") + "</strong>";
                }
                else
                {
                    output += "<em>" + GetString("om.contact.parentvalue") + "</em> <strong>" + GetString("general.unknown") + "</strong>";
                }
            }
            // Datetime values
            else if (dataType == FieldDataType.DateTime)
            {
                output += "<em>" + GetString("om.contact.parentvalue") + "</em> <strong>" + ValidationHelper.GetDateTime(fieldValue, DateTimeHelper.ZERO_TIME) + "</strong>";
            }
            // Get all contacts which have same string value
            else
            {
                output += "<em>" + GetString("om.contact.parentvalue") + "</em> ";
                if (fieldName == "ContactCountryID")
                {
                    CountryInfo country = CountryInfoProvider.GetCountryInfo(ValidationHelper.GetInteger(fieldValue, 0));
                    if (country != null)
                    {
                        output += "<strong>" + HTMLHelper.HTMLEncode(country.CountryDisplayName) + "</strong>";
                    }
                    else
                    {
                        output += GetString("general.na");
                    }
                }
                else if (fieldName == "ContactStateID")
                {
                    StateInfo state = StateInfoProvider.GetStateInfo(ValidationHelper.GetInteger(fieldValue, 0));
                    if (state != null)
                    {
                        output += "<strong>" + HTMLHelper.HTMLEncode(state.StateDisplayName) + "</strong>";
                    }
                    else
                    {
                        output += GetString("general.na");
                    }
                }
                else if (fieldName == "ContactStatusID")
                {
                    ContactStatusInfo status = ContactStatusInfoProvider.GetContactStatusInfo(ValidationHelper.GetInteger(fieldValue, 0));
                    if (status != null)
                    {
                        output += "<strong>" + HTMLHelper.HTMLEncode(status.ContactStatusDisplayName) + "</strong>";
                    }
                    else
                    {
                        output += GetString("general.na");
                    }
                }
                else
                {
                    output += "<strong>" + HTMLHelper.HTMLEncode(fieldValue) + "</strong>";
                }
            }
        }
        else
        {
            output += "<em>" + GetString("om.contact.parentvalue") + "</em> " + GetString("general.na");
        }
        output += "<div><em>" + GetString("om.contact.mergedvalues") + "</em></div>";

        // Display N/A for empty merged records
        if (DataHelper.DataSourceIsEmpty(dt))
        {
            output += "<div>" + GetString("general.na") + "</div>";
        }
        // Display values of merged records
        else
        {
            // Loop through all distinct values of given column
            foreach (DataRow dr in dt.Rows)
            {
                output += "<div>";

                // Sort contacts by full name
                var contactsView = mMergedContacts.Tables[0].DefaultView;
                contactsView.Sort = "ContactFullNameJoined";

                mMergedContacts.CaseSensitive = true;

                var value = dr[fieldName];

                if (fieldName == "ContactBirthday")
                {
                    // Get all contacts which have same ContactBirthday value
                    output += "<div><strong>" + HTMLHelper.HTMLEncode(ValidationHelper.GetDateTime(value, DateTimeHelper.ZERO_TIME).ToShortDateString()) + "</strong></div>";
                    contactsView.RowFilter = fieldName + " = '" + value + "'";
                }
                // Display gender
                else if (fieldName == "ContactGender")
                {
                    int gender = ValidationHelper.GetInteger(value, 0);
                    if (gender == (int)UserGenderEnum.Male)
                    {
                        output += GetTooltipItem(GetString("general.male"));
                    }
                    else if (gender == (int)UserGenderEnum.Female)
                    {
                        output += GetTooltipItem(GetString("general.female"));
                    }
                    else
                    {
                        output += GetTooltipItem(GetString("general.unknown"));
                    }

                    if (String.IsNullOrEmpty(ValidationHelper.GetString(value, null)))
                    {
                        contactsView.RowFilter = fieldName + " IS NULL";
                    }
                    else
                    {
                        contactsView.RowFilter = fieldName + " = " + value;
                    }
                }
                // Need to transform status ID to displayname
                else if (fieldName == "ContactStatusID")
                {
                    ContactStatusInfo status = ContactStatusInfoProvider.GetContactStatusInfo((int)value);
                    output += GetTooltipItem(ResHelper.LocalizeString(status.ContactStatusDisplayName));
                    contactsView.RowFilter = fieldName + " = '" + status.ContactStatusID + "'";
                }
                // Need to transform country ID to displayname
                else if (fieldName == "ContactCountryID")
                {
                    CountryInfo country = CountryInfoProvider.GetCountryInfo((int)value);
                    output += GetTooltipItem(country.CountryDisplayName);
                    contactsView.RowFilter = fieldName + " = '" + country.CountryID + "'";
                }
                // Need to transform state ID to displayname
                else if (fieldName == "ContactStateID")
                {
                    StateInfo state = StateInfoProvider.GetStateInfo((int)value);
                    output += GetTooltipItem(state.StateDisplayName);
                    contactsView.RowFilter = fieldName + " = '" + state.StateID + "'";
                }
                // Other fields, process based on field type
                else
                {
                    output += GetTooltipItem(ValidationHelper.GetString(value, null));
                    contactsView.RowFilter = fieldName + " = '" + ContactHelper.EscapeString(ValidationHelper.GetString(value, "")) + "'";
                }

                // Display all contact
                DataTable contacts = contactsView.ToTable(false, "ContactFullNameJoined");
                foreach (DataRow contactRow in contacts.Rows)
                {
                    output += "<div>&nbsp;-&nbsp;" + HTMLHelper.HTMLEncode(ValidationHelper.GetString(contactRow["ContactFullNameJoined"], "").Trim()) + "</div>";
                }
                output += "</div>";
            }
        }

        return(output);
    }
Exemplo n.º 18
0
 /// <summary>
 /// Returns the state with the specified code name.
 /// </summary>
 /// <param name="stateName">The code name of the state.</param>
 /// <returns>The state with the specified code name, if found; otherwise, null.</returns>
 public StateInfo GetState(string stateName)
 {
     return(StateInfoProvider.GetStateInfo(stateName));
 }
Exemplo n.º 19
0
    /// <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 += "&nbsp;-&nbsp;" + HTMLHelper.HTMLEncode(((string)row["AccountName"]).Trim()) + "<br />";
                }
            }
        }
    }
Exemplo n.º 20
0
    /// <summary>
    /// Fills tooltip with appropriate data.
    /// </summary>
    private string FillTooltipData(DataTable dt, string fieldName, string fieldValue, string dataType)
    {
        var output = String.Empty;

        // Insert header into tooltip with parent value
        if (!String.IsNullOrEmpty(fieldValue))
        {
            output += "<em>" + GetString("om.account.parentvalue") + "</em> ";

            // Datetime values
            if (dataType == FieldDataType.DateTime)
            {
                output += "<strong>" + ValidationHelper.GetDateTime(fieldValue, DateTimeHelper.ZERO_TIME) + "</strong>";
            }
            else
            {
                // Country
                if (fieldName == "AccountCountryID")
                {
                    CountryInfo country = CountryInfoProvider.GetCountryInfo(ValidationHelper.GetInteger(fieldValue, 0));
                    if (country != null)
                    {
                        output += "<strong>" + HTMLHelper.HTMLEncode(country.CountryDisplayName) + "</strong>";
                    }
                    else
                    {
                        output += GetString("general.na");
                    }
                }
                // State
                else if (fieldName == "AccountStateID")
                {
                    StateInfo state = StateInfoProvider.GetStateInfo(ValidationHelper.GetInteger(fieldValue, 0));
                    if (state != null)
                    {
                        output += "<strong>" + HTMLHelper.HTMLEncode(state.StateDisplayName) + "</strong>";
                    }
                    else
                    {
                        output += GetString("general.na");
                    }
                }
                // Status
                else if (fieldName == "AccountStatusID")
                {
                    AccountStatusInfo status = AccountStatusInfoProvider.GetAccountStatusInfo(ValidationHelper.GetInteger(fieldValue, 0));
                    if (status != null)
                    {
                        output += "<strong>" + HTMLHelper.HTMLEncode(status.AccountStatusDisplayName) + "</strong>";
                    }
                    else
                    {
                        output += GetString("general.na");
                    }
                }
                // Otherwise
                else
                {
                    output += "<strong>" + HTMLHelper.HTMLEncode(fieldValue) + "</strong>";
                }
            }
        }
        else
        {
            output += "<em>" + GetString("om.account.parentvalue") + "</em> " + GetString("general.na");
        }
        output += "<br /><br /><em>" + GetString("om.account.mergedvalues") + "</em><br />";

        // Display N/A for empty merged records
        if (DataHelper.DataSourceIsEmpty(dt))
        {
            output += "<br /> " + GetString("general.na");
        }
        // Display values of merged records
        else
        {
            // Loop through all distinct values of given column
            foreach (DataRow dr in dt.Rows)
            {
                output += "<br />";

                // Sort accounts by full name
                var accountsView = mMergedAccounts.Tables[0].DefaultView;
                accountsView.Sort = "AccountName";

                mMergedAccounts.CaseSensitive = true;

                var value = dr[fieldName];

                // Need to transform status ID to displayname
                if (fieldName == "AccountStatusID")
                {
                    AccountStatusInfo status = AccountStatusInfoProvider.GetAccountStatusInfo((int)value);
                    output += GetTooltipItem(ResHelper.LocalizeString(status.AccountStatusDisplayName));
                    accountsView.RowFilter = fieldName + " = '" + status.AccountStatusID + "'";
                }
                // Need to transform country ID to displayname
                else if (fieldName == "AccountCountryID")
                {
                    CountryInfo country = CountryInfoProvider.GetCountryInfo((int)value);
                    output += GetTooltipItem(country.CountryDisplayName);
                    accountsView.RowFilter = fieldName + " = '" + country.CountryID + "'";
                }
                // Need to transform state ID to displayname
                else if (fieldName == "AccountStateID")
                {
                    StateInfo state = StateInfoProvider.GetStateInfo((int)value);
                    output += GetTooltipItem(state.StateDisplayName);
                    accountsView.RowFilter = fieldName + " = '" + state.StateID + "'";
                }
                // Other fields, process based on field type
                else
                {
                    output += GetTooltipItem(ValidationHelper.GetString(value, null));
                    accountsView.RowFilter = fieldName + " = '" + ContactHelper.EscapeString((string)value) + "'";
                }

                // Display all accounts
                var accounts = accountsView.ToTable(false, "AccountName");
                foreach (DataRow row in accounts.Rows)
                {
                    output += "&nbsp;-&nbsp;" + HTMLHelper.HTMLEncode(((string)row["AccountName"]).Trim()) + "<br />";
                }
            }
        }

        return(output);
    }