private void FillingCancellationReasons()
 {
     foreach (CancellationReason cr in CancellationReasonDAL.GetAllCancellationReasons())
     {
         cbReason.Items.Add(cr.Reason);
     }
 }
Beispiel #2
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);
            }
        }
 private void CancellationReasonsFilling()
 {
     foreach (CancellationReason r in CancellationReasonDAL.GetAllCancellationReasons())
     {
         listBoxCT.Items.Add(r.Reason);
     }
 }
 private void VisibleReason()
 {
     lbRTPassport.Text                 = "Причина";
     dgvRT.Columns[0].HeaderText       = "Причина";
     dgvRT.Columns[0].DataPropertyName = "Reason";
     dgvRT.Columns[0].Name             = "Reason";
     dgvRT.DataSource = CancellationReasonDAL.GetAllCancellationReasons();
 }
        private void AddReasons()
        {
            if (String.IsNullOrEmpty(tbRTPassport.Text))
            {
                MessageBox.Show("Введите причину!");
                return;
            }
            string reason = tbRTPassport.Text;

            CancellationReasonDAL.Insert(reason);
            dgvRT.DataSource = CancellationReasonDAL.GetAllCancellationReasons();
            ClearText();
        }
        private void updateCancellationReason()
        {
            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 CancellationReason).Id_Reason;
            fmChangeValueRT f         = new fmChangeValueRT(type, value, id, typeTable);

            f.Text = dgvRT.SelectedCells[0].OwningColumn.HeaderText;
            if (f.ShowDialog() == DialogResult.OK)
            {
                MessageBox.Show("Значение изменено");
                dgvRT.DataSource = CancellationReasonDAL.GetAllCancellationReasons();
            }
        }
Beispiel #7
0
        private static List <CanceledTrip> GetTripsListFromDataReader(SqlDataReader reader)
        {
            List <CanceledTrip> result = new List <CanceledTrip>();

            while (reader.Read())
            {
                CanceledTrip t = new CanceledTrip()
                {
                    Id_CanceledTrip = reader.GetInt32(0),
                    Reason          = CancellationReasonDAL.GetCancellationReasonById(reader.GetInt32(1)).Reason,
                    Id_id_Trip      = reader.GetInt32(2)
                };
                result.Add(t);
            }
            return(result);
        }
        private void DelCancelledTrip()
        {
            int idCanceledTrip = (dgvCT.SelectedCells[0].OwningRow.DataBoundItem as CanceledTrip).Id_CanceledTrip;

            CanceledTripDAL.Delete(idCanceledTrip);
            if (listBoxCT.SelectedIndex >= 0)
            {
                int idReason = CancellationReasonDAL.GetCancellationReasonByReason(CancellationReasonDAL.GetAllCancellationReasons()[listBoxCT.SelectedIndex].Reason).Id_Reason;
                dgvCT.DataSource = CanceledTripDAL.GetCancelledTripsByReason(idReason);
            }
            else
            {
                dgvCT.DataSource = CanceledTripDAL.GetAllCancelledTrips();
            }
            MessageBox.Show("Строка удалена");
        }
        private void btnAddTrips_Click(object sender, EventArgs e)
        {
            if (!GetReason())
            {
                return;
            }
            if (!GetTrip())
            {
                return;
            }
            int idReason = CancellationReasonDAL.GetAllCancellationReasons()[cbReason.SelectedIndex].Id_Reason;
            int idTrip   = TripDAL.GetAllTrips()[cbNumTrip.SelectedIndex].Id_Trip;

            CanceledTripDAL.Insert(idReason, idTrip);
            DialogResult = DialogResult.OK;
        }
        private void btnCTAdd_Click(object sender, EventArgs e)
        {
            fmAddCancelledtrip f = new fmAddCancelledtrip();

            if (f.ShowDialog() == DialogResult.OK)
            {
                MessageBox.Show("Строка добавлена");
                if (listBoxCT.SelectedIndex >= 0)
                {
                    int idReason = CancellationReasonDAL.GetAllCancellationReasons()[listBoxCT.SelectedIndex].Id_Reason;
                    dgvCT.DataSource = CanceledTripDAL.GetCancelledTripsByReason(idReason);
                }
                else
                {
                    dgvCT.DataSource = CanceledTripDAL.GetAllCancelledTrips();
                }
            }
        }
 public fmChangeCancelledTrip(string TypeV, string Value, int id)
 {
     InitializeComponent();
     Type         = TypeV;
     Id           = id;
     tbValue.Text = Value;
     if (Type == CancelledTripConst.Id_canTrip)
     {
         foreach (Trip tr in TripDAL.GetAllTrips())
         {
             cbNewV.Items.Add(tr.Id_Trip);
         }
     }
     else
     {
         foreach (CancellationReason cr in CancellationReasonDAL.GetAllCancellationReasons())
         {
             cbNewV.Items.Add(cr.Reason);
         }
     }
 }
        private void btnChange_Click_1(object sender, EventArgs e)
        {
            string txt    = cbNewV.Text;
            int    idNewV = Type == CancelledTripConst.Id_canTrip ? int.Parse(txt.Trim()): CancellationReasonDAL.GetCancellationReasonByReason(txt).Id_Reason;

            UpdateCancelledTrip(idNewV);
        }
 private void DelCancellationReason(int id)
 {
     CancellationReasonDAL.Delete(id);
     dgvRT.DataSource = CancellationReasonDAL.GetAllCancellationReasons();
 }
        private void listBoxCT_SelectedIndexChanged(object sender, EventArgs e)
        {
            int idReason = CancellationReasonDAL.GetCancellationReasonByReason(CancellationReasonDAL.GetAllCancellationReasons()[listBoxCT.SelectedIndex].Reason).Id_Reason;

            dgvCT.DataSource = CanceledTripDAL.GetCancelledTripsByReason(idReason);
        }