private void updProperty_Click(object sender, EventArgs e) { //Validate Data if (txtRent.Text.Equals("") || txtBedrooms.Text.Equals("") || txtBathrooms.Text.Equals("") || txtHouse.Text.Equals("") || txtAdd1.Text.Equals("") || txtAdd2.Text.Equals("") || txtCounty.Text.Equals("") || txtActivity.Text.Equals("")) { MessageBox.Show("All fields must be entered", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } String rent = txtRent.Text; foreach (char c in rent) { if (c < '0' || c > '9') { MessageBox.Show("Rent must be numeric!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (txtActivity.Text.ToUpper() != "A" && txtActivity.Text.ToUpper() != "I") { MessageBox.Show("Activity must be A or I!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Instantiate Property Object Property myProps = new Property(); if (PropertySysv2.Owner.validNumbers(txtRent.Text)) { myProps.setRentPerMonth(Convert.ToInt32(txtRent.Text)); } else { MessageBox.Show("Rent must be numbers only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtRent.Text = ""; txtRent.Focus(); return; } if (PropertySysv2.Owner.validNumbers(txtBedrooms.Text)) { myProps.setBedrooms(Convert.ToInt32(txtBedrooms.Text)); } else { MessageBox.Show("Bedrooms must be numbers only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtBedrooms.Text = ""; txtBedrooms.Focus(); return; } if (PropertySysv2.Owner.validNumbers(txtBathrooms.Text)) { myProps.setBathrooms(Convert.ToInt32(txtBathrooms.Text)); } else { MessageBox.Show("Bathrooms must be numbers only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtBathrooms.Text = ""; txtBathrooms.Focus(); return; } if (PropertySysv2.Owner.validText(txtHouse.Text)) { myProps.setHouseType(txtHouse.Text); } else { MessageBox.Show("House Type must be letters only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtHouse.Text = ""; txtHouse.Focus(); return; } if (PropertySysv2.Owner.validText(txtAdd1.Text)) { myProps.setStreet(txtAdd1.Text); } else { MessageBox.Show("Address Line 1 must be letters only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtAdd1.Text = ""; txtAdd1.Focus(); return; } if (PropertySysv2.Owner.validText(txtAdd2.Text)) { myProps.setTown(txtAdd2.Text); } else { MessageBox.Show("Address Line 2 must be letters only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtAdd2.Text = ""; txtAdd2.Focus(); return; } if (PropertySysv2.Owner.validText(txtCounty.Text)) { myProps.setCounty(txtCounty.Text); } else { MessageBox.Show("County must be letters only", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtCounty.Text = ""; txtCounty.Focus(); return; } myProps.setActivity(txtActivity.Text); myProps.setOwnerId(Convert.ToInt32(txtOwnerID.Text)); //INSERT Property record into Property Table myProps.updProp(); //Display Confirmation message MessageBox.Show("Owner Updated In System", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); //Reset UI txtRent.Text = ""; txtBedrooms.Text = ""; txtBathrooms.Text = ""; txtHouse.Text = ""; txtAdd1.Text = ""; txtAdd2.Text = ""; txtCounty.Text = ""; txtActivity.Text = ""; txtOwnerID.Text = ""; grdProperties.Visible = false; grpProperties.Visible = false; cboBeds.SelectedIndex = -1; cboTown.SelectedIndex = -1; }