Esempio n. 1
0
        private bool LookupCities()
        {
            bool lookedUp = false;

            dnlCity.Items.Clear();
            IShippingProvider provider = ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                var lookupResults = provider.GetCitiesForState(
                    ProductsBase.CountryCode, ProductsBase.CountryCode);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    foreach (var city in lookupResults)
                    {
                        dnlCity.Items.Add(new ListItem(city));
                    }
                    dnlCity.Items.Insert(
                        0, new ListItem(GetLocalResourceObject("Select") as string, string.Empty));
                    dnlCity.SelectedIndex = 0;
                    lookedUp = true;
                }
            }
            return(lookedUp);
        }
        /// <summary>
        ///     Gets the cities from service.
        /// </summary>
        /// <returns>Success flag.</returns>
        private bool LookupCities()
        {
            dnlCity.Items.Clear();
            IShippingProvider provider =
                ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                // For Serbia, state code is same as country code in db
                var lookupResults = provider.GetCitiesForState(ProductsBase.CountryCode, ProductsBase.CountryCode);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    foreach (var cityZip in lookupResults)
                    {
                        // value is postal code, text is city name
                        dnlCity.Items.Add(new RadComboBoxItem(cityZip.Split(',')[1],
                                                              cityZip.Split(',')[0]));
                    }
                    dnlCity.Items.Insert(0, new RadComboBoxItem(GetLocalResourceObject("Select") as string, string.Empty));
                    dnlCity.SelectedIndex = 0;
                    return(true);
                }
            }
            return(false);
        }
        private bool LookupCities(string state)
        {
            bool lookedUp = false;

            ddlCity.Items.Clear();
            IShippingProvider provider = ShippingProvider.
                                         GetShippingProvider(_countryCode);

            if (provider != null)
            {
                if (!state.Equals(string.Empty))
                {
                    List <string> lookupResults = provider.GetCitiesForState(_countryCode, state);
                    if (null != lookupResults && lookupResults.Count > 0)
                    {
                        for (int i = 0; i < lookupResults.Count; i++)
                        {
                            ddlCity.Items.Insert(i, new ListItem(lookupResults[i]));
                        }
                        ddlCity.Items.Insert(0,
                                             new ListItem(base.GetLocalResourceObject("Select") as string, string.Empty));
                        ddlCity.SelectedIndex = 0;
                        lookedUp = true;
                    }
                }
            }

            return(lookedUp);
        }
        /// <summary>
        ///     Get the cities of a state from provider.
        /// </summary>
        /// <param name="state">State name.</param>
        /// <returns>Success flag.</returns>
        private bool LookupCities(string state)
        {
            bool lookedUp = false;

            dnlCity.Items.Clear();
            dnlPostCode.Items.Clear();
            IShippingProvider provider =
                ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                var lookupResults = provider.GetCitiesForState(ProductsBase.CountryCode, state);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    var items = (from s in lookupResults select new ListItem {
                        Text = s, Value = s
                    }).ToArray();
                    dnlCity.Items.AddRange(items);
                    dnlCity.Items.Insert(0, new ListItem(GetLocalResourceObject("Select") as string, string.Empty));
                    dnlCity.SelectedIndex = 0;
                    lookedUp = true;
                }
                else
                {
                    dnlState.Focus();
                }
            }
            return(lookedUp);
        }
Esempio n. 5
0
        /// <scess flag.ummary>
        ///     Gets the localities for a city from service.
        ///     </summary>
        ///     <param name="city">City name.</param>
        ///     <returns>Succes flag.</returns>
        private bool LookupLocalities(string city)
        {
            bool lookedUp = false;

            dnlLocality.Items.Clear();
            dnlStreetType.Items.Clear();
            dnlStreet.Items.Clear();
            dnlStreet.Text = string.Empty;
            dnlPostCode.Items.Clear();
            IShippingProvider provider =
                ShippingProvider.GetShippingProvider(ProductsBase.CountryCode);

            if (provider != null)
            {
                // We use the city field from service to store the locality info
                var lookupResults = provider.GetCitiesForState(ProductsBase.CountryCode, city);
                if (lookupResults != null && lookupResults.Count > 0)
                {
                    foreach (var locality in lookupResults)
                    {
                        dnlLocality.Items.Add(new ListItem(locality));
                    }
                    dnlLocality.Items.Insert(0,
                                             new ListItem(base.GetLocalResourceObject("Select") as string, string.Empty));
                    dnlLocality.SelectedIndex = 0;
                    lookedUp = true;
                }
                else
                {
                    dnlCity.Focus();
                }
            }
            return(lookedUp);
        }