using MESClassLibrary.BLL.BasicInfo; using MESClassLibrary.EFModel; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; namespace MESWebSite.HttpHandlers { /// /// StationHandler 的摘要说明 /// public class ForeignColorMapHandler : 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 "QueryForComboboxByLineID": QueryForComboboxByLineID(); break; default: break; } } public bool IsReusable { get { return false; } } void QueryList() { string page = Request.Params["page"]; string pagesize = Request.Params["rows"]; string TypeCode = Request.Params["TypeCode"]; string PartCode = Request.Params["PartCode"]; if (string.IsNullOrEmpty(page)) { page = "0"; } if (string.IsNullOrEmpty(pagesize)) { pagesize = "15"; } ForeignColorMapBLL bll = new ForeignColorMapBLL(); Response.Write(bll.SearchInfo(page, pagesize, TypeCode, PartCode)); Response.End(); } void SaveInfo() { string ForeignID = Request.Params["ID"]; string TypeCode = Request.Params["TypeCode"]; string PartCode = Request.Params["PartCode"]; string PartName = Request.Params["PartName"]; string Color = Request.Params["Color"]; string StockNo = Request.Params["StockNo"]; ForeignColorMapBLL bll = new ForeignColorMapBLL(); tb_ForeignColorMap md = new tb_ForeignColorMap(); md.ID = int.Parse( ForeignID); md.TypeCode = TypeCode; md.PartCode = PartCode; md.Color = Color; md.StockNo = StockNo; string partName = PartName; ProductBLL productBLL = new ProductBLL(); DataTable dt = productBLL.SearchInfoByPartNo( PartCode); if (dt.Rows.Count == 0) { Response.Write($"零件号[{PartCode}]在系统中不存在!"); Response.End(); return; } else { List rows = dt.AsEnumerable().Where(p => p.Field("StockNo") == StockNo).ToList(); if(rows.Count == 0) { Response.Write($"零件号[{PartCode}]与存货代码[{StockNo}]不匹配!"); Response.End(); return; } partName = rows[0]["ProductName"].ToString(); } md.PartName = partName; if (ForeignID == "0") { //新增 //md.ID = Guid.NewGuid().ToString(); Response.Write(bll.AddInfo(md) == true ? "true" : "false"); } else { //修改 //md.StationID = StationID; Response.Write(bll.UpdateInfo(md) == true ? "true" : "false"); } Response.End(); } void DelInfo() { string ForeignID = Request.Params["ID"]; ForeignColorMapBLL bll = new ForeignColorMapBLL(); tb_ForeignColorMap md = new tb_ForeignColorMap(); md.ID = int.Parse(ForeignID); Response.Write(bll.DelInfo(md) == true ? "true" : "false"); Response.End(); } void QueryForCombobox() { string StationNo = Request.Params["StationNo"]; StationBLL bll = new StationBLL(); Response.Write(bll.GetComboboxData(StationNo)); Response.End(); } void QueryForComboboxByLineID() { string LineID = "68dd1857-5e78-43f9-a065-6be76335e7fe"; StationBLL bll = new StationBLL(); Response.Write(bll.GetComboboxDataByLine(LineID)); Response.End(); } } }