//view the booking selected private void btnNext_Click(object sender, RoutedEventArgs e) { //send booking and customer to BookingForm BookingForm bf = new BookingForm(aBooking, aCustomer); bf.Show(); this.Close(); }
//add info to the booking, save it and go to next page private void btnNext_Click(object sender, RoutedEventArgs e) { DateTime _dateIn; DateTime _dateOut; try { _dateIn = Convert.ToDateTime(dateInPicker.SelectedDate); _dateOut = Convert.ToDateTime(dateOutPicker.SelectedDate); if (_dateIn.Date < DateTime.Now.Date) { throw new ArgumentException("Date in is wrong"); } if (_dateOut.Date <= _dateIn) { throw new ArgumentException("Date out is wrong"); } } catch (Exception except) //if any of these values are wrong, the program will not crash { MessageBox.Show(except.Message); return; } //do not leave window until both dates are chosen if (dateInPicker.SelectedDate == null || dateOutPicker.SelectedDate == null) { MessageBox.Show("select datessss pls"); } else { //create a booking with the dates Booking aBooking = BookingsFactory.createBookingFactory(); aBooking.ArrivalDate = _dateIn; aBooking.DepartureTime = _dateOut; //save booking in customer aCustomer.BookingsList.Add(aBooking); //save booking to all bookings list dataLayerSingleton.allBookings.Add(aBooking); //go to next window passing the customer and booking BookingForm nc = new BookingForm(aBooking, aCustomer); nc.Show(); this.Close(); } }