Exemplo n.º 1
0
        private void NewData_DGV_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            if (TableName == "Маршруты")
            {
                for (int i = 0; i < NewData_DGV.ColumnCount; i++)
                {
                    if (i == (int)RoutesColumnsIndexes.TrainName)
                    {
                        DataGridViewComboBoxCell CB_cell = new DataGridViewComboBoxCell
                        {
                            DataSource    = Presenter.GetAllNames("SELECT Название FROM Поезда"),
                            ValueMember   = "Name",
                            DisplayMember = "Name"
                        };

                        NewData_DGV.Rows[NewData_DGV.RowCount - 1].Cells[i] = CB_cell;
                    }
                    else if (i == (int)RoutesColumnsIndexes.FistStopName || i == (int)RoutesColumnsIndexes.LastStopName)
                    {
                        DataGridViewComboBoxCell CB_cell = new DataGridViewComboBoxCell
                        {
                            DataSource    = Presenter.GetAllNames("SELECT Название FROM Остановки"),
                            ValueMember   = "Name",
                            DisplayMember = "Name"
                        };

                        NewData_DGV.Rows[NewData_DGV.RowCount - 1].Cells[i] = CB_cell;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void Update_Form_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < DGV_row.Count; i++)
            {
                Updatable_DGV.Columns.Add(DGV_header[i], DGV_header[i]);
                NewData_DGV.Columns.Add(DGV_header[i], DGV_header[i]);
            }
            NewData_DGV.Rows.Add();

            switch (SelectedOption)
            {
            case "Update":
                for (int i = 0; i < DGV_row.Count; i++)
                {
                    Updatable_DGV.Rows[0].Cells[i].Value = DGV_row[i];
                    NewData_DGV.Rows[0].Cells[i].Value   = DGV_row[i];
                }
                OperationOption_lbl.Text       = "Изменить строку";
                NewData_DGV.AllowUserToAddRows = false;
                OperationRun_button.Text       = "Изменить";
                //
                if (TableName == "Маршруты")
                {
                    for (int i = 0; i < (int)RoutesColumnsIndexes.DepartmentTime; i++)
                    {
                        if (i == (int)RoutesColumnsIndexes.TrainName)
                        {
                            DataGridViewComboBoxCell CB_cell = new DataGridViewComboBoxCell
                            {
                                DataSource    = Presenter.GetAllNames("SELECT Название FROM Поезда"),
                                ValueMember   = "Name",
                                DisplayMember = "Name"
                            };
                            NewData_DGV.Rows[0].Cells[i]       = CB_cell;
                            NewData_DGV.Rows[0].Cells[i].Value = DGV_row[i];
                        }
                        else if (i == (int)RoutesColumnsIndexes.FistStopName || i == (int)RoutesColumnsIndexes.LastStopName)
                        {
                            DataGridViewComboBoxCell CB_cell = new DataGridViewComboBoxCell
                            {
                                DataSource    = Presenter.GetAllNames("SELECT Название FROM Остановки"),
                                ValueMember   = "Name",
                                DisplayMember = "Name"
                            };

                            NewData_DGV.Rows[0].Cells[i]       = CB_cell;
                            NewData_DGV.Rows[0].Cells[i].Value = DGV_row[i];
                        }
                    }
                }
                //
                break;

            case "Add":
                Updatable_DGV.Hide();
                OperationOption_lbl.Hide();
                OperationOption2_lbl.Text = "Добавить строки";
                NewData_DGV.Rows.Clear();
                OperationRun_button.Text = "Добавить";
                break;

            default:
                Close();
                break;
            }

            NewData_DGV.Columns[0].Visible   = false;
            NewData_DGV.ReadOnly             = false;
            Updatable_DGV.Columns[0].Visible = false;
        }