I am checking for duplicates and it finds them and the If(isDuplicate) all works fine. But the code continues and does all the submit because I am not telling it to stop. How would I do this ? to stop and throw the error panel which it does but not submit?
_db.tbl_Localities.InsertOnSubmit(locality);
bool isDuplicate = _db.tbl_Localities
.Any(x => x.Locality == txt_Locality.Text);
if (isDuplicate)
{
pnl_Message.Visible = true;
lbl_message.Text = " Duplicate entry!";
txt_Locality.Text = "";
}
// Save
// ====
_db.SubmitChanges();