using MESClassLibrary.BLL.Plan247; using MESClassLibrary.EFModel; using NPOI.SS.UserModel; using NPOI.XSSF.UserModel; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using MESClassLibrary.BLL.Plan243; namespace MESWebSite.HttpHandlers { /// /// Plan_247Handler 的摘要说明 /// public class Plan_247Handler : 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 "SaveInfo_u": SaveInfo_u(); break; case "SearchOrderNo": SearchOrderNo(); break; case "QueryForCombobox": QueryForCombobox(); break; case "GetMistake": GetMistake(); break; case "QueryForComboboxOrderNo": QueryForComboboxOrderNo(); break; case "QueryForItem": QueryForItem(); break; case "QueryExcel": QueryExcel(); 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 StartTime = Request.Params["StartTime"]; string EndTime = Request.Params["EndTime"]; string OrderNo = Request.Params["OrderNo"]; if (string.IsNullOrEmpty(page)) { page = "0"; } if (string.IsNullOrEmpty(pagesize)) { pagesize = "15"; } Plan247BLL bll = new Plan247BLL(); Response.Write(bll.SearchInfoAll(page, pagesize, StartTime, EndTime, OrderNo)); Response.End(); } void SaveInfo() { string ID = Request.Params["ID"]; string OrderNo = Request.Params["OrderNo"]; string Item = Request.Params["Item"]; string PartNo = Request.Params["PartNo"]; string PartName = Request.Params["PartName"]; string PartConfig = Request.Params["PartConfig"]; string OrderCount = Request.Params["OrderCount"]; string Des = Request.Params["Des"]; Plan247BLL bll = new Plan247BLL(); tb_Plan_247 md = new tb_Plan_247(); md.OrderNo = OrderNo; md.PartNo = PartNo; md.Des = Des; int Item_ = 0; Int32.TryParse(Item, out Item_); md.Item = Item_; int OrderCount_ = 0; Int32.TryParse(OrderCount, out OrderCount_); md.OrderCount = OrderCount_; if (ID == "0") { md.ID = Guid.NewGuid().ToString(); md.CreateTime = DateTime.Now; md.LyCount = 0; md.RepairCount = 0; md.ScrapCount1 = 0; md.ScrapCount2 = 0; md.CompleteCount = 0; md.IsFinish = 0; //新增 Response.Write(bll.AddInfo(md) == true ? "true" : "false"); } else { md.ID = ID; //修改 Response.Write(bll.UpdateInfo(md) == true ? "true" : "false"); } Response.End(); } void SaveInfo_u() { string ID = Request.Params["ID"]; string OrderNo = Request.Params["OrderNo"]; string Item = Request.Params["Item"]; string PartNo = Request.Params["PartNo"]; string PartName = Request.Params["PartName"]; string PartConfig = Request.Params["PartConfig"]; string OrderCount = Request.Params["OrderCount"]; string Des = Request.Params["Des"]; Plan247BLL bll = new Plan247BLL(); tb_Plan_247 md = new tb_Plan_247(); md.OrderNo = OrderNo; md.PartNo = PartNo; md.Des = Des; int Item_ = 0; Int32.TryParse(Item, out Item_); md.Item = Item_; int OrderCount_ = 0; Int32.TryParse(OrderCount, out OrderCount_); md.OrderCount = OrderCount_; if (ID == "0") { md.ID = Guid.NewGuid().ToString(); md.CreateTime = DateTime.Now; md.LyCount = 0; md.RepairCount = 0; md.ScrapCount1 = 0; md.ScrapCount2 = 0; md.CompleteCount = 0; md.IsFinish = 0; //新增 Response.Write(bll.UpdateAddInfo(md) == true ? "true" : "false"); } else { md.ID = ID; //修改 Response.Write(bll.UpdateInfo(md) == true ? "true" : "false"); } Response.End(); } void SearchOrderNo() { string StartTime = Request.Params["StartTime"]; Plan247BLL bll = new Plan247BLL(); Response.Write(bll.SearchOrderNo(StartTime)); Response.End(); } void QueryForCombobox() { Plan247BLL bll = new Plan247BLL(); Response.Write(bll.GetComboboxData()); Response.End(); } void GetMistake() { string ID = Request.Params["ID"]; Plan247BLL bll = new Plan247BLL(); Response.Write(bll.GetMistake(ID)); Response.End(); } void QueryForComboboxOrderNo() { string StartTime = Request.Params["StartTime"]; Plan247BLL bll = new Plan247BLL(); Response.Write(bll.QueryForComboboxOrderNo(StartTime)); Response.End(); } void QueryForItem() { string OrderNo = Request.Params["OrderNo"]; Plan247BLL bll = new Plan247BLL(); Response.Write(bll.QueryForItem(OrderNo)); Response.End(); } void QueryExcel() { string StartTime = Request.Params["StartTime"]; string EndTime = Request.Params["EndTime"]; string OrderNo = Request.Params["OrderNo"]; Plan247BLL bll = new Plan247BLL(); List> list = bll.SearchForExcel(StartTime, EndTime, OrderNo); XSSFWorkbook book = new XSSFWorkbook(); ISheet sheet = book.CreateSheet("Sheet1"); for (int i = 0; i < list.Count; i++) { IRow row = sheet.CreateRow(i); for (int k = 0; k < list[i].Count; k++) { row.CreateCell(k).SetCellValue(list[i][k].ToString()); } } // 写入到客户端 MemoryStream ms = new MemoryStream(); book.Write(ms); Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.xlsx", DateTime.Now.ToString("yyyyMMddHHmmssfff"))); Response.BinaryWrite(ms.ToArray()); book = null; ms.Close(); ms.Dispose(); } void DelInfo() { string ID = Request.Params["ID"]; Plan247BLL bll = new Plan247BLL(); tb_Plan_247 md = new tb_Plan_247(); md.ID = ID; Response.Write(bll.DeleteInfo(md) == true ? "true" : "false"); Response.End(); } } }