Пример #1
0
        private void ConditionControlDeleted(object sender, EventArgs e)
        {
            FlightCrewRecordControl control = (FlightCrewRecordControl)sender;
            FlightCrewRecord        cond    = control.FlightCrewRecord;

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

                flowLayoutPanelMain.Controls.Remove(control);
                control.Deleted           -= ConditionControlDeleted;
                control.CrewMemberChanged -= CrewMemberChanged;
                control.Dispose();
                InvokeCrewChanged();
            }
            else if (cond.ItemId <= 0)
            {
                flowLayoutPanelMain.Controls.Remove(control);
                control.Deleted           -= ConditionControlDeleted;
                control.CrewMemberChanged -= CrewMemberChanged;
                control.Dispose();
                InvokeCrewChanged();
            }
        }
Пример #2
0
        private void LinkLabelAddNewLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            FlightCrewRecordControl performance =
                new FlightCrewRecordControl(new FlightCrewRecord {
                FlightId = Flight.ItemId
            });

            performance.Deleted           += ConditionControlDeleted;
            performance.CrewMemberChanged += CrewMemberChanged;
            if (flowLayoutPanelMain.Controls.Count > 1)
            {
                performance.ShowHeaders = false;
            }
            flowLayoutPanelMain.Controls.Remove(panelAdd);
            flowLayoutPanelMain.Controls.Add(performance);
            flowLayoutPanelMain.Controls.Add(panelAdd);
            performance.Focus();
        }
Пример #3
0
        /*
         * Реализация
         */

        #region private void BuildControls()
        /// <summary>
        /// Строит нужные контролы
        /// </summary>
        private void BuildControls()
        {
            // Освобождаем старые контролы
            flowLayoutPanelMain.Controls.Clear();

            if (Flight != null && Flight.FlightCrewRecords != null)
            {
                for (int i = 0; i < Flight.FlightCrewRecords.Count; i++)
                {
                    // Добавляем контрол для ввода данных по маслу
                    FlightCrewRecordControl c = new FlightCrewRecordControl(Flight.FlightCrewRecords[i]);
                    c.Deleted           += ConditionControlDeleted;
                    c.CrewMemberChanged += CrewMemberChanged;
                    if (i > 0)
                    {
                        c.ShowHeaders = false;
                    }
                    flowLayoutPanelMain.Controls.Add(c);
                }
            }

            flowLayoutPanelMain.Controls.Add(panelAdd);
        }