private void cSuggestionList_SelectionChanged(object sender, SelectionChangedEventArgs e) { string name = null; int country_position = 0; int city_position = 0; int index; int address_id; addressConnection = new AddressConnection(); DataSet ds; if (cSuggestionList.ItemsSource != null) { cSuggestionList.Visibility = System.Windows.Visibility.Collapsed; clubName.TextChanged -= new TextChangedEventHandler(clubName_TextChanged); index = cSuggestionList.SelectedIndex; if (cSuggestionList.SelectedIndex != -1) { name = cSuggestionList.SelectedItem.ToString(); address_id = int.Parse(filteredClubs.Tables[0].Rows[index][5].ToString()); this.clubName.Text = filteredClubs.Tables[0].Rows[index][1].ToString(); this.clubPhone.Text = filteredClubs.Tables[0].Rows[index][2].ToString(); this.clubEmail.Text = filteredClubs.Tables[0].Rows[index][3].ToString(); ds = addressConnection.getAddress(address_id); this.clubAddress.Text = ds.Tables[0].Rows[0][1].ToString(); this.clubAddressNum.Text = ds.Tables[0].Rows[0][2].ToString(); this.clubTK.Text = ds.Tables[0].Rows[0][4].ToString(); string clubCity = ds.Tables[0].Rows[0][3].ToString(); int ix = ds.Tables[0].Columns.Count; string clubCountry = ds.Tables[0].Rows[0][5].ToString(); // //the fix for the country selection error // CountryConnection countryconn = new CountryConnection(); DataSet countriname = countryconn.getCountryNameByCode(clubCountry); clubCountry = countriname.Tables[0].Rows[0][0].ToString(); for (int i = 0; i < this.cmbCCountryChooses.Items.Count; i++) { if (clubCountry.Equals(cmbCCountryChooses.Items[i].ToString())) { country_position = i; break; } } this.cmbCCountryChooses.SelectedIndex = country_position; CityConnection cityConnection = new CityConnection(); DataSet cityNa = cityConnection.GetCityNameByCityId(int.Parse(clubCity)); clubCity = cityNa.Tables[0].Rows[0][0].ToString(); for (int i = 0; i < this.cmbCCityChooses.Items.Count; i++) { if (clubCity.Equals(cmbCCityChooses.Items[i].ToString())) { city_position = i; break; } } this.cmbCCityChooses.SelectedIndex = city_position; } clubName.TextChanged += new TextChangedEventHandler(clubName_TextChanged); } //this.sugestioListScroler.Visibility = System.Windows.Visibility.Hidden; }
private void clubUpdateCities(string countryCode) { CityConnection citiesconn = new CityConnection(); this.cities = citiesconn.GetCities(countryCode); //cmbACityChooses = new ComboBox(); int count = cmbCCityChooses.Items.Count; for (int i = 0; i < count; i++) { cmbCCityChooses.Items.RemoveAt(0); } foreach (DataRow dr in cities.Tables[0].Rows) { cmbCCityChooses.Items.Add(dr[1].ToString()); } cmbCCityChooses.SelectedIndex = 0; //deixnei poio tha einai to proepilegmeno cmbCCityChooses.Items.Refresh(); }