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.
169 lines
5.4 KiB
C#
169 lines
5.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using Estsh.Web.Util;
|
|
using Estsh.Web.Service;
|
|
using System.Collections;
|
|
using Estsh.Web.Models;
|
|
using System.Data;
|
|
using NPOI.HSSF.UserModel;
|
|
using System.IO;
|
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
{
|
|
/***************************************************************************
|
|
*
|
|
*****************************************************************************/
|
|
public class EnergyDefineController:Controller
|
|
{
|
|
private EnergyDefineService service = new EnergyDefineService();
|
|
|
|
//
|
|
// GET: /Menu/
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
/// <summary>
|
|
/// 获取列表数据
|
|
/// </summary>
|
|
/// <param name="device_name"></param>
|
|
/// <param name="pager"></param>
|
|
/// <param name="direction"></param>
|
|
/// <param name="sort"></param>
|
|
/// <returns></returns>
|
|
public ActionResult getEnergyListByPage(string device_name,Pager pager, String direction, String sort)
|
|
{
|
|
|
|
Hashtable result = new Hashtable();
|
|
Hashtable dataHt = this.service.getEnergyListByPage(device_name, 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 getFactoryList()
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
ArrayList menuList = CommonService.getFactoryInfo();
|
|
result.Add("list", menuList);
|
|
return Json(result, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存产线数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult saveEnergy()
|
|
{
|
|
String editType = Request["editType"].ToString();
|
|
|
|
String device_id = Request["device_id"].ToString();
|
|
String device_name = Request["device_name"].ToString();
|
|
String target_value = Request["target_value"].ToString();
|
|
String seq = Request["seq"].ToString();
|
|
Hashtable htParams = new Hashtable();
|
|
htParams.Add("@device_name", device_name);
|
|
htParams.Add("@target_value", target_value);
|
|
htParams.Add("@seq", seq);
|
|
|
|
String message = "";
|
|
String flag = "";
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
{
|
|
try
|
|
{
|
|
htParams.Add("@device_id", device_id);
|
|
this.service.updateEnergy(htParams);
|
|
message = "修改成功";
|
|
flag = "OK";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
message = "修改失败!";
|
|
flag = "Fail";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
this.service.saveEnergy(htParams);
|
|
message = "添加成功";
|
|
flag = "OK";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
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 getEnergyDetail(String device_id)
|
|
{
|
|
Hashtable ht = this.service.getEnergyDetail(device_id);
|
|
ViewData.Add("device_id", ht["device_id"]);
|
|
ViewData.Add("device_name", ht["device_name"]);
|
|
ViewData.Add("target_value", ht["target_value"]);
|
|
ViewData.Add("seq", ht["seq"]);
|
|
return View("~/Views/EnergyDefine/ViewEnergyDefine.aspx");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑菜单
|
|
/// </summary>
|
|
/// <param name="ruid"></param>
|
|
/// <returns></returns>
|
|
public ActionResult editEnergy(String device_id)
|
|
{
|
|
Hashtable ht = this.service.getEnergyDetail(device_id);
|
|
ViewData.Add("editType", "edit");
|
|
ViewData.Add("device_id", ht["device_id"]);
|
|
ViewData.Add("device_name", ht["device_name"]);
|
|
ViewData.Add("target_value", ht["target_value"]);
|
|
ViewData.Add("seq", ht["seq"]);
|
|
return View("~/Views/EnergyDefine/EditEnergyDefine.aspx");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除菜单
|
|
/// </summary>
|
|
/// <param name="ids"></param>
|
|
/// <returns></returns>
|
|
public ActionResult deletePdLine(String ids)
|
|
{
|
|
int delCount = 0;
|
|
try
|
|
{
|
|
delCount = this.service.deleteMenu(ids);
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
delCount = -1;
|
|
}
|
|
Hashtable result = new Hashtable();
|
|
result.Add("status", delCount);
|
|
return Json(result);
|
|
}
|
|
}
|
|
}
|