zoukankan      html  css  js  c++  java
  • 数据后台查询分页条件查询数据

            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;
            }
  • 相关阅读:
    Transformers 简介(下)
    OpenCV-Python 姿态估计 | 五十
    Transformers 简介(上)
    OpenCV-Python 相机校准 | 四十九
    在Keras中可视化LSTM
    分析师和统计学家可以和谐相处吗?
    Array类模板
    C++中 公有继承 私有继承 和保护继承的区别
    文件输入输出
    PTA(浙大数据结构,c语言)
  • 原文地址:https://www.cnblogs.com/Zpyboke/p/5292995.html
Copyright © 2011-2022 走看看