You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data;
using System.Linq;
using System.Text;
namespace MenuTool
{
public class StaticModel
{
public static string SetupPath = "";
public static string BaseDirectoryName = "";
#region 查询机构
public static List<BaseModel> GetListCompany(int UserID, string UserType)
{
string tsql = @"
if @UserType='M' --超级管理员
begin
select ID=CompanyID,Name=CompanyName from JC_Company where State=1
end
else
begin
select ID=a.CompanyID,Name=a.CompanyName from JC_Company a
inner join JC_UserInfo b on a.CompanyID=b.CompanyID
where UserID=@UserID
end
";
Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetSqlStringCommand(tsql);
db.AddInParameter(cmd, "@UserType", DbType.String, UserType);
db.AddInParameter(cmd, "@UserID", DbType.Int32, UserID);
DataTable tb = db.ExecuteDataTable(cmd);
List<BaseModel> ListModel = tb.ToList<BaseModel>();
return ListModel;
}
#endregion
}
}