AspNetPager分页控件的应用(一)


关于asp.net中分页控件的应用,引用dll文件

 

前台控件:

 <webdiyer:AspNetPager ID="aspPageRange" runat="server"
                    HorizontalAlign="left"
                    PageSize="2"
                    CssClass="pages" CurrentPageButtonClass="cpb" FirstPageText="首页"
            LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页"
                    ShowBoxThreshold="11" TextAfterInputBox="" AlwaysShow="true"
            TextBeforeInputBox="" onpagechanged="aspPageRange_PageChanged"
              SubmitButtonStyle="width:30px">
   </webdiyer:AspNetPager>

后台代码:

dll.GetList(entity,  this.aspPageRange.CurrentPageIndex, this.aspPageRange.PageSize, out total);

 

三层中的DLL类中的方法:

  public static DataSet GetListByUserTypeAndRangeType(DeviceBreakdown deviceBreakdown, int RangeType, int pageIndex, int pageSize, out int recordCount)
        {
            DataSet dsResult = null;
            recordCount = 0;

            DataAccessBase dataAccess = DataAccessFactory.GetDataAccess();
            try
            {
                BindParams(ref dataAccess, ref deviceBreakdown);
                dataAccess.AddParam("RanggeType", RangeType);
                dataAccess.AddParam("PageIndex", pageIndex);
                dataAccess.AddParam("PageSize", pageSize);
                dataAccess.AddParam("PageTotal", recordCount, ParameterDirection.Output);
                dataAccess.AddParam("ActionType", 13);
                dsResult = dataAccess.ExecuteDataSet("P_DeviceBreakdown", CommandType.StoredProcedure);
                recordCount = (int)dataAccess.GetCommandParam("PageTotal").Value;
            }
            catch (Exception ex) { throw ex; }
            finally { dataAccess.CompletedCommand(); }
            return dsResult;
        }

 添加参数即可.

 

SQL中的存储过程

 

SELECT * FROM
  (
  SELECT *,ROW_NUMBER() over(order by DeclaredOn desc) AS rn FROM
  (
   SELECT T_DeviceBreakdown.*,(select datediff(HOUR,T_DeviceBreakdown.DeclaredOn,getdate())) as tt,(case when T_DeviceMaintainBill.Id IS null then 0 else 1 end) as WeiXiu 
   FROM T_DeviceBreakdown left join T_DeviceMaintainBill 
   on T_DeviceMaintainBill.[DBId] = T_DeviceBreakdown.Id
  
  ) nt
  WHERE (MaintainAlarm= @MaintainAlarm or @MaintainAlarm is null) --是否确认
  and (nt.WeiXiu = @RanggeType or @RanggeType is null) --是否维修
  and (BreakdownLevel = @BreakdownLevel or @BreakdownLevel is null) --故障等级
  and (cast(convert(varchar,DeclaredOn,112) as smalldatetime) = @DeclaredOn or @DeclaredOn is null)--申报时间
  AND (nt.MaintainUserId=@MaintainUserId or @MaintainUserId is null) --登录人 角色
  and (WId =@WId or @WId is null) --仓库
  ) nnt
  WHERE nnt.rn between (isnull(@PageIndex,0) - 1)*@PageSize+1  and @PageIndex*@PageSize;

  SELECT @PageTotal= COUNT(Id) FROM
  (
   SELECT T_DeviceBreakdown.*,(select datediff(HOUR,T_DeviceBreakdown.DeclaredOn,getdate())) as tt,(case when T_DeviceMaintainBill.Id IS null then 0 else 1 end) as WeiXiu 
   FROM T_DeviceBreakdown left join T_DeviceMaintainBill 
   on T_DeviceMaintainBill.[DBId] = T_DeviceBreakdown.Id
  
  ) nt
  WHERE (MaintainAlarm= @MaintainAlarm or @MaintainAlarm is null) 
  and (nt.WeiXiu = @RanggeType or @RanggeType is null) 
  and (BreakdownLevel = @BreakdownLevel or @BreakdownLevel is null) --故障等级
  and (cast(convert(varchar,DeclaredOn,112) as smalldatetime) = @DeclaredOn or @DeclaredOn is null)--申报时间
  --cast(convert(varchar,DeclaredOn,112) as smalldatetime) 截取数据库带有时分秒时间段的年月日,用横杠表示
  AND (nt.MaintainUserId=@MaintainUserId or @MaintainUserId is null) 
  and (WId =@WId or @WId is null)
  return @PageTotal


 dll文件下载:

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值