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 SaveButton_Click(object sender, EventArgs e) { CustomerResource customer = new CustomerResource(); customer.CustomerId = this.customer.CustomerId; 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 { repo.UpdateCustomer(customer); if (alterationFormCallback != null) { alterationFormCallback(customer); } this.Close(); } catch { MessageBox.Show("There was an error saving the customer. Please check the fields and try again"); } }
private void SearchButton_Click(object sender, EventArgs e) { if (ValidateForm() == false) { MessageBox.Show("Please enter at least 1 search criteria."); return; } ResultGrid.Rows.Clear(); Dictionary<CustomerRepository.CustomerProperty, object> searchArguments = new Dictionary<CustomerRepository.CustomerProperty, object>(); if (FirstNameTextBox.Text != "") { searchArguments.Add(CustomerRepository.CustomerProperty.FirstName, FirstNameTextBox.Text); } if (MiddleNameTextBox.Text != "") { searchArguments.Add(CustomerRepository.CustomerProperty.MiddleName, MiddleNameTextBox.Text); } if (LastNameTextBox.Text != "") { searchArguments.Add(CustomerRepository.CustomerProperty.LastName, LastNameTextBox.Text); } if (AddressTextBox.Text != "") { searchArguments.Add(CustomerRepository.CustomerProperty.Address, AddressTextBox.Text); } if (CityTextBox.Text != "") { searchArguments.Add(CustomerRepository.CustomerProperty.City, CityTextBox.Text); } if (StateTextBox.Text != "") { searchArguments.Add(CustomerRepository.CustomerProperty.State, StateTextBox.Text); } if (ZipTextBox.Text != "") { searchArguments.Add(CustomerRepository.CustomerProperty.Zip, ZipTextBox.Text); } if (TelephoneTextBox.Text != "") { searchArguments.Add(CustomerRepository.CustomerProperty.Telephone, TelephoneTextBox.Text); } if (EmailTextBox.Text != "") { searchArguments.Add(CustomerRepository.CustomerProperty.Email, EmailTextBox.Text); } try { CustomerRepository repo = new CustomerRepository(); searchResults = repo.GetCustomersByArguments(searchArguments); if (searchResults.Count == 0) { MessageBox.Show("I couldn't find any matching csutomers. Please check the search criteria and try again."); } else { for (int i = 0; i < searchResults.Count; i++) { ResultGrid.Rows.Add(searchResults[i].FirstName, searchResults[i].LastName, searchResults[i].Email, searchResults[i].Telephone); } } enableSelectCustomerButton(); } catch (Exception ex) { MessageBox.Show("There was an error. Please contact Jay with this message: " + ex.Message); } }
private void NewTicketWithCustomerBttn_Click(object sender, EventArgs e) { if (ticketID == 0) { MessageBox.Show("You need to save this ticket before you can create a new ticket with this customer!"); return; } CustomerRepository repo = new CustomerRepository(); CustomerResource resource = repo.getCustomerById(customerId); AlterationForm form = new AlterationForm(resource); form.Show(); }
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(); }