zoukankan      html  css  js  c++  java
  • C# 封装首页、上一页、下一月、尾页处理器

     1 public void BtnPageClickEvent(object sender,string focusForeground,string lostFocusForeground)
     2         {
     3             Button btn = (Button)sender;
     4             string btnContent = btn.Content as string;
     5             if (btn.Focus())
     6             {
     7                 btn.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(focusForeground));
     8             }
     9             btn.LostFocus += delegate
    10             {
    11                 btn.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(lostFocusForeground));
    12             };
    13             switch (btnContent)
    14             {
    15                 case "首页":
    16                     {
    17                         PagedHelper.PageIndex = 1;
    18                         this.DGAlertInfos.ItemsSource = PagedHelper.GetPagedData(AlertLists, 0, PagedHelper.PageSize).ToList();
    19                         break;
    20                     }
    21                 case "上一页":
    22                     {
    23                         if (PagedHelper.PageIndex != 1)
    24                         {
    25                             PagedHelper.PageIndex--;
    26                         }
    27                         if (PagedHelper.PageIndex <= 1)
    28                         {
    29                             this.DGAlertInfos.ItemsSource = PagedHelper.GetPagedData(AlertLists, 0, PagedHelper.PageSize).ToList(); ;
    30                         }
    31                         else
    32                         {
    33                             this.DGAlertInfos.ItemsSource = PagedHelper.GetPagedData(AlertLists, (PagedHelper.PageIndex - 1) * PagedHelper.PageSize, PagedHelper.PageSize).ToList();
    34                         }
    35                         break;
    36                     }
    37                 case "下一页":
    38                     {
    39                         if (PagedHelper.PageIndex != PagedHelper.PageCount)
    40                         {
    41                             PagedHelper.PageIndex++;
    42                         }
    43                         if (PagedHelper.PageIndex >= PagedHelper.PageCount)
    44                         {
    45 
    46                             this.DGAlertInfos.ItemsSource = PagedHelper.GetPagedData(AlertLists, PagedHelper.PageSize * (PagedHelper.PageCount - 1), PagedHelper.PageSize).ToList();
    47                         }
    48                         else
    49                         {
    50                             this.DGAlertInfos.ItemsSource = PagedHelper.GetPagedData(AlertLists, (PagedHelper.PageIndex - 1) * 10, PagedHelper.PageSize).ToList();
    51                         }
    52                         break;
    53                     }
    54                 case "尾页":
    55                     {
    56                         PagedHelper.PageIndex = PagedHelper.PageCount;
    57                         this.DGAlertInfos.ItemsSource = PagedHelper.GetPagedData(AlertLists, PagedHelper.PageSize * (PagedHelper.PageCount - 1), PagedHelper.PageSize).ToList();
    58                         break;
    59                     }
    60                 default:
    61                     {
    62 
    63                         break;
    64                     }
    65             }
    66         }

    使用:

    1 private void BtnPageClick(object sender, RoutedEventArgs e)
    2         {
    3             BtnPageClickEvent(sender, "#007CF1", "#4D4D4D");
    4         }
  • 相关阅读:
    qt tableview中如何添加右键菜单且不可编辑单元格
    C++typedef struct和struct的区别
    Qt5配置winpCap
    C++虚函数和纯虚函数的用法和区别
    c++11 智能指针 unique_ptr、shared_ptr与weak_ptr
    C++ windows进程间通信
    C++并发多线程(一)
    Maven无法下载2.1.7.js7版本的itext依赖
    PostgreSQL
    SQL
  • 原文地址:https://www.cnblogs.com/dotnetHui/p/8603258.html
Copyright © 2011-2022 走看看