View Code
1 /// <summary> 2 /// 历史记录 3 /// </summary> 4 private static int sumcount; 5 private void BindHistory() 6 { 7 this .gdvHistory.DataSource = null ; 8 this .gdvHistory.DataBind(); 9 DataTable table = null ; 10 DateTime dtst = Convert.ToDateTime(DateTime.Now.ToShortDateString() + " 00:00:00 " ); 11 DateTime dtend = Convert.ToDateTime(DateTime.Now.ToShortDateString() + " 23:59:59 " ); 12 try 13 { 14 table = _service.getOrderInfosHistory(officeInfo.ofNote1, 0 , 0 , 0 , officeInfo.ofLogin, 13 , - 1 , dtst, dtend); 15 if (table != null ) 16 { 17 if (table.Rows.Count > 0 ) 18 { 19 DataRow[] successRows = table.Select( " 订单状态='缴费成功' " ); 20 int suMoney = 0 ; 21 foreach (DataRow item in successRows) 22 { 23 suMoney += Convert.ToInt32(item[ " 交易金额 " ] ?? " 0 " ); 24 } 25 DataRow[] paRows = table.Select( " 订单状态='缴费失败' " ); 26 int paMOney = 0 ; 27 foreach (DataRow item in paRows) 28 { 29 paMOney += Convert.ToInt32(item[ " 交易金额 " ] ?? " 0 " ); 30 } 31 DataRow[] SubRows = table.Select( " 订单状态='提交缴费' " ); 32 int SubOney = 0 ; 33 foreach (DataRow item in SubRows) 34 { 35 SubOney += Convert.ToInt32(item[ " 交易金额 " ] ?? " 0 " ); 36 } 37 this .AspNetPager1.Visible = true ; 38 sumcount = table.Rows.Count; 39 PagedDataSource pds = new PagedDataSource(); 40 AspNetPager1.RecordCount = sumcount; 41 pds.AllowPaging = true ; 42 pds.PageSize = AspNetPager1.PageSize; 43 pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1 ; 44 pds.DataSource = table.DefaultView; 45 this .gdvHistory.DataSource = pds; 46 this .gdvHistory.DataBind(); 47 this .AspNetPager1.CustomInfoHTML = string .Format( " 当前第{0}/{1}页 共{2}条记录 其中成功{3}笔,总金额{4}元 失败{5}笔,总金额{6}元 提交{7}笔,总金额{8}元 " , new object [] { this .AspNetPager1.CurrentPageIndex, this .AspNetPager1.PageCount, this .AspNetPager1.RecordCount, successRows.Length, suMoney, paRows.Length, paMOney, SubRows.Length, SubOney }); 48 } 49 else 50 { 51 this .AspNetPager1.Visible = false ; 52 } 53 54 } 55 else 56 { 57 this .AspNetPager1.Visible = false ; 58 } 59 } 60 catch { } 61 }
这是后台代码,前台页面代码如下
View Code
其中 webdiyer是引用2,<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %> 1 < webdiyer:AspNetPager ID = " AspNetPager1 " 2 CssClass = " paginator " CurrentPageButtonClass = " cpb " runat = " server " AlwaysShow = " True " 3 4 FirstPageText = " 首页 " LastPageText = " 尾页 " NextPageText = " 下一页 " PageSize = " 18 " 5 PrevPageText = " 上一页 " ShowCustomInfoSection = " Left " 6 7 ShowInputBox = " Never " onpagechanged = " AspNetPager1_PageChanged " Visible = " false " 8 CustomInfoTextAlign = " Left " LayoutType = " Table " Wrap = " False " BorderStyle = " None " 9 ButtonImageAlign = " Middle " HorizontalAlign = " Right " NumericButtonCount = " 6 " 10 Font - Size = " Smaller " > 11 </ webdiyer:AspNetPager >