Exemple #1
0
        private void LinkLabelAddNewLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            PassengerControl performance =
                new PassengerControl(new FlightPassengerRecord {
                FlightId = Flight.ItemId
            });

            performance.Deleted += ConditionControlDeleted;
            performance.PassengerCountChanged    += ControlPassengerCountChanged;
            performance.PassengerCategoryChanged += PassengerCategoryChanged;
            if (flowLayoutPanelMain.Controls.Count > 1)
            {
                performance.ShowHeaders = false;
            }
            flowLayoutPanelMain.Controls.Remove(panelAdd);
            flowLayoutPanelMain.Controls.Add(performance);
            flowLayoutPanelMain.Controls.Add(panelAdd);
            performance.Focus();
        }
Exemple #2
0
        private void ConditionControlDeleted(object sender, EventArgs e)
        {
            PassengerControl      control = (PassengerControl)sender;
            FlightPassengerRecord cond    = control.FlightPassengerRecord;

            if (cond.ItemId > 0 && MessageBox.Show("Do you really want to delete flight passenger record?",
                                                   "Deleting confirmation", MessageBoxButtons.YesNoCancel,
                                                   MessageBoxIcon.Exclamation,
                                                   MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                //если информация о состоянии сохранена в БД
                //и получен положительный ответ на ее удаление
                try
                {
                    GlobalObjects.CasEnvironment.NewKeeper.Delete(cond);
                }
                catch (Exception ex)
                {
                    Program.Provider.Logger.Log("Error while removing data", ex);
                }

                flowLayoutPanelMain.Controls.Remove(control);
                control.Deleted -= ConditionControlDeleted;
                control.PassengerCountChanged    -= ControlPassengerCountChanged;
                control.PassengerCategoryChanged -= PassengerCategoryChanged;
                control.Dispose();
            }
            else if (cond.ItemId <= 0)
            {
                flowLayoutPanelMain.Controls.Remove(control);
                control.Deleted -= ConditionControlDeleted;
                control.PassengerCountChanged    -= ControlPassengerCountChanged;
                control.PassengerCategoryChanged -= PassengerCategoryChanged;
                control.Dispose();
            }
        }
Exemple #3
0
        /*
         * Реализация
         */

        #region private void BuildControls()
        /// <summary>
        /// Строит нужные контролы
        /// </summary>
        private void BuildControls()
        {
            double countEconomy  = 0;
            double countBusiness = 0;
            double countFirst    = 0;

            _maxEconomy  = 0;
            _maxBusiness = 0;
            _maxFirst    = 0;
            // Освобождаем старые контролы
            flowLayoutPanelMain.Controls.Clear();

            if (Flight != null)
            {
                var aircraft = GlobalObjects.AircraftsCore.GetAircraftById(Flight.AircraftId);
                if (aircraft != null)
                {
                    _maxEconomy  = aircraft.SeatingEconomy;
                    _maxBusiness = aircraft.SeatingBusiness;
                    _maxFirst    = aircraft.SeatingFirst;
                }
                if (Flight.FlightPassengerRecords != null)
                {
                    for (int i = 0; i < Flight.FlightPassengerRecords.Count; i++)
                    {
                        // Добавляем контрол для ввода данных по маслу
                        PassengerControl c = new PassengerControl(Flight.FlightPassengerRecords[i]);
                        c.Deleted += ConditionControlDeleted;
                        c.PassengerCountChanged    += ControlPassengerCountChanged;
                        c.PassengerCategoryChanged += PassengerCategoryChanged;
                        if (i > 0)
                        {
                            c.ShowHeaders = false;
                        }
                        flowLayoutPanelMain.Controls.Add(c);

                        countEconomy  += c.CountEconomy;
                        countBusiness += c.CountBusiness;
                        countFirst    += c.CountFirst;
                    }
                }
            }

            flowLayoutPanelMain.Controls.Add(panelAdd);

            double persentEconomy  = _maxEconomy != 0 ? countEconomy / _maxEconomy * 100 : 0;
            double persentBusiness = _maxBusiness != 0 ? (countBusiness / _maxBusiness) * 100 : 0;
            double persentFirst    = _maxFirst != 0 ? (countFirst / _maxFirst) * 100 : 0;
            double countAll        = countFirst + countBusiness + countEconomy;

            _maxAll = _maxEconomy + _maxBusiness + _maxFirst;
            double persentAll = _maxAll != 0 ? (countAll / _maxAll) * 100 : 0;

            textEconomyTotal.Text  = countEconomy.ToString();
            textBusinessTotal.Text = countBusiness.ToString();
            textFirstTotal.Text    = countFirst.ToString();
            textBoxAllTotal.Text   = countAll.ToString();

            textBoxEconomyMax.Text  = _maxEconomy.ToString();
            textBoxBusinessMax.Text = _maxBusiness.ToString();
            textBoxFirstMax.Text    = _maxFirst.ToString();
            textBoxAllMax.Text      = _maxAll.ToString();

            textBoxAllPersents.Text      = persentAll.ToString("F") + " %";
            textBoxEconomyPersents.Text  = persentEconomy.ToString("F") + " %";
            textBoxBusinessPersents.Text = persentBusiness.ToString("F") + " %";
            textBoxFirstPersents.Text    = persentFirst.ToString("F") + " %";
        }