Exemplo n.º 1
0
 public static void TurnPageSqlite(System.Windows.Data.ObjectDataProvider odp, string str_offset, int pagesize, int totalcount)
 {
     if (odp != null)
     {
         try
         {
             //2015.12.20 发现DeferRefresh可以在改变参数的时候,延迟刷行,利用using。注释掉下面三行
             using (odp.DeferRefresh())
             {
                 //odp.MethodParameters[1] = "";
                 int offset = int.Parse(str_offset);
                 int pageNum = (int)(odp.MethodParameters[4]) + offset;
                 int index = pagesize * (pageNum - 1);
                 if (index > totalcount)
                 {
                     int maxindex = totalcount % pagesize > 0 ? totalcount / pagesize + 1 : totalcount / pagesize;
                     odp.MethodParameters[4] = maxindex;
                 }
                 if (pageNum > 0 && totalcount > index)
                 {
                     odp.MethodParameters[4] = pageNum;
                     //odp.Refresh();
                 }
                 //odp.MethodParameters[1] = "1";
             }
         }
         catch (Exception e)
         {
             throw e;
         }
     }
 }
Exemplo n.º 2
0
 public static void TurnPageOriginal(System.Windows.Data.ObjectDataProvider odp, string str_offset, string pagesize)
 {
     if (odp != null)
     {
         try
         {
             //odp.MethodParameters[1] = "";
             //odp.MethodParameters[3] = int.Parse(pagesize);
             //odp.MethodParameters[4] = int.Parse(str_offset);
             //odp.Refresh();
             //odp.MethodParameters[1] = "1";
             //2015.12.20 发现DeferRefresh可以在改变参数的时候,延迟刷行,利用using。注释掉下面三行
             using (odp.DeferRefresh())
             {
                 odp.MethodParameters[1] = "";
                 //odp.MethodParameters[3] = int.Parse(pagesize);
                 odp.MethodParameters[3] = GlobalBindingHelper.PageSize;
                 odp.MethodParameters[4] = int.Parse(str_offset);
             }
         }
         catch (Exception e)
         {
             throw e;
         }
     }
 }