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 MESOD10Controller : BaseController
{
private IMESOD10Service service;
public MESOD10Controller(IMESOD10Service _service)
{
service = _service;
}
//
// GET: /MESOD10/
public ActionResult Index()
{
return View();
}
///
/// 获取出货单维护列表数据
///
/// 菜单名称
/// 分页
/// 排序方式
/// 排序列
///
public ActionResult getMESOD10ListByPage(String QiShiHuoYunDan, String JieShuHuoYunDan, Pager pager, String direction, String sort, String enabled = "Y")
{
Hashtable result = new Hashtable();
result.Add("pager.pageNo", pager.pageNo);
Hashtable dataHt = this.service.getMESOD10ListByPage(QiShiHuoYunDan, JieShuHuoYunDan, pager, direction, sort, enabled);
result.Add("rows", dataHt["dataList"]);
result.Add("pager.totalRows", dataHt["totalCount"]);
result.Add("sort", sort);
result.Add("direction", direction);
return Json(result);
}
///
/// 获取下拉列表数据
///
///
public ActionResult GetTerminalName()
{
string a = "";
Hashtable result = new Hashtable();
List MESOD10List = this.service.GetTerminalName();
result.Add("list", MESOD10List);
return Json(result);
}
///
/// 保存数据
///
///
public ActionResult saveMESOD10()
{
String editType = Request.Form["editType"].ToString();
String partId = Request.Form["partId"].ToString();
String cust_order = Request.Form["cust_order"].ToString();
String ship_unit = Request.Form["ship_unit"].ToString();
SysPartCustOrder sysPartCustOrder = new SysPartCustOrder();
sysPartCustOrder.PartId = Convert.ToInt32(partId);
sysPartCustOrder.CustOrder = cust_order;
sysPartCustOrder.ShipUnit = ship_unit;
String message = "";
if (editType != null && editType.Trim().Equals("edit"))
{
try
{
sysPartCustOrder.UpdateUserId = CurrentEmp.EmpId;
this.service.updateMESOD10(sysPartCustOrder);
message = "修改成功";
}
catch (Exception e)
{
message = "修改失败!";
}
}
else
{
try
{
sysPartCustOrder.CreateUserId = CurrentEmp.EmpId;
this.service.saveMESOD10(sysPartCustOrder);
message = "添加成功";
}
catch (Exception e)
{
message = "添加失败!";
}
}
Hashtable result = new Hashtable();
result.Add("message", message);
return Json(result);
}
///
/// 查看详情
///
///
///
public ActionResult getMESOD10(String MESOD10_id)
{
List MESOD10Info = this.service.getMESOD10(MESOD10_id);
ViewData.Add("partId", MESOD10Info[0].PartId);
ViewData.Add("cust_order", MESOD10Info[0].CustOrder);
ViewData.Add("ship_unit", MESOD10Info[0].ShipUnit);
return View("viewMESOD10");
}
///
/// 编辑
///
///
///
public ActionResult editMESOD10(String partId)
{
List MESOD10Info = this.service.getMESOD10(partId);
ViewData.Add("editType", "edit");
ViewData.Add("partId", partId);
ViewData.Add("cust_order", MESOD10Info[0].CustOrder);
ViewData.Add("ship_unit", MESOD10Info[0].ShipUnit);
return View("EditMESOD10");
}
///
/// 删除
///
///
///
public ActionResult deleteMESOD10(String ids)
{
int delCount = 0;
try
{
delCount = this.service.deleteMESOD10(ids);
}
catch (Exception e)
{
delCount = -1;
}
Hashtable result = new Hashtable();
result.Add("status", delCount);
return Json(result);
}
///
/// 导出
///
///
///
///
///
///
///
public ActionResult ExportMESOD10(String locationDate, String terminal_name, String Date, String Date2, Pager pager, String sort, String direction, String isPage)
{
if (string.IsNullOrEmpty(locationDate))
{
return Json("");
}
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(locationDate, terminal_name, Date, Date2, pager, direction, sort, paging);
var memoryStream = ExcelHelper.ToExcel(dataHt);
return File(memoryStream.ToArray(), "application/ms-excel", "解锁记录明细.xls");
}
}
}