// **********
        // * EVENTS *
        // **********

        // User clicked Ok Button
        private void OkButton_Click(object sender, EventArgs e)
        {
            if (this.isFormValid() == true)
            {
                // Grab the Database Instance
                DatabaseWrapper databaseWrapper = DatabaseWrapper.getInstance();
                // Grab the CustomerID
                long customerID = Convert.ToInt64(this.IDTextBox.Text);
                // If there is a customer with the ID
                if (databaseWrapper.isCustomer(customerID) == true)
                {
                    // Grab Customer
                    Customer customer = databaseWrapper.getCustomer(customerID);
                    // Make a New Customer Window
                    this.customerWindow = new CustomerWindow();
                    // Set the Customer for our New Window
                    this.customerWindow.setCustomer(customer);
                    // Clear the Window
                    this.clear();
                    // Show dialog for our new Window
                    this.customerWindow.ShowDialog();
                    return;
                }
                else
                {
                    // Message to the user
                    MessageBox.Show("ERROR: No Customer found with that Record");
                    // Return due to error
                    return;
                }
            }
            else
            {
                // Return due to error
                return;
            }
        }
예제 #2
0
        // **********
        // * EVENTS *
        // **********

        // User Clicked Ok Button
        private void OKButton_Click(object sender, EventArgs e)
        {
            // Validate the form
            if (this.validateForm() == true)
            {
                // Grab the CustomerID
                long customerID = Convert.ToInt64(this.IDTextBox.Text);
                // Grab the Database Wrapper Instance
                DatabaseWrapper databaseWrapper = DatabaseWrapper.getInstance();
                // Check to see if there is a customer
                if (databaseWrapper.isCustomer(customerID) == true)
                {
                    // Remove the Customer
                    databaseWrapper.removeCustomer(customerID);
                    // Popup Message to the User
                    MessageBox.Show("Customer Record removed from the database");
                }
                else
                {
                    // Popup Message to the User
                    MessageBox.Show("ERROR: No Customer Record to remove");
                    // Return due to Error
                    return;
                }
            }
            else
            {
                // Popup Message to the User
                MessageBox.Show("ERROR: Invalid ID");
                // Return due to Error
                return;
            }
            // Clear this Window
            this.clear();
            // Close this Window
            this.Close();
        }
예제 #3
0
        // ***********
        // * GENERAL *
        // ***********

        /* Refresh clears the Database Table Control
         *  and populates it with fresh data from
         *  the database */
        public void refresh()
        {
            // Clear the window conttrols
            this.clear();
            // Grab an instance of the Database Wrapper
            DatabaseWrapper databaseWrapper = DatabaseWrapper.getInstance();
            // Grab the list of Customers from the database
            List <Customer> customers = databaseWrapper.getCustomers();

            // Go through each customer one at a time
            foreach (Customer customer in customers)
            {
                // Grab CustomerID
                String customerID = customer.CustomerID.ToString();
                // Grab CustomerTitle
                String customerTitle = customer.Title;
                // Grab CustomerGivenNames
                String customerGivenNames = customer.GivenNames;
                // Grab CustomerLastNames
                String customerLastNames = customer.LastName;
                // Add a new row to the DatabaseTableControl
                this.DatabaseTableControl.Rows.Add(customerID, customerTitle, customerGivenNames, customerLastNames);
            }
        }
예제 #4
0
        // **********
        // * EVENTS *
        // **********

        // The User Clicks Ok
        private void OkButton_Click(object sender, EventArgs e)
        {
            // Grab the Instance of our Database Wrapper
            DatabaseWrapper databaseWrapper = DatabaseWrapper.getInstance();
            String          customerTitle   = this.TitleComboBox.Text;
            String          givenNames      = this.GivenNamesTextBox.Text;
            String          lastName        = this.LastNameTextBox.Text;

            // Try and Add the Customer to the Databaase
            if (databaseWrapper.addCustomer(customerTitle, givenNames, lastName) == false)
            {
                // Show a MessageBox
                MessageBox.Show("Error: Unable to add customer: " + customerTitle + " " + givenNames + " " + lastName);
            }
            else
            {
                // Show a MessageBox
                MessageBox.Show("Success! Added customer: " + customerTitle + " " + givenNames + " " + lastName);
            }
            // Clear the Window
            this.clear();
            // Close the Window
            this.Close();
        }