博 之 文

以 拼 搏 设 计 梦 想 , 以 恒 心 编 程 明 天
  首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

增加SortPage输出参数

Posted on 2012-02-15 15:27  IsNull_Soft  阅读(390)  评论(0编辑  收藏  举报

/// <summary>        

/// 增加SortPage输出参数         

/// </summary>        

/// <param name="arParams">引用参数</param>        

/// <param name="sortPage">分页对象</param>        

/// <param name="rowCountParamName">输出行数</param>        

/// <param name="outCursorParamName">输出游标</param>        

public static void AddSortPageParam(ref SqlParameter[] arParams, SortPage sortPage,               string rowCountParamName)        

{            

  SqlParameter[] pagerParams = SqlHelper.GetSqlParams("@pagesize,@pageindex,@sortby", false, sortPage.pageSize, sortPage.curPage, sortPage.orderBy);

  int newParamLen = 0;            

   if (arParams == null)

    newParamLen = 0;            

  else

    newParamLen = arParams.Length;

  SqlParameter[] newParams = new SqlParameter[newParamLen + 4];            

  for (int i = 0; i < newParamLen; i++)            

  {                

    newParams[i] = arParams[i];            

  }

  newParams[newParamLen] = pagerParams[0];            

  newParams[newParamLen + 1] = pagerParams[1];            

  newParams[newParamLen + 2] = pagerParams[2];

       //输出rowcount            

  SqlParameter rowCountParam = new SqlParameter(rowCountParamName, SqlDbType.Int);            

  rowCountParam.Direction = ParameterDirection.Output;            

  newParams[newParamLen + 3] = rowCountParam;

      arParams = newParams;

        }