using MESClassLibrary.BLL.BasicInfo; using MESClassLibrary.EFModel; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace MESWebSite.HttpHandlers { /// /// ColorHandler 的摘要说明 /// public class ColorHandler : IHttpHandler { HttpRequest Request = null; HttpResponse Response = null; public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; Request = context.Request; Response = context.Response; string method = Request.Params["method"]; switch (method) { case "QueryList": QueryList(); break; case "SaveInfo": SaveInfo(); break; case "DelInfo": DelInfo(); break; case "QueryForCombobox": QueryForCombobox(); break; case "GetColorCombobox": GetColorCombobox(); break; default: break; } } public bool IsReusable { get { return false; } } void QueryList() { string page = Request.Params["page"]; string pagesize = Request.Params["rows"]; string ColorCode = Request.Params["ColorCode"]; if (string.IsNullOrEmpty(page)) { page = "0"; } if (string.IsNullOrEmpty(pagesize)) { pagesize = "15"; } ColorBLL bll = new ColorBLL(); Response.Write(bll.SearchInfoAll(page, pagesize, ColorCode)); Response.End(); } void SaveInfo() { string ID = Request.Params["ID"]; string ColorCode = Request.Params["ColorCode"]; string ColorNo = Request.Params["ColorNo"]; string ColorQQCode = Request.Params["ColorQQCode"]; string ColorDQCode = Request.Params["ColorDQCode"]; string Des = Request.Params["Des"]; ColorBLL bll = new ColorBLL(); tb_Color md = new tb_Color(); md.ColorCode = ColorCode; md.ColorNo = ColorNo; md.ColorQQCode = ColorQQCode; md.ColorDQCode = ColorDQCode; md.Des = Des; var info = Request.Cookies.Get("LoginUserInfo"); if (info != null) { md.UserID = info["UserID"].ToUpper(); } if (ID == "0") { //新增 md.ID = Guid.NewGuid().ToString(); Response.Write(bll.AddInfo(md) == true ? "true" : "false"); } else { //修改 md.ID = ID; Response.Write(bll.UpdateInfo(md) == true ? "true" : "false"); } Response.End(); } void DelInfo() { string ID = Request.Params["ID"]; ColorBLL bll = new ColorBLL(); tb_Color md = new tb_Color(); md.ID = ID; var info = Request.Cookies.Get("LoginUserInfo"); if (info != null) { md.UserID = info["UserID"].ToUpper(); } Response.Write(bll.DeleteInfo(md) == true ? "true" : "false"); Response.End(); } void QueryForCombobox() { ColorBLL bll = new ColorBLL(); Response.Write(bll.GetComboboxData()); Response.End(); } void GetColorCombobox() { ColorBLL bll = new ColorBLL(); Response.Write(bll.GetComboboxColor()); Response.End(); } } }