public MainWindow() { InitializeComponent(); radioButtons = new Dictionary <RadioButton, string>() { { economyRadio, "Economy" }, { businessRadio, "Business" }, { firstRadio, "First" } }; newReservation = new Reservation(); scheduleRows = ConnectionObject.LoadScheduleRows(); //never used??? AirportRows = ConnectionObject.LoadAirports(); // subscribe to changes to the reservation object newReservation.changeChecker.changeMadeEvent += disableBookingButton; // //newReservation.changeChecker.changeMadeEvent += new ChangeChecker.changeMade(delegate () //{ // // createBooking.IsEnabled = newReservation.isValid(); //}); // get flights with distinct departures this.departuresBox.ItemsSource = scheduleRows.Distinct(new compareDepartures()); this.departuresBox.DisplayMemberPath = "DepartingName"; }
public FlightsPage() { InitializeComponent(); this.dateControl.SelectedDate = DateTime.Now.Date; airports = ConnectionObject.LoadAirports(); //airportDictionary = new Dictionary<string, string>(); //foreach (Airport airport in airports) //{ // airportDictionary.Add( airport.AirportCode, airport.Description); //} selectedItem = new ScheduleRow(); scheduleRows = ConnectionObject.LoadScheduleRows(); editMode = false; //rows = from flight in scheduleRows // select flight; arrivalRows = scheduleRows.Distinct(new compareArrivals()); departureRows = scheduleRows.Distinct(new compareDepartures()); listViewRows = from flight in scheduleRows select flight; this.ArrivingBox.ItemsSource = airports; this.ArrivingBox.DisplayMemberPath = "Description"; //this.DepartingBox.ItemsSource = departureRows; //this.DepartingBox.DisplayMemberPath = "Departing"; this.DepartingBox.ItemsSource = airports; this.DepartingBox.DisplayMemberPath = "Description"; GridView flightsGrid = new GridView(); flightsGrid.AllowsColumnReorder = true; flightsGrid.ColumnHeaderToolTip = "flight Data2"; GridViewColumn departuresColumn = new GridViewColumn(); departuresColumn.DisplayMemberBinding = new Binding("DepartingName"); departuresColumn.Header = "Departing"; departuresColumn.Width = 100; flightsGrid.Columns.Add(departuresColumn); GridViewColumn arrivalsColumn = new GridViewColumn(); arrivalsColumn.Header = "Arriving"; arrivalsColumn.Width = 100; arrivalsColumn.DisplayMemberBinding = new Binding("ArrivingName"); flightsGrid.Columns.Add(arrivalsColumn); GridViewColumn timeColumn = new GridViewColumn(); timeColumn.Header = "Time"; //timeColumn.Width = 100; timeColumn.DisplayMemberBinding = new Binding("Time"); flightsGrid.Columns.Add(timeColumn); this.FlightsList.View = flightsGrid; this.FlightsList.ItemsSource = scheduleRows; }
private void Update_Click(object sender, RoutedEventArgs e) { ConnectionObject.UpdateFlight(this.selectedItem); scheduleRows = ConnectionObject.LoadScheduleRows(); selectedItem = new ScheduleRow(); editMode = false; somethingChanged(); }
private void Delete_Click(object sender, RoutedEventArgs e) { ConnectionObject.RemoveFlight(selectedItem); scheduleRows = ConnectionObject.LoadScheduleRows(); selectedItem = new ScheduleRow(); editMode = false; FlightsList.SelectedItem = null; somethingChanged(); }
private void CreateBooking_Click(object sender, RoutedEventArgs e) { // pick the selected flight from the times combo box ScheduleRow flight = this.timeBox.SelectedItem as ScheduleRow; //updates the reservations table ConnectionObject.CreateBooking(newReservation); //updates the sql database and the local variable ConnectionObject.RemoveSeat(newReservation.SeatClass, flight); string successText = $"Success! You've booked {(newReservation.SeatClass == "Economy" ? "an" : "a")} {newReservation.SeatClass} seat on the flight {selectedItem} for {newReservation.PassengerName}" + $"{System.Environment.NewLine}Reference Number: {newReservation.Reference}"; //reset the reservation object newReservation = new Reservation(); //resubscribe to the new reservation object newReservation.changeChecker.changeMadeEvent += disableBookingButton; //reset the text boxes this.passengerName.Text = null; this.passportNo.Text = null; this.passengerName.Text = null; this.departuresBox.SelectedItem = null; //uncheck all seat class controls foreach (KeyValuePair <RadioButton, string> item in radioButtons) { item.Key.IsChecked = false; } //display the success message this.successMessage.Text = successText; MessageBox.Show(this.successBorder.IsVisible.ToString()); this.successBorder.Visibility = Visibility.Visible; this.successMessage.Visibility = Visibility.Visible; this.UpdateLayout(); }