コード例 #1
0
        /// <summary>
        /// 同步角色下的用户权限
        /// </summary>
        /// <param name="menus">要同步的菜单权限</param>
        private void SetPersmissionByRole(List <MyTreeNode> menus)
        {
            int roleID = Convert.ToInt32(Request.QueryString["id"]);

            //角色下的用户ID,已“,”分隔
            string users = LoginDataLimitManager.GetUsersByRole(roleID);

            if (users != string.Empty)
            {
                string[] usersArr = users.Split(',');
                //删除用户权限
                for (int i = 0; i < usersArr.Length; i++)
                {
                    LoginUserLimitManager.DeleteLoginLimitByUser(int.Parse(usersArr[i]));
                }

                LoginUserLimit userLimit = new LoginUserLimit();
                //添加用户权限
                for (int i = 0; i < usersArr.Length; i++)
                {
                    for (int j = 0; j < menus.Count(); j++)
                    {
                        LoginUserLimitManager.InsertUserLimt(usersArr[i], menus[j].Id.ToString());
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        ///[LoginUserLimit]表查询实体的方法
        /// </summary>
        public static LoginUserLimit getLoginUserLimitById(int limitid)
        {
            LoginUserLimit loginuserlimit = null;

            string sql = "select * from LoginUserLimit where limitid=@limitid";

            SqlParameter[] sp = new SqlParameter[]
            {
                new SqlParameter("@limitid", limitid)
            };
            DataTable dt = DBHelper.GetDataSet(sql, sp);

            if (dt.Rows.Count > 0)
            {
                loginuserlimit = new LoginUserLimit();
                foreach (DataRow dr in dt.Rows)
                {
                    loginuserlimit.Limitid = Convert.ToInt32(dr["limitid"]);
                    loginuserlimit.Loginid = Convert.ToString(dr["loginid"]);
                    loginuserlimit.Nodeid  = MenuService.getMenuById((int)dr["nodeid"]);
                }
            }

            return(loginuserlimit);
        }
コード例 #3
0
        /// <summary>
        ///[LoginUserLimit]表添加的方法
        /// </summary>
        public static int addLoginUserLimit(LoginUserLimit loginuserlimit)
        {
            string sql = "insert into LoginUserLimit([loginid],[nodeid]) values (@loginid,@nodeid)";

            SqlParameter[] sp = new SqlParameter[]
            {
                new SqlParameter("@loginid", loginuserlimit.Loginid),
                new SqlParameter("@nodeid", loginuserlimit.Nodeid.Nodeid)
            };
            return(DBHelper.ExecuteCommand(sql, sp));
        }
コード例 #4
0
        /// <summary>
        ///[LoginUserLimit]表修改的方法
        /// </summary>
        public static int updateLoginUserLimitById(LoginUserLimit loginuserlimit)
        {
            string sql = "update LoginUserLimit set loginid=@loginid,nodeid=@nodeid where limitid=@limitid";

            SqlParameter[] sp = new SqlParameter[]
            {
                new SqlParameter("@limitid", loginuserlimit.Limitid),
                new SqlParameter("@loginid", loginuserlimit.Loginid),
                new SqlParameter("@nodeid", loginuserlimit.Nodeid.Nodeid)
            };
            return(DBHelper.ExecuteCommand(sql, sp));
        }
コード例 #5
0
        /// <summary>
        ///根据SQL语句获取实体
        /// </summary>
        public static LoginUserLimit getLoginUserLimitBySql(string sql)
        {
            LoginUserLimit loginuserlimit = null;
            DataTable      dt             = DBHelper.GetDataSet(sql);

            if (dt.Rows.Count > 0)
            {
                loginuserlimit = new LoginUserLimit();
                foreach (DataRow dr in dt.Rows)
                {
                    loginuserlimit.Limitid = Convert.ToInt32(dr["limitid"]);
                    loginuserlimit.Loginid = Convert.ToString(dr["loginid"]);
                    loginuserlimit.Nodeid  = MenuService.getMenuById((int)dr["nodeid"]);
                }
            }
            return(loginuserlimit);
        }
コード例 #6
0
 public static int updateLoginUserLimit(LoginUserLimit loginuserlimit)
 {
     return(LoginUserLimitService.updateLoginUserLimitById(loginuserlimit));
 }
コード例 #7
0
 public static int addLoginUserLimit(LoginUserLimit loginuserlimit)
 {
     return(LoginUserLimitService.addLoginUserLimit(loginuserlimit));
 }