private void btnDelTableRow_Click(object sender, EventArgs e)
 {
     if (btnDelTableRow.Text == "Изменить")
     {
         ChangeTableCell();
     }
     else
     {
         TrainTableDAL.Delete((dgvTable.SelectedCells[0].OwningRow.DataBoundItem as TrainTable).Id_Table);
         dgvTable.DataSource = TrainTableDAL.GetAllTrainTables();
         MessageBox.Show("Строка удалена");
     }
 }
 private void DataGridVeiwFilling()
 {
     dgvRT.AutoGenerateColumns      = false;
     dgvRT.DataSource               = PassengerDAL.GetAllPassengers();
     dgvTable.AutoGenerateColumns   = false;
     dgvTable.DataSource            = TrainTableDAL.GetAllTrainTables();
     dgvCT.AutoGenerateColumns      = false;
     dgvCT.DataSource               = CanceledTripDAL.GetAllCancelledTrips();
     dgvTrips.AutoGenerateColumns   = false;
     dgvTrips.DataSource            = TripDAL.GetAllTrips();
     dgvTickets.AutoGenerateColumns = false;
     dgvTickets.DataSource          = TicketDAL.GetAllTickets();
 }
        private void ChangeTableCell()
        {
            string        type  = dgvTable.SelectedCells[0].OwningColumn.Name;
            string        value = dgvTable.SelectedCells[0].Value.ToString();
            int           id    = (dgvTable.SelectedCells[0].OwningRow.DataBoundItem as TrainTable).Id_Table;
            fmChangeTable f     = new fmChangeTable(type, value, id);

            f.Text = dgvTable.SelectedCells[0].OwningColumn.HeaderText;
            if (f.ShowDialog() == DialogResult.OK)
            {
                MessageBox.Show("Значение изменено");
                dgvTable.DataSource = TrainTableDAL.GetAllTrainTables();
            }
        }
        private void SearchTableByStations()
        {
            int IdDepartureStation = cbTableDS.SelectedIndex != 0  ? StationDAL.GetStationByName(cbTableDS.Text).Id_Station : 0;
            int IdArrivalStation   = cbTableAS.SelectedIndex != 0 ? StationDAL.GetStationByName(cbTableAS.Text).Id_Station : 0;

            if (cbTableDS.SelectedIndex != 0 && cbTableAS.SelectedIndex != 0)
            {
                dgvTable.DataSource = TrainTableDAL.GetTrainTablesByStation(IdDepartureStation, IdArrivalStation);
                return;
            }
            if (cbTableAS.SelectedIndex != 0)
            {
                dgvTable.DataSource = TrainTableDAL.GetTrainTablesByAStation(IdArrivalStation);
                return;
            }
            if (cbTableDS.SelectedIndex != 0)
            {
                dgvTable.DataSource = TrainTableDAL.GetTrainTablesByDStation(IdDepartureStation);
                return;
            }
            dgvTable.DataSource = TrainTableDAL.GetAllTrainTables();
        }