/// <summary> /// 绑定数据 /// </summary> private void DisplayData() { try { cbkSystems.DataSource = loginService.AdminSystems; cbkSystems.DataTextField = "Name"; cbkSystems.DataValueField = "ID"; cbkSystems.DataBind(); cbkAdminSystems.DataSource = loginService.AdminSystems; cbkAdminSystems.DataTextField = "Name"; cbkAdminSystems.DataValueField = "ID"; cbkAdminSystems.DataBind(); List <UserSystem> selectedUserSystems = new URRightsService().GetUserSystems(UserID); foreach (ListItem item in cbkSystems.Items) { if (selectedUserSystems.Exists(a => int.Parse(item.Value) == a.SystemID)) { item.Selected = true; } } foreach (ListItem item in cbkAdminSystems.Items) { if (selectedUserSystems.Exists(a => int.Parse(item.Value) == a.SystemID && a.Admin)) { item.Selected = true; } } } catch (NotRightException) { AlertBack("您没有权限执行此操作"); } }
/// <summary> /// 绑定数据 /// </summary> private void DisplayData() { try { URBasicInfoService biService = new URBasicInfoService(); //特定用户类型要限定特定角色 List <Role> rangeRoles = biService.GetRoles(SelectedSysID); User user = biService.GetUser(UserID); if (user.AccountType == UserTypeOptions.Channel) { rangeRoles = rangeRoles.Where(a => a.RoleType == RoleTypeOptions.Channel).ToList(); } else if (user.AccountType == UserTypeOptions.ChannelPartner) { rangeRoles = rangeRoles.Where(a => a.RoleType == RoleTypeOptions.ChannelPartner).ToList(); } cbkListrole.DataSource = rangeRoles; cbkListrole.DataTextField = "Name"; cbkListrole.DataValueField = "ID"; cbkListrole.DataBind(); List <int> selectedRoleIds = new URRightsService().GetUserRoles(SelectedSysID, UserID); foreach (ListItem item in cbkListrole.Items) { if (selectedRoleIds.Exists(a => int.Parse(item.Value) == a)) { item.Selected = true; } } } catch (NotRightException) { AlertBack("您没有权限执行此操作"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (RoleID > 0) { int sysId = GetQueryString("sysId").ToInt32(0); if (sysId <= 0) { throw new NotRightException(); } ddlSystems.DataSource = loginService.AdminSystems.Where(a => a.ID == sysId); } else { List <UserSystem> userSystems = new URRightsService().GetUserSystems(UserID); ddlSystems.DataSource = loginService.AdminSystems.Where(a => userSystems.Exists(b => a.ID == b.SystemID)); } ddlSystems.DataTextField = "Name"; ddlSystems.DataValueField = "ID"; ddlSystems.DataBind(); ddlSystems.SelectedValue = Request["sysId"]; ddlSystems.AutoPostBack = true; } PageTitle = string.Format("为{0}【{1}】设置权限", UserID > 0 ? "用户" : "角色", GetQueryString("name")); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { List <UserSystem> userSystems = new URRightsService().GetUserSystems(UserID); ddlSystems.DataSource = loginService.AdminSystems.Where(a => userSystems.Exists(b => a.ID == b.SystemID)); ddlSystems.DataTextField = "Name"; ddlSystems.DataValueField = "ID"; ddlSystems.DataBind(); ddlSystems.SelectedValue = Request["sysId"]; ddlSystems.AutoPostBack = true; DisplayData(); } }