public void Init() { if (Id.HasValue) { BllResult <Role> result = AppSession.BllService.GetRoleById(Id.Value); if (result.Success) { CurrentRole.Id = result.Data.Id; CurrentRole.RoleName = result.Data.RoleName; CurrentRole.Remark = result.Data.Remark; } else { MessageBox.Show("未能获取指定角色"); } } this.GridMain.DataContext = CurrentRole; BllResult <List <MenuOperation> > result2 = AppSession.BllService.GetAllMenuOperation(); if (!result2.Success) { MessageBox.Show("未能获取权限值"); } else { AllMenuOperations = result2.Data; } if (CurrentRole.Id != null) { result2 = AppSession.BllService.FindMenuOperation(new List <Role>() { CurrentRole }); if (!result2.Success) { MessageBox.Show("未能获取拥有的权限值"); } else { HasMenuOperations = result2.Data; AllMenuOperations.ForEach(t => { t.HasPerm = HasMenuOperations.Count(i => i.Id == t.Id) > 0; }); } } AppSession.BllService.Combine(AllMenuOperations.FindAll(t => t.ParentId == null).ToList(), AllMenuOperations); treeMain.ItemsSource = AllMenuOperations.FindAll(t => t.ParentId == null).ToList(); }
private void CheckBox_Click(object sender, RoutedEventArgs e) { CheckBox cb = (CheckBox)sender; int? id = (int?)cb.Tag; var temp = AllMenuOperations.Find(t => t.Id == id); List <int> ids = new List <int>(); AppSession.BllService.GetMenuOperationIds(new List <MenuOperation> { temp }, AllMenuOperations, ids); AllMenuOperations.ForEach(t => { if (ids.Count(i => i == t.Id) > 0) { t.HasPerm = !t.HasPerm; } }); }