'how to conditionally return to form with messagebox yes/no
I'm not sure how to handle returning to the form after this checkbox value check. My intention is to identify that two checkboxes were not selected and give the user a chance to go back to the form and choose if they click no on a messagebox. If they click yes, then proceed. What is the proper way to handle?
private void btnConfirmCheckin_Click(object sender, EventArgs e)
{
string activity_log_id = txtactivity_log_id.Text;
string CheckInTime = txtCheckInTime.Text;
bool @bm = checkBoxBM.Checked;
bool @ur = checkBoxUr.Checked;
string activity_id = comboactivity_id.SelectedValue.ToString();
if (checkBoxBM.Checked == false && checkBoxUr.Checked == false)
{
DialogResult dialogResult = MessageBox.Show("Nothing was selected for this outing. Continue?", "Business Confirmation", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
//user correctly chose nothing, wants to continue
return;
}
else if (dialogResult == DialogResult.No)
{
//user made mistake, return to form and make a selection
}
}
AssignRescueActivity ara = new AssignRescueActivity();
ara.SaveCheckin(activity_log_id, CheckInTime, bm, ur, activity_id);
this.Close();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
