private void btn_save_sub_category_Click(object sender, EventArgs e) { try { if (!IsNewSubCategory && !hasAccessUpdate) { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "You have no save rights.", "Access Denied"); return; } if (txt_new_sub_category.IsNotEmpty()) { using (DataTable Table = new BL_OrganisationSubCategory().select(new ML_OrganisationSubCategory { SubCategory = txt_new_sub_category.Text })) { if (Table.Rows.Count < 1) { if (IsNewSubCategory) { new BL_OrganisationSubCategory().insert(new ML_OrganisationSubCategory { CategoryKey = CategoryID, SubCategory = txt_new_sub_category.Text }); } else if (SubCategoryID > 0) { new BL_OrganisationSubCategory().update(new ML_OrganisationSubCategory { Key = SubCategoryID, SubCategory = txt_new_sub_category.Text }); } LastCategory = lst_categories.Text; LastSubCategory = txt_new_sub_category.Text; ResetSubCategoryForm(); lst_categories_SelectedIndexChanged(this, new EventArgs()); SetPrevious(); } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, "The entered sub category is already in the database. Please re-check!", "Error"); } } } else { ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Exclamation, "Null value detected for sub category. Please re-check!", "Error!"); } } catch (Exception ex) { AuditFactory.AuditLog(ex); ApplicationUtilities.ShowMessage(UniversalEnum.MessageTypes.Error, ex.Message); } }
private int BindSubCategory(int CategoryID) { using (DataTable dt = new BL_OrganisationSubCategory().selectByCategory(new ML_OrganisationSubCategory { CategoryKey = CategoryID })) { cbo_sub_category.Properties.DataSource = dt; cbo_sub_category.Properties.DisplayMember = "SubCategory"; cbo_sub_category.Properties.ValueMember = "SubCategoryKey"; cbo_sub_category.ItemIndex = dt.Rows.Count > 0 ? 0 : -1; return(dt.Rows.Count); } }
private int BindSubCategory(int CategoryID) { using (DataTable dt = new BL_OrganisationSubCategory().selectByCategory(new ML_OrganisationSubCategory { CategoryKey = CategoryID })) { txt_new_sub_category.Clear(); lst_sub_categories.UnSelectAll(); lst_sub_categories.DataSource = dt; lst_sub_categories.DisplayMember = "SubCategory"; lst_sub_categories.ValueMember = "Key"; return(dt.Rows.Count); } }