一厂MES,含注塑,喷涂,冲孔
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.

119 lines
4.0 KiB

3 months ago
using MESClassLibrary.BLL.BasicInfo;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using MESWebSite.CommonClass;
using MESWebSite.Export;
using MESWebSite.Tool;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
namespace MESWebSite.HttpHandlers
{
/// <summary>
/// ZPPlanHandler 的摘要说明
/// </summary>
public class ZPPlanHandler : BaseHandler
{
public ZPPlanHandler() : base()
{
RegisterAction(ExportExcel);
}
protected override void DelInfo()
{
string ID = GetParam("ID");
ZPPlanBLL bll = new ZPPlanBLL();
Response.Write(bll.DeleteInfo(new tb_ZPPlan() { ID = ID }) ? ResponseResult.Success() : ResponseResult.Fail("删除失败"));
Response.End();
}
protected override void QueryList()
{
string StartTime = GetParam("StartTime");
string EndTime = GetParam("EndTime");
string PartNo = GetParam("PartNo");
int page = Page.To32Int();
int pageSize = Rows.To32Int();
ZPPlanBLL bll = new ZPPlanBLL();
string reslut = bll.SearchInfoAll(page, pageSize, StartTime, EndTime, PartNo);
Response.Write(reslut);
Response.End();
}
protected override void SaveInfo()
{
string id = GetParam("ID");
//string stationID = GetParam("StationID");
string partNo = GetParam("PartNo");
int orderCount = GetParam("OrderCount").To32Int();
//string isOneMore = GetParam("IsOneMore");
string isOneMore = "";
DateTime orderDate;
if (!DateTime.TryParse(GetParam("OrderDate"), out orderDate))
{
Response.Write("false");
Response.End();
return;
};
ZPPlanBLL bll = new ZPPlanBLL();
tb_ZPPlan zpp = new tb_ZPPlan
{
ID = id,
//StationID = stationID,
PartNo = partNo,
OrderDate = orderDate,
OrderCount = orderCount,
//IsOneMore = isOneMore
};
//DataTable dt = bll.SearchOrderNo(DateTime.Now.ToString("yyyMMdd"));
//if (dt != null && dt.Rows.Count > 0)
//{
// string old = dt.Rows[0]["OrderNo"].ToString();
// zpp.OrderNo = DateTime.Now.ToString("yyyMMdd") + (Convert.ToInt32(old.Substring(old.Length - 4, 4))+1).ToString().PadLeft(4,'0');
//}
//else
//{
// zpp.OrderNo = DateTime.Now.ToString("yyyMMdd") + "0001";
//}
if (id == "0")
{
Response.Write(bll.AddInfo(zpp) ? ResponseResult.Success() : ResponseResult.Fail("添加失败"));
}
else
{
string msg = string.Empty;
Response.Write(bll.UpdateInfo(zpp, ref msg) ? ResponseResult.Success() : ResponseResult.Fail(msg));
}
Response.End();
}
public void ExportExcel()
{
string StartTime = GetParam("StartTime");
string EndTime = GetParam("EndTime");
string PartNo = GetParam("PartNo");
ZPPlanBLL bll = new ZPPlanBLL();
List<ZPPlanModel> result = bll.SearchByCreateTime(StartTime, EndTime, PartNo);
ExcelTool excelTool = new ExcelTool();
XSSFWorkbook book = excelTool.Export(result, typeof(ExportZPPlan));
using (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());
Response.End();
}
}
}
}