客户端回调实现gridView无刷新分页
2008-02-22 09:43:06来源:互联网 阅读 ()
由于客户对速度和性能上的要求越来越变态,而数据量一天天的庞大,因此本人产生了数据的查询和分页完全由客户端回调来实现。想法看上去复杂,实现起来也不难。废话不多说,看程序吧。
一、存储过程
包头:
create or replace package H_QUERYPACK is
-- Author : Evorul
-- Created : 2007-3-29
-- Purpose : 查询机构表
-- Public type declarations
type MYCURSOR is REF CURSOR;
PROCEDURE QUERYLOG (RET_CURSOR OUT MYCURSOR,ERRORCODE OUT INT,p_logID int,p_StartTime Date,p_EndTime Date,p_Operator varchar2 ,p_OrderField varchar2 ,
p_Desc int,p_PageSize Int,p_PageIndex Int,p_RecordCount Out Int);
end H_QUERYPACK;
包体:
create or replace package body H_QUERYPACK Is
-- Author : Evorul
-- Created : 2007-3-29
-- Purpose : 查询
-- 查询公司,分页用
PROCEDURE QUERYLOG (RET_CURSOR OUT MYCURSOR,ERRORCODE OUT INT,p_logID int,p_StartTime Date,p_EndTime Date,p_Operator varchar2 ,p_OrderField varchar2 ,
p_Desc int,p_PageSize Int,p_PageIndex Int,p_RecordCount Out Int)
AS
v_sql varchar2(3000);
v_sqlcount varchar2(3000);
v_orderfield varchar2(100);
v_order VARCHAR2(5); --顺序
v_count int;
v_heiRownum int;
v_lowRownum int;
BEGIN
ERRORCODE:=0;
v_sql:='select * from LOG Where 1=1 ';
if(p_logID <> 0)then
v_sql := v_sql || ' and id = ' || TO_CHAR(p_logID);
end if;
IF p_Operator Is Not Null Then then
v_sql := v_sql || 'And operator LIKE ''%' || RTRIM(LTRIM(p_Operator))||'%''';
end if;
v_sql := v_sql ||' and (TO_CHAR(time,''YYYYMMDD'') between ''' || to_char(p_StartTime, 'YYYYMMDD') ||''' and ''' || to_char(p_EndTime, 'YYYYMMDD') ||''')';
----取记录总数
v_sqlcount := 'select count(*) from (' || v_sql || ')';
execute immediate v_sqlcount into v_count;
p_RecordCount := v_count;
--排序字段
IF p_OrderField IS NOT NULL THEN
v_orderfield:=p_OrderField;
Else
v_orderfield:='ID';
END IF;
--是否降序
IF p_Desc <>0 THEN
v_order:=' ASC';
Else
v_order:=' DESC';
END IF;
v_sql:=v_sql || 'ORDER BY '|| v_orderfield || v_order;
----执行分页查询
v_heiRownum := p_PageIndex * p_PageSize;
v_lowRownum := v_heiRownum - p_PageSize 1;
v_sql := 'SELECT * FROM (
SELECT A.*, rownum rn FROM ('|| v_sql ||') A WHERE rownum <= '|| to_char(v_heiRownum) || ') B WHERE rn >= ' || to_char(v_lowRownum) ;
OPEN RET_CURSOR FOR v_sql;
EXCEPTION
WHEN NO_DATA_FOUND THEN
ERRORCODE:=9999;
WHEN OTHERS THEN
ERRORCODE:=9999;
END QUERYLOG;
END H_QUERYPACK;
二、程序
DataAccess.cs
using System;
using System.Data;
using System.Data.OracleClient;
using System.Collections;
using System.Collections.Specialized;
/**//// <summary>
///数据层 author: EvoRul date:2007-03-29
/// </summary>
public class DataAccess
...{
/**//// <summary>
/// 返回数据库连接字符串
/// </summary>
public static String DatabaseConnectionString
...{
get
...{
NameValueCollection configSettings = (NameValueCollection)System.Configuration.ConfigurationManager.GetSection("appSettings");
return configSettings["connectionString"];
}
}
/**//// <summary>
/// 返回每一页显示的纪录数
/// </summary>
public static int RowsPerPage
...{
get
...{
NameValueCollection configSettings = (NameValueCollection)System.Configuration.ConfigurationManager.GetSection("appSettings");
return Convert.ToInt32(configSettings["rowsPerPage"]);
}
}
/**//// <summary>
/// 获取特定日志集合
/// </summary>
/// <param name="typeID">日志类型</param>
/// <param name="userID">操作人</param>
/// <param name="strOrderField">排序字段</param>
/// <param name="intASC">是否升序 0-降序,1-升</param>
/// <param name="PageIndex">页码</param>
/// <param name="rowCount">页行数</param>
/// <param name="recordSum">符合条件的总记录数</param>
/// <returns></returns>
public static ArrayList QueryLog(string strOperator,DateTime dtStartTime,DateTime dtEndTime, string strOrderField,
int intASC, int PageIndex, int rowCount, out int recordSum)
...{
// 返回集合
ArrayList myArrayList = new ArrayList();
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash