updated solution as per the comments from Dave Kreskowiak, removed the
return
keyword from each condition block.
replace it with a return variable and use it in required condition block and return the variable.
private bool ValidData()
{
bool returnValue = false;
if (((service_NoTextBox.Text == String.Empty)
|| (Information.IsNumeric(service_NoTextBox.Text) == false)))
{
MessageBox.Show("Service Number is not complete", "Promotion List Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
service_NoTextBox.Focus();
service_NoTextBox.SelectAll();
}
else if (((file_NoTextBox.Text == String.Empty)
|| (Information.IsNumeric(file_NoTextBox.Text) == false)))
{
MessageString = "File Number is required and must be in five digit format.";
MessageBox.Show(MessageString, "Data Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
file_NoTextBox.Focus();
file_NoTextBox.SelectAll();
}
.
.
.
.
else
{
returnValue = true;
}
return returnValue;
}
}