|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Web;
|
|
|
using System.Web.Mvc;
|
|
|
using Estsh.Web.Service;
|
|
|
using System.Collections;
|
|
|
using System.Text;
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
using System.Data;
|
|
|
using System.IO;
|
|
|
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
|
{
|
|
|
public class DeliveryOrderReportController : Controller
|
|
|
{
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 作者:张茂忠
|
|
|
* 创建时间:2013.04.23
|
|
|
* 描述:出货单信息查询模块Controller层
|
|
|
* 修改日志:
|
|
|
*
|
|
|
*
|
|
|
* *************************************************************************************************/
|
|
|
StringBuilder value = null;
|
|
|
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
private DeliveryOrderReportService service = new DeliveryOrderReportService();
|
|
|
/// <summary>
|
|
|
/// 获取车型
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult GetModelType()
|
|
|
{
|
|
|
Hashtable resault = new Hashtable();
|
|
|
ArrayList list = service.GetModelType();
|
|
|
resault.Add("list", list);
|
|
|
return Json(resault, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取打印类型
|
|
|
/// </summary>
|
|
|
/// <param name="enum_type">枚举类型</param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult GetPrintType()
|
|
|
{
|
|
|
Hashtable resault = new Hashtable();
|
|
|
ArrayList list = service.GetEnum("print_type");
|
|
|
resault.Add("list", list);
|
|
|
return Json(resault, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取查询结果
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult GetQuery()
|
|
|
{
|
|
|
DataTable dt = null;
|
|
|
value = new StringBuilder(1024);
|
|
|
Session["_where"] = value.ToString();
|
|
|
//开始送货单
|
|
|
if (!string.IsNullOrEmpty(Request["txtSendCode"]))
|
|
|
{
|
|
|
value.Append(" and Number>='" + Request["txtSendCode"].ToString().Trim() + "'");
|
|
|
}
|
|
|
|
|
|
//结束送货单
|
|
|
if (!string.IsNullOrEmpty(Request["txtEndCode"]))
|
|
|
{
|
|
|
value.Append(" and Number<='" + Request["txtEndCode"].ToString().Trim() + "'");
|
|
|
}
|
|
|
|
|
|
//打印类型
|
|
|
if (!string.IsNullOrEmpty(Request["sendType"]))
|
|
|
{
|
|
|
value.Append(" and print_type='" + Request["sendType"].ToString() + "'");
|
|
|
}
|
|
|
|
|
|
//车型
|
|
|
if (!string.IsNullOrEmpty(Request["ModelType"]))
|
|
|
{
|
|
|
value.Append(" and model_type_id='" + Request["ModelType"].ToString() + "'");
|
|
|
}
|
|
|
|
|
|
//开始车身号
|
|
|
if (!string.IsNullOrEmpty(Request["txtStartCarNo"]))
|
|
|
{
|
|
|
value.Append(" and start_car_no>='" + Request["txtStartCarNo"].ToString().Trim() + "'");
|
|
|
}
|
|
|
|
|
|
//结束车身号
|
|
|
if (!string.IsNullOrEmpty(Request["txtEndCarNo"]))
|
|
|
{
|
|
|
value.Append(" and end_car_no<='" + Request["txtEndCarNo"].ToString().Trim() + "'");
|
|
|
}
|
|
|
|
|
|
//开始订单号
|
|
|
if (!string.IsNullOrEmpty(Request["txtStartOrderNo"]))
|
|
|
{
|
|
|
value.Append(" and cust_order>='" + Request["txtStartOrderNo"].ToString() + "'");
|
|
|
}
|
|
|
|
|
|
//结束订单号
|
|
|
if (!string.IsNullOrEmpty(Request["txtEndOrderNo"]))
|
|
|
{
|
|
|
value.Append(" and cust_order<='" + Request["txtEndOrderNo"].ToString() + "'");
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(Request["txtStartPrintTime"]) && !string.IsNullOrEmpty(Request["txtEndPrintTime"]))
|
|
|
{
|
|
|
value.Append(" and CONVERT(VARCHAR(10),update_ymd,23) between convert(datetime,'" + Request["txtStartPrintTime"].ToString() + "') and convert(datetime,'" + Request["txtEndPrintTime"].ToString() + "')");
|
|
|
}
|
|
|
ArrayList list = null;
|
|
|
Hashtable resault = new Hashtable();
|
|
|
if (!value.ToString().Equals(""))
|
|
|
{
|
|
|
list = service.GetQuery(value.ToString(), ref dt);
|
|
|
Session["_where"] = value.ToString();
|
|
|
|
|
|
}
|
|
|
resault.Add("rows", list);
|
|
|
return Json(resault);
|
|
|
}
|
|
|
|
|
|
public ActionResult exportData()
|
|
|
{
|
|
|
DataTable dataHt = null;
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
Stream outputStream = Response.OutputStream;
|
|
|
HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("出货单信息");
|
|
|
if (Session["_where"].ToString() != "")
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
ArrayList list = this.service.GetQuery(Session["_where"].ToString(), ref dataHt);
|
|
|
if (workbook != null)
|
|
|
{
|
|
|
HSSFRow headRow = (HSSFRow)sheet.CreateRow(0);
|
|
|
headRow.CreateCell(0).SetCellValue("送货单号");
|
|
|
headRow.CreateCell(1).SetCellValue("订单号");
|
|
|
headRow.CreateCell(2).SetCellValue("零件编号");
|
|
|
headRow.CreateCell(3).SetCellValue("送货日期");
|
|
|
headRow.CreateCell(5).SetCellValue("车型");
|
|
|
headRow.CreateCell(6).SetCellValue("单位");
|
|
|
headRow.CreateCell(7).SetCellValue("数量");
|
|
|
headRow.CreateCell(8).SetCellValue("起始车身号");
|
|
|
headRow.CreateCell(9).SetCellValue("结束车身号");
|
|
|
headRow.CreateCell(10).SetCellValue("起始补充车身号");
|
|
|
headRow.CreateCell(11).SetCellValue("结束补充车身号");
|
|
|
headRow.CreateCell(12).SetCellValue("出货类型");
|
|
|
headRow.CreateCell(13).SetCellValue("班次");
|
|
|
headRow.CreateCell(14).SetCellValue("包装方式");
|
|
|
headRow.CreateCell(15).SetCellValue("打印日期");
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < dataHt.Rows.Count; i++)
|
|
|
{
|
|
|
int row = i + 1;
|
|
|
HSSFRow dataRow = (HSSFRow)sheet.CreateRow(row);
|
|
|
|
|
|
dataRow.CreateCell(0).SetCellValue(dataHt.Rows[i]["Number"].ToString());
|
|
|
dataRow.CreateCell(1).SetCellValue(dataHt.Rows[i]["cust_order"].ToString());
|
|
|
dataRow.CreateCell(2).SetCellValue(dataHt.Rows[i]["part_no"].ToString());
|
|
|
dataRow.CreateCell(3).SetCellValue(dataHt.Rows[i]["create_ymd"].ToString());
|
|
|
dataRow.CreateCell(5).SetCellValue(dataHt.Rows[i]["type_name"].ToString());
|
|
|
dataRow.CreateCell(6).SetCellValue(dataHt.Rows[i]["ship_unit"].ToString());
|
|
|
dataRow.CreateCell(7).SetCellValue(dataHt.Rows[i]["qty"].ToString());
|
|
|
dataRow.CreateCell(8).SetCellValue(dataHt.Rows[i]["start_car_no"].ToString());
|
|
|
dataRow.CreateCell(9).SetCellValue(dataHt.Rows[i]["end_car_no"].ToString());
|
|
|
dataRow.CreateCell(10).SetCellValue(dataHt.Rows[i]["bs_car_no"].ToString());
|
|
|
dataRow.CreateCell(11).SetCellValue(dataHt.Rows[i]["be_car_no"].ToString());
|
|
|
dataRow.CreateCell(12).SetCellValue(dataHt.Rows[i]["print_type"].ToString());
|
|
|
dataRow.CreateCell(13).SetCellValue(dataHt.Rows[i]["shift_name"].ToString());
|
|
|
dataRow.CreateCell(14).SetCellValue(dataHt.Rows[i]["pack_type"].ToString());
|
|
|
dataRow.CreateCell(15).SetCellValue(dataHt.Rows[i]["update_ymd"].ToString());
|
|
|
}
|
|
|
|
|
|
Response.Clear();
|
|
|
workbook.Write(outputStream);
|
|
|
|
|
|
Response.Buffer = true;
|
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=Excel.xls");
|
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
|
Response.ContentType = "application/vnd.ms-excel";
|
|
|
Response.Flush();
|
|
|
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
workbook = null;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
workbook.Write(outputStream);
|
|
|
|
|
|
Response.Buffer = true;
|
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=Excel.xls");
|
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
|
Response.ContentType = "application/vnd.ms-excel";
|
|
|
Response.Flush();
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
}
|