using System.Collections;
using Microsoft.AspNetCore.Mvc;
using Estsh.Core.Services.IServices;
using Estsh.Core.Models;
using Estsh.Core.Util;
using Estsh.Core.Controllers;
using Estsh.Core.Model.Result;
/***************************************************************************************************
*
* 更新人:sitong.dong
* 描述:提前量维护
* 修改时间:2022.06.22
* 修改日志:系统迭代升级
*
**************************************************************************************************/
namespace Estsh.Core.Web.Controllers
{
public class CustPreQtyController : BaseController
{
private ICustPreQtyService service;
public CustPreQtyController(ICustPreQtyService _service)
{
this.service = _service;
}
//
// GET: /CustPreQty/
public ActionResult Index()
{
return View();
}
///
/// 获取提前量维护列表数据
///
/// 查询条件
///
/// 排序方式
/// 排序字段
///
public ActionResult getListByPage(Pager pager, String direction, String sort)
{
Hashtable result = new Hashtable();
String sql = "0=0 ";
result.Add("pager.pageNo", pager.pageNo);
Hashtable dataHt = this.service.getListByPage(sql, pager, direction, sort);
result.Add("rows", dataHt["dataList"]);
result.Add("pager.totalRows", dataHt["totalCount"]);
result.Add("sort", sort);
result.Add("direction", direction);
return Json(result);
}
public ActionResult Edit(int param_id)
{
if (param_id != 0)
{
Hashtable ht = service.ExistsCustPDLine(param_id);
ViewData.Add("editType", "editType");
ViewData.Add("custPdlineId", ht["custPdlineId"].ToString());
ViewData.Add("custPdlineSeq", ht["custPdlineSeq"].ToString());
ViewData.Add("pdlineSeq", ht["pdlineSeq"].ToString());
ViewData.Add("preQty", ht["preQty"].ToString());
ViewData.Add("custPdlineName", ht["custPdlineName"].ToString());
ViewData.Add("cycleTime", ht["cycleTime"].ToString());
}
else
{
ViewData.Add("editType", "new");
}
return View("EditCustPreQty");
}
public ActionResult save()
{
Hashtable result = new Hashtable();
String editType = Request.Form["editType"].ToString();
String message = string.Empty;
string custPdlineSeq = Request.Form["custPdlineSeq"].ToString();
string cycleTime = Request.Form["cycleTime"].ToString();
string pdlineSeq = Request.Form["custPdline"].ToString();
string preQty = Request.Form["preQty"].ToString();
if (!string.IsNullOrEmpty(editType) && editType.Equals("editType"))
{
try
{
string custPDLineID = Request.Form["custPdlineId"].ToString();
if (service.edit(Convert.ToInt32(custPDLineID), custPdlineSeq, cycleTime, CurrentEmp.EmpId))
{
message = "修改成功";
}
else
{
message = "修改失败";
}
}
catch (Exception ee)
{
message = "修改失败," + ee.Message;
}
}
else
{
try
{
SysCustPdlineProdinfo sysCust = new SysCustPdlineProdinfo();
sysCust.CustPdlineId = Convert.ToInt32(Request.Form["custPdlineName"].ToString());
sysCust.CustPdlineSeq = Convert.ToInt32(custPdlineSeq);
sysCust.PreQty = Convert.ToInt32(preQty);
sysCust.CycleTime = Convert.ToInt32(cycleTime);
sysCust.PdlineSeq = Convert.ToInt32(pdlineSeq);
sysCust.CreateUserId = CurrentEmp.EmpId;
int num = this.service.Save(sysCust);
if (num > 0)
message = "添加成功";
else
message = "添加失败";
}
catch (Exception ee)
{
message = "添加失败" + ee.Message;
}
}
result.Add("message", message);
return Json(result);
}
public ActionResult getCust_pdline()
{
Hashtable hs = new Hashtable();
List list = service.getCust_pdline();
hs.Add("list", list);
return Json(hs);
}
///
/// 删除
///
///
///
public ActionResult delete(String ids)
{
int delCount = 0;
try
{
delCount = this.service.Delete(ids);
}
catch (Exception e)
{
delCount = -1;
}
Hashtable result = new Hashtable();
result.Add("status", delCount);
return Json(result);
}
///
/// 启用
///
///
///
public ActionResult onEnable(String ids)
{
int delCount = 0;
try
{
delCount = this.service.EnableData(ids);
}
catch (Exception e)
{
delCount = -1;
}
Hashtable result = new Hashtable();
result.Add("status", delCount);
return Json(result);
}
///
/// 禁用
///
///
///
public ActionResult onDisable(String ids)
{
int delCount = 0;
try
{
delCount = this.service.DisableData(ids);
}
catch (Exception e)
{
delCount = -1;
}
Hashtable result = new Hashtable();
result.Add("status", delCount);
return Json(result);
}
}
}