private void button1_Click(object sender, EventArgs e)
 {
     TrainHandling.EditTrain(Id,txtFrom.Text, txtTo.Text, txtDepDate.Text, txtArrDate.Text, int.Parse(txtCarsNum.Text));
      var frm = new EditTrain();
      this.Hide();
      frm.Closed += (hh, uu) => this.Close();
 }
        private void button2_Click(object sender, EventArgs e)
        {
            int  x;
            bool t = int.TryParse(txtTrainID.Text, out x);

            if (t)
            {
                var train = TrainHandling.GetTrainById(x);
                if (train == null)
                {
                    MessageBox.Show("Invalid Train ID");
                }
                else
                {
                    EditTrain tr = new EditTrain();
                    tr.Init(x, train.StartingStation, train.EndingStation,
                            train.DepartureDate, train.ArrivalDate, train.NumberOfCars);
                    tr.Show();
                }
            }
            else
            {
                MessageBox.Show("Invalid Train ID");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            TrainHandling.EditTrain(Id, txtFrom.Text, txtTo.Text, txtDepDate.Text, txtArrDate.Text, int.Parse(txtCarsNum.Text));
            var frm = new EditTrain();

            this.Hide();
            frm.Closed += (hh, uu) => this.Close();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            int x;
            bool t = int.TryParse(txtTrainID.Text, out x);
            if (t)
            {
                var train = TrainHandling.GetTrainById(x);
                if (train == null)
                {
                    MessageBox.Show("Invalid Train ID");
                }
                else
                {
                    EditTrain tr = new EditTrain();
                    tr.Init(x, train.StartingStation, train.EndingStation,
                        train.DepartureDate, train.ArrivalDate, train.NumberOfCars);
                    tr.Show();
                }

            }
            else MessageBox.Show("Invalid Train ID");
        }