Here Is my class file function when it finds duplicate it shows messagebox but problem is that it does not stop by return statemtnt it also executes next queries on windows form
Code On Class File
public void FindDuplicate(String sql, string message)
{
SqlDataAdapter sda = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count > 0)
{
MessageBox.Show(message, "Duplicate Record", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
else
{
// MessageBox.Show("No Records Found","No Record Found",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
Code On Windows Form
db.FindDuplicate("Select * from Supplier_Details WHERE Sup_Name='"+txtSupplierName.Text+"'", "Name Already Exist");
If Record Found Then Shows MessageBox But Also Executes Next Statements I want to stop Here till User Enter Non-Duplicate Name
if (txtSupplierName.Text == "" || txtContactNo.Text == "" || txtAddress.Text == "")
{
MessageBox.Show("Please Fill All Details", "Empty TextBoxes", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
db.WriteLog("Empty TextBoxes: " + " " + txtSupplierID.Text + " ");
return;
}