Example #1
0
        private void PlaneEdit_Load(object sender, EventArgs e)
        {
            AircompaniesList _aclist = AircompaniesList.GetRefAircompaniesList();

            if (_aclist.Count == 0)
            {
                MessageBox.Show("Ні одної авіакомпанії не знайдено. Добавте їх або зверніться до адміністратора.", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            else
            {
                //airCompanycomboBox.SelectedValue = plane.PlaneAircompanyID;
                airCompanycomboBox.DataSource = _aclist;

                airCompanycomboBox.DisplayMember = "AircompanyName";
                airCompanycomboBox.ValueMember   = "AircompanyID";

                planeNumberTextbox.Text = plane.PlaneNumber;
                modeltextBox.Text       = plane.PlaneModel;
                if (act == Action.Update)
                {
                    airCompanycomboBox.SelectedValue = plane.PlaneAircompanyID;
                    if (Config.HasUserAccess("UpdatePlane"))
                    {
                        OKbutton.Visible = true;
                    }
                    else
                    {
                        OKbutton.Visible = false;
                    }
                }
            }
        }
Example #2
0
        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;
                }
            }
        }