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.
413 lines
17 KiB
C#
413 lines
17 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using Estsh.Web.Service;
|
|
using System.Data;
|
|
using System.Collections;
|
|
using NPOI.HSSF.UserModel;
|
|
using System.IO;
|
|
using Estsh.Web.Util;
|
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
{
|
|
public class NewShippingInformationDefineController:Controller
|
|
{
|
|
NewShippingInformationDefineService service = new NewShippingInformationDefineService();
|
|
//
|
|
// GET: /Menu/
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
|
|
string _where = "";
|
|
public string SetWhere()
|
|
{
|
|
int condition = 0;
|
|
_where = "";
|
|
|
|
DateTime startDate = Request.RequestContext.HttpContext.Timestamp.AddDays(-1);
|
|
DateTime endDate = Request.RequestContext.HttpContext.Timestamp;
|
|
|
|
string starttime = startDate.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
string endtime = endDate.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
if (!string.IsNullOrEmpty(Request["txtOrderNo"]))
|
|
{
|
|
condition++;
|
|
_where += " and a.order_no like '%" + Request["txtOrderNo"].ToString().Trim() + "%' ";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(Request["txtPartNo"]))
|
|
{
|
|
condition++;
|
|
_where += " and a.part_no = '%" + Request["txtPartNo"].ToString().Trim() + "%' ";
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(Request["txtStartTime"]) || !string.IsNullOrEmpty(Request["txtEndTime"]))
|
|
{
|
|
condition++;
|
|
_where += " and a.create_ymd+' '+a.create_hms BETWEEN '" + Request["txtStartTime"].Trim() + "' and '" + Request["txtEndTime"].Trim() + "' ";
|
|
}
|
|
if (condition == 0)
|
|
{
|
|
_where += " and a.create_ymd+' '+a.create_hms BETWEEN '" + starttime + "' and '" + endtime + "' ";
|
|
|
|
}
|
|
return _where;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取列表数据
|
|
/// </summary>
|
|
/// <param name="PartMasterName">菜单名称</param>
|
|
/// <param name="pager">分页</param>
|
|
/// <param name="direction">排序方式</param>
|
|
/// <param name="sort">排序列</param>
|
|
/// <returns></returns>
|
|
public ActionResult getShippingListByPage(Pager pager, String direction, String sort)
|
|
{
|
|
_where = SetWhere();
|
|
Hashtable result = new Hashtable();
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
Hashtable dataHt = this.service.getShippingListByPage(_where, pager);
|
|
result.Add("rows", dataHt["dataList"]);
|
|
result.Add("pager.totalRows", dataHt["totalCount"]);
|
|
result.Add("sort", sort);
|
|
result.Add("direction", direction);
|
|
|
|
return Json(result);
|
|
}
|
|
|
|
public ActionResult getShippingListDetail(String ruid)
|
|
{
|
|
Hashtable ht = this.service.getShippingListDetail(ruid);
|
|
ViewData.Add("ruid", ht["ruid"]);
|
|
ViewData.Add("order_no", ht["order_no"]);
|
|
ViewData.Add("part_no", ht["part_no"]);
|
|
ViewData.Add("part_spec", ht["part_spec"]);
|
|
ViewData.Add("qty", ht["qty"]);
|
|
ViewData.Add("piqty", ht["piqty"]);
|
|
return View("~/Views/NewShippingInformationDefine/ViewNewShippingInformationListDefine.aspx");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑菜单
|
|
/// </summary>
|
|
/// <param name="type_id"></param>
|
|
/// <returns></returns>
|
|
public ActionResult editShippingList(String ruid)
|
|
{
|
|
Hashtable ht = this.service.getShippingListDetail(ruid);
|
|
ViewData.Add("editType", "edit");
|
|
|
|
ViewData.Add("ruid", ht["ruid"]);
|
|
ViewData.Add("order_no", ht["order_no"]);
|
|
ViewData.Add("part_no", ht["part_no"]);
|
|
ViewData.Add("part_spec", ht["part_spec"]);
|
|
ViewData.Add("qty", ht["qty"]);
|
|
ViewData.Add("piqty", ht["piqty"]);
|
|
return View("~/Views/NewShippingInformationDefine/EditNewShippingInformationListDefine.aspx");
|
|
}
|
|
|
|
public ActionResult saveShippingList()
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
String message = "";
|
|
String flag = "";
|
|
|
|
String editType = Request["editType"].ToString();
|
|
|
|
String ruid = Request["ruid"].ToString();
|
|
String order_no = Request["order_no"].ToString();
|
|
String part_no = Request["part_no"].ToString();
|
|
String part_spec = Request["part_spec"].ToString();
|
|
String qty = Request["qty"].ToString();
|
|
String piqty = Request["piqty"].ToString();
|
|
|
|
//传递要更新的数据库字段
|
|
Hashtable htParams = new Hashtable();
|
|
htParams.Add("@order_no", order_no);
|
|
htParams.Add("@part_no", part_no);
|
|
htParams.Add("@part_spec", part_spec);
|
|
htParams.Add("@qty", qty);
|
|
htParams.Add("@piqty", piqty);
|
|
|
|
//用户id
|
|
//UserInfo user = (UserInfo)Session["loginedUser"];
|
|
//htParams.Add("@update_userid", user.updateUserId);
|
|
//htParams.Add("@create_userid", user.updateUserId);
|
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
{
|
|
try
|
|
{
|
|
htParams.Add("@ruid", ruid);
|
|
if (Convert.ToInt32(qty) < Convert.ToInt32(piqty))
|
|
{
|
|
message = "需求数量不能小于实发数量,不允许修改!";
|
|
}
|
|
else
|
|
{
|
|
this.service.updateShippingList(htParams);
|
|
message = "修改成功";
|
|
flag = "OK";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
message = "修改失败!";
|
|
flag = "Fail";
|
|
}
|
|
}
|
|
//else
|
|
//{
|
|
// try
|
|
// {
|
|
// htParams.Add("@ruid", ruid);
|
|
// this.service.saveShippingList(htParams);
|
|
// message = "添加成功";
|
|
// flag = "OK";
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// message = "添加失败!";
|
|
// flag = "Fail";
|
|
// }
|
|
//}
|
|
result.Add("message", message);
|
|
result.Add("flag", flag);
|
|
return Json(result);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取列表数据
|
|
/// </summary>
|
|
/// <param name="PartMasterName">菜单名称</param>
|
|
/// <param name="pager">分页</param>
|
|
/// <param name="direction">排序方式</param>
|
|
/// <param name="sort">排序列</param>
|
|
/// <returns></returns>
|
|
public ActionResult getShippingListDetailByPage(Pager pager, String direction, String sort)
|
|
{
|
|
_where = SetWhere();
|
|
Hashtable result = new Hashtable();
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
Hashtable dataHt = this.service.getShippingListDetailByPage(_where, pager);
|
|
result.Add("rows", dataHt["dataList"]);
|
|
result.Add("pager.totalRows", dataHt["totalCount"]);
|
|
result.Add("sort", sort);
|
|
result.Add("direction", direction);
|
|
return Json(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出数据到Excel
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <param name="txtOrderNo"></param>
|
|
/// <param name="sort"></param>
|
|
/// <param name="direction"></param>
|
|
/// <param name="isPage"></param>
|
|
/// <returns></returns>
|
|
//public ActionResult exportData(String txtStartTime, String txtEndTime, String cust_pdline_name, String shipping_sn, 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;
|
|
// // }
|
|
// //}
|
|
// _where = SetWhere();
|
|
// DataTable dataHt = this.service.getShippingExport(_where, pager, direction, sort);
|
|
// 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("配置描述");
|
|
// headRow.CreateCell(3).SetCellValue("零件号");
|
|
// headRow.CreateCell(4).SetCellValue("零件描述");
|
|
// headRow.CreateCell(5).SetCellValue("客户流水号");
|
|
// headRow.CreateCell(6).SetCellValue("VIN号");
|
|
// headRow.CreateCell(7).SetCellValue("发运条码");
|
|
// headRow.CreateCell(8).SetCellValue("数量");
|
|
// headRow.CreateCell(9).SetCellValue("发运状态");
|
|
// headRow.CreateCell(10).SetCellValue("修改日期");
|
|
// headRow.CreateCell(11).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]["cust_pdline_name"].ToString());
|
|
// dataRow.CreateCell(1).SetCellValue(dataHt.Rows[i]["model_name"].ToString());
|
|
// dataRow.CreateCell(2).SetCellValue(dataHt.Rows[i]["model_desc"].ToString());
|
|
// dataRow.CreateCell(3).SetCellValue(dataHt.Rows[i]["part_no"].ToString());
|
|
// dataRow.CreateCell(4).SetCellValue(dataHt.Rows[i]["part_spec"].ToString());
|
|
// dataRow.CreateCell(5).SetCellValue(dataHt.Rows[i]["order_seq"].ToString());
|
|
// dataRow.CreateCell(6).SetCellValue(dataHt.Rows[i]["vin"].ToString());
|
|
// dataRow.CreateCell(7).SetCellValue(dataHt.Rows[i]["shipping_sn"].ToString());
|
|
// dataRow.CreateCell(8).SetCellValue(dataHt.Rows[i]["qty"].ToString());
|
|
// dataRow.CreateCell(9).SetCellValue(dataHt.Rows[i]["ship_status"].ToString());
|
|
// dataRow.CreateCell(10).SetCellValue(dataHt.Rows[i]["update_ymd"].ToString());
|
|
// dataRow.CreateCell(11).SetCellValue(dataHt.Rows[i]["update_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;
|
|
//}
|
|
|
|
/// <summary>
|
|
/// 导出全部
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult exportData(Pager pager)
|
|
{
|
|
|
|
|
|
_where = SetWhere();
|
|
|
|
|
|
DataTable sumList = service.GetCountShipping(_where);
|
|
|
|
DataTable detailList = service.GetCountShippingDetail(_where);
|
|
|
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
Stream outputStream = Response.OutputStream;
|
|
HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("汇总");
|
|
HSSFSheet sheet2 = (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("零件号");
|
|
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("建单日期");
|
|
headRow.CreateCell(10).SetCellValue("建单时间");
|
|
|
|
}
|
|
|
|
for (int i = 0; i < sumList.Rows.Count; i++)
|
|
{
|
|
int row = i + 1;
|
|
HSSFRow dataRow = (HSSFRow)sheet.CreateRow(row);
|
|
|
|
dataRow.CreateCell(0).SetCellValue(sumList.Rows[i]["order_no"].ToString());
|
|
dataRow.CreateCell(1).SetCellValue(sumList.Rows[i]["werks"].ToString());
|
|
dataRow.CreateCell(2).SetCellValue(sumList.Rows[i]["part_no"].ToString());
|
|
dataRow.CreateCell(3).SetCellValue(sumList.Rows[i]["part_spec"].ToString());
|
|
dataRow.CreateCell(4).SetCellValue(sumList.Rows[i]["qty"].ToString());
|
|
dataRow.CreateCell(5).SetCellValue(sumList.Rows[i]["piqty"].ToString());
|
|
dataRow.CreateCell(6).SetCellValue(sumList.Rows[i]["flag"].ToString());
|
|
dataRow.CreateCell(7).SetCellValue(sumList.Rows[i]["update_ymd"].ToString());
|
|
dataRow.CreateCell(8).SetCellValue(sumList.Rows[i]["update_hms"].ToString());
|
|
dataRow.CreateCell(9).SetCellValue(sumList.Rows[i]["create_ymd"].ToString());
|
|
dataRow.CreateCell(10).SetCellValue(sumList.Rows[i]["create_hms"].ToString());
|
|
|
|
}
|
|
|
|
if (workbook != null)
|
|
{
|
|
HSSFRow headRow = (HSSFRow)sheet2.CreateRow(0);
|
|
headRow.CreateCell(0).SetCellValue("发运单号");
|
|
headRow.CreateCell(1).SetCellValue("条码");
|
|
headRow.CreateCell(2).SetCellValue("零件号");
|
|
headRow.CreateCell(3).SetCellValue("零件描述");
|
|
headRow.CreateCell(4).SetCellValue("发运人");
|
|
headRow.CreateCell(5).SetCellValue("发运日期");
|
|
headRow.CreateCell(6).SetCellValue("发运时间");
|
|
}
|
|
|
|
for (int i = 0; i < detailList.Rows.Count; i++)
|
|
{
|
|
int row = i + 1;
|
|
HSSFRow dataRow = (HSSFRow)sheet2.CreateRow(row);
|
|
|
|
dataRow.CreateCell(0).SetCellValue(detailList.Rows[i]["order_no"].ToString());
|
|
dataRow.CreateCell(1).SetCellValue(detailList.Rows[i]["serial_number"].ToString());
|
|
dataRow.CreateCell(2).SetCellValue(detailList.Rows[i]["part_no"].ToString());
|
|
dataRow.CreateCell(3).SetCellValue(detailList.Rows[i]["part_spec"].ToString());
|
|
dataRow.CreateCell(4).SetCellValue(detailList.Rows[i]["emp_name"].ToString());
|
|
dataRow.CreateCell(5).SetCellValue(detailList.Rows[i]["create_ymd"].ToString());
|
|
dataRow.CreateCell(6).SetCellValue(detailList.Rows[i]["create_hms"].ToString());
|
|
}
|
|
|
|
Response.Clear();
|
|
workbook.Write(outputStream);
|
|
|
|
Response.Buffer = true;
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=发运信息_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
Response.ContentType = "application/vnd.ms-excel";
|
|
Response.Flush();
|
|
}
|
|
catch (Exception ex)
|
|
{ }
|
|
return null;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 客户产线集合
|
|
/// </summary>
|
|
/// <returns>数据集</returns>
|
|
public ActionResult GetCustPDLineName()
|
|
{
|
|
Hashtable resault = new Hashtable();
|
|
ArrayList list = service.GetCustPDLineName();
|
|
resault.Add("list", list);
|
|
return Json(resault, JsonRequestBehavior.AllowGet);
|
|
}
|
|
}
|
|
} |