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