分页

 1 public enum EnumPagerAction
 2     {
 3         /// <summary>
 4         /// 移动到首页
 5         /// </summary>
 6         MoveHomePage,
 7 
 8         /// <summary>
 9         /// 移动到上一页
10         /// </summary>
11         MovePreviousPage,
12 
13         /// <summary>
14         /// 移动到下一页
15         /// </summary>
16         MoveNextPage,
17 
18         /// <summary>
19         /// 移动到尾页
20         /// </summary>
21         MoveLastPage,
22 
23         /// <summary>
24         /// 移动到指定页
25         /// </summary>
26         MoveToPage,
27     }
 1        ///// <summary>
 2         ///// 查询分页列表
 3         ///// </summary>
 4         ///// <param name="pagerAction">分页动作</param>
 5         ///// <param name="pageIndex">页索引,在pagerAction=EnumPagerAction.MoveToPage时有效</param>
 6         public void GetListPage(EnumPagerAction pagerAction, int pageIndex = 1)
 7         {
 8             switch (pagerAction)
 9             {
10                 case EnumPagerAction.MoveHomePage:
11                     Search.PageIndex = 1;
12                     break;
13                 case EnumPagerAction.MovePreviousPage:
14                     Search.PageIndex = (Search.PageIndex > 1) ? Search.PageIndex - 1 : 1;
15                     break;
16                 case EnumPagerAction.MoveNextPage:
17                     Search.PageIndex = (Search.PageIndex < AlertInfoList.PageCount) ? Search.PageIndex + 1 : AlertInfoList.PageCount;
18                     break;
19                 case EnumPagerAction.MoveLastPage:
20                     Search.PageIndex = AlertInfoList.PageCount;
21                     break;
22                 case EnumPagerAction.MoveToPage:
23                     {
24                         Search.PageIndex = pageIndex > AlertInfoList.PageCount
25                             ? AlertInfoList.PageCount
26                             : pageIndex <= 0 ? 1 : pageIndex;
27                     }
28                     break;
29             }
30 
31             ReLoadList();
32         }
33 
34         private void ReLoadList()
35         {
36             var result = WaterQualityBusiness.GetWarningMsgPaged(Search);
37             if(result.Status == ResultStatus.Success)
38             {
39                 AlertInfoList = result.AppendData;
40             }
41             else
42             {
43                 MessageBox.Show(result.Message,"错误",MessageBoxButton.OK,MessageBoxImage.Error);
44             }
45         }

 

posted @ 2018-09-09 10:09  liu_xh  阅读(137)  评论(0编辑  收藏  举报