private void button1Ok_Click(object sender, EventArgs e) { try { FlightCollection File = new FlightCollection("Flights.txt"); Flight Current = File.FindByNumber(Number); string depDay = dateTimePicker1DepartureDay.Value.Day.ToString() + "." + dateTimePicker1DepartureDay.Value.Month.ToString() + "." + dateTimePicker1DepartureDay.Value.Year.ToString(); string arrDay = dateTimePicker2arrivalDay.Value.Day.ToString() + "." + dateTimePicker2arrivalDay.Value.Month.ToString() + "." + dateTimePicker2arrivalDay.Value.Year.ToString(); string depTime = numericUpDown1DepHour.Value + ":" + numericUpDown2DepMinutes.Value; string arrTime = numericUpDown1ArrHours.Value + ":" + numericUpDown1ArrMinutes.Value; string StopStation = Program.RemoveSpaces(textBox3stopstat.Text); if (StopStation != "") { Current.AddStopStation(StopStation); } Current.Departure = Convert.ToDateTime(depDay + " " + depTime); Current.Arrival = Convert.ToDateTime(arrDay + " " + arrTime); File.ClearFile(); File.WriteInFile(); this.Close(); Program.MainForm.OnLoadFuction(); } catch (Exception myexp) { MessageBox.Show(myexp.Message, "Оповещение"); } }
private void button3_Click(object sender, EventArgs e) { string num = FlightTable1.CurrentRow.Cells[0].Value.ToString(); FlightCollection file = new FlightCollection("Flights.txt"); file.RemoveFlightAndFile(num); file.ClearFile(); file.WriteInFile(); OnLoadFuction(); }