private void AddCustomerButton_Click(object sender, EventArgs e) { if (!validateForm()) { return; } CustomerResource customer = new CustomerResource(); customer.Title = TitleComboBox.Text ?? ""; customer.FirstName = FirstNameTextBox.Text ?? ""; customer.MiddleName = MiddleNameTextBox.Text ?? ""; customer.LastName = LastNameTextBox.Text ?? ""; customer.Address = AddressTextBox.Text ?? ""; customer.Address2 = Address2TextBox.Text ?? ""; customer.City = CityTextBox.Text ?? ""; customer.State = StateTextBox.Text ?? ""; customer.Zip = ZipTextBox.Text; customer.Telephone = PhoneTextBox.Text ?? ""; customer.Email = EmailTextBox.Text ?? ""; CustomerRepository repo = new CustomerRepository(); try { int custId = repo.InsertCustomer(customer); customer.CustomerId = custId; CustomerProfile profile = new CustomerProfile(customer); profile.Show(); this.Close(); } catch { MessageBox.Show("There was an error saving the customer. Please check the fields and try again"); } }
private void EditCustomerButton_Click(object sender, EventArgs e) { CustomerRepository repo = new CustomerRepository(); CustomerResource resource = repo.getCustomerById(customerId); CustomerProfile profile = new CustomerProfile(resource, CustomerProfileFinishedEditing); profile.Show(); }