private void BindData(int pageIndex) { string bookName = txtBooklink.Text; if (bookName == "全部") { bookName = ""; } string timestart = textTimeStart.Text; string timeend = textTimeEnd.Text; if (string.IsNullOrEmpty(timestart)) { timestart = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd"); textTimeStart.Text = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd"); } if (string.IsNullOrEmpty(timeend)) { timeend = DateTime.Now.ToString("yyyy-MM-dd"); textTimeEnd.Text = DateTime.Now.ToString("yyyy-MM-dd"); } if (pageIndex <= 0) { pageIndex = 1; } int recordCount = 0; T_DownLoaded_Book_Data dataAccess = new T_DownLoaded_Book_Data(); DataTable dtResult = dataAccess.GetCountData(pageIndex, 10, bookName, timestart, timeend, ref recordCount); num.Value = recordCount.ToString(); AspNetPager1.CurrentPageIndex = pageIndex; AspNetPager1.RecordCount = recordCount; AspNetPager1.DataBind(); }
/// <summary> /// 获取统计数据 /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="bookName">图书名称</param> /// <param name="dateStart">统计开始时间</param> /// <param name="dateEnd">统计结束时间</param> /// <returns></returns> public void GetCountData(HttpContext context) { int pageIndex = ConvertHelper.ToInt32(context.Request["pageIndex"]); int pageSize = ConvertHelper.ToInt32(context.Request["pageSize"]); string bookName = context.Request["bookName"]; string dateStart = context.Request["dateStart"]; string dateEnd = context.Request["dateEnd"]; int recordCount = 0; T_DownLoaded_Book_Data dataAccess = new T_DownLoaded_Book_Data(); DataTable dtResult = dataAccess.GetCountData(pageIndex, pageSize, bookName, dateStart, dateEnd, ref recordCount); BaseResponse result = new BaseResponse(); result.recordCount = recordCount; result.list = dtResult; string strJson = JsonConvert.SerializeObject(dtResult); context.Response.Write(strJson); }