private void btn_save_category_Click(object sender, EventArgs e) { try { if (!IsNewCategory && !hasAccessUpdate) { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "You have no save rights.", "Access Denied"); return; } if (txt_new_category.IsNotEmpty()) { using (DataTable Table = new BL_OrganisationCategory().select(new ML_OrganisationCategory { Category = txt_new_category.Text })) { if (Table.Rows.Count < 1) { if (IsNewCategory) { new BL_OrganisationCategory().insert(new ML_OrganisationCategory { Category = txt_new_category.Text }); } else if (CategoryID > 0) { new BL_OrganisationCategory().update(new ML_OrganisationCategory { Key = CategoryID, Category = txt_new_category.Text }); } LastCategory = txt_new_category.Text; ResetCategoryForm(); BindCategory(); SetPrevious(); } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The entered category is already in the database. Please re-check!", "Error"); } } } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Exclamation, "Null value detected for category. Please re-check!", "Error!"); } } catch (Exception ex) { AuditFactory.AuditLog(ex); ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message); } }
private int BindCategory() { using (DataTable dt = new BL_OrganisationCategory().select(new ML_OrganisationCategory { Category = null })) { cbo_category.Properties.DataSource = dt; cbo_category.Properties.DisplayMember = "Category"; cbo_category.Properties.ValueMember = "Key"; return(dt.Rows.Count); } }
private int BindCategory() { using (DataTable dt = new BL_OrganisationCategory().select(new ML_OrganisationCategory { Category = null })) { lst_categories.UnSelectAll(); lst_categories.DataSource = dt; lst_categories.DisplayMember = "Category"; lst_categories.ValueMember = "Key"; return(dt.Rows.Count); } }