public DataTable SelectV2(DateTime time1, DateTime time2, int czlx, string Name, int pageIndex, int pageSize, out int pageCount)
{
StringBuilder sb = new StringBuilder();
StringBuilder sbCount = new StringBuilder();
StringBuilder Sqlstr = new StringBuilder();
Sqlstr.Append("select *");
sbCount.Append("select Count(*)");
sb.Append(" from (SELECT ROW_NUMBER() OVER (order by RecordTime desc) AS ROWID, ");
sb.Append("* ");
sb.Append(" from T_SystemLog");
if (time1.Date == time2.Date)
{
time1 = time1.Date;
}
sb.Append(" where RecordTime between ‘"+time1+"‘ and ‘"+time2+ "‘" );
if (czlx != 4)
{
sb.AppendFormat("and StatemType = {0} ", czlx);
}
if (Name != "" && Name != null && Name.Length > 0)
{
sb.AppendFormat(" and systemUser like ‘%{0}%‘ ", Name);
}
//sb.Append(" order by RecordTime desc ");
sb.Append(" )tempTable ");
Sqlstr.Append(sb.ToString());
Sqlstr.Append(" where ROWID between " + ((pageIndex * pageSize - pageSize) + 1) + " and " + pageIndex * pageSize + "");
sbCount.Append(sb.ToString());
DataSet ds = DbHelper.Query(Sqlstr.ToString());
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
pageCount = Convert.ToInt32(DbHelper.GetSingle(sbCount.ToString()));
}
else
{
pageCount = 0;
}
return ds.Tables[0];
}