private void btn_save_profession_Click(object sender, EventArgs e) { try { if (!IsNewRecord && !hasAccessUpdate) { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "You have no save rights.", "Access Denied"); return; } if (txt_new_profession.IsNotEmpty()) { using (DataTable Table = new BL_Profession().select(new ML_Profession { Profession = txt_new_profession.Text })) { if (Table.Rows.Count < 1) { if (IsNewRecord) { new BL_Profession().insert(new ML_Profession { Profession = txt_new_profession.Text.Trim(), UserKey = UniversalVariables.UserKey }); } else if (SelectedID > 0) { new BL_Profession().update(new ML_Profession { Key = SelectedID, Profession = txt_new_profession.Text.Trim(), UserKey = UniversalVariables.UserKey }); } BindProfession(); ResetForm(false, true, true, hasAccessInsert, hasAccessDelete, true); SetPrevious(); } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The entered profession is already in the database. Please re-check!", "Error"); } } } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Exclamation, "Null value detected for profession. Please re-check!", "Error!"); } } catch (Exception ex) { AuditFactory.AuditLog(ex); ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message); } }
private int BindProfession() { using (DataTable dt = new BL_Profession().select(new ML_Profession { Profession = null })) { lst_professions.UnSelectAll(); lst_professions.DataSource = dt; lst_professions.DisplayMember = "Profession"; lst_professions.ValueMember = "Key"; return(dt.Rows.Count); } }