protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["trang"] != null) { trang = Request.QueryString["trang"].ToString(); } if (string.IsNullOrEmpty(trang)) { trang = "1"; } if (Request.QueryString["s"] != null) { keyword = Request.QueryString["s"].ToString(); } txtTimKiem.Text = keyword; int.TryParse(trang, out pageIndex); StartIndex = pageSize * (pageIndex - 1); Sys_DanhMucNhomRepository repository = new Sys_DanhMucNhomRepository(); List <Sys_DanhMucNhom> data = repository.GetTable().Where(x => string.IsNullOrEmpty(keyword) || x.TenNhom.Contains(keyword)).OrderByDescending(x => x.NgayThayDoi).ToList(); CollectionPager1.MaxPages = 10000; CollectionPager1.PageSize = 10; // số items hiển thị trên một trang. CollectionPager1.DataSource = data; CollectionPager1.BindToControl = rptData; rptData.DataSource = CollectionPager1.DataSourcePaged; rptData.DataBind(); }
private void ShowDetail() { ///Show Groups Sys_NguoiDungNhomRepository userGroupRepository = new Sys_NguoiDungNhomRepository(); List <Sys_NguoiDungNhom> userGroups = userGroupRepository.GetTable().Where(x => x.UserId == new Guid(user.ProviderUserKey.ToString())).ToList(); List <int> userGroupsIds = new List <int>(); userGroups.ForEach(x => userGroupsIds.Add(x.GroupID)); Sys_DanhMucNhomRepository groupRepository = new Sys_DanhMucNhomRepository(); List <Sys_DanhMucNhom> groups = groupRepository.GetAll().ToList(); List <UserGroupViewModel> vms = new List <UserGroupViewModel>(); groups.FindAll(x => userGroupsIds.Contains(x.ID)).ForEach(x => vms.Add(new UserGroupViewModel { Group = x, IsChecked = true })); rptGroups.DataSource = vms.OrderBy(x => x.Group.TenNhom).ToList(); rptGroups.DataBind(); ///Show Permissions IsSystemAdmin = xRPMembership.IsSystemAdmin(user.UserName); if (!IsSystemAdmin) { List <Role> roles = xRPMembership.GetRoleForUser(user.UserName); rptPermissions.DataSource = roles; rptPermissions.DataBind(); } else { rptPermissions.Visible = false; } if (staff != null) { txtName.Text = staff.TenCanBo; txtSoDienThoai.Text = staff.SoDienThoai; } List <PositionViewModel> positions = new List <PositionViewModel>(); if (staff != null) { positions = staffService.GetPositionByStaff(staff.ID); } rptDepartments.DataSource = positions; rptDepartments.DataBind(); }
public static string DeleteGroupItem(string itemID) { AjaxResponse response = new AjaxResponse(); try { //Initial data context variable, this class is declared in .dbml file in xRPDAL namespace Sys_DanhMucNhomRepository repository = new Sys_DanhMucNhomRepository(); Sys_DanhMucNhom entity = repository.GetById(int.Parse(itemID)); repository.DeleteOnSubmit(entity); repository.SubmitChanges(); response.IsSuccess = true; response.Message = "OK"; } catch (Exception ex) { response.IsSuccess = false; response.Message = (ex.Message + ex.StackTrace).EncodeJsString(); } return(JsonConvert.SerializeObject(response)); }
private void ShowDetail() { ///Show Groups Sys_NguoiDungNhomRepository userGroupRepository = new Sys_NguoiDungNhomRepository(); List <Sys_NguoiDungNhom> userGroups = userGroupRepository.GetTable().Where(x => x.UserId == new Guid(user.ProviderUserKey.ToString())).ToList(); List <int> userGroupsIds = new List <int>(); userGroups.ForEach(x => userGroupsIds.Add(x.GroupID)); Sys_DanhMucNhomRepository groupRepository = new Sys_DanhMucNhomRepository(); List <Sys_DanhMucNhom> groups = groupRepository.GetAll().ToList(); List <UserGroupViewModel> vms = new List <UserGroupViewModel>(); groups.FindAll(x => !userGroupsIds.Contains(x.ID)).ForEach(x => vms.Add(new UserGroupViewModel { Group = x, IsChecked = false })); groups.FindAll(x => userGroupsIds.Contains(x.ID)).ForEach(x => vms.Add(new UserGroupViewModel { Group = x, IsChecked = true })); rptGroups.DataSource = vms.OrderBy(x => x.Group.TenNhom).ToList(); rptGroups.DataBind(); ///Show Permissions List <UserPermissionViewModel> permissions = new List <UserPermissionViewModel>(); List <Role> allRole = xRPMembership.GetAllRoles(); List <Role> rolesFromGroup = xRPMembership.GetUserRolesFromGroup(new Guid(user.ProviderUserKey.ToString())); List <Role> grantRoles = xRPMembership.GetGrantRolesForUser(new Guid(user.ProviderUserKey.ToString())); List <Role> denyRoles = xRPMembership.GetDenyRolesForUser(new Guid(user.ProviderUserKey.ToString())); List <Guid> guids = new List <Guid>(); List <Guid> groupRoleGuids = new List <Guid>(); rolesFromGroup.ForEach(x => groupRoleGuids.Add(x.ID)); rolesFromGroup.ForEach(x => guids.Add(x.ID)); grantRoles.ForEach(x => guids.Add(x.ID)); denyRoles.ForEach(x => guids.Add(x.ID)); allRole.RemoveAll(x => guids.Contains(x.ID)); guids = new List <Guid>(); denyRoles.ForEach(x => guids.Add(x.ID)); grantRoles.ForEach(x => guids.Add(x.ID)); rolesFromGroup.RemoveAll(x => guids.Contains(x.ID)); rolesFromGroup.ForEach(x => permissions.Add(new UserPermissionViewModel { IsInherit = true, Role = x })); grantRoles.FindAll(x => groupRoleGuids.Contains(x.ID)).ForEach(x => permissions.Add(new UserPermissionViewModel { IsOverride = true, Role = x, IsGrant = true, IsAssigned = true })); grantRoles.FindAll(x => !groupRoleGuids.Contains(x.ID)).ForEach(x => permissions.Add(new UserPermissionViewModel { Role = x, IsGrant = true, IsAssigned = true })); denyRoles.FindAll(x => groupRoleGuids.Contains(x.ID)).ForEach(x => permissions.Add(new UserPermissionViewModel { IsOverride = true, Role = x, IsDeny = true, IsAssigned = true })); denyRoles.FindAll(x => !groupRoleGuids.Contains(x.ID)).ForEach(x => permissions.Add(new UserPermissionViewModel { Role = x, IsDeny = true, IsAssigned = true })); allRole.ForEach(x => permissions.Add(new UserPermissionViewModel { Role = x, IsOrphan = true })); rptPermissions.DataSource = permissions.OrderBy(x => x.Role.Name).ToList(); rptPermissions.DataBind(); }