public partial class ui_Report_Dengji :PDWebBase
{
protected static int trcount;
protected static DataTable pdperson;
protected static string[] doindex;
public int Record_Per_Page; //定义每页显示记录数
int nPageCount; //定义总页数
int nRecCount; //定义总记录数
int nPage; //定义当前页
protected static string strlnk; protected void Page_Load(object sender, EventArgs e)
{
PDPerson pd = new PDPerson();
if (Request["page"] == null)
nPage = 1;
else
nPage = Convert.ToInt32(Request["page"]);
DateTime timeStart = DateTime.Parse(Request["timestart"]);
DateTime timeEnd = DateTime.Parse(Request["timeend"]);
if(timeStart==null && timeEnd==null)
pdperson = pd.getAllObject();
else
{
pdperson = pd.GetObjectByTime(timeStart,timeEnd);
}
trcount = pdperson.Rows.Count;
PageDisplay();
}
//分页
public void PageDisplay()
{
string sql;
PDPerson pd = new PDPerson();
//取得当前页数,并判断
if (Request["pagesize"] == null)
Record_Per_Page = 25;
else
Record_Per_Page = Convert.ToInt32(Request["pagesize"]); //获得总记录数
nRecCount = trcount;
StringBuilder strHtml = new StringBuilder(""); //判断是否存在数据记录
if (nRecCount > 0)
{
//确定数据记录要显示的页面数
nPageCount = nRecCount / Record_Per_Page;
if (nRecCount % Record_Per_Page > 0)
nPageCount++;
if (nPage < 1)
nPage = 1;
if (nPage > nPageCount)
nPage = nPageCount; //将页面显示到屏幕上,并作连接
for (int i = 1; i < nPageCount; i++)
{
strHtml.Append("<a href='Dengji.aspx?page=" + i + "'>");
if (i == nPage) strHtml.Append("<b>" + i + "</b>");
else strHtml.Append(i);
strHtml.Append("</a> ");
}
//确认当前页面的开始记录和终止记录
int nStart = Record_Per_Page * (nPage - 1);
int nEnd = nStart + Record_Per_Page - 1;
if (nEnd > nRecCount - 1)
nEnd = nRecCount - 1;
strlnk = strHtml.ToString();
sql = "SELECT TOP " + Record_Per_Page.ToString() + " * FROM C_Work_Object WHERE " +
"(obj_id NOT IN (SELECT TOP " + (Record_Per_Page * (nPage - 1)).ToString() + " obj_id FROM C_Work_Object ORDER BY obj_id DESC))" +
"ORDER BY obj_id DESC";
pdperson = pd.GetObjectBySql(sql);
//Response.Write(strHtml);
}
}我现在要根据if(timeStart==null && timeEnd==null)
pdperson = pd.getAllObject(); //上面的分页只是显示此分页的 else
{
pdperson = pd.GetObjectByTime(timeStart,timeEnd);//我想这里面的分页怎么处理??? }
类中代码 public DataTable GetObjectByTime(DateTime timeStart,DateTime timeEnd)
{
string SQLString;
if (timeStart == null)
SQLString = "select * from [dbo].[C_Work_Object] where Obj_optime < '" + timeEnd .ToString()+ "'";
else if (timeEnd == null)
SQLString = "select * from [dbo].[C_Work_Object] where Obj_optime > '" + timeStart .ToString()+ "'";
else
SQLString = "select * from [dbo].[C_Work_Object] where Obj_optime between '" + timeStart.ToString() + "' and '" + timeEnd .ToString()+ "'";
return this.dbProcessor.SelectDataTable(SQLString);
}哪位大狭帮忙一下 啊??多谢~~~~
{
protected static int trcount;
protected static DataTable pdperson;
protected static string[] doindex;
public int Record_Per_Page; //定义每页显示记录数
int nPageCount; //定义总页数
int nRecCount; //定义总记录数
int nPage; //定义当前页
protected static string strlnk; protected void Page_Load(object sender, EventArgs e)
{
PDPerson pd = new PDPerson();
if (Request["page"] == null)
nPage = 1;
else
nPage = Convert.ToInt32(Request["page"]);
DateTime timeStart = DateTime.Parse(Request["timestart"]);
DateTime timeEnd = DateTime.Parse(Request["timeend"]);
if(timeStart==null && timeEnd==null)
pdperson = pd.getAllObject();
else
{
pdperson = pd.GetObjectByTime(timeStart,timeEnd);
}
trcount = pdperson.Rows.Count;
PageDisplay();
}
//分页
public void PageDisplay()
{
string sql;
PDPerson pd = new PDPerson();
//取得当前页数,并判断
if (Request["pagesize"] == null)
Record_Per_Page = 25;
else
Record_Per_Page = Convert.ToInt32(Request["pagesize"]); //获得总记录数
nRecCount = trcount;
StringBuilder strHtml = new StringBuilder(""); //判断是否存在数据记录
if (nRecCount > 0)
{
//确定数据记录要显示的页面数
nPageCount = nRecCount / Record_Per_Page;
if (nRecCount % Record_Per_Page > 0)
nPageCount++;
if (nPage < 1)
nPage = 1;
if (nPage > nPageCount)
nPage = nPageCount; //将页面显示到屏幕上,并作连接
for (int i = 1; i < nPageCount; i++)
{
strHtml.Append("<a href='Dengji.aspx?page=" + i + "'>");
if (i == nPage) strHtml.Append("<b>" + i + "</b>");
else strHtml.Append(i);
strHtml.Append("</a> ");
}
//确认当前页面的开始记录和终止记录
int nStart = Record_Per_Page * (nPage - 1);
int nEnd = nStart + Record_Per_Page - 1;
if (nEnd > nRecCount - 1)
nEnd = nRecCount - 1;
strlnk = strHtml.ToString();
sql = "SELECT TOP " + Record_Per_Page.ToString() + " * FROM C_Work_Object WHERE " +
"(obj_id NOT IN (SELECT TOP " + (Record_Per_Page * (nPage - 1)).ToString() + " obj_id FROM C_Work_Object ORDER BY obj_id DESC))" +
"ORDER BY obj_id DESC";
pdperson = pd.GetObjectBySql(sql);
//Response.Write(strHtml);
}
}我现在要根据if(timeStart==null && timeEnd==null)
pdperson = pd.getAllObject(); //上面的分页只是显示此分页的 else
{
pdperson = pd.GetObjectByTime(timeStart,timeEnd);//我想这里面的分页怎么处理??? }
类中代码 public DataTable GetObjectByTime(DateTime timeStart,DateTime timeEnd)
{
string SQLString;
if (timeStart == null)
SQLString = "select * from [dbo].[C_Work_Object] where Obj_optime < '" + timeEnd .ToString()+ "'";
else if (timeEnd == null)
SQLString = "select * from [dbo].[C_Work_Object] where Obj_optime > '" + timeStart .ToString()+ "'";
else
SQLString = "select * from [dbo].[C_Work_Object] where Obj_optime between '" + timeStart.ToString() + "' and '" + timeEnd .ToString()+ "'";
return this.dbProcessor.SelectDataTable(SQLString);
}哪位大狭帮忙一下 啊??多谢~~~~
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货