You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
3.4 KiB
108 lines
3.4 KiB
3 months ago
|
using MESClassLibrary.BLL.Log;
|
||
|
using MESClassLibrary.Model;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Data;
|
||
|
using System.Data.SqlClient;
|
||
|
using System.Linq;
|
||
|
using System.Reflection;
|
||
|
using System.Text;
|
||
|
|
||
|
namespace MESClassLibrary.DAL.User
|
||
|
{
|
||
|
public class Sys_NavMenuData
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 根据userID查询用户菜单
|
||
|
/// </summary>
|
||
|
/// <param name="userID"></param>
|
||
|
/// <returns></returns>
|
||
|
public DataTable BuilderLeftMenu(string userID)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
List<Sys_NavMenuInfo> list = new List<Sys_NavMenuInfo>();
|
||
|
DataTable dt = new DataTable();
|
||
|
/*
|
||
|
string sql = @"
|
||
|
SELECT [MenuID]
|
||
|
,[MenuName]
|
||
|
,[URLStr]
|
||
|
,[ItemPic]
|
||
|
,[PowerID]
|
||
|
,[ParentMenuID]
|
||
|
,[IsEnabled]
|
||
|
,[OrderNum]
|
||
|
FROM [T_Sys_NavMenu]
|
||
|
where PowerID in (
|
||
|
select e.PowerID
|
||
|
from T_Sys_Users a
|
||
|
join T_Sys_UserRole b
|
||
|
on a.UserID = b.UserID
|
||
|
join T_Sys_Role c
|
||
|
on b.RoleID = c.RoleID
|
||
|
join T_Sys_RoleLinkPower d
|
||
|
on c.RoleID = d.RoleID
|
||
|
join T_Sys_Power e
|
||
|
on d.PowerID = e.PowerID
|
||
|
where a.UserID = @userID
|
||
|
)
|
||
|
and IsEnabled = '1'
|
||
|
order by OrderNum
|
||
|
";
|
||
|
*/
|
||
|
string sql = @"
|
||
|
IF EXISTS(SELECT * from T_Sys_Users where UserID=@userID and UserName='admin')
|
||
|
BEGIN
|
||
|
SELECT m.[MenuID],
|
||
|
m.[MenuName],
|
||
|
m.[URLStr],
|
||
|
m.[ItemPic],
|
||
|
m.[PowerID],
|
||
|
m.[ParentMenuID],
|
||
|
m.[IsEnabled],
|
||
|
m.[OrderNum]
|
||
|
FROM [T_Sys_NavMenu] m
|
||
|
END
|
||
|
ELSE
|
||
|
BEGIN
|
||
|
SELECT m.[MenuID],
|
||
|
m.[MenuName],
|
||
|
m.[URLStr],
|
||
|
m.[ItemPic],
|
||
|
m.[PowerID],
|
||
|
m.[ParentMenuID],
|
||
|
m.[IsEnabled],
|
||
|
m.[OrderNum]
|
||
|
FROM [T_Sys_NavMenu] m
|
||
|
WHERE m.ParentMenuID IS NULL
|
||
|
UNION ALL
|
||
|
SELECT m.[MenuID],
|
||
|
m.[MenuName],
|
||
|
m.[URLStr],
|
||
|
m.[ItemPic],
|
||
|
m.[PowerID],
|
||
|
m.[ParentMenuID],
|
||
|
m.[IsEnabled],
|
||
|
m.[OrderNum]
|
||
|
FROM [T_Sys_NavMenu] m
|
||
|
INNER JOIN T_Sys_Users_NavMenu um ON m.MenuID = um.MenuID
|
||
|
WHERE um.UserID = @userID
|
||
|
END";
|
||
|
SqlParameter[] param = new SqlParameter[1];
|
||
|
param[0] = new SqlParameter("@userID", SqlDbType.UniqueIdentifier);
|
||
|
param[0].Value = new Guid(userID);
|
||
|
|
||
|
dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
|
||
|
|
||
|
return dt;
|
||
|
}
|
||
|
catch(Exception ex)
|
||
|
{
|
||
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
||
|
return new DataTable();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|