Esempio n. 1
0
        private static List <Trip> GetTripsListFromDataReader(SqlDataReader reader)
        {
            List <Trip> result = new List <Trip>();

            while (reader.Read())
            {
                Driver dr  = DriverDAL.GetDriverById(reader.GetInt32(2));
                string fio = dr.Surname + " " + dr.Name[0] + "." + " " + dr.Patronymic[0] + ".";
                Trip   t   = new Trip()
                {
                    Id_Trip           = reader.GetInt32(0),
                    Id_Id_Table       = reader.GetInt32(1),
                    DStation          = TrainTableDAL.GetTrainTableById(reader.GetInt32(1)).DepartureStation,
                    AStation          = TrainTableDAL.GetTrainTableById(reader.GetInt32(1)).ArrivalStation,
                    Id_id_driver      = reader.GetInt32(2),
                    Driver            = fio,
                    Id_id_train       = reader.GetInt32(3),
                    TrainNum          = TrainDAL.GetTrainById(reader.GetInt32(3)).TrainNumber,
                    RealDepartureDate = reader.GetDateTime(4).ToShortDateString(),
                    RealDepartureTime = reader.GetValue(5).ToString(),
                    RealArrivalDate   = reader.GetDateTime(6).ToShortDateString(),
                    RealArrivalTime   = reader.GetValue(7).ToString(),
                };
                result.Add(t);
            }
            return(result);
        }
Esempio n. 2
0
 private void FillingTrain()
 {
     foreach (Train dr in TrainDAL.GetAllTrains())
     {
         cbTrain.Items.Add(dr.TrainNumber);
     }
 }
Esempio n. 3
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            Passenger          p = new Passenger();
            Station            s = new Station();
            Driver             d = new Driver();
            Train              t = new Train();
            CancellationReason c = new CancellationReason();

            if (TableType.Equals(p.GetType()))
            {
                UpdatePassenger(tbNewValue.Text);
            }
            if (TableType.Equals(s.GetType()))
            {
                UpdateStation(tbNewValue.Text);
            }
            if (TableType.Equals(d.GetType()))
            {
                UpdateDriver(tbNewValue.Text);
            }
            if (TableType.Equals(t.GetType()))
            {
                TrainDAL.UpdateTrainNum(tbNewValue.Text, Id);
            }
            if (TableType.Equals(c.GetType()))
            {
                CancellationReasonDAL.UpdateCancellationReason(tbNewValue.Text, Id);
            }
        }
Esempio n. 4
0
 private void TrainsFilling()
 {
     foreach (Train dr in TrainDAL.GetAllTrains())
     {
         cbTripsTrain.Items.Add(dr.TrainNumber);
     }
     cbTripsTrain.SelectedIndex = 0;
 }
Esempio n. 5
0
 private void VisibleTrain()
 {
     lbRTPassport.Text                 = "Номер поезда";
     dgvRT.Columns[0].HeaderText       = "Номер поезда";
     dgvRT.Columns[0].DataPropertyName = "TrainNumber";
     dgvRT.Columns[0].Name             = "TrainNumber";
     dgvRT.DataSource = TrainDAL.GetAllTrains();
 }
Esempio n. 6
0
        /*private void AddSoftCount(int idAddedTrip)
         * {
         *  int cnt = int.Parse(numericUpDown1.Value.ToString());
         *  foreach (CarriageType t in CarriageTypeDAL.GetAllCarriageTypes())
         *  {
         *      if (t.Type.Trim() == CarriageTypeConst.Soft) Trip_CarriageDAL.Insert(t.Id_CarriageType, idAddedTrip, cnt);
         *  }
         * }
         *
         * private void AddCoupeCount(int idAddedTrip)
         * {
         *  int cnt = int.Parse(numericUpDown2.Value.ToString());
         *  foreach (CarriageType t in CarriageTypeDAL.GetAllCarriageTypes())
         *  {
         *      if (t.Type.Trim() == CarriageTypeConst.Coupe)Trip_CarriageDAL.Insert(t.Id_CarriageType, idAddedTrip, cnt);
         *  }
         * }
         *
         * private void AddLuxCount(int idAddedTrip)
         * {
         *  int cnt = int.Parse(numericUpDown3.Value.ToString());
         *  foreach (CarriageType t in CarriageTypeDAL.GetAllCarriageTypes())
         *  {
         *      if (t.Type.Trim() == CarriageTypeConst.Lux)Trip_CarriageDAL.Insert(t.Id_CarriageType, idAddedTrip, cnt);
         *  }
         * }
         *
         * private void AddSittingCount(int idAddedTrip)
         * {
         *  int cnt = int.Parse(numericUpDown4.Value.ToString());
         *  foreach (CarriageType t in CarriageTypeDAL.GetAllCarriageTypes())
         *  {
         *      if (t.Type.Trim() == CarriageTypeConst.Sitting)Trip_CarriageDAL.Insert(t.Id_CarriageType, idAddedTrip, cnt);
         *  }
         * }
         *
         * private void AddReserverSeatCount(int idAddedTrip)
         * {
         *  int cnt = int.Parse(numericUpDown5.Value.ToString());
         *  foreach (CarriageType t in CarriageTypeDAL.GetAllCarriageTypes())
         *  {
         *      if (t.Type.Trim() == CarriageTypeConst.ReserverSeat)Trip_CarriageDAL.Insert(t.Id_CarriageType, idAddedTrip, cnt);
         *  }
         * }
         *
         * private void AddCarriageCount()
         * {
         *  int id = TripDAL.GetAllTrips()[TripDAL.GetAllTrips().Count - 1].Id_Trip;
         *  AddCoupeCount(id);
         *  AddLuxCount(id);
         *  AddReserverSeatCount(id);
         *  AddSittingCount(id);
         *  AddSoftCount(id);
         * }*/

        private void InsertTrip()
        {
            int    driver        = DriverDAL.GetAllDrivers()[cbDriver.SelectedIndex].Id_Driver;
            int    train         = TrainDAL.GetAllTrains()[cbTrain.SelectedIndex].Id_Train;
            string departureDate = dtpDate1.Text;
            string departureTime = dtpTime1.Text;
            string arrivalDate   = dtpDate2.Text;
            string arrivalTime   = dtpTime2.Text;

            TripDAL.Insert(Id_Table, driver, train, departureDate, departureTime, arrivalDate, arrivalTime);
        }
Esempio n. 7
0
        private void AddTrains()
        {
            if (String.IsNullOrEmpty(tbRTPassport.Text))
            {
                MessageBox.Show("Введите номер поезда!");
                return;
            }
            int number = int.Parse(tbRTPassport.Text);

            TrainDAL.Insert(number);
            dgvRT.DataSource = TrainDAL.GetAllTrains();
            ClearText();
        }
Esempio n. 8
0
        private void updateTrain()
        {
            string          type      = dgvRT.SelectedCells[0].OwningColumn.Name;
            string          value     = dgvRT.SelectedCells[0].Value.ToString();
            Type            typeTable = dgvRT.SelectedCells[0].OwningRow.DataBoundItem.GetType();
            int             id        = (dgvRT.SelectedCells[0].OwningRow.DataBoundItem as Train).Id_Train;
            fmChangeValueRT f         = new fmChangeValueRT(type, value, id, typeTable);

            f.Text = dgvRT.SelectedCells[0].OwningColumn.HeaderText;
            if (f.ShowDialog() == DialogResult.OK)
            {
                MessageBox.Show("Значение изменено");
                dgvRT.DataSource = TrainDAL.GetAllTrains();
            }
        }
Esempio n. 9
0
        private void SearchByDriverAndTrain()
        {
            int idDriver = cbTripsDriver.SelectedIndex != 0 ? DriverDAL.GetAllDrivers()[cbTripsDriver.SelectedIndex].Id_Driver: 0;
            int idTrain  = cbTripsTrain.SelectedIndex != 0? idTrain = TrainDAL.GetAllTrains()[cbTripsTrain.SelectedIndex].Id_Train : 0;

            if (cbTripsDriver.SelectedIndex != 0 && cbTripsTrain.SelectedIndex != 0)
            {
                dgvTrips.DataSource = TripDAL.GetTripsByDriverAndTrain(idDriver, idTrain);
            }
            if (cbTripsTrain.SelectedIndex != 0)
            {
                dgvTrips.DataSource = TripDAL.GetTripsByTrain(idTrain);
            }
            if (cbTripsDriver.SelectedIndex != 0)
            {
                dgvTrips.DataSource = TripDAL.GetTripsByDriver(idDriver);
            }
        }
Esempio n. 10
0
 private void DelTrains(int id)
 {
     TrainDAL.Delete(id);
     dgvRT.DataSource = TrainDAL.GetAllTrains();
 }