/// <summary> /// Gets the districts from provider /// </summary> /// <param name="city">The city</param> /// <param name="suburb">The suburb</param> private void LookupDistricts(string city, string suburb) { ddlDistrict.Items.Clear(); ddlDistrict.SelectedIndex = -1; ddlDistrict.SelectedValue = null; ddlDistrict.ClearSelection(); txtPostalCode.Text = string.Empty; if (string.IsNullOrEmpty(city)) { return; } suburb = (selectText == suburb) ? string.Empty : suburb; var provider = new ShippingProvider_HU(); var lookupResults = provider.GetDistrictsForCity(ProductsBase.CountryCode, city, suburb); if (lookupResults != null && lookupResults.Count > 0) { lookupResults.Remove(selectText); if (lookupResults.Count > 1) { lookupResults.Insert(0, selectText); } ddlDistrict.DataSource = lookupResults; ddlDistrict.DataBind(); ddlDistrict.SelectedIndex = 0; if (lookupResults.Count == 1) { ddlDistrict_SelectedIndexChanged(ddlDistrict, null); } if (lookupResults.Count > 0) { ddlDistrict.Visible = true; txtDistrict.Visible = false; } } else { ddlDistrict.Visible = false; txtDistrict.Visible = true; ddlStreet.Visible = false; txtStreet.Visible = true; ddlStreetType.Visible = false; txtStreetType.Visible = true; } //if (ddlDistrict.SelectedValue == string.Empty) //{ // LookupStreets(city, suburb, string.Empty); //} }
private void LookupStreets(string city, string suburb, string district) { ddlStreetType.Items.Clear(); ddlStreetType.SelectedIndex = -1; ddlStreetType.SelectedValue = null; ddlStreetType.ClearSelection(); txtPostalCode.Text = string.Empty; ddlStreet.Items.Clear(); ddlStreet.SelectedIndex = -1; ddlStreet.SelectedValue = null; ddlStreet.ClearSelection(); var provider = new ShippingProvider_HU(); var lookupResults = provider.GetStreets(ProductsBase.CountryCode, city, suburb, district); if (lookupResults != null && lookupResults.Count > 0) { lookupResults.Remove("^"); lookupResults.Remove(selectText); if (lookupResults.Count > 0) { ddlStreet.Visible = true; txtStreet.Visible = false; if (lookupResults.Count > 1) { lookupResults.Insert(0, selectText); } ddlStreet.DataSource = lookupResults; ddlStreet.DataBind(); ddlStreet.SelectedIndex = 0; if (lookupResults.Count == 1) { ddlStreet_SelectedIndexChanged(ddlStreet, null); } } } else { ddlStreet.Visible = false; txtStreet.Visible = true; } if (ddlStreet.SelectedValue == string.Empty) { LookupStreetTypes(city, suburb, district, string.Empty); } }
/// <summary> /// Get the suburbs from provider /// </summary> /// <param name="city">The city</param> private void LookupSuburbs(string city) { ddlDistrict.Items.Clear(); ddlSuburb.Items.Clear(); ddlSuburb.SelectedIndex = -1; ddlSuburb.SelectedValue = null; ddlSuburb.ClearSelection(); ddlStreet.Items.Clear(); ddlStreetType.Items.Clear(); var provider = new ShippingProvider_HU(); var lookupResults = provider.GetSuburbsForCity(ProductsBase.CountryCode, city); if (lookupResults != null && lookupResults.Count > 0) { lookupResults.Remove(selectText); if (lookupResults[0] == string.Empty) { lookupResults.Remove(string.Empty); lookupResults.Insert(0, Dashes); } lookupResults.Insert(0, selectText); ddlSuburb.DataSource = lookupResults; ddlSuburb.DataBind(); ddlSuburb.ClearSelection(); ddlSuburb.Items[0].Selected = true; ddlSuburb.Visible = true; txtSuburb.Visible = false; } else { ddlSuburb.Visible = false; txtSuburb.Visible = true; ddlDistrict.Visible = false; txtDistrict.Visible = true; LookupDistrictsAndSetUp(city, string.Empty); } //if (ddlSuburb.SelectedValue == string.Empty) //{ // LookupStreets(city, string.Empty, string.Empty); //} }