// ********** // * 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(); }
// ********** // * 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; } }