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

107 lines
3.2 KiB

2 months ago
using MESClassLibrary.BLL.Painting;
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>
/// ChaimUpRecordHandler 的摘要说明
/// </summary>
public class ChaimUpRecordHandler : 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 "QueryExcel":
QueryExcel();
break;
default:
break;
}
}
void QueryList()
{
string page = Request.Params["page"];
string pagesize = Request.Params["rows"];
string startTime = Request.Params["startTime"];
string endTime = Request.Params["endTime"];
int flag = Convert.ToInt32( Request.Params["flag"]);
string barCode = Request.Params["barCode"];
if (string.IsNullOrEmpty(page))
{
page = "0";
}
if (string.IsNullOrEmpty(pagesize))
{
pagesize = "15";
}
ChaimUpRecordBll bll = new ChaimUpRecordBll();
Response.Write(bll.SearchInfoAll(page, pagesize, startTime, endTime,flag,barCode));
Response.End();
}
void QueryExcel()
{
string page = Request.Params["page"];
string pagesize = Request.Params["rows"];
string startTime = Request.Params["startTime"];
string endTime = Request.Params["endTime"];
int flag = Convert.ToInt32(Request.Params["flag"]);
string barCode = Request.Params["barCode"];
ChaimUpRecordBll bll = new ChaimUpRecordBll();
List<List<string>> list = bll.SearchForExcel(page, pagesize, startTime, endTime, flag, barCode);
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;
}
}
}
}