private void backButton_Click(object sender, RoutedEventArgs e) //Calls the appropriate class to load BookingsWindow
        {
            BookingsWindow BW = new BookingsWindow(currentCustomerID);

            BW.Show();
            BW.BookingsBoxRefresh();
            this.Close();
        }
        private void backButton_Click(object sender, RoutedEventArgs e)     //Cancel operation and return to the BookingWindow
        {
            BookingsWindow BW = new BookingsWindow(currentCustomerID);

            BW.Show();
            BW.BookingsBoxRefresh();
            this.Close();
        }
예제 #3
0
 private void bookingsButton_Click(object sender, RoutedEventArgs e) //Calls the appropriate class to load BookingsWindow
 {
     try
     {
         String[]       selectedLine = CustomerBox.SelectedItem.ToString().Split(' ');
         int            selectedInt  = Int32.Parse(selectedLine[0]);
         BookingsWindow BW           = new BookingsWindow(selectedInt);
         BW.Show();
         BW.BookingsBoxRefresh();
         this.Close();
     }
     catch
     {
         MessageBox.Show("Click on an item in the left had list to select it!");
     }
 }
        private void addButton_Click(object sender, RoutedEventArgs e)  //Controls to take in, validate and add the fields to create or amend a booking upon button press
        {
            int Errors = 0;

            try
            {
                currentBooking.ChaletID = Int32.Parse(idInBox.Text);
                idError.Content         = "";
                if (currentBooking.ChaletID > 10 || currentBooking.ChaletID < 1)
                {
                    Errors++;
                    idError.Content = "!";
                }
            }
            catch
            {
                Errors++;
                idError.Content = "!";
            }

            try
            {
                currentBooking.ArrivalDate = DateTime.Parse(arrivalInBox.Text);
                arrivalError.Content       = "";
            }
            catch
            {
                Errors++;
                arrivalError.Content = "!";
            }

            try
            {
                currentBooking.DepartureDate = DateTime.Parse(departureInBox.Text);
                departureError.Content       = "";
                if (currentBooking.ArrivalDate.Date > currentBooking.DepartureDate.Date)
                {
                    Errors++;
                    departureError.Content = "!";
                }
            }
            catch
            {
                Errors++;
                departureError.Content = "!";
            }


            if (Errors == 0)
            {
                bool hit = false;
                foreach (var thisCustomer in MainWindow.AllCustomers.Customers)
                {
                    foreach (var thisBooking in MainWindow.AllCustomers.getBookings(thisCustomer.CustomerID))
                    {
                        if (thisBooking.ChaletID == currentBooking.ChaletID)
                        {
                            if (thisBooking.ArrivalDate <= currentBooking.DepartureDate && currentBooking.ArrivalDate <= thisBooking.DepartureDate)
                            {
                                hit = true;
                            }
                        }
                    }
                }
                if (hit == true)
                {
                    Errors++;
                    idError.Content = "!";
                    MessageBox.Show("Selected Chalet is already booked for this date, try a different Chalet!");
                }
            }

            if (Errors == 0)
            {
                if (newOrEdit.Equals("N"))
                {
                    MainWindow.BookingRefGen++;
                    currentBooking.BookingRef       = MainWindow.BookingRefGen;
                    currentBooking.BreakfastExtra   = false;
                    currentBooking.EveningMealExtra = false;
                    MainWindow.AllCustomers.addBooking(currentCustomerID, currentBooking);
                    AddExitGuest AEG = new AddExitGuest("N", true, currentCustomerID, currentBooking.BookingRef);
                    AEG.Show();
                    this.Close();
                }
                else
                {
                    BookingsWindow BW = new BookingsWindow(currentCustomerID);
                    BW.Show();
                    BW.BookingsBoxRefresh();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("There are " + Errors + " invalid entries, they have each been marked with '!'. Please fix these then try again!");
            }
        }