private void btnUpdate_Click(object sender, EventArgs e) { // validate data if (txtForename.Text.Equals("") || txtSurname.Text.Equals("") || txtPhone.Text.Equals("") || txtEmail.Text.Equals("")) { MessageBox.Show("All fields must be entered", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } String phone = txtPhone.Text; foreach (char c in phone) { if (c < '0' || c > '9') { MessageBox.Show("Phone must be numeric!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPhone.Text = ""; return; } } if (txtActivity.Text.ToUpper() != "A" && txtActivity.Text.ToUpper() != "I") { MessageBox.Show("Activity must be A or I!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtActivity.Text = ""; return; } //Display Confirmation message MessageBox.Show("Tenant Updated!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); //instantiate Tenant Object Tenant myTenant = new Tenant(); myTenant.setTenantId(Convert.ToInt32(txtTenantID.Text)); if (PropertySysv2.Owner.validText(txtForename.Text)) { myTenant.setForename(txtForename.Text); } else { MessageBox.Show("Forename must be letters only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtForename.Text = ""; txtForename.Focus(); return; } if (PropertySysv2.Owner.validText(txtSurname.Text)) { myTenant.setSurname(txtSurname.Text); } else { MessageBox.Show("Address Line 2 must be letters only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtSurname.Text = ""; txtSurname.Focus(); return; } myTenant.setPhone(txtPhone.Text); if (PropertySysv2.Owner.validEmail(txtEmail.Text)) { myTenant.setEmail(txtEmail.Text); } else { MessageBox.Show("Email must be correct format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Focus(); return; } myTenant.setActivity(txtActivity.Text); //INSERT Tenant record into tenant table myTenant.updTenant(); //reset UI txtTenantSearch.Text = ""; txtForename.Text = ""; txtSurname.Text = ""; txtPhone.Text = ""; txtEmail.Text = ""; txtActivity.Text = ""; grpTenants.Visible = false; grdTenants.Visible = false; txtTenantSearch.Focus(); }