/// <summary> /// 查询用户所属的菜单信息 /// </summary> /// <param name="userno">用户编码</param> /// <returns></returns> public List <sysmenu> QueryMenus(string userno) { SysUserRoleDal userroledal = new SysUserRoleDal(); sysuser_role userrole = new sysuser_role() { userno = userno, roleno = "Administrator" }; userrole = userroledal.QueryEntity(userrole); string strSQL = "select a.* from sysmenu a order by a.menusort"; List <DBMemberEntity> entitys = new List <DBMemberEntity>(); if (userrole == null) { strSQL = @"select a.* from sysmenu a,sysuser_role b,sysrole_menu c where a.menuno = c.menuno and c.roleno = b.roleno and b.userno = @userno order by a.menusort"; entitys.AddMember("userno", userno); } DataSet ds = dbhelper.Query(strSQL, entitys); List <sysmenu> menus = new List <sysmenu>(); if (ds != null && ds.Tables.Count > 0) { menus = ModelHelper.ToModel <List <sysmenu> >(ds.Tables[0]); } return(menus); }
/// <summary> /// 获得用户对应菜单的权限 /// </summary> /// <param name="userno">用户编号</param> /// <param name="menuno">菜单编号</param> /// <returns></returns> public List <syspower> QueryUserPower(string userno, string menuno) { SysUserRoleDal userroledal = new SysUserRoleDal(); sysuser_role userrole = new sysuser_role() { userno = userno, roleno = "Administrator" }; userrole = userroledal.QueryEntity(userrole); string strSQL = @"select a.* from syspower a,sysmenu_power b where a.powerno = b.powerno and b.menuno = @menuno"; List <DBMemberEntity> entitys = new List <DBMemberEntity>(); if (userrole == null) { strSQL = @"select d.* from syspower a,sysuser_role b,sysrole_menu c,sysrole_menu_power d where b.roleno = c.roleno and c.roleno = d.roleno and c.menuno = d.menuno and d.powerno = a.powerno and b.userno = @userno and c.menuno = @menuno"; entitys.AddMember("userno", userno); entitys.AddMember("menuno", menuno); } else { entitys.AddMember("menuno", menuno); } DataSet ds = dbhelper.Query(strSQL, entitys); List <syspower> powers = new List <syspower>(); if (ds != null && ds.Tables.Count > 0) { powers = ModelHelper.ToModel <List <syspower> >(ds.Tables[0]); } return(powers); }