|
|
using System.Collections;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Estsh.Core.Services.IServices;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Util;
|
|
|
using Estsh.Core.Controllers;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:不良代码维护
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
|
{
|
|
|
public class DefectCodeController : BaseController
|
|
|
{
|
|
|
private IDefectCodeService service;
|
|
|
public DefectCodeController(IDefectCodeService _service)
|
|
|
{
|
|
|
this.service = _service;
|
|
|
}
|
|
|
//
|
|
|
// GET: /DefectCode/
|
|
|
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
public ActionResult GetDefectCodeWhere(Pager pager)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
Hashtable dataHt = service.GetDefectCodeWhere( pager);
|
|
|
result.Add("rows", dataHt["dataList"]);
|
|
|
result.Add("pager.totalRows", dataHt["totalCount"]);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
public ActionResult SaveDefectInfo()
|
|
|
{
|
|
|
string editType = Request.Form["editType"].ToString();
|
|
|
string defectId = Request.Form["defectId"].ToString();
|
|
|
string defectCode = Request.Form["defectCode"].ToString();
|
|
|
string defectLevel = Request.Form["defectLevel"].ToString();
|
|
|
string defectType = Request.Form["defectType"].ToString();
|
|
|
string defectDesc = Request.Form["defectDesc"].ToString();
|
|
|
string enabled = Request.Form["enabled"].ToString();
|
|
|
|
|
|
int userId = CurrentEmp.EmpId;
|
|
|
|
|
|
SysDefect sysDefect = new SysDefect();
|
|
|
sysDefect.DefectCode = defectCode;
|
|
|
sysDefect.DefectLevel = Convert.ToInt32(defectLevel);
|
|
|
sysDefect.DefectType = defectType;
|
|
|
sysDefect.DefectDesc = defectDesc;
|
|
|
sysDefect.Enabled = enabled;
|
|
|
|
|
|
String message = "";
|
|
|
String flag = "";
|
|
|
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
sysDefect.UpdateUserId = userId;
|
|
|
sysDefect.DefectId = Convert.ToInt32(defectId);
|
|
|
|
|
|
bool value = service.UpdateById(sysDefect);
|
|
|
if (value)
|
|
|
{
|
|
|
message = "修改成功";
|
|
|
flag = "OK";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
flag = "Fail";
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!Detail:" + e.Message;
|
|
|
flag = "Fail";
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sysDefect.CreateUserId = userId;
|
|
|
|
|
|
bool value = service.AddDefect(sysDefect);
|
|
|
if (value)
|
|
|
{
|
|
|
message = "添加成功";
|
|
|
flag = "OK";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
message = "添加失败!";
|
|
|
flag = "Fail";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("message", message);
|
|
|
result.Add("flag", flag);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult editDefectInfo(string defectId)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(defectId))
|
|
|
{
|
|
|
Hashtable result = this.service.GetDefectById(Convert.ToInt32( defectId));
|
|
|
List<SysDefect> arrList = (List<SysDefect>)result["dataList"];
|
|
|
ViewData.Add("editType", "edit");
|
|
|
ViewData.Add("defectId", defectId);
|
|
|
|
|
|
ViewData.Add("defectCode", arrList[0].DefectCode);
|
|
|
ViewData.Add("defectLevel", arrList[0].DefectLevel);
|
|
|
ViewData.Add("defectType", arrList[0].DefectType);
|
|
|
ViewData.Add("defectDesc", arrList[0].DefectDesc);
|
|
|
ViewData.Add("enabled", arrList[0].Enabled);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ViewData.Add("editType", "new");
|
|
|
}
|
|
|
|
|
|
return View("EditDefectCode");
|
|
|
}
|
|
|
|
|
|
public ActionResult deleteDefect(int defectId)
|
|
|
{
|
|
|
string message = string.Empty;
|
|
|
string flag = string.Empty;
|
|
|
bool value = service.DeleteDefectById(defectId);
|
|
|
if (value)
|
|
|
{
|
|
|
message = "删除成功!";
|
|
|
flag = "OK";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
message = "删除失败!";
|
|
|
flag = "Fail";
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("message", message);
|
|
|
result.Add("flag", flag);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 启用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|