- 注册时间
- 2014-1-14
- 最后登录
- 2014-3-20
- 阅读权限
- 10
- 积分
- 212
- 精华
- 0
- 帖子
- 65
|
factory 发表于 2014-2-17 10:18
pageIndex 为0 说明已经获取到了啊, 第一页就是0
grid.reload({ PlusId: e.node.id }) 没有这种写法
create proc [dbo].[p_propage]
@pagecount int,@index int,@id int,@type varchar(10),@sumcount int output,@counts int output
as
begin
declare @sum int
select @sum=COUNT(*) from t_productPrice
if(@sum%@pagecount=0)
select @sumcount=@sum/@pagecount
else
select @sumcount=@sum/@pagecount+1
select @counts=@index
select top (@pagecount) * from t_productPrice where ID not in
(select top ((@pagecount)*(@index-1)) ID from t_productPrice) and plusid=@id and PType=@type
end
GO
我用存储过程分页,这是代码
public List<SupplierInfo> GetPageSupplier(int pagecount, int index, int id,out int sumpage, out int count)
{
List<SupplierInfo> list = new List<SupplierInfo>();
SupplierInfo info = null;
string sql = "p_prosupplier";
SqlParameter[] p = new SqlParameter[5]
{
new SqlParameter("@pagecount",pagecount),
new SqlParameter("@index",index),
new SqlParameter("@id",id),
new SqlParameter("@sumcount",SqlDbType.Int),//输出参数
new SqlParameter("@counts",SqlDbType.Int)
};
p[3].Direction = ParameterDirection.Output;
p[4].Direction = ParameterDirection.Output;
using (SqlDataReader reader = SqlHelper.SqlData(sql, CommandType.StoredProcedure, p))
{
while (reader.Read())
{
info = new SupplierInfo();
//info = new SupplierInfo();
info.Id = Convert.ToInt32(reader[0]);
info.Supplier = reader[1].ToString();
info.SupplierNumber = reader[2].ToString();
info.ProdColorQty = Convert.ToInt32(reader[3]);
info.ProdQty = Convert.ToInt32(reader[4]);
info.SampleColorQty = Convert.ToInt32(reader[5]);
info.PlusId = Convert.ToInt32(reader[6]);
info.SmapleQty = Convert.ToInt32(reader[7]);
info.SampleCycle = Convert.ToInt32(reader[8]);
info.Remark = reader[9].ToString();
info.UserName = reader[10].ToString();
info.DateTimes = Convert.ToDateTime(reader[11]);
list.Add(info);
}
}
sumpage = Convert.ToInt32(p[3].Direction);
count = Convert.ToInt32(p[4].Direction);
return list;
}
这是分页代码DAL层的
public List<SupplierInfo> GetPageSupplier(int pagesize,int index,int id,out int sum,out int counts)
{
return server.GetPageSupplier(pagesize, index, id, out sum, out counts);
}这是BLL层的
public void SearchSupplier()
{
string plusid = Request["PlusId"];
string json;
int pageIndex = Convert.ToInt32(Request["pageIndex"]);
int pageSize = Convert.ToInt32(Request["pageSize"]);
int i; int j;
json = new JavaScriptSerializer().Serialize(supplinfo.GetPageSupplier(pageSize,pageIndex,Convert.ToInt32(plusid),out i,out j));
i=0;j=0;
//json = new JavaScriptSerializer().Serialize(supplinfo.GetSupplierBuPlusId(Convert.ToInt32(plusid)));
Response.Write(json);
}
这是ui层的
grid.load({ PlusId: e.node.id});这是前台 |
|