private void RoutsItemClick(object sender, object e) { Rout routs = (Rout)GetSelectedItem(routsTreeView); if (routs == null) { return; } ShowGroupBox(routGroup); flighFreqBox.SelectedItem = routs.FlightFrequency; toAirportBox.SelectedItem = routs.ToAirport; fromAirportBox.SelectedItem = routs.FromAirport; planeBox.SelectedItem = routs.Plane; routDatePicker.SelectedDate = routs.FirstDeparturTime; schedulesComboBox.ItemsSource = routs.GetSchedules(); routTimerLabel.Text = routs.FirstDeparturTime.ToString("HH:mm:ss"); passengersTreeView.ItemsSource = null; schedulesComboBox.SelectedItem = null; seatsAndSeatsLimitLabel.Content = "--/--"; flightArriveTime.Content = "--"; if (routs.IsSetUp()) { generateRout.IsEnabled = false; } else { generateRout.IsEnabled = true; } }
public void RemoveRout(Rout rout) { //Gdy trasa jest stworzona i ustalona if (rout.IsSetUp()) { //Lista psażerów do usunięcia List <Customer> cusToRemove = new List <Customer>(); rout.GetSchedules().ForEach(s => { s.GetPassengersList().ForEach(p => { cusToRemove.Add(p); //p.SetFlightSchedule(null); }); }); //Usuń loty dla każdego pasażera cusToRemove.ForEach(c => c.SetFlightSchedule(null)); } Routs.Remove(rout); //Ustaw status samolotu na wolny i sprawdź czy jest wykorzystywany w innych lotach, //Jak tak to zmień jego status ponownie rout.Plane.Unassign(); Routs.ForEach(r => { if (r.Plane == rout.Plane) { rout.Plane.Assign(); return; } }); }
private void CustomerFlightChangedEvent(object sender, SelectionChangedEventArgs e) { Rout rout = (Rout)((ComboBox)sender).SelectedItem; if (rout == null) { return; } if (!rout.IsSetUp()) { customerFlightScheduleLabel.Text = ""; ((ComboBox)sender).SelectedItem = null; PushError("Wybrany lot nie jest skonfigurowany!"); return; } Schedule schedule = rout.GetSchedules().ElementAt <Schedule>(0); SetTextBoxDataContextAndText(customerFlightScheduleLabel, schedule); customerFlightArriveTime.Content = schedule.GetArrivalTimeAsString(); }