注塑喷涂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

290 lines
8.3 KiB

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using MESClassLibrary.BLL.Plan247;
using MESClassLibrary.BLL.PunchAndWeld;
using MESClassLibrary.EFModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
namespace MESWebSite.HttpHandlers
{
/// <summary>
/// Plan_PunchHandler 的摘要说明
/// </summary>
public class Plan_PunchHandler : 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";
}
PlanPunchBLL bll = new PlanPunchBLL();
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"];
PlanPunchBLL bll = new PlanPunchBLL();
tb_Plan_Punch md = new tb_Plan_Punch();
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.BadCount = 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 SearchOrderNo()
{
string StartTime = Request.Params["StartTime"];
string Banci = Request.Params["Banci"];
PlanPunchBLL bll = new PlanPunchBLL();
Response.Write(bll.SearchOrderNo(StartTime, Banci));
Response.End();
}
void QueryForCombobox()
{
PlanPunchBLL bll = new PlanPunchBLL();
Response.Write(bll.GetComboboxData());
Response.End();
}
void GetMistake()
{
string PartNo = Request.Params["PartNo"];
PlanPunchBLL bll = new PlanPunchBLL();
Response.Write(bll.GetMistake(PartNo));
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"];
PlanPunchBLL bll = new PlanPunchBLL();
tb_Plan_Punch md = new tb_Plan_Punch();
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.BadCount = 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 QueryForComboboxOrderNo()
{
string StartTime = Request.Params["StartTime"];
PlanPunchBLL bll = new PlanPunchBLL();
Response.Write(bll.QueryForComboboxOrderNo(StartTime));
Response.End();
}
void QueryForItem()
{
string OrderNo = Request.Params["OrderNo"];
PlanPunchBLL bll = new PlanPunchBLL();
Response.Write(bll.QueryForItem(OrderNo));
Response.End();
}
void DelInfo()
{
string ID = Request.Params["ID"];
PlanPunchBLL bll = new PlanPunchBLL();
tb_Plan_Punch md = new tb_Plan_Punch();
md.ID = ID;
Response.Write(bll.DeleteInfo(md) == true ? "true" : "false");
Response.End();
}
void QueryExcel()
{
string StartTime = Request.Params["StartTime"];
string EndTime = Request.Params["EndTime"];
string OrderNo = Request.Params["OrderNo"];
PlanPunchBLL bll = new PlanPunchBLL();
List<List<string>> 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();
}
}
}