using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Estsh.Web.Util;
using Estsh.Web.Service;
using System.Collections;
using Estsh.Web.Models;
using NPOI.HSSF.UserModel;
using System.IO;
using System.Data;
using ApServerProvider;
/***************************************************************************************************
*
* 作者:王勇
*
* *************************************************************************************************/
namespace Estsh.Core.Web.Controllers
{
///
///
///
public class XTShipShiftDefineController : Controller
{
private XTShipShiftDefineService service = new XTShipShiftDefineService();
private RemotingProxy.RecordStatus _recordStatus = RemotingProxy.RecordStatus.Enable;
//
// GET: /XTShipDefine/
public ActionResult Index()
{
return View();
}
///
/// 获取列表数据
///
/// 菜单名称
/// 分页
/// 排序方式
/// 排序列
///
public ActionResult getXTShipShiftDefineListByPage(Pager pager, String direction, String sort, string cbModelName, string SN,String txtStartTime, String txtEndTime, string status)
{
Hashtable result = new Hashtable();
result.Add("pager.pageNo", pager.pageNo);
Hashtable dataHt = this.service.getXTShipShiftDefineListByPage( pager, direction, sort, cbModelName, SN,txtStartTime, txtEndTime,status);
result.Add("rows", dataHt["dataList"]);
result.Add("pager.totalRows", dataHt["totalCount"]);
result.Add("sort", sort);
result.Add("direction", direction);
return Json(result);
}
///
///车型集合
///
/// 数据集
public ActionResult GetModelName()
{
Hashtable resault = new Hashtable();
ArrayList list = service.GetModelName();
resault.Add("list", list);
return Json(resault, JsonRequestBehavior.AllowGet);
}
///
/// 导出数据到Excel
/// BY NOAH
///
///
///
///
///
///
///
public ActionResult exportData(Pager pager, String sort, String direction, String isPage)
{
Boolean paging = false;
if (isPage == null || "".Equals(isPage))
{
paging = false;
}
else
{
if ("1".Equals(isPage.Trim()))
{
paging = true;
}
else
{
paging = false;
}
}
string cbModelName = Request["cbModelName"];
string SN = Request["SN"];
string txtStartTime = Request["txtStartTime"];
string txtEndTime = Request["txtEndTime"];
string status = Request["status"];
DataTable dataHt = this.service.getTableListByPage(pager, direction, sort, paging, cbModelName, SN, txtStartTime, txtEndTime, status);
HSSFWorkbook workbook = new HSSFWorkbook();
Stream outputStream = Response.OutputStream;
HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("发运数据");
try
{
if (workbook != null)
{
HSSFRow headRow = (HSSFRow)sheet.CreateRow(0);
headRow.CreateCell(0).SetCellValue("排序单号");
headRow.CreateCell(1).SetCellValue("吉利件号");
headRow.CreateCell(2).SetCellValue("VIN");
headRow.CreateCell(3).SetCellValue("接收日期");
headRow.CreateCell(4).SetCellValue("接收时间");
headRow.CreateCell(5).SetCellValue("发运状态");
headRow.CreateCell(6).SetCellValue("包装条码");
headRow.CreateCell(7).SetCellValue("配置");
headRow.CreateCell(8).SetCellValue("发运日期");
headRow.CreateCell(9).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]["order_no"].ToString());
dataRow.CreateCell(1).SetCellValue(dataHt.Rows[i]["PNRSTRING"].ToString());
dataRow.CreateCell(2).SetCellValue(dataHt.Rows[i]["VIN"].ToString());
dataRow.CreateCell(3).SetCellValue(dataHt.Rows[i]["create_ymd"].ToString());
dataRow.CreateCell(4).SetCellValue(dataHt.Rows[i]["create_hms"].ToString());
dataRow.CreateCell(5).SetCellValue(dataHt.Rows[i]["status"].ToString());
dataRow.CreateCell(6).SetCellValue(dataHt.Rows[i]["serial_number"].ToString());
dataRow.CreateCell(7).SetCellValue(dataHt.Rows[i]["model_name"].ToString());
dataRow.CreateCell(8).SetCellValue(dataHt.Rows[i]["ship_create_ymd"].ToString());
dataRow.CreateCell(9).SetCellValue(dataHt.Rows[i]["ship_create_hms"].ToString());
}
Response.Clear();
workbook.Write(outputStream);
Response.Buffer = true;
Response.AppendHeader("Content-Disposition", "attachment;filename=生产指令调整.xls");
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "application/vnd.ms-excel";
Response.Flush();
}
catch (Exception e)
{
}
finally
{
workbook = null;
}
return null;
}
}
}