private void addbtn_Click(object sender, EventArgs e) { try { if (ValidateBeforeAdd()) { using (UtilityData ut = new UtilityData(true)) { ut.NameID = NameID; ut.Value = nameTextBoxX.Text; if (ID == 0) { if (ut.Add() == 1) { MessageView.ShowMsg("Sucessfully Added"); //errorProvider1.SetError(idTxt, string.Empty); //errorProvider1.SetError(nameTxt, string.Empty); clear(); } } else { ut.ID = ID; if (MessageView.ShowQuestionMsg("Update ") == DialogResult.OK) { if (ut.Update() == 1) { MessageView.ShowMsg("Sucessfully Updated"); //errorProvider1.SetError(idTxt, string.Empty); //errorProvider1.SetError(nameTxt, string.Empty); clear(); } } } } } } catch (Exception ex) { MessageView.ShowErrorMsg(ex.Message); } }