Beispiel #1
0
 private void FillingTrain()
 {
     foreach (Train dr in TrainDAL.GetAllTrains())
     {
         cbTrain.Items.Add(dr.TrainNumber);
     }
 }
 private void TrainsFilling()
 {
     foreach (Train dr in TrainDAL.GetAllTrains())
     {
         cbTripsTrain.Items.Add(dr.TrainNumber);
     }
     cbTripsTrain.SelectedIndex = 0;
 }
 private void VisibleTrain()
 {
     lbRTPassport.Text                 = "Номер поезда";
     dgvRT.Columns[0].HeaderText       = "Номер поезда";
     dgvRT.Columns[0].DataPropertyName = "TrainNumber";
     dgvRT.Columns[0].Name             = "TrainNumber";
     dgvRT.DataSource = TrainDAL.GetAllTrains();
 }
Beispiel #4
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);
        }
        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();
        }
        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();
            }
        }
        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);
            }
        }
 private void DelTrains(int id)
 {
     TrainDAL.Delete(id);
     dgvRT.DataSource = TrainDAL.GetAllTrains();
 }