• 数据后台查询分页条件查询数据


            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;
            }
  • 相关阅读:
    leetCode算法题(一)
    node学习笔记1(http模块)
    mySql常用命令总结
    django学习遇到的问题解决方式
    WebSSH2 界面ssh(转载)
    垃圾回收策略学习总结
    5种数组扁平化方法
    冒泡、插入、选择、归并、快速排序
    手写ES6数组方法
    HTTP options预请求
  • 原文地址:https://www.cnblogs.com/Zpyboke/p/5292995.html
Copyright © 2020-2023  润新知