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.

205 lines
6.5 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 SystemParametersController : BaseController
{
private IBaseManagerService service;
public SystemParametersController(IBaseManagerService _service)
{
this.service = _service;
}
//
// GET: /BaseManager/
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 getBaseListByPage(String BaseValue,String BaseName, Pager pager, String direction, String sort, String enabled = "Y")
{
Hashtable result = new Hashtable();
result.Add("pager.pageNo", pager.pageNo);
Hashtable dataHt = this.service.getListByPage(BaseValue, BaseName, 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 saveBase()
{
Hashtable result = new Hashtable();
String editType = Request.Form["editType"].ToString();
string paramName = Request.Form["paramName"].ToString();
string paramValue = Request.Form["paramValue"].ToString();
string paramDesc = Request.Form["paramDesc"].ToString();
string enabled = Request.Form["enabled"].ToString();
SysBase sysBase = new SysBase();
sysBase.ParamName = paramName;
sysBase.ParamValue = paramValue;
sysBase.ParamDesc = paramDesc;
sysBase.Enabled = enabled;
String message = string.Empty;
if (!string.IsNullOrEmpty(editType) && editType.Equals("edit"))
{
try
{
sysBase.UpdateUserId = CurrentEmp.EmpId;
String paramId = Request.Form["paramId"].ToString();
sysBase.ParamId = Convert.ToInt32(paramId);
int num = this.service.EditBase(sysBase);
if (num > 0)
message = "修改成功";
else
message = "修改失败";
}
catch (Exception ee)
{
message = "修改失败," + ee.Message;
}
}
else
{
try
{
if (string.IsNullOrEmpty(paramName))
{
message = "参数名称不能为空";
}
else
{
sysBase.CreateUserId = CurrentEmp.EmpId;
int num = this.service.SaveBase(sysBase);
if (num > 0)
message = "添加成功";
else
message = "添加失败";
}
}
catch (Exception ee)
{
message = "添加失败," + ee.Message;
}
}
result.Add("message", message);
return Json(result);
}
public ActionResult EditBase(string paramId)
{
if (!String.IsNullOrEmpty(paramId))
{
List<SysBase> model = service.getList(paramId);
ViewData.Add("editType", "edit");
ViewData.Add("paramId", model[0].ParamId);
ViewData.Add("paramName", model[0].ParamName);
ViewData.Add("paramValue", model[0].ParamValue);
ViewData.Add("paramDesc", model[0].ParamDesc);
ViewData.Add("enabled", model[0].Enabled);
}
else
{
ViewData.Add("editType", "new");
}
return View("EditBase");
}
/// <summary>
/// 删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public ActionResult deleteBase(String ids)
{
int delCount = 0;
try
{
ids = ids.Substring(0, ids.Length - 1);
delCount = this.service.deleteBase(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 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);
}
}
}