注塑喷涂
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.

288 lines
8.7 KiB

6 months ago
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using MESClassLibrary.BLL.BasicInfo;
using MESClassLibrary.BLL.PunchAndWeld;
using MESClassLibrary.EFModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
namespace MESWebSite.HttpHandlers
{
/// <summary>
/// Plan_PunchNewHandler 的摘要说明
/// </summary>
public class Plan_PunchNewHandler : 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 "QueryForCombobox_partNo":
QueryForCombobox_partNo();
break;
case "QueryForComboboxOrderNo":
QueryForComboboxOrderNo();
break;
case "QueryForItem":
QueryForItem();
break;
case "SearchOrderNo":
SearchOrderNo();
break;
case "DelInfo":
DelInfo();
break;
case "QueryExcel":
QueryExcel();
break;
}
}
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";
}
PlanPunchNewBLL bll = new PlanPunchNewBLL();
_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 StationNo = _request.Params["StationNo"];
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"];
PlanPunchNewBLL bll = new PlanPunchNewBLL();
StationBLL sbll=new StationBLL();
tb_Plan_Punch_214 md = new tb_Plan_Punch_214();
DataTable dt = sbll.SearchInfoByNo(StationNo);
if (dt != null && dt.Rows.Count > 0)
{
md.StationId = dt.Rows[0]["StationID"].ToString();
}
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 SaveInfo_u()
{
string ID = _request.Params["ID"];
string OrderNo = _request.Params["OrderNo"];
string Item = _request.Params["Item"];
string StationNo = _request.Params["StationNo"];
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"];
PlanPunchNewBLL bll = new PlanPunchNewBLL();
StationBLL sbll = new StationBLL();
tb_Plan_Punch_214 md = new tb_Plan_Punch_214();
DataTable dt = sbll.SearchInfoByNo(StationNo);
if (dt != null && dt.Rows.Count > 0)
{
md.StationId = dt.Rows[0]["StationID"].ToString();
}
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"];
PlanPunchNewBLL bll = new PlanPunchNewBLL();
_response.Write(bll.QueryForComboboxOrderNo(StartTime));
_response.End();
}
void QueryForCombobox_partNo()
{
string stationNo = _request.Params["stationNo"];
PunchAndStationBLL bll = new PunchAndStationBLL();
_response.Write(bll.GetComboboxData(stationNo));
_response.End();
}
void QueryForItem()
{
string OrderNo = _request.Params["OrderNo"];
PlanPunchNewBLL bll = new PlanPunchNewBLL();
_response.Write(bll.QueryForItem(OrderNo));
_response.End();
}
void SearchOrderNo()
{
string StartTime = _request.Params["StartTime"];
string Banci = _request.Params["Banci"];
PlanPunchNewBLL bll = new PlanPunchNewBLL();
_response.Write(bll.SearchOrderNo(StartTime, Banci));
_response.End();
}
void DelInfo()
{
string ID = _request.Params["ID"];
PlanPunchNewBLL bll = new PlanPunchNewBLL();
tb_Plan_Punch_214 md = new tb_Plan_Punch_214();
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"];
PlanPunchNewBLL bll = new PlanPunchNewBLL();
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();
}
public bool IsReusable
{
get
{
return false;
}
}
}
}