using MESClassLibrary.BLL; using MESClassLibrary.BLL.BasicInfo; using MESClassLibrary.EFModel; using MESWebSite.CommonClass; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace MESWebSite.HttpHandlers { /// /// Bom_MKHandler 的摘要说明 /// public class Bom_MKHandler : 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; default: break; } } public bool IsReusable { get { return false; } } void QueryList() { string page = Request.Params["page"]; string pagesize = Request.Params["rows"]; string partNo1 = Request.Params["PartNo1"]; string partNo2 = Request.Params["PartNo2"]; string placeName = Request.Params["PlaceName"]; if (string.IsNullOrEmpty(page)) { page = "0"; } if (string.IsNullOrEmpty(pagesize)) { pagesize = "15"; } Bom_MKBLL bll = new Bom_MKBLL(); Response.Write(bll.SearchInfoAll(page, pagesize, partNo1, partNo2, placeName)); Response.End(); } void SaveInfo() { string BomID = Request.Params["BomID"]; string PartNo1 = Request.Params["PartNo1"]; string PartNo2 = Request.Params["PartNo2"]; string IsChecked = Request.Params["IsChecked"]; string IsPartAssemble = Request.Params["IsPartAssemble"]; string StationNo = Request.Params["StationNo"]; string PlaceName = Request.Params["PlaceName"]; string stationNo = ""; BasicBLL stationDB = new BasicBLL(); var stationList = stationDB.Search(p => p.StationNo == StationNo); if (stationList != null && stationList.Count > 0) { stationNo = stationList[0].StationNo; } if (string.IsNullOrEmpty(stationNo)) { Response.Write(ResponseResult.Fail("工位号不存在!")); Response.End(); return; } Bom_MKBLL bll = new Bom_MKBLL(); tb_Bom_MK md = new tb_Bom_MK(); md.PartNo1 = PartNo1; md.PartNo2 = PartNo2; md.PlaceName = PlaceName; md.StationNo = StationNo; if(IsPartAssemble == "1") { md.IsPartAssemble = 1; } else { md.IsPartAssemble = 0; } if (IsChecked == "1") { md.IsChecked = true; } var info = Request.Cookies.Get("LoginUserInfo"); if (info != null) { md.UserID = info["UserID"].ToUpper(); } if (BomID == "0") { //新增 //md.BomID = Guid.NewGuid().ToString(); Response.Write(bll.AddInfo(md) == true ? ResponseResult.Success() : ResponseResult.Fail("添加失败")); } else { //修改 md.BomID = int.Parse(BomID); Response.Write(bll.UpdateInfo(md) == true ? ResponseResult.Success() : ResponseResult.Fail("更新失败")); } Response.End(); } void DelInfo() { string BomID = Request.Params["BomID"]; Bom_MKBLL bll = new Bom_MKBLL(); tb_Bom_MK md = new tb_Bom_MK(); md.BomID = int.Parse(BomID); var info = Request.Cookies.Get("LoginUserInfo"); if (info != null) { md.UserID = info["UserID"].ToUpper(); } Response.Write(bll.DeleteInfo(md) == true ? "true" : "false"); Response.End(); } } }