コード例 #1
0
        //this is a button for going back to the main window
        private void btnArrowBack_Click(object sender, RoutedEventArgs e)
        {
            WindowNewCu back = new WindowNewCu();

            back.Show();
            this.Close();
        }
コード例 #2
0
        //saves the booking
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            //checks if the user has verified the chateau is free for booking
            if (!chateauCheck)
            {
                MessageBox.Show("Please check if selected chateau is available for booking",
                                "No Chateau Selected", MessageBoxButton.OK, MessageBoxImage.Question);
            }
            else
            {
                if ((bool)chkCar.IsChecked && !(dateStart.SelectedDate >= dateArrival.SelectedDate && dateEnd.SelectedDate <= dateDeparture.SelectedDate))

                {
                    MessageBox.Show("Car hiring dates must be in the booking interval", "Incorrect date");
                }
                else
                {
                    //stores the data to the booking
                    newBooking.Arrival   = dateArrival.SelectedDate.Value;
                    newBooking.Departure = dateDeparture.SelectedDate.Value;
                    newBooking.ChaletID  = ((comboChaletNo.SelectedIndex) + 1);
                    newBooking.Breakfast = (bool)chkBreakfast.IsChecked;
                    newBooking.Evening   = (bool)chkEvening.IsChecked;
                    newBooking.Hire      = (bool)chkCar.IsChecked;
                    foreach (Guest guest in currGuests)
                    {
                        if (newBooking.GuestList.IndexOf(guest) == -1)
                        {
                            newBooking.AddGuest(guest);
                        }
                    }
                    //if this is a new booking, add it to the lists
                    if (temp.CurrentBooking == 0)
                    {
                        newBooking.BookingRefference = instance.BookingRef;
                        List <Customer> customers       = temp.Customers;
                        int             cuNo            = temp.CurrentCustomer;
                        Customer        currentCustomer = temp.GetCustomer(cuNo);
                        currentCustomer.AddBooking(newBooking.BookingRefference);
                        temp.AddBooking(newBooking);
                    }
                    //saves the data since it has been modified
                    temp.SaveData("booking");
                    temp.SaveData("customer");
                    WindowNewCu customer = new WindowNewCu();
                    customer.Show();
                    this.Close();
                }
            }
        }
コード例 #3
0
 //a button for deleting a customer
 private void btnDelCu_Click(object sender, RoutedEventArgs e)
 {
     //the customer must be deleted only if the customer has no bookings
     if (currentCustomer.Bookings.Count() != 0)
     {
         MessageBox.Show("You can only delete a customer that has no bookings", "Customer has bookings");
     }
     else
     {
         instance.Customers.Remove(currentCustomer);
         instance.SaveData("customer");
         WindowNewCu cust = new WindowNewCu();
         cust.Show();
         this.Close();
     }
 }