コード例 #1
0
        private void backButton_Click(object sender, RoutedEventArgs e) //Cancel operation and return to the CustomerWindow
        {
            CustomerWindow CW = new CustomerWindow();

            CW.Show();
            CW.customerBoxRefresh();
            this.Close();
        }
コード例 #2
0
        private void backButton_Click(object sender, RoutedEventArgs e) //Calls the appropriate class to load CustomerWindow
        {
            CustomerWindow CW = new CustomerWindow();

            CW.Show();
            CW.customerBoxRefresh();
            Close();
        }
コード例 #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!");
            }
        }