using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;
namespace pgDiv
{
/// <summary>
/// Summary description for Handler
/// </summary>
public class Handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
System.Web.HttpResponse Response = context.Response;
System.Web.HttpRequest Request = context.Request;
//string sql = "select * from wr_menu_b order by id asc";
//string cols = Request["cols"].ToString();
//string table = Request["table"].ToString();
//string orderField = Request["orderField"].ToString();
//string dir = Request["dir"].ToString();
int pageSize = Convert.ToInt32(Request["pageSize"] != null ? Request["pageSize"].ToString() : "10");
int pageIndex = Convert.ToInt32(Request["pageIndex"] != null ? Request["pageIndex"].ToString() : "1");
string start = ((pageIndex - 1) * pageSize).ToString(); //从哪条记录开始
//string sql = "select " + cols + " from " + table + " order by " + orderField + " " + dir+" limit "+start+","+pageSize;
//Response.Write(sql);
//pageSize = 10;
//pageIndex = 4;
int recordCount = 0;
//(int pageindex, int pagesize, string orderfield, string ordertype, string condition, ref int recordCount)
//Sql = "select top " + pagesize + " * from dbo.hr where " + condition + " order by " + orderfield + " " + ordertype;
IList<CityInfo> citys = CityInfo.GetListByPage(pageIndex, pageSize, "ID", "asc", "1=1", ref recordCount);
string result = JsonConvert.SerializeObject(citys);
int totalpage = 0;
if (recordCount % pageSize == 0)
totalpage = recordCount / pageSize;
else
totalpage = recordCount / pageSize + 1;
Response.Write("{\"total\": \"" + totalpage.ToString() + "\",\"curPage\":\"" + pageIndex + "\", \"records\": \"" + recordCount.ToString() + "\", \"rows\" : " + result + "}");
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
Hander.ashx.cs
最新推荐文章于 2025-08-08 12:35:56 发布