You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
5.5 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Collections;
using Estsh.Web.Service;
using Estsh.Web.Util;
using NPOI.HSSF.UserModel;
using System.IO;
using System.Data;
namespace Estsh.Core.Web.Controllers
{
public class OffLineController : Controller
{
/***************************************************************************************************
*
* 作者:张茂忠
* 创建时间2013.04.24
* 描述下线回冲查询模块Controller层
* 修改日志:
*
*
* *************************************************************************************************/
private OffLineService service = new OffLineService();
public ActionResult Index()
{
return View();
}
public ActionResult GetSumData(Pager pager)
{
Hashtable result = new Hashtable();
if (!string.IsNullOrEmpty(Request["sendType"]) && !string.IsNullOrEmpty(Request["txtOrderNo"]))
{
DataTable FactoryList = service.GetCount(ref pager,Request["txtOrderNo"].ToString(), Request["sendType"].ToString());
result.Add("rows", DataTypeConvert.NewObject.DataTableToArrayList(FactoryList));
result.Add("pager.totalRows", pager.totalRows);
}
return Json(result, JsonRequestBehavior.AllowGet);
}
public ActionResult GetModelType()
{
Hashtable resault = new Hashtable();
ArrayList list = service.GetModelType();
resault.Add("list", list);
return Json(resault, JsonRequestBehavior.AllowGet);
}
public ActionResult GetDetailData(Pager pager)
{
string ruid = Request["ruid"];
string car_no = Request["car_no"];
string serial_number = Request["serial_number"];
string part_id = Request["part_id"];
string part_no = Request["part_no"];
if (string.IsNullOrEmpty(ruid) && string.IsNullOrEmpty(car_no) && string.IsNullOrEmpty(serial_number) && string.IsNullOrEmpty(part_id) && string.IsNullOrEmpty(part_no))
{
return null;
}
DataTable dt = service.GetQuery(ref pager, part_no, car_no);
if (dt == null || dt.Rows.Count == 0)
{
dt = service.GetQuery(ref pager, part_no, car_no);
if (dt == null || dt.Rows.Count == 0)
{
if (service.isGetVirtualData() == "Y")
{
dt = service.GetDataSourse(ruid, car_no, serial_number, part_id);
}
}
}
Hashtable result = new Hashtable();
if (dt != null && dt.Rows.Count > 0)
{
ArrayList FactoryList = DataTypeConvert.NewObject.DataTableToArrayList(dt);
result.Add("rows", FactoryList);
result.Add("pager.totalRows", pager.totalRows);
}
return Json(result, JsonRequestBehavior.AllowGet);
}
public ActionResult ExportData(int pageNo,int rowCount)
{
Pager pager = new Pager();
pager.pageNo = pager.pageNo;
pager.pageSize = rowCount;
string ruid = Request["ruid"];
string car_no = Request["car_no"];
string serial_number = Request["serial_number"];
string part_id = Request["part_id"];
string part_no = Request["part_no"];
if (string.IsNullOrEmpty(ruid) && string.IsNullOrEmpty(car_no) && string.IsNullOrEmpty(serial_number) && string.IsNullOrEmpty(part_id) && string.IsNullOrEmpty(part_no))
{
return null;
}
DataTable dt = service.GetQuery(ref pager, part_no, car_no);
if (dt == null || dt.Rows.Count == 0)
{
dt = service.GetQuery(ref pager, part_no, car_no);
if (dt == null || dt.Rows.Count == 0)
{
if (service.isGetVirtualData() == "Y")
{
dt = service.GetDataSourse(ruid, car_no, serial_number, part_id);
}
}
}
Stream outputStream = Response.OutputStream;
string AbsolutePath = Request.UrlReferrer.AbsolutePath;
string url = AbsolutePath.Remove(0, Request.ApplicationPath.Length);
GridColumnService colService = new GridColumnService();
Models.SysWebGridColumn[] detailItems = colService.GetColumnByUrl(url, "明细");
HSSFWorkbook workbook = NPOIExcelTools.DataTableToWorkbook(detailItems, dt, "明细");
Response.Clear();
workbook.Write(outputStream);
Response.Buffer = true;
if (Request.Browser.Type.ToUpper().IndexOf("IE") >= 0)
{
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("下线回冲查询明细.xls", System.Text.Encoding.UTF8));
}
else
{
Response.AppendHeader("Content-Disposition", "attachment;filename=下线回冲查询明细.xls");
}
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "application/vnd.ms-excel";
Response.Flush();
return null;
}
}
}