private void btnAddUser_Click(object sender, EventArgs e) { if (this.iGridEXGroup.CurrentRow != null) { var group = (SecurityGroupDto)this.iGridEXGroup.CurrentRow.DataRow; SecurityUserPresenter presenter = new SecurityUserPresenter(); var users = presenter.GetAll().UserDtoList; var tbl = DataTableHelper.ConvertToDatatable <UserDto>(users); ILov lovActionOrder; LovFields lfActionOrder; lfActionOrder = new LovFields(); lfActionOrder.AddItem(AssemblyReflector.GetMemberName((UserDto m) => m.FirstName), "نام", 100, true); lfActionOrder.AddItem(AssemblyReflector.GetMemberName((UserDto m) => m.LastName), "نام خانوادگی", 100, true); lfActionOrder.AddItem(AssemblyReflector.GetMemberName((UserDto m) => m.PersonelCode), "کد پرسنلی", 100, true); lfActionOrder.AddItem(AssemblyReflector.GetMemberName((UserDto m) => m.NationalNo), "کد ملی", 100, true); lovActionOrder = new ILov(this.btnAddUser, "ليست کاربران", tbl, lfActionOrder); var row = lovActionOrder.ShowDialog() as DataRow; if (row != null) { var userId = row.Field <long>(AssemblyReflector.GetMemberName((UserDto m) => m.UserId)); var selectedUser = users.Where(it => it.UserId == userId).FirstOrDefault(); string message = string.Format("آیا از انتساب گروه {0} به {1} مطمئن هستید؟", group.DisplayName, selectedUser.FullName); if (ISE.Framework.Client.Win.Viewer.MessageViewer.ShowAlert(message) != DialogResult.OK) { return; } view.AssignUser(group, selectedUser); } } }
private void gridUsers_SelectionChanged(object sender, EventArgs e) { if (this.gridUsers.CurrentRow != null) { var user = (UserDto)this.gridUsers.CurrentRow.DataRow; if (user != null) { SecurityUserPresenter presenter = new SecurityUserPresenter(); if (user.RoleIdList == null || user.RoleIdList.Count == 0) { user.RoleIdList = presenter.GetUserRoleIds(user.UserId); } if (user.GroupIdList == null || user.GroupIdList.Count == 0) { user.GroupIdList = presenter.GetUserGroupIds(user.UserId); } groupBS.DataSource = view.BindGroups(user.GroupIdList); roleBS.DataSource = view.BindRoles(user.RoleIdList); this.iGridEXGrp.DataSource = groupBS; this.iGridEXRole.DataSource = roleBS; LoadAccounts(); //time consum ReloadTree(); } } }
public void DeAssignUser(RoleDto role, UserDto user) { SecurityUserPresenter userPresenter = new SecurityUserPresenter(); if (userPresenter.DeAssignUserToRole(user, role.RoleId)) { SecurityUserBindingList.Remove(user); } }