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


            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;
            }
  • 相关阅读:
    基于稀疏表示学习的图像分类
    多个for循环嵌套会影响速度
    LP-KPN
    C++ const
    C++面向对象
    使用最新的“huihui中文语音库”实现文本转语音功能
    后缀crt证书转换
    server2012 配置SSL证书
    解决windows server2012 评估版本过期,系统会自动关机
    Win2008 r2 IIS7.5出现FastCGI进程最近常常失败。请过一会再尝试此请求的解决方法
  • 原文地址:https://www.cnblogs.com/Zpyboke/p/5292995.html
Copyright © 2020-2023  润新知