private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { CitiesList cl = CitiesList.GetCitiesListByCountry((int)countryComboBox.SelectedValue); CityComboBox.DataSource = cl; CityComboBox.DisplayMember = "CityName"; CityComboBox.ValueMember = "CityID"; }
private void countrycomboBox_SelectedValueChanged(object sender, EventArgs e) { if (_loaded == true) { int _selectedCountry = (int)countrycomboBox.SelectedValue; CitiesList _citiesList = CitiesList.GetCitiesListByCountry(_selectedCountry); //citycomboBox.DataSource = null; citycomboBox.DisplayMember = "CityName"; citycomboBox.ValueMember = "CityID"; citycomboBox.DataSource = _citiesList; } }
private void addCitiesToComboBox(int CountryID) { CitiesList cl = CitiesList.GetCitiesListByCountry(CountryID); City ci = new City(); ci.CityID = 0; ci.CityName = "Виберіть місто..."; cl.Insert(0, ci); cityComboBox.DataSource = null; //cityComboBox.SelectedItem = null; //cityComboBox.Items.Clear(); cityComboBox.DataSource = cl; cityComboBox.DisplayMember = "CityName"; cityComboBox.ValueMember = "CityID"; }
private void EditFlightForm_Load(object sender, EventArgs e) { //для всіх PlaneList _PlaneList = PlaneList.GetRefPlanesList(); planecomboBox.DataSource = _PlaneList; planecomboBox.DisplayMember = "PlaneNumber"; planecomboBox.ValueMember = "PlaneID"; AircompaniesList _AircompaniesList = AircompaniesList.GetRefAircompaniesList(); aircompanycomboBox.DataSource = _AircompaniesList; aircompanycomboBox.DisplayMember = "AirCompanyName"; aircompanycomboBox.ValueMember = "AirCompanyID"; if (act == Action.Insert) { //для вставки CountriesList _countriesList = CountriesList.GetRefCountriesList(); countrycomboBox.DataSource = _countriesList; countrycomboBox.DisplayMember = "CountryName"; countrycomboBox.ValueMember = "CountryID"; int _selectedCountry = (int)countrycomboBox.SelectedValue; CitiesList _citiesList = CitiesList.GetCitiesListByCountry(_selectedCountry); citycomboBox.DataSource = _citiesList; citycomboBox.DisplayMember = "CityName"; citycomboBox.ValueMember = "CityID"; int _selectedCity = (int)citycomboBox.SelectedValue; AirPortList _airportList = AirPortList.GetRefAirportListByCity(_selectedCity); airportcomboBox.DataSource = _airportList; airportcomboBox.DisplayMember = "AirportName"; airportcomboBox.ValueMember = "AirportID"; flightTypecomboBox.SelectedIndex = 0; _loaded = true; } if (act == Action.Update) { //для оновлення try { aircompanycomboBox.SelectedValue = Flight.FlightAircompanyID; planecomboBox.SelectedValue = Flight.FlightPlaneID; AirPort _apinfo = new AirPort(); _apinfo.GetAirport(Flight.FlightAirPortID); City _City = new City(); _City.GetCity(_apinfo.AirPortCityID); CountriesList _countriesList = CountriesList.GetRefCountriesList(); countrycomboBox.DataSource = _countriesList; countrycomboBox.DisplayMember = "CountryName"; countrycomboBox.ValueMember = "CountryID"; countrycomboBox.SelectedValue = _City.CountryID; CitiesList _citiesList = CitiesList.GetCitiesListByCountry(_City.CountryID); citycomboBox.DataSource = _citiesList; citycomboBox.DisplayMember = "CityName"; citycomboBox.ValueMember = "CityID"; citycomboBox.SelectedValue = _apinfo.AirPortCityID; AirPortList _airportList = AirPortList.GetRefAirportListByCity(_apinfo.AirPortCityID); airportcomboBox.DataSource = _airportList; airportcomboBox.DisplayMember = "AirportName"; airportcomboBox.ValueMember = "AirportID"; airportcomboBox.SelectedValue = _apinfo.AirPortID; if (Flight.FlightType == "Вхідний") { flightTypecomboBox.SelectedIndex = 0; } else if (Flight.FlightType == "Вихідний") { flightTypecomboBox.SelectedIndex = 1; } startdateTimePicker.Value = Flight.FlightDateTimeStart; DateTime _tempDuration = Convert.ToDateTime("1900-01-01 " + Flight.FlightDuration); economnumericUpDown.Value = Flight.FlightPriceEconom; businessnumericUpDown.Value = Flight.FlightPriceBusiness; firstnumericUpDown.Value = Flight.FlightPriceFirst; numOfFlishgslabel.Visible = false; periodicitylabel.Visible = false; numOfFlightsnumericUpDown.Visible = false; periodicitydateTimePicker.Visible = false; if (Config.HasUserAccess("UpdateFlight")) { okButton.Visible = true; } else { okButton.Visible = false; } _loaded = true; } catch (Exception) { _error = true; } } }
private void AirPortEditForm_Load(object sender, EventArgs e) { CountriesList _countries = CountriesList.GetDefaultCountriesList(); countryComboBox.DataSource = _countries; countryComboBox.DisplayMember = "CountryName"; countryComboBox.ValueMember = "CountryID"; //якщо кількість країн рівна нулю if (_countries.Count == 0) { DialogResult di = MessageBox.Show("Список країн пустий, операція неможлива. Зверніться до адміністратора для вирішення даної проблеми.", "Операція неможлива", MessageBoxButtons.OK, MessageBoxIcon.Error); if (di == System.Windows.Forms.DialogResult.OK) { this.Close(); } } //Якщо є інші країни else if (_countries.Count > 0) { /*int countryID = (int)countryComboBox.SelectedValue; * CitiesList _cities = CitiesList.GetCitiesListByCountry(countryID); * CityComboBox.DataSource = _cities; * CityComboBox.DisplayMember = "CityName"; * CityComboBox.ValueMember = "CityID"; */ //для вставки //для оновлення if (act == Action.update) { //місто і країна в яких знаходиться аеропорт Country country = new Country(); City city = new City(); city.GetCity(airport.AirPortCityID); country.GetCountry(city.CountryID); int _selectedCountryID = country.CountryID; int _selectedCityID = city.CityID; //Заповняємо комбобокс містами CitiesList _cities = CitiesList.GetCitiesListByCountry(_selectedCountryID); CityComboBox.DataSource = _cities; CityComboBox.DisplayMember = "CityName"; CityComboBox.ValueMember = "CityID"; countryComboBox.SelectedValue = _selectedCountryID; CityComboBox.SelectedValue = _selectedCityID; airPortNameTextBox.Text = airport.AirPortName; if (Config.HasUserAccess("UpdateAirport")) { OKbutton.Visible = true; } else { OKbutton.Visible = false; } } else if (act == Action.insert) { } } }