using Estsh.Core.Controllers;
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 ShiftDefineController : BaseController
{
private IShiftDefineService service;
public ShiftDefineController(IShiftDefineService _service)
{
service = _service;
}
//
// GET: /Menu/
public ActionResult Index()
{
return View();
}
///
/// 获取看板管理列表数据
///
///
///
///
///
///
public ActionResult GetListByPage(String shiftName, Pager pager, String direction, String sort)
{
Hashtable result = new Hashtable();
result.Add("pager.pageNo",pager.pageNo);
Hashtable dataHt = this.service.GetListByPage(shiftName,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 GetSelect()
{
Hashtable result = new Hashtable();
List list = this.service.GetSelect();
result.Add("list", list);
return Json(result);
}
///
/// 保存看板数据
///
///
public ActionResult Save()
{
String editType = Request.Form["editType"].ToString();
String shiftId = Request.Form["shiftId"].ToString();
String shiftCode = Request.Form["shiftCode"].ToString();
String shiftName = Request.Form["shiftName"].ToString();
String startTime = Request.Form["startTime"].ToString();
String endTime = Request.Form["endTime"].ToString();
String enabled = Request.Form["enabled"].ToString();
SysShift model = new SysShift();
model.ShiftCode = shiftCode;
model.ShiftName = shiftName;
model.StartTime = startTime;
model.EndTime = endTime;
model.Enabled = enabled;
String message = "";
String flag = "";
if (editType != null && editType.Trim().Equals("edit"))
{
try
{
model.UpdateUserId = CurrentEmp.EmpId;
model.ShiftId =Convert.ToInt32( shiftId);
this.service.Update(model);
message = "修改成功";
flag = "OK";
}
catch (Exception e)
{
message = "修改失败!";
flag = "Fail";
}
}
else
{
try
{
model.CreateUserId = CurrentEmp.EmpId;
this.service.Insert(model);
message = "添加成功";
flag = "OK";
}
catch (Exception e)
{
message = "添加失败!";
flag = "Fail";
}
}
Hashtable result = new Hashtable();
result.Add("message", message);
result.Add("flag", flag);
return Json(result) ;
}
///
/// 查看看板详情
///
///
///
public ActionResult GetDetail(String shiftId)
{
List Info = this.service.GetDetail(shiftId);
//Hashtable ht = (Hashtable)Info[0];
SysShift ht = Info[0];
ViewData.Add("shiftCode", ht.ShiftCode);
ViewData.Add("shiftName", ht.ShiftName);
ViewData.Add("startTime", ht.StartTime);
ViewData.Add("endTime", ht.EndTime);
ViewData.Add("enabled", ht.Enabled);
return View("viewShiftDefine");
}
///
/// 编辑看板
///
///
///
public ActionResult Edit(String shiftId)
{
if (!string.IsNullOrEmpty(shiftId))
{
List Info = this.service.GetDetail(shiftId);
//Hashtable ht = (Hashtable)Info[0];
SysShift ht = Info[0];
ViewData.Add("editType", "edit");
ViewData.Add("shiftId", shiftId);
ViewData.Add("shiftCode", ht.ShiftCode);
ViewData.Add("shiftName", ht.ShiftName);
ViewData.Add("startTime", ht.StartTime);
ViewData.Add("endTime", ht.EndTime);
ViewData.Add("enabled", ht.Enabled);
}
else
{
ViewData.Add("editType", "new");
}
return View("editShiftDefine");
}
///
/// 删除看板
///
///
///
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);
}
}
}