public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BulletinTypeBll bll = new BulletinTypeBll(); //当前页码 int pageIndex = int.Parse(context.Request["pageIndex"] ?? "1"); int pageSize = 10; //每页显示数量 int total = bll.GetCount(); //总数量 //总页数 int pageCount = Convert.ToInt32(Math.Ceiling(1.0 * total / pageSize)); pageIndex = pageIndex < 1 ? 1 : pageIndex; pageIndex = pageIndex > pageCount ? pageCount : pageIndex; //获取 数据 List <BulletinType> list = bll.GetPageList(pageIndex, pageSize); // 分页 html 代码 string pageNavHtml = Common.PageNav.PageNavGenerate(pageIndex, pageSize, total); //序列化成 json JavaScriptSerializer json = new JavaScriptSerializer(); string jsonStr = json.Serialize(new { NavHtml = pageNavHtml, List = list }); //发送到前端 context.Response.Write(jsonStr); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int id = int.Parse(context.Request["Id"] ?? "0"); BulletinTypeBll bll = new BulletinTypeBll(); if (bll.Delete(id)) { context.Response.Write("Ok"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BulletinType type = new BulletinType(); type.TypeName = context.Request["TypeName"]; BulletinTypeBll bll = new BulletinTypeBll(); if (bll.Add(type)) { context.Response.Write("Ok"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; BulletinTypeBll bll = new BulletinTypeBll(); if (context.Request.RequestType.ToUpper() == "GET") { int id = int.Parse(context.Request["Id"] ?? "0"); BulletinType type = bll.GetModelById(id); //根据Id 获取数据 System.Web.Script.Serialization.JavaScriptSerializer javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer(); string jsonStr = javaScriptSerializer.Serialize(type); //将对象序列化成json context.Response.Write(jsonStr); } else { BulletinType type = new BulletinType(); type.Id = int.Parse(context.Request["EditId"] ?? "0"); type.TypeName = context.Request["EditText"]; if (bll.Update(type)) { context.Response.Write("Ok"); } } }