So I have a Windows form with a few fields to accept data and write to a SQL database. My button_click event is what handles all the work except for validating the user input. These are handling by separate methods. My question is that if a user has incorrect input, how do I reset the form after showing the messagebox? Maybe just use the button click event to start a separate method so I can control it better?
private void enter_button_Click(object sender, EventArgs e)
{
restart:
try {
try {
Validate(fname);
Validate(lname);
Validate(city);
Validate(state);
} catch (Exception ex) {
MessageBox.Show(ex.Message);
if (ex != null) {
fname.Clear();
lname.Clear();
city.Clear();
state.Clear();
goto restart;
}
}
try {
exValidate(address);
} catch (Exception ex1) {
MessageBox.Show(ex1.Message);
if (ex1 != null) {
address.Clear();
goto restart;
}
}
//blah blah...write to database.
}
// ...
}