private void CreateAccountButton_Click(object sender, EventArgs e) { try { ParseFields(); CheckForValidEmail(); CheckForValidPhoneNumber(); var accountContact = new AccountContact(AccountNameTextBox.Text, AccountContactNameTextBox.Text, PhoneNumberTextBox.Text, EmailTextBox.Text); var account = new Account(accountContact); } catch (FormatException) // we catch this exception so that we can take advantage of MailAddress throwing an exception { DisplayMessageBox(EMAIL_MESSAGE, EMAIL_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception) { DisplayMessageBox(FIELD_VALIDATION_MESSAGE, FIELD_VALIDATION_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Account(AccountContact contactInformation) { ContactInformation = contactInformation; AccountNumber = GenerateNewAccountNumber(); }