private void FillActions() { ContextManager manager = new ContextManager(); SecurityActionsLogic actions = new SecurityActionsLogic(manager); if (RolesCB.SelectedIndex >= 0) { int categoryId = Convert.ToInt32(CategoriesCB.SelectedValue); ActionsGV.DataSource = actions.GetByCategory(categoryId); } else { ActionsGV.DataSource = actions.GetAll(); } //ContextManager manager = new ContextManager(); DataGridViewCheckBoxCell ch1 = new DataGridViewCheckBoxCell(); SecurityRoleActionsLogic roleActions = new SecurityRoleActionsLogic(manager); foreach (DataGridViewRow row in ActionsGV.Rows) { ch1 = (DataGridViewCheckBoxCell)row.Cells["AllowAction"]; int actionId = Convert.ToInt32(row.Cells["ID"].Value.ToString()); int roleId = Convert.ToInt32(RolesCB.SelectedValue); bool actionAllow = roleActions.Exists(roleId, actionId, true); ch1.Value = actionAllow; } manager.CloseContext(); }
public ActionEdit(int _ID) { ID = _ID; InitializeComponent(); ContextManager manager = new ContextManager(); SecurityActionsLogic logic = new SecurityActionsLogic(manager); SecurityAction action = logic.Get(ID); NameTB.Text = action.Name; CodeTB.Text = action.Code; DescriptionTB.Text = action.Description; SecurityCategoriesLogic categoriesLogic = new SecurityCategoriesLogic(manager); //role.SecurityCategory.Name var categories = categoriesLogic.GetAll(); int i = 0; foreach (var category in categories) { Helpers.Item item = new Helpers.Item(); item.ID = category.ID.ToString(); item.Name = category.Name; CategoriesCB.Items.Add(item); if (action.CategoryID == category.ID) { CategoriesCB.SelectedIndex = i; } i++; } manager.CloseContext(); }
private void SaveBt_Click(object sender, EventArgs e) { ContextManager manager = new ContextManager(); SecurityActionsLogic logic = new SecurityActionsLogic(manager); logic.Create(NameTB.Text, CodeTB.Text, Convert.ToInt32(CategoriesCB.SelectedValue), DescriptionTB.Text); manager.Save(); manager.CloseContext(); this.Close(); }
private void DeleteSB_Click(object sender, EventArgs e) { ContextManager manager = new ContextManager(); SecurityActionsLogic sr = new SecurityActionsLogic(manager); sr.Delete(Convert.ToInt32(DataGV.SelectedRows[0].Cells[0].FormattedValue)); manager.Save(); FillGrid(); }
private void SaveBt_Click(object sender, EventArgs e) { ContextManager manager = new ContextManager(); SecurityActionsLogic logic = new SecurityActionsLogic(manager); int categoryId = Convert.ToInt32(((Helpers.Item)(CategoriesCB.SelectedItem)).ID); logic.Update(ID, NameTB.Text, categoryId, CodeTB.Text, DescriptionTB.Text); manager.Save(); manager.CloseContext(); this.Close(); }
private void FillGrid() { ContextManager manager = new ContextManager(); SecurityActionsLogic logic = new SecurityActionsLogic(manager); if (CategoriesLB.SelectedItems.Count > 0) { Compas.Model.SecurityCategory item = ((Compas.Model.SecurityCategory)(CategoriesLB.SelectedItems[0])); int categoryId = Convert.ToInt32(item.ID); DataGV.DataSource = logic.GetByCategory(categoryId); } else { DataGV.DataSource = logic.GetAll(); } manager.CloseContext(); }