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.
176 lines
6.2 KiB
C#
176 lines
6.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using Estsh.BLL;
|
|
using System.Collections;
|
|
using System.Data;
|
|
using Estsh.Web.Util;
|
|
using System.IO;
|
|
using Estsh.Web.Service;
|
|
using NPOI.HSSF.UserModel;
|
|
|
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
{
|
|
public class XTStockDataQueryController : Controller
|
|
{
|
|
//
|
|
// GET: /ProductOffLineNotShipedQuery/
|
|
|
|
XTStockDataQueryService Service = new XTStockDataQueryService();
|
|
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
|
|
|
|
public string SetWhere()
|
|
{
|
|
string _where = "";
|
|
|
|
if (!string.IsNullOrEmpty(Request["txtPartNo"]))
|
|
{
|
|
|
|
_where += " and b.part_no= '" + Request["txtPartNo"].ToString().Trim() + "'";
|
|
}
|
|
//如果配置不为空
|
|
if (!string.IsNullOrEmpty(Request["cmbModelName"]))
|
|
{
|
|
_where += " and c.model_name = '" + Request["cmbModelName"].Trim() + "'";
|
|
}
|
|
|
|
//如果车型不为空
|
|
if (!string.IsNullOrEmpty(Request["cmbTypeName"]))
|
|
{
|
|
_where += " and f.type_name = '" + Request["cmbTypeName"].Trim() + "'";
|
|
}
|
|
|
|
|
|
|
|
return _where;
|
|
}
|
|
/// <summary>
|
|
/// 汇总
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <returns></returns>
|
|
public ActionResult GetStockData(Pager pager)
|
|
{
|
|
if (string.IsNullOrEmpty(Request["txtPartNo"]) && string.IsNullOrEmpty(Request["cmbModelName"]) && string.IsNullOrEmpty(Request["cmbTypeName"]))
|
|
{
|
|
return null;
|
|
}
|
|
string where = SetWhere();
|
|
int totalCount = 0;
|
|
DataTable dtQuery = Service.GetStockData(where, pager, ref totalCount);
|
|
Hashtable result = new Hashtable();
|
|
result.Add("rows", DataTypeConvert.NewObject.DataTableToArrayList(dtQuery));
|
|
result.Add("pager.totalRows", totalCount);
|
|
return Json(result);
|
|
}
|
|
/// <summary>
|
|
/// 明细
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <returns></returns>
|
|
public ActionResult GetDetailData(Pager pager)
|
|
{
|
|
if (string.IsNullOrEmpty(Request["txtPartNo"]) && string.IsNullOrEmpty(Request["cmbModelName"]) && string.IsNullOrEmpty(Request["cmbTypeName"]))
|
|
{
|
|
return null;
|
|
}
|
|
string where = SetWhere();
|
|
int totalCount = 0;
|
|
DataTable dtQuery = Service.GetDetailData(where, pager, ref totalCount);
|
|
Hashtable result = new Hashtable();
|
|
result.Add("rows", DataTypeConvert.NewObject.DataTableToArrayList(dtQuery));
|
|
result.Add("pager.totalRows", totalCount);
|
|
return Json(result);
|
|
}
|
|
/// <summary>
|
|
/// 车型
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult GetTypeName()
|
|
{
|
|
Hashtable ht = new Hashtable();
|
|
ArrayList alType = Service.GetTypeName();
|
|
ht.Add("list", alType);
|
|
return Json(ht, JsonRequestBehavior.AllowGet);
|
|
|
|
}
|
|
/// <summary>
|
|
/// 配置
|
|
/// </summary>
|
|
/// <param name="typeName"></param>
|
|
/// <returns></returns>
|
|
public ActionResult GetModelName(string typeName)
|
|
{
|
|
Hashtable ht = new Hashtable();
|
|
ArrayList alModel = Service.GetModelName(typeName);
|
|
ht.Add("list", alModel);
|
|
return Json(ht, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
|
|
public ActionResult exportData(Pager pager, Pager pager1, int a)
|
|
{
|
|
int totalCount = 0;
|
|
int totalCount2 = 0;
|
|
|
|
string where = SetWhere();
|
|
|
|
DataTable dtQuery = Service.GetStockData(where, pager, ref totalCount);
|
|
|
|
DataTable dtDetailQuery = Service.GetDetailData(where, pager1, ref totalCount2);
|
|
|
|
|
|
Stream outputStream = Response.OutputStream;
|
|
string AbsolutePath = Request.UrlReferrer.AbsolutePath;
|
|
string url = AbsolutePath.Remove(0, Request.ApplicationPath.Length);
|
|
GridColumnService colService = new GridColumnService();
|
|
Models.SysWebGridColumn[] detailGridItems = colService.GetColumnByUrl(url, "汇总");//查询汇总GtidColumn]
|
|
Models.SysWebGridColumn[] SNCurrent = colService.GetColumnByUrl(url, "明细");
|
|
|
|
HSSFWorkbook workbook = NPOIExcelTools.DataTableToWorkbook(detailGridItems, dtQuery, "汇总信息");//将汇总表转换为Workbook
|
|
NPOIExcelTools.AddSheet(workbook, SNCurrent, dtDetailQuery, "明细信息");//添加明细Sheet
|
|
Response.Clear();
|
|
workbook.Write(outputStream);
|
|
|
|
Response.Buffer = true;
|
|
if (a == 1)
|
|
{
|
|
if (Request.Browser.Type.ToUpper().IndexOf("IE") >= 0)
|
|
{
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("下线未发运_当前页_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls", System.Text.Encoding.UTF8));
|
|
}
|
|
else
|
|
{
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=下线未发运_当前页_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (Request.Browser.Type.ToUpper().IndexOf("IE") >= 0)
|
|
{
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("下线未发运_当前页_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls", System.Text.Encoding.UTF8));
|
|
}
|
|
else
|
|
{
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=下线未发运_所有页_" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls");
|
|
}
|
|
}
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
Response.ContentType = "application/vnd.ms-excel";
|
|
Response.Flush();
|
|
return null;
|
|
|
|
|
|
}
|
|
}
|
|
}
|