|
|
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 WarehouseDefineController : BaseController
|
|
|
{
|
|
|
private IWarehouseDefineService service;
|
|
|
public WarehouseDefineController(IWarehouseDefineService _service)
|
|
|
{
|
|
|
service = _service;
|
|
|
}
|
|
|
//
|
|
|
// GET: /Menu/
|
|
|
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 getWarehouseListByPage(string warehouseName, string warehouseDesc, Pager pager, String direction, String sort, string enabled = "Y")
|
|
|
{
|
|
|
int factoryId = CurrentEmp.FactoryId;
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
|
Hashtable dataHt = this.service.getWarehouseListByPage(warehouseName, warehouseDesc, enabled, factoryId, 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>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getSelectFactory()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
List<KeyValueResult> menuList = this.service.getSelectFactory();
|
|
|
result.Add("list", menuList);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存菜单数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult saveWarehouse()
|
|
|
{
|
|
|
String editType = Request.Form["editType"].ToString();
|
|
|
|
|
|
String warehouseId = Request.Form["warehouseId"].ToString();
|
|
|
String warehouseName = Request.Form["warehouseName"].ToString();
|
|
|
String warehouseDesc = Request.Form["warehouseDesc"].ToString();
|
|
|
String enabled = Request.Form["enabled"].ToString();
|
|
|
|
|
|
////传递要更新的数据库字段 2013 0327 14:05 by NOAH
|
|
|
SysWarehouse sysWarehouse = new SysWarehouse();
|
|
|
sysWarehouse.WarehouseName = warehouseName;
|
|
|
sysWarehouse.FactoryId = CurrentEmp.FactoryId;
|
|
|
sysWarehouse.FactoryCode = CurrentEmp.FactoryCode;
|
|
|
sysWarehouse.WarehouseDesc = warehouseDesc;
|
|
|
sysWarehouse.Enabled = enabled;
|
|
|
String message = "";
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
sysWarehouse.UpdateUserId = CurrentEmp.EmpId;
|
|
|
sysWarehouse.WarehouseId =Convert.ToInt32( warehouseId);
|
|
|
this.service.updateWarehouse(sysWarehouse);
|
|
|
message = "修改成功";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (this.service.getWarehouseByExistName(warehouseName)!=null)
|
|
|
{
|
|
|
message = "仓库代码已存在,请检查!";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sysWarehouse.CreateUserId = CurrentEmp.EmpId;
|
|
|
this.service.saveWarehouse(sysWarehouse);
|
|
|
message = "添加成功";
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "添加失败!";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("message", message);
|
|
|
return Json(result) ;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult editWarehouse(String warehouseId)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(warehouseId))
|
|
|
{
|
|
|
Hashtable ht = this.service.getWarehouseDetail(warehouseId);
|
|
|
ViewData.Add("editType", "edit");
|
|
|
ViewData.Add("warehouseId", ht["warehouseId"]);
|
|
|
ViewData.Add("factoryId", ht["factoryId"]);
|
|
|
ViewData.Add("factoryName", ht["factoryName"]);
|
|
|
ViewData.Add("warehouseName", ht["warehouseName"]);
|
|
|
ViewData.Add("warehouseDesc", ht["warehouseDesc"]);
|
|
|
|
|
|
ViewData.Add("enabled", ht["enabled"]);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ViewData.Add("editType", "new");
|
|
|
}
|
|
|
return View("EditWarehouseDefine");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 启用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult onEnable(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.EnableWarehouse(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.DisableWarehouse(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
}
|
|
|
}
|