コード例 #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            RoleBll roleBll = new RoleBll();

            RoleInfo roleInfo = roleBll.GetRoleByName(txtRoleName.Text.Trim());

            if (roleInfo != null && roleInfo.RoleId > 0)
            {
                if (roleInfo.RoleId != RoleId)
                {
                    MessageBox.Show(this.UpdatePanel1, this.GetType(), "存在相同的角色");

                    return;
                }
            }
            roleInfo = GetModel();

            if (RoleId == 0)
            {
                roleBll.AddRole(roleInfo);
            }
            else
            {
                roleInfo.RoleId = RoleId;

                roleBll.UpdateRole(roleInfo);
            }
            MessageBox.Show(this.UpdatePanel1, this.GetType(), "保存成功!");
            InitGridView();
            txtRoleName.Text = "";
        }
コード例 #2
0
        public void InitData()
        {
            RoleBll roleBll = new RoleBll();

            RoleInfo roleInfo = roleBll.GetRoleById(RoleId);

            if (roleInfo != null)
            {
                lblCurrentRoleName.Text = roleInfo.RoleName;
            }
        }
コード例 #3
0
        public List<RoleInfo> GetRoleListByUserId(int userId)
        {
            RoleBll roleBll = new RoleBll();

            return roleBll.GetRoleListByUserId(userId);
        }
コード例 #4
0
        private void InitMenuList()
        {
            MenuBll menuBll = new MenuBll();

            List<MenuInfo> menuList = menuBll.GetMenuListByParentId(0);

            RoleMenuBll roleMenuBll = new RoleMenuBll();

            List<RoleMenuInfo> roleMenuList =  roleMenuBll.GetRoleMenuListByRoleId(RoleId);

            if (menuList != null)
            {
                RoleBll roleBll = new RoleBll();

                RoleInfo roleInfo = roleBll.GetRoleById(RoleId);

                if (roleInfo == null)
                {
                    return;
                }
                foreach (MenuInfo menuInfo in menuList)
                {

                    Label lbl = new Label();

                    lbl.Text = menuInfo.MenuName;

                    trMenuList.Controls.Add(lbl);

                    List<MenuInfo> subMenuList = menuBll.GetMenuListByParentId(menuInfo.MenuId);

                    CheckBoxList cbList = new CheckBoxList();

                    cbList.ID = "menuInfo_" + menuInfo.MenuId;

                    cbList.RepeatDirection = RepeatDirection.Horizontal;

                    cbList.RepeatColumns = 4;

                    cbList.DataSource = subMenuList;
                    cbList.DataTextField = "MenuName";

                    cbList.DataValueField = "MenuId";

                    cbList.DataBind();

                    foreach (ListItem li in cbList.Items)
                    {

                        if (roleMenuList != null)
                        {
                            foreach (RoleMenuInfo roleMenu in roleMenuList)
                            {
                                if (li.Value == roleMenu.MenuId.ToString())
                                {
                                    li.Selected = true;
                                }
                            }
                        }

                    }
                    trMenuList.Controls.Add(cbList);
                }
            }
        }
コード例 #5
0
        private void InitExistGridView()
        {
            RoleBll roleBll = new RoleBll();

            RoleInfo roleInfo = roleBll.GetRoleById(RoleId);

            if (roleInfo != null)
            {
                lblCurrentRoleName.Text = roleInfo.RoleName;
            }

            UserInfoBll userBll = new UserInfoBll();

            List<UserInfo> userList = userBll.GetUserListByRoleId(RoleId);

            if (userList.Count > 0)
            {
                gvExistsUserList.DataSource = userList;

                gvExistsUserList.DataBind();
            }
            else
            {
                BindNotRecord(gvExistsUserList);
            }
        }
コード例 #6
0
        protected void lbtnDelete_Click(object sender, EventArgs e)
        {
            LinkButton lbtnDelete = (LinkButton)sender;

            DataControlFieldCell dcf = (DataControlFieldCell)lbtnDelete.Parent;
            GridViewRow gvr = (GridViewRow)dcf.Parent;

            int roleId = 0;
            int.TryParse(gvRoleList.DataKeys[gvr.RowIndex][0].ToString(), out roleId);

            RoleId = roleId;

            RoleBll roleBll = new RoleBll();

            RoleInfo roleInfo = roleBll.GetRoleById(RoleId);

            if (roleInfo != null)
            {
                roleBll.DeleteRoleById(RoleId);

                RoleId = 0; ;

                InitGridView();
            }
        }
コード例 #7
0
        private void InitGridView()
        {
            RoleBll roleBll = new RoleBll();

            List<RoleInfo> roleList = roleBll.GetAllRole();

            if (roleList.Count > 0)
            {
                gvRoleList.DataSource = roleList;
                gvRoleList.DataBind();
            }
            else
            {
                BindNotRecord(gvRoleList);
            }
        }
コード例 #8
0
        protected void lbtnEdit_Click(object sender, EventArgs e)
        {
            LinkButton lbtnEdit = (LinkButton)sender;
            int roleId = 0;
            int.TryParse(lbtnEdit.ToolTip, out roleId);
            RoleId = roleId;

            RoleBll roleBll = new RoleBll();

            RoleInfo roleInfo = roleBll.GetRoleById(RoleId);

            if (roleInfo != null)
            {
                txtRoleName.Text = roleInfo.RoleName;

                txtRoleName.Focus();
            }
        }