private void btnModifyCustomer_Click(object sender, RoutedEventArgs e) { try { if (txtCustomerName.Text == String.Empty || txtCustomerAddress.Text == String.Empty) { throw new ArgumentException("You need to fill both customer name and address!", "Customer"); } customer.Address = txtCustomerAddress.Text; customer.Name = txtCustomerName.Text; win.updateCustomer(customer); win.dataGridCustomer.SelectedItem = null; win.disableButtons(); win.dataGridBooking.Items.Refresh(); win.Show(); this.Close(); } catch (Exception ee) { MessageBox.Show(ee.Message); } }
private void btnUpdateBooking_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Are you sure of the details?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { return; } else { Guest g = new Guest(); try { if (facade.Guests.Count < 1 || lstBoxViewGuests.Items.IsEmpty) { throw new ArgumentException("There are no guests! Add guests!"); } int breakfast = checkBreakfast(); int eveningMeal = checkEveningMeal(); facade.UpdateBooking(customer, facade.Guests, booking, car, breakfast, eveningMeal, checkBoxCar.IsChecked.Value); facade.Guests.Clear(); MessageBox.Show("Succesfully Saved!", "Confirmation"); win.dataGridBooking.SelectedItem = null; win.dataGridCustomer.SelectedItem = null; win.disableButtons(); win.dataGridBooking.ItemsSource = null; win.dataGridBooking.Items.Refresh(); win.Show(); this.Close(); } catch (Exception ee) { MessageBox.Show(ee.Message, "Update"); } } }
private void btnUpdateBooking_Click(object sender, RoutedEventArgs e) { try { SelectedDatesCollection Dates = calendarBookingDate.SelectedDates; if (Dates.Count <= 1) { throw new ArgumentException("You need to select and drag a range of dates!"); } if (Dates[0].Date > Dates[Dates.Count - 1].Date) { throw new ArgumentException("The Arrival Date Can't be after the Departure Date!"); } if (Dates.Count > 1) { booking.ArrivalDate = Dates[0]; booking.DepartureDate = Dates[Dates.Count - 1]; booking.ChaletID = facade.setChaletForBooking(Dates[0], Dates[Dates.Count - 1]); } win.updateBookingDates(booking); win.disableButtons(); win.dataGridBooking.SelectedItem = null; win.dataGridCustomer.SelectedItem = null; win.dataGridBooking.Items.Refresh(); win.Show(); this.Close(); } catch (Exception ee) { MessageBox.Show(ee.Message, "Booking"); } }