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 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 ListModel = tb.ToList(); return ListModel; } #endregion } }