private void addButton_Click(object sender, RoutedEventArgs e)  //Calls the appropriate classes to create a new booking object
        {
            AddEditBooking AEB = new AddEditBooking("N", currentCustomerID);

            AEB.Show();
            AEB.titleLabel.Content = "New Booking";
            Close();
        }
 private void amendButton_Click(object sender, RoutedEventArgs e)    //Calls the appropriate classes to modify an existing booking object
 {
     try
     {
         String[]       selectedLine = BookingBox.SelectedItem.ToString().Split(' ');
         int            selectedInt  = Int32.Parse(selectedLine[0]);
         AddEditBooking AEB          = new AddEditBooking("A", currentCustomerID);
         AEB.Show();
         AEB.loadData(selectedInt);
         AEB.titleLabel.Content = "Edit Booking";
         Close();
     }
     catch
     {
         MessageBox.Show("Click on an item in the above list to select it!");
     }
 }
Esempio n. 3
0
        private void addButton_Click(object sender, RoutedEventArgs e)  //Controls to take in, validate and add the fields to create or amend a customer upon button press
        {
            int Errors = 0;

            try
            {
                currentCustomer.CustomerName = nameInBox.Text;
                nameError.Content            = "";
                if (currentCustomer.CustomerName.Equals(""))
                {
                    Errors++;
                    nameError.Content = "!";
                }
            }
            catch
            {
                Errors++;
                nameError.Content = "!";
            }

            try
            {
                currentCustomer.CustomerAddress = addressInBox.Text;
                addressError.Content            = "";
                if (currentCustomer.CustomerAddress.Equals(""))
                {
                    Errors++;
                    addressError.Content = "!";
                }
            }
            catch
            {
                Errors++;
                addressError.Content = "!";
            }

            if (Errors == 0)
            {
                if (newOrEdit.Equals("N"))
                {
                    MainWindow.CustomerIDGen++;
                    currentCustomer.CustomerID = MainWindow.CustomerIDGen;
                    MainWindow.AllCustomers.addCustomer(currentCustomer);
                    MessageBoxResult makeNewBooking = MessageBox.Show("Would you like to add a booking to this customer? This can also be done via Manage Customers > View Bookings of Selected Customer.", "Add a booking?", MessageBoxButton.YesNo);
                    if (makeNewBooking == MessageBoxResult.Yes)
                    {
                        AddEditBooking AEB = new AddEditBooking("N", currentCustomer.CustomerID);
                        AEB.Show();
                        AEB.titleLabel.Content = "New Booking";
                        Close();
                    }
                    else
                    {
                        CustomerWindow CW = new CustomerWindow();
                        CW.Show();
                        CW.customerBoxRefresh();
                        this.Close();
                    }
                }
                else
                {
                    CustomerWindow CW = new CustomerWindow();
                    CW.Show();
                    CW.customerBoxRefresh();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("There are " + Errors + " invalid entries, they have each been marked with '!'. Please fix these then try again!");
            }
        }