private void BtnSeat_Click(object sender, RoutedEventArgs e) { if (cbClass.SelectedIndex > -1) { clas = (EClass)cbClass.SelectedItem; if (clas.Equals(EClass.BUSINESS)) { txtPrice.Text = (flight.OneWayTicketPrice * (decimal)5.0).ToString(); } PickSeatWindow ps = new PickSeatWindow(flight, clas); if (ps.ShowDialog() == true) { SelectedSeat = ps.SelectedSeat; txtSeat.Text = SelectedSeat.SeatLabel.ToString(); } } else { MessageBox.Show("You must select a class"); } }
public PickSeatWindow(Flight flight, EClass Clas) { InitializeComponent(); this.flight = flight; foreach (Seat s in Data.Instance.SeatAvailable) { if (s.AirplaneId == flight.AirplaneId.Pilot) { seats.Add(s); if (Clas.Equals(EClass.BUSINESS)) { view = CollectionViewSource.GetDefaultView(seats.Where(ss => ss.SeatClass.Equals(EClass.BUSINESS))); LbBSeats.ItemsSource = view; } else { view = CollectionViewSource.GetDefaultView(seats.Where(ss => ss.SeatClass.Equals(EClass.ECONOMY))); LbBSeats.ItemsSource = view; } } } }