コード例 #1
0
        private void btnSaveCustomerAndBooking_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Are you sure of the details?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
            {
                return;
            }
            else
            {
                try
                {
                    if (facade.Guests.Count < 1 && lstBoxViewGuests.Items.Count < 1)
                    {
                        throw new ArgumentException("There are no guests! Add guests!");
                    }

                    if (checkBoxCar.IsChecked != true && car != null)
                    {
                        car = null;
                    }

                    int breakfast   = checkBreakfast();
                    int eveningMeal = checkEveningMeal();

                    if (addBooking == true)
                    {
                        facade.SaveCustomerAndBooking(customer, facade.Guests, booking, car, breakfast, eveningMeal, addBooking);


                        MessageBox.Show("Succesfully Saved!", "Confirmation");

                        facade.Guests.Clear();

                        ExistingCustomer win = new ExistingCustomer();
                        win.Show();
                        this.Close();
                    }
                    else
                    {
                        facade.SaveCustomerAndBooking(customer, facade.Guests, booking, car, breakfast, eveningMeal, false);


                        MessageBox.Show("Succesfully Saved!", "Confirmation");

                        facade.Guests.Clear();

                        MainWindow win = new MainWindow();
                        win.Show();
                        this.Close();
                    }
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message, "Save");
                }
            }
        }