using Estsh.Core.Controllers;
using Estsh.Core.Model.ExcelModel;
using Estsh.Core.Model.Result;
using Estsh.Core.Models;
using Estsh.Core.Services.IServices;
using Estsh.Core.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections;
/***************************************************************************************************
*
* 更新人:sitong.dong
* 描述:生产指令转化查询
* 修改时间:2022.06.22
* 修改日志:系统迭代升级
*
**************************************************************************************************/
namespace Estsh.Core.Web.Controllers
{
///
/// 生产指令转化查询
///
public class ProduceSerchController : BaseController
{
private IProduceSerchService service;
public ProduceSerchController(IProduceSerchService _service)
{
service = _service;
}
//
// GET: /ProduceSerch/
public ActionResult Index()
{
return View();
}
///
/// 获取生产指令转化查询列表数据
///
/// 菜单名称
/// 分页
/// 排序方式
/// 排序列
///
public ActionResult getProduceSerchListByPage(String cust_pdline_name, String comtype_name, String Model, String Type, Pager pager, String direction, String sort, String enabled = "Y")
{
String factoryId = CurrentEmp.FactoryId.ToString();
Hashtable result = new Hashtable();
result.Add("pager.pageNo", pager.pageNo);
Hashtable dataHt = this.service.getProduceSerchListByPage(cust_pdline_name, comtype_name, Model, Type, pager, direction, sort, factoryId, 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 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 getModelListData(String model_type_id)
{
string a = "";
Hashtable result = new Hashtable();
List ProduceSerchList = this.service.getModelListData(model_type_id);
result.Add("list", ProduceSerchList);
return Json(result);
}
///
/// 保存数据
///
///
public ActionResult saveProduceSerch()
{
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.updateProduceSerch(sysPartCustOrder);
message = "修改成功";
}
catch (Exception e)
{
message = "修改失败!";
}
}
else
{
try
{
sysPartCustOrder.CreateUserId = CurrentEmp.EmpId;
this.service.saveProduceSerch(sysPartCustOrder);
message = "添加成功";
}
catch (Exception e)
{
message = "添加失败!";
}
}
Hashtable result = new Hashtable();
result.Add("message", message);
return Json(result);
}
///
/// 查看详情
///
///
///
public ActionResult getProduceSerch(String ProduceSerch_id)
{
List ProduceSerchInfo = this.service.getProduceSerch(ProduceSerch_id);
ViewData.Add("partId", ProduceSerchInfo[0].PartId);
ViewData.Add("custOrder", ProduceSerchInfo[0].CustOrder);
ViewData.Add("shipUnit", ProduceSerchInfo[0].ShipUnit);
return View("viewProduceSerch");
}
///
/// 编辑
///
///
///
public ActionResult editProduceSerch(String partId)
{
List ProduceSerchInfo = this.service.getProduceSerch(partId);
ViewData.Add("editType", "edit");
ViewData.Add("partId", partId);
ViewData.Add("custOrder", ProduceSerchInfo[0].CustOrder);
ViewData.Add("shipUnit", ProduceSerchInfo[0].ShipUnit);
return View("EditProduceSerch");
}
///
/// 删除
///
///
///
public ActionResult deleteProduceSerch(String ids)
{
int delCount = 0;
try
{
delCount = this.service.deleteProduceSerch(ids);
}
catch (Exception e)
{
delCount = -1;
}
Hashtable result = new Hashtable();
result.Add("status", delCount);
return Json(result);
}
///
/// 导出
///
///
///
///
///
///
///
public ActionResult ExportProduceSerch(String part_no, 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;
}
}
Hashtable dataHt = this.service.getTableListByPage(part_no, custOrder, pager, direction, sort, paging);
List listHt = (List)dataHt["dataList"];
var memoryStream = ExcelHelper.ToExcel(listHt);
return File(memoryStream.ToArray(), "application/ms-excel", "客户订单号明细.xls");
}
}
}