protected void Page_Load(object sender, System.EventArgs e)
        {
            string s = Request.Params["UserID"];

            userID      = int.Parse(Request.Params["UserID"]);
            currentUser = new User(userID);

            Label1.Text = "用户: " + currentUser.UserName + " 角色分配";
            if (!Page.IsPostBack)
            {
                DataSet dsRole = AccountsTool.GetRoleList();
                CheckBoxList1.DataSource     = dsRole.Tables[0].DefaultView;
                CheckBoxList1.DataTextField  = "Description";
                CheckBoxList1.DataValueField = "RoleID";
                CheckBoxList1.DataBind();

                AccountsPrincipal newUser = new AccountsPrincipal(currentUser.UserName);

                if (newUser.Roles.Count > 0)
                {
                    ArrayList roles = newUser.Roles;
                    for (int i = 0; i < roles.Count; i++)
                    {
//						RoleList.Text += "<li>" + roles[i] + "</li>";
                        foreach (ListItem item in CheckBoxList1.Items)
                        {
                            if (item.Text == roles[i].ToString())
                            {
                                item.Selected = true;
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        private void BindRoles()
        {
            if (DropUserlist.SelectedItem == null)
            {
                return;
            }

            string UserName = DropUserlist.SelectedItem.Text;

            currentUser = new User(UserName);
            AccountsPrincipal newUser = new AccountsPrincipal(UserName);

            DataSet dsRole = AccountsTool.GetRoleList();

            chkboxRolelist.DataSource     = dsRole.Tables[0].DefaultView;
            chkboxRolelist.DataTextField  = "Description";
            chkboxRolelist.DataValueField = "RoleID";
            chkboxRolelist.DataBind();

            if (newUser.Roles.Count > 0)
            {
                ArrayList roles = newUser.Roles;
                for (int i = 0; i < roles.Count; i++)
                {
                    //RoleList.Text += "<li>" + roles[i] + "</li>";
                    foreach (ListItem item in chkboxRolelist.Items)
                    {
                        if (item.Text == roles[i].ToString())
                        {
                            item.Selected = true;
                        }
                    }
                }
            }
        }
Пример #3
0
        }                                                           //系统管理_用户角色分配管理_分配角色设置页

        public void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //Check
                string departmentId = this.DepartmentId;
                string userType     = this.UserType;
                if (string.IsNullOrWhiteSpace(departmentId) || string.IsNullOrWhiteSpace(UserType))
                {
                    return;
                }

                int enterpriseId = Globals.SafeInt(departmentId, -1);
                if (enterpriseId < 1)
                {
                    return;
                }

                ////获取企业信息
                //BLL.Ms.Enterprise enterpriseBll = new BLL.Ms.Enterprise();
                //Model.Ms.Enterprise enterprise = enterpriseBll.GetModel(enterpriseId);
                //lblName.Text = enterprise.Name;

                //获取下属用户
                User userBll = new User();
                ltbUser.DataSource     = userBll.GetUserList(userType, departmentId, string.Empty);
                ltbUser.DataTextField  = "UserName";
                ltbUser.DataValueField = "UserID";
                ltbUser.DataBind();
                ltbUser.SelectedIndex = 0;

                ////识别关联用户
                //for (int i = 0; i < ltbUser.Items.Count; i++)
                //{
                //    if (ltbUser.Items[i].Text == enterprise.UserName)
                //    {
                //        ltbUser.Items[i].Text += DefaultText;
                //    }
                //}

                //获取可分配角色
                DataSet dsRole = AccountsTool.GetRoleList();
                cblRole.DataSource     = dsRole.Tables[0].DefaultView;
                cblRole.DataTextField  = "Description";
                cblRole.DataValueField = "RoleID";
                cblRole.DataBind();

                //移除保留角色
                for (int n = 0; n < cblRole.Items.Count; n++)
                {
                    if (ReservedRoleIDs.Contains(cblRole.Items[n].Value))
                    {
                        cblRole.Items.Remove(cblRole.Items[n]);
                    }
                }

                //设置选择用户角色
                SelectionRoles();
            }
        }
Пример #4
0
        private void dataBind()
        {
            roles = AccountsTool.GetRoleList();
            DataView dv = roles.Tables["Roles"].DefaultView;

            //保留角色
            if (!UserPrincipal.HasPermissionID(GetPermidByActID(Act_ShowReservedRole)))
            {
                dv.RowFilter = "RoleID not in (" + ReservedRoleIDs + ")";
            }
            RoleList.DataSource = dv; //roles.Tables["Roles"];
            RoleList.DataBind();
        }
Пример #5
0
        }                                                           //系统管理_用户管理_角色分配页面
        public void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if ((Request.Params["UserID"] != null) && (Request.Params["UserID"] != ""))
                {
                    string userID = Request.Params["UserID"];
                    lblUserID.Text = userID;
                    User    currentUser = new User(Convert.ToInt32(userID));
                    DataSet dsRole      = AccountsTool.GetRoleList();
                    CheckBoxList1.DataSource     = dsRole.Tables[0].DefaultView;
                    CheckBoxList1.DataTextField  = "Description";
                    CheckBoxList1.DataValueField = "RoleID";
                    CheckBoxList1.DataBind();

                    AccountsPrincipal newUser = new AccountsPrincipal(currentUser.UserName);
                    if (newUser.Roles.Count > 0)
                    {
                        ArrayList roles = newUser.Roles;
                        for (int i = 0; i < roles.Count; i++)
                        {
                            foreach (ListItem item in CheckBoxList1.Items)
                            {
                                if (item.Text == roles[i].ToString())
                                {
                                    item.Selected = true;
                                }
                            }
                        }
                    }


                    //移除保留角色
                    if (!UserPrincipal.HasPermissionID(GetPermidByActID(Act_ShowReservedRole)))
                    {
                        for (int n = 0; n < CheckBoxList1.Items.Count; n++)
                        {
                            if (ReservedRoleIDs.Contains(CheckBoxList1.Items[n].Value))
                            {
                                CheckBoxList1.Items.Remove(CheckBoxList1.Items[n]);
                            }
                        }
                    }
                }
            }
        }
Пример #6
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            userID      = int.Parse(Request.Params["UserID"]);
            currentUser = new User(userID);

            Label1.Text = "为用户: " + currentUser.UserName + " 分配角色";
            if (!Page.IsPostBack)
            {
                //获取并显示所有角色
                DataSet dsRole = AccountsTool.GetRoleList();
                CheckBoxList1.DataSource     = dsRole.Tables[0].DefaultView;
                CheckBoxList1.DataTextField  = "Description";
                CheckBoxList1.DataValueField = "RoleID";
                CheckBoxList1.DataBind();

                //获取用户已经拥有的角色,遍历CheckBoxList控件设置选中状态
                AccountsPrincipal newUser = new AccountsPrincipal(currentUser.UserName);
                if (newUser.Roles.Count > 0)
                {
                    ArrayList roles = newUser.Roles;
                    for (int i = 0; i < roles.Count; i++)
                    {
                        foreach (ListItem item in CheckBoxList1.Items)
                        {
                            if (item.Text == roles[i].ToString())
                            {
                                item.Selected = true;
                            }
                        }
                    }
                }

                if (newUser.Permissions.Count > 0)
                {
                    RoleList.Visible = true;
                    ArrayList Permissions = newUser.Permissions;
                    RoleList.Text = "用户拥有的权限列表:<ul>";
                    for (int i = 0; i < Permissions.Count; i++)
                    {
                        RoleList.Text += "<li>" + Permissions[i] + "</li>";
                    }
                    RoleList.Text += "</ul>";
                }
            }
        }
Пример #7
0
 private void dataBind()
 {
     roles = AccountsTool.GetRoleList();
     RoleList.DataSource = roles.Tables["Roles"];
     RoleList.DataBind();
 }