public DataSet getProjectDs(int pageRecord, int page, string searchVal, string operateUserId)
{
bool searchAll = SecurityUtil.hasPermission(operateUserId, "功能权限/项目管理/项目列表/查看所有项目");
string strWhere = string.Empty;
if (searchVal.Length > 0)
{
searchVal = searchVal.Replace("'", "’").Replace("del", "").Replace("drop", "").Replace("update", "").Replace("alter", "");
string[] str = searchVal.Split(new char[] { ',' });
if (str.Length > 0 && str[0].Length > 0) { strWhere += " and (a.code like '%" + str[0] + "%' or a.name like '%" + str[0] + "%')"; }
//if (str.Length > 1 && str[1].Length > 0) { strWhere += " and a.name like '%" + str[1] + "%'"; }
}
DataSet projectDs = null;
StringBuilder strSql = new StringBuilder();
strSql.Append(" select * from (");
strSql.Append(" select row_number() over(order by a.code desc) as id,");
strSql.Append(" a.*, b.name typeName, c.itemContent statusName, d.itemContent provinceName, e.name creatorName,");
strSql.Append(" CONVERT(varchar(10), a.actualStartDate, 20) _actualStartDate,");
strSql.Append(" CONVERT(varchar(10), a.planStartDate, 20) _planStartDate,");
strSql.Append(" CONVERT(varchar(10), a.planEndDate, 20) _planEndDate,");
strSql.Append(" (select sysId from om_account where human_Id =(select top 1 human_id from dbo.OM_Rel_Human_Post where post_Id=a.managerId)) manager,"); //项目经理id
strSql.Append(" (select name from om_account where human_Id =(select top 1 human_id from dbo.OM_Rel_Human_Post where post_Id=a.managerId)) managerName,");
strSql.Append(" (select name from OM_Account where sysId = a.leaderId) leaderName");
strSql.Append(" from project_Project a");
strSql.Append(" left join OM_Department b on a.[type] = b.sysId");
strSql.Append(" left join DictionaryItem c on a.[status] = c.sysId");
strSql.Append(" left join DictionaryItem d on a.province = d.sysId");
strSql.Append(" left join OM_Account e on a.creatorId = e.sysId");
strSql.Append(" where a.del = 0");
if (!searchAll)
strSql.Append(" and a.sysId in (select sysId from fnGetProjectPurview('" + operateUserId + "'))");
strSql.Append(strWhere);
strSql.Append(" ) t where id between (@Page - 1) * @PageRecord + 1 and @Page * @PageRecord");
strSql.Append(" select COUNT(1) cnt");
strSql.Append(" from project_Project a");
strSql.Append(" left join DictionaryItem b on a.[type] = b.sysId");
strSql.Append(" left join DictionaryItem c on a.[status] = c.sysId");
strSql.Append(" left join DictionaryItem d on a.province = d.sysId");
strSql.Append(" left join OM_Account e on a.creatorId = e.sysId");
strSql.Append(" where a.del = 0");
if (!searchAll)
strSql.Append(" and a.sysId in (select sysId from fnGetProjectPurview('" + operateUserId + "'))");
strSql.Append(strWhere);
SqlParameter[] parameters = {
new SqlParameter("@pageRecord", pageRecord),
new SqlParameter("@page", page),
new SqlParameter("@operateUserId", operateUserId)};
projectDs = SqlHelper.ExecuteDataSet(strSql.ToString(), parameters);
return projectDs;
}