using System.Collections;
using Microsoft.AspNetCore.Mvc;
using Estsh.Core.Services.IServices;
using Estsh.Core.Model.Result;
using Estsh.Core.Models;
using Estsh.Core.Controllers;
using Estsh.Core.Util;
using Estsh.Core.Model.ExcelModel;
/***************************************************************************************************
*
* 更新人:sitong.dong
* 描述:随车单打印
* 修改时间:2022.06.22
* 修改日志:系统迭代升级
*
**************************************************************************************************/
namespace Estsh.Core.Web.Controllers
{
///
/// 客户订单维护
///
public class TruckOrderPrintController : BaseController
{
private ITruckOrderPrintService service;
public TruckOrderPrintController(ITruckOrderPrintService _service)
{
service = _service;
}
//
// GET: /TruckOrderPrint/
public ActionResult Index()
{
return View();
}
///
/// 获取列表数据
///
/// 菜单名称
/// 分页
/// 排序方式
/// 排序列
///
public ActionResult getTruckOrderPrintListByPage(String custPdlineName, String comtype_name,String StartCar_no,String EndCar_no,String date,String date2, Pager pager, String direction, String sort)
{
Hashtable result = new Hashtable();
if (string.IsNullOrEmpty(custPdlineName))
{
result.Add("message", "请选择客户产线! ");
}
else if (string.IsNullOrEmpty(comtype_name))
{
result.Add("message", " 请选择客户产线!");
}
Hashtable dataHt = this.service.getTruckOrderPrintListByPage(custPdlineName, comtype_name, StartCar_no, EndCar_no, date, date2, pager, direction, sort);
return Json(result);
}
///
/// 获取下拉列表数据
///
///
public ActionResult getSelectTruckOrderPrint()
{
Hashtable result = new Hashtable();
List TruckOrderPrintList = this.service.getSelectTruckOrderPrint();
result.Add("list", TruckOrderPrintList);
return Json(result);
}
///
/// 保存数据
///
///
public ActionResult saveTruckOrderPrint()
{
String editType = Request.Form["editType"].ToString();
String partId = Request.Form["partId"].ToString();
String custOrder = Request.Form["custOrder"].ToString();
String shipUnit = Request.Form["shipUnit"].ToString();
SysPartCustOrder sysPartCustOrder = new SysPartCustOrder();
sysPartCustOrder.PartId = Convert.ToInt32(partId);
sysPartCustOrder.CustOrder = custOrder;
sysPartCustOrder.ShipUnit = shipUnit;
String message = "";
if (editType != null && editType.Trim().Equals("edit"))
{
try
{
sysPartCustOrder.UpdateUserId = CurrentEmp.EmpId;
this.service.updateTruckOrderPrint(sysPartCustOrder);
message = "修改成功";
}
catch (Exception e)
{
message = "修改失败!";
}
}
else
{
try
{
sysPartCustOrder.CreateUserId = CurrentEmp.EmpId;
this.service.saveTruckOrderPrint(sysPartCustOrder);
message = "添加成功";
}
catch (Exception e)
{
message = "添加失败!";
}
}
Hashtable result = new Hashtable();
result.Add("message", message);
return Json(result);
}
///
/// 查看详情
///
///
///
public ActionResult getTruckOrderPrint(String TruckOrderPrint_id)
{
List TruckOrderPrintInfo = this.service.getTruckOrderPrint(TruckOrderPrint_id);
ViewData.Add("partId", TruckOrderPrintInfo[0].PartId);
ViewData.Add("custOrder", TruckOrderPrintInfo[0].CustOrder);
ViewData.Add("shipUnit", TruckOrderPrintInfo[0].ShipUnit);
return View("viewTruckOrderPrint");
}
///
/// 编辑
///
///
///
public ActionResult editTruckOrderPrint(String partId)
{
if (!string.IsNullOrEmpty(partId))
{
List TruckOrderPrintInfo = this.service.getTruckOrderPrint(partId);
ViewData.Add("editType", "edit");
ViewData.Add("partId", partId);
ViewData.Add("custOrder", TruckOrderPrintInfo[0].CustOrder);
ViewData.Add("shipUnit", TruckOrderPrintInfo[0].ShipUnit);
}
else
{
ViewData.Add("editType", "new");
}
return View("EditTruckOrderPrint");
}
///
/// 删除
///
///
///
public ActionResult deleteTruckOrderPrint(String ids)
{
int delCount = 0;
try
{
delCount = this.service.deleteTruckOrderPrint(ids);
}
catch (Exception e)
{
delCount = -1;
}
Hashtable result = new Hashtable();
result.Add("status", delCount);
return Json(result);
}
///
/// 获取下拉列表数据
///
///
public ActionResult getCust_pdline_nameListData()
{
string a = "";
Hashtable result = new Hashtable();
List ProduceSerchList = this.service.getCust_pdline_nameListData();
result.Add("list", ProduceSerchList);
return Json(result);
}
///
/// 获取下拉列表数据
///
///
public ActionResult getType_nameListData(String custPdlineId)
{
string a = "";
Hashtable result = new Hashtable();
List ProduceSerchList = this.service.getType_nameListData(custPdlineId);
result.Add("list", ProduceSerchList);
return Json(result);
}
///
/// 导出
///
///
///
///
///
///
///
public ActionResult ExportTruckOrderPrint(String partNo, String custOrder, Pager pager, String sort, String direction, String isPage)
{
Boolean paging = false;
if (isPage == null || "".Equals(isPage))
{
paging = false;
}
else
{
if ("1".Equals(isPage))
{
paging = true;
}
else
{
paging = false;
}
}
List dataHt = this.service.getTableListByPage(partNo, custOrder, pager, direction, sort, paging);
var memoryStream = ExcelHelper.ToExcel(dataHt);
return File(memoryStream.ToArray(), "application/ms-excel", "随车单打印.xls");
}
}
}