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;
            }
  • 相关阅读:
    ASP.NET——From验证:全部代码及讲解
    JavaScript 经典代码大全:有 目录 及 编号 的哦 !
    很好的一首英文歌曲:不论是旋律、还是歌词或者MV
    2007年10月份_很想念大家
    NND,8月没有来发贴,现在是9月了,要发一个
    买了一个新的域名和主机,呵呵,
    视频下载:HTML基础及应用
    简单的哲理,放在最上面,提醒自己
    学的东西忘记得差不多啦......
    欲找情人 要做哪些准备?
  • 原文地址:https://www.cnblogs.com/Zpyboke/p/5292995.html
Copyright © 2011-2022 走看看