/// <summary> /// Заповнюємо список ролей /// </summary> private void FillRoles() { SecurityUserRolesLogic userRoles = new SecurityUserRolesLogic(manager); SecurityRolesLogic roles = new SecurityRolesLogic(manager); List<SecurityRole> allRoles = roles.GetAll(); if (userId != null) { List<SecurityUserRole> userHasRoles = userRoles.GetAll(Convert.ToInt32(userId)); foreach (var role in allRoles) { Helpers.Item item = new Item(); item.ID = role.ID.ToString(); item.Name = role.Name; ((ListBox)RolesLB).DisplayMember = "Name"; ((ListBox)RolesLB).ValueMember = "ID"; SecurityUserRole userRole = userHasRoles.Where(a => a.RoleID == role.ID).Select(a => a).FirstOrDefault(); bool selected = false; if (userRole != null) { selected = true; } RolesLB.Items.Add(item, selected); } } }
private void FillGrid() { ContextManager manager = new ContextManager(); SecurityRolesLogic sr = new SecurityRolesLogic(manager); RolesGV.DataSource = sr.GetAll(); manager.CloseContext(); }
/// <summary> /// Заповнюємо список ролей /// </summary> private void FillRoles() { SecurityUserRolesLogic userRoles = new SecurityUserRolesLogic(manager); SecurityRolesLogic roles = new SecurityRolesLogic(manager); List <SecurityRole> allRoles = roles.GetAll(); if (userId != null) { List <SecurityUserRole> userHasRoles = userRoles.GetAll(Convert.ToInt32(userId)); foreach (var role in allRoles) { Helpers.Item item = new Item(); item.ID = role.ID.ToString(); item.Name = role.Name; ((ListBox)RolesLB).DisplayMember = "Name"; ((ListBox)RolesLB).ValueMember = "ID"; SecurityUserRole userRole = userHasRoles.Where(a => a.RoleID == role.ID).Select(a => a).FirstOrDefault(); bool selected = false; if (userRole != null) { selected = true; } RolesLB.Items.Add(item, selected); } } }
private void DeleteSB_Click(object sender, EventArgs e) { ContextManager manager = new ContextManager(); SecurityRolesLogic sr = new SecurityRolesLogic(manager); sr.Delete(Convert.ToInt32(RolesGV.SelectedRows[0].Cells[0].FormattedValue)); manager.Save(); FillGrid(); manager.CloseContext(); }
private void SaveBt_Click(object sender, EventArgs e) { ContextManager manager = new ContextManager(); SecurityRolesLogic sr = new SecurityRolesLogic(manager); sr.Create(NameTB.Text, DescriptionTB.Text); manager.Save(); manager.CloseContext(); this.Close(); }
public RoleEdit(int _ID) { ID = _ID; InitializeComponent(); ContextManager manager = new ContextManager(); SecurityRolesLogic sr = new SecurityRolesLogic(manager); SecurityRole role = sr.Get(ID); NameTB.Text = role.Name; DescriptionTB.Text = role.Description; manager.CloseContext(); }
public RoleActionsF() { InitializeComponent(); //створюэмо грід з можливістю групування GroupByGrid grid = new GroupByGrid(); ContextManager manager = new ContextManager(); SecurityActionsLogic actions = new Logic.Security.SecurityActionsLogic(manager); SecurityCategoriesLogic categories = new SecurityCategoriesLogic(manager); SecurityRolesLogic roles = new SecurityRolesLogic(manager); ActionsGV.AutoGenerateColumns = false; RolesCB.DataSource = roles.GetAll(); CategoriesCB.DataSource = categories.GetAll(); manager.CloseContext(); }