一厂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.
 
 
 
 
 

258 lines
8.8 KiB

using MESClassLibrary.BLL.BasicInfo;
using MESClassLibrary.EFModel;
using MESWebSite.CommonClass;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
namespace MESWebSite.HttpHandlers
{
/// <summary>
/// ProductHandler 的摘要说明
/// </summary>
public class ProductHandler : BaseHandler
{
public ProductHandler() : base()
{
RegisterAction(QueryForCombobox);
RegisterAction(GetComboboxProduct);
RegisterAction(GetComboboxDataForStockNo);
RegisterAction(GetComboboxProduct2);
RegisterAction(GetComboboxProduct3);
RegisterAction(GetComboboxProduct4);
RegisterAction(GetComboboxProductByIsOneMore);
RegisterAction(GetComboboxProductAll);
RegisterAction(QueryExcel);
}
protected override void QueryList()
{
string page = Request.Params["page"];
string pagesize = Request.Params["rows"];
string stockNo = Request.Params["StockNo"];
string productName = Request.Params["ProductName"];
string partNo = Request.Params["PartNo"];
string productTypeID = Request.Params["ProductTypeID"];
if (string.IsNullOrEmpty(page))
{
page = "0";
}
if (string.IsNullOrEmpty(pagesize))
{
pagesize = "15";
}
ProductBLL bll = new ProductBLL();
Response.Write(bll.SearchInfoAll(page, pagesize, stockNo, productTypeID, productName, partNo));
Response.End();
}
protected override void SaveInfo()
{
string ProductID = Request.Params["ProductID"];
string ProductTypeID = Request.Params["ProductTypeID"];
string CarTypeID = Request.Params["CarTypeID"];
string StockNo = Request.Params["StockNo"];
string PartName = Request.Params["PartName"];
string ProductName = Request.Params["ProductName"];
string ColorName = Request.Params["ColorName"];
string PartNo = Request.Params["PartNo"];
string Rows = Request.Params["Rows"];
string Cols = Request.Params["Cols"];
string PackCount = Request.Params["PackCount"];
string Layers = Request.Params["Layers"];
string PicturePath = Request.Params["PicturePath"];
string Des = Request.Params["Des"];
string isImport = Request.Params["isImport"];
string openFailNum = Request.Params["OpenFailNum"];
string qLevel = Request.Params["QLevel"];
string isPrintOneTag = Request.Params["IsPrintOneTag"];
string isPrintPackList = Request.Params["IsPrintPackList"];
string isSupply = Request.Params["IsSupply"];
string isOneMore = Request.Params["IsOneMore"];
string backPlatingNum = Request.Params["BackPlatingNum"];
string isPlating = Request.Params["IsPlating"];
string isSame = Request.Params["IsSame"];
string customerNo = Request.Params["CustomerNo"];
string carModelCode = Request.Params["CarModelCode"];
string colorCodeB = Request.Params["ColorCodeB"];
string IsHigh = Request.Params["IsHigh"];
ProductBLL bll = new ProductBLL();
tb_Product md = new tb_Product
{
ProductTypeID = ProductTypeID,
CarTypeID = CarTypeID,
StockNo = StockNo,
PartName = PartName,
ProductName = ProductName,
ColorName = ColorName,
PartNo = PartNo,
Rows = Rows.To32Int(),
Cols = Cols.To32Int(),
Layers = Layers.To32Int(),
PicturePath = PicturePath,
PackCount = PackCount.To32Int(),
Des = Des,
isImport = isImport.To16Int(),
OpenFailNum = openFailNum.To32Int(),
QLevel = qLevel,
IsPrintOneTag = isPrintOneTag,
IsPrintPackList = isPrintPackList,
IsSupply = isSupply,
IsOneMore = isOneMore,
BackPlatingNum = backPlatingNum.To32Int(),
IsPlating = isPlating,
IsSame = isSame.To32Int(),
CustomerNo = customerNo,
CarModelCode = carModelCode,
ColorCodeB = colorCodeB,
IsHigh=IsHigh
};
var info = Request.Cookies.Get("LoginUserInfo");
if (info != null)
{
md.UserID = info["UserID"].ToUpper();
}
if (ProductID == "0")
{
//新增
md.ProductID = Guid.NewGuid().ToString();
Response.Write(bll.AddInfo(md) == true ? md.ProductID.ToString() : "false");
}
else
{
//修改
md.ProductID = ProductID;
Response.Write(bll.UpdateInfo(md) == true ? md.ProductID.ToString() : "false");
}
Response.End();
}
protected override void DelInfo()
{
string ProductID = Request.Params["ProductID"];
ProductBLL bll = new ProductBLL();
tb_Product md = new tb_Product();
md.ProductID = ProductID;
var info = Request.Cookies.Get("LoginUserInfo");
if (info != null)
{
md.UserID = info["UserID"].ToUpper();
}
Response.Write(bll.DeleteInfo(md) == true ? "true" : "false");
Response.End();
}
void QueryForCombobox()
{
string ProductTypeNo = Request.Params["ProductTypeNo"];
ProductBLL bll = new ProductBLL();
Response.Write(bll.GetComboboxData(ProductTypeNo));
Response.End();
}
void GetComboboxProduct()
{
string ProductTypeNo = Request.Params["ProductTypeNo"];
ProductBLL bll = new ProductBLL();
Response.Write(bll.GetComboboxProduct(ProductTypeNo));
Response.End();
}
void GetComboboxDataForStockNo()
{
string ProductTypeNo = Request.Params["ProductTypeNo"];
ProductBLL bll = new ProductBLL();
Response.Write(bll.GetComboboxDataForStockNo(ProductTypeNo));
Response.End();
}
void GetComboboxProductAll()
{
ProductBLL bll = new ProductBLL();
Response.Write(bll.GetComboboxProductAll());
Response.End();
}
void GetComboboxProduct2()
{
ProductBLL bll = new ProductBLL();
Response.Write(bll.GetComboboxProduct2());
Response.End();
}
void GetComboboxProduct3()
{
ProductBLL bll = new ProductBLL();
Response.Write(bll.GetComboboxProduct3());
Response.End();
}
void GetComboboxProduct4()
{
ProductBLL bll = new ProductBLL();
Response.Write(bll.GetComboboxProduct4());
Response.End();
}
void GetComboboxProductByIsOneMore()
{
string isOneMore = Request.Params["IsOneMore"];
ProductBLL bll = new ProductBLL();
Response.Write(bll.SearchInfoByIsOneMore(isOneMore));
Response.End();
}
void QueryExcel()
{
string page = Request.Params["page"];
string pagesize = Request.Params["rows"];
string stockNo = Request.Params["StockNo"];
string productName = Request.Params["ProductName"];
string partNo = Request.Params["PartNo"];
string productTypeID = Request.Params["ProductTypeID"];
ProductBLL bll = new ProductBLL();
List<List<string>> list = bll.SearchForExcel(page, pagesize, stockNo, productTypeID, productName, partNo);
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();
}
}
}