You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
6.3 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Estsh.Core.Controllers;
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 OrgDefineAppController : BaseController
{
private IOrgService service;
public OrgDefineAppController(IOrgService _service)
{
service = _service;
}
//
// GET: /OrgDefine_App/
public ActionResult Index()
{
return View();
}
/// <summary>
/// 获取厂区定义列表数据
/// </summary>
/// <param name="menuName">查询条件</param>
/// <param name="pager"></param>
/// <param name="direction">排序方式</param>
/// <param name="sort">排序字段</param>
/// <returns></returns>
public ActionResult getOrgListByPage(String factoryCode,String factoryName, Pager pager, String direction, String sort, String enabled = "Y")
{
Hashtable result = new Hashtable();
result.Add("pager.pageNo", pager.pageNo);
Hashtable dataHt = this.service.getMenuListByPage(factoryCode, factoryName, enabled, 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);
}
/// <summary>
/// 保存
/// </summary>
/// <returns></returns>
public ActionResult saveOrg()
{
Hashtable result = new Hashtable();
String editType = Request.Form["editType"].ToString();
String ruid = Request.Form["ruid"].ToString();
string factoryCode = Request.Form["factoryCode"].ToString();
string factoryName = Request.Form["factoryName"].ToString();
string factoryDesc = Request.Form["factoryDesc"].ToString();
SysFactory sysFactory = new SysFactory();
sysFactory.FactoryName = factoryName;
sysFactory.FactoryCode = factoryCode;
sysFactory.FactoryDesc = factoryDesc;
String message = string.Empty;
string flag = "";
if (!string.IsNullOrEmpty(editType) && editType.Equals("editType"))
{
try
{
sysFactory.FactoryId =Convert.ToInt32( ruid);
sysFactory.UpdateUserId = CurrentEmp.EmpId;
int num = this.service.UpdateOrg(sysFactory);
if (num > 0)
{
message = "修改成功";
flag = "OK";
}
else
{
message = "修改失败";
flag = "Fail";
}
}
catch (Exception ee)
{
message = "修改失败," + ee.Message;
flag = "Fail";
}
}
else
{
try
{
//验证厂区代码是否已维护
if (this.service.IsExistFac(factoryCode))
{
message = "" + factoryCode + ":该厂区代码已存在!";
flag = "Fail";
}
else
{
sysFactory.CreateUserId = CurrentEmp.EmpId;
int num = this.service.SaveOrg(sysFactory);
if (num > 0)
{
message = "添加成功";
flag = "OK";
}
else
{
message = "添加失败";
flag = "Fail";
}
}
}
catch (Exception ee)
{
message = "添加失败"+ee.Message;
flag = "Fail";
}
}
result.Add("message", message);
result.Add("flag", flag);
return Json(result);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public ActionResult deleteOrg(String ids)
{
int delCount = 0;
try
{
delCount = this.service.DeleteOrg(ids);
}
catch (Exception e)
{
delCount = -1;
}
Hashtable result = new Hashtable();
result.Add("status", delCount);
return Json(result);
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="factoryId"></param>
/// <returns></returns>
public ActionResult editOrg(string factoryId)
{
if (!string.IsNullOrEmpty(factoryId))
{
Hashtable hs = service.getRow(factoryId);
ViewData.Add("editType", "editType");
ViewData.Add("factoryId", hs["factoryId"].ToString());
ViewData.Add("factoryName", hs["factoryName"].ToString());
ViewData.Add("factoryCode", hs["factoryCode"].ToString());
ViewData.Add("factoryDesc", hs["factoryDesc"].ToString());
ViewData.Add("enabled", hs["enabled"].ToString());
ViewData.Add("createYmd", hs["createYmd"].ToString());
ViewData.Add("createHms", hs["createHms"].ToString());
ViewData.Add("createUserid", hs["createUserid"].ToString());
}
else
{
ViewData.Add("editType", "new");
}
return View("/SystemFactory/editOrg");
}
}
}