|
|
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 System.Text.RegularExpressions;
|
|
|
using System.Data;
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
using System.IO;
|
|
|
using Estsh.Web.Models;
|
|
|
|
|
|
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
|
{
|
|
|
/*****************************************************************
|
|
|
*
|
|
|
* 工站管制信息管理
|
|
|
*
|
|
|
* NOAH
|
|
|
*
|
|
|
******************************************************************/
|
|
|
public class ViewBoardController : Controller
|
|
|
{
|
|
|
private ViewBoardService service = new ViewBoardService();
|
|
|
|
|
|
//
|
|
|
// GET: /Menu/
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 加载功能树
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getMenuTree()
|
|
|
{
|
|
|
string path = Request.ApplicationPath; if (path.EndsWith("/")) { path = path.Substring(0, path.Length - 1); }
|
|
|
List<TreeNode> treeNodes = new List<TreeNode>();
|
|
|
treeNodes = service.getMenuList("isIndex = '是'", " RUID ASC ", path);
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("treeNodes", treeNodes);
|
|
|
String json = Estsh.Web.Util.JSON.Encode(result);
|
|
|
return Json(result, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取菜单管理列表数据
|
|
|
/// </summary>
|
|
|
/// <param name="menuName"></param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getKeyDataListByPage(String lableName, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
|
ArrayList menuList = this.service.getKeyDataListByPage(lableName, pager, direction, sort);
|
|
|
result.Add("rows", menuList);
|
|
|
int total = this.service.getMenuCount(lableName);
|
|
|
result.Add("pager.totalRows", total);
|
|
|
result.Add("sort", sort);
|
|
|
result.Add("direction", direction);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存菜单数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult saveKeyData()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
String message = "";
|
|
|
string flag = "";
|
|
|
String editType = Request["editType"].ToString();
|
|
|
|
|
|
String ruid = Request["ruid"].ToString();
|
|
|
String lableName = Request["lableName"].ToString();
|
|
|
String lableValue = Request["lableValue"].ToString();
|
|
|
|
|
|
////判断输入的字符是否为空
|
|
|
//if (String.IsNullOrEmpty(keydata_name))
|
|
|
//{
|
|
|
// message = "关键数据名称为空!";
|
|
|
// result.Add("message", message);
|
|
|
// return Json(result);
|
|
|
//}
|
|
|
|
|
|
//传递要更新的数据库字段 2013 0506 14:05 by NOAH
|
|
|
Hashtable htParams = new Hashtable();
|
|
|
htParams.Add("@lableName", lableName);
|
|
|
htParams.Add("@lableValue", lableValue);
|
|
|
|
|
|
//用户id
|
|
|
UserInfo user = (UserInfo)Session["loginedUser"];
|
|
|
htParams.Add("@update_userid", user.updateUserId);
|
|
|
htParams.Add("@create_userid", user.updateUserId);
|
|
|
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
htParams.Add("@ruid",ruid);
|
|
|
this.service.updateKeyData(htParams);
|
|
|
message = "Successfully modified!";
|
|
|
flag = "OK";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "fail to edit!";
|
|
|
flag = "NO";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
htParams.Add("@ruid", ruid);
|
|
|
this.service.saveKeyData(htParams);
|
|
|
message = "Added successfully!";
|
|
|
flag = "OK";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "add failed!";
|
|
|
flag = "NO";
|
|
|
}
|
|
|
}
|
|
|
result.Add("message", message);
|
|
|
result.Add("flag",flag);
|
|
|
return Json(result) ;
|
|
|
}
|
|
|
|
|
|
///// <summary>
|
|
|
///// 查看菜单详情
|
|
|
///// </summary>
|
|
|
///// <param name="keydata_id"></param>
|
|
|
///// <returns></returns>
|
|
|
//public ActionResult getKeyDataDetail(String keydata_id)
|
|
|
//{
|
|
|
// Hashtable ht = this.service.getKeyDataDetail(keydata_id);
|
|
|
// ViewData.Add("lableName", ht["lableName"]);
|
|
|
// ViewData.Add("lableValue", ht["lableValue"]);
|
|
|
// return View("~/Views/ViewBoard/ViewKeyDataDefine.aspx");
|
|
|
//}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult editKeyData(String ruid)
|
|
|
{
|
|
|
Hashtable ht = this.service.getKeyDataDetail(ruid);
|
|
|
ViewData.Add("editType", "edit");
|
|
|
|
|
|
ViewData.Add("ruid", ht["ruid"]);
|
|
|
ViewData.Add("lableName", ht["lableName"]);
|
|
|
ViewData.Add("lableValue", ht["lableValue"]);
|
|
|
return View("~/Views/ViewBoard/EditViewBoard.aspx");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult deleteKeyData(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.deleteKeyData(ids);
|
|
|
}
|
|
|
catch(Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取 站点 信息
|
|
|
/// BY NOAH
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getTerminalName()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
ArrayList menuList = this.service.getTerminalName();
|
|
|
result.Add("list", menuList);
|
|
|
return Json(result, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取 产线 信息
|
|
|
/// BY NOAH
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getBoardName()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
ArrayList menuList = this.service.getBoardName();
|
|
|
result.Add("list", menuList);
|
|
|
return Json(result, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断是否为数字类型
|
|
|
/// BY NOAH
|
|
|
/// </summary>
|
|
|
/// <param name="s"></param>
|
|
|
/// <returns></returns>
|
|
|
public bool isNum(string s)
|
|
|
{
|
|
|
string pattern = "^[0-9]*$";
|
|
|
Regex rx = new Regex(pattern);
|
|
|
return rx.IsMatch(s);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 导出数据到Excel
|
|
|
/// BY NOAH
|
|
|
/// </summary>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="txtOrderNo"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="isPage"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult exportData(String keydata_name_search, String enabled_search, Pager pager, String sort, String direction, String isPage)
|
|
|
{
|
|
|
|
|
|
Boolean paging = false;
|
|
|
if (isPage == null || "".Equals(isPage))
|
|
|
{
|
|
|
paging = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if ("1".Equals(isPage.Trim()))
|
|
|
{
|
|
|
paging = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
paging = false;
|
|
|
}
|
|
|
}
|
|
|
DataTable dataHt = this.service.getTableListByPage(keydata_name_search, enabled_search, pager, direction, sort, paging);//txtOrderNo, pager, direction, sort, paging
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
Stream outputStream = Response.OutputStream;
|
|
|
HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("KeyData");
|
|
|
try
|
|
|
{
|
|
|
if (workbook != null)
|
|
|
{
|
|
|
HSSFRow headRow = (HSSFRow)sheet.CreateRow(0);
|
|
|
headRow.CreateCell(0).SetCellValue("keydata_name");
|
|
|
headRow.CreateCell(1).SetCellValue("keydata_desc");
|
|
|
headRow.CreateCell(2).SetCellValue("max_value");
|
|
|
headRow.CreateCell(3).SetCellValue("min_value");
|
|
|
headRow.CreateCell(4).SetCellValue("max_tolerance");
|
|
|
headRow.CreateCell(5).SetCellValue("min_tolerance");
|
|
|
headRow.CreateCell(6).SetCellValue("seq");
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < dataHt.Rows.Count; i++)
|
|
|
{
|
|
|
int row = i + 1;
|
|
|
HSSFRow dataRow = (HSSFRow)sheet.CreateRow(row);
|
|
|
|
|
|
dataRow.CreateCell(0).SetCellValue(dataHt.Rows[i]["keydata_name"].ToString());
|
|
|
dataRow.CreateCell(1).SetCellValue(dataHt.Rows[i]["keydata_desc"].ToString());
|
|
|
dataRow.CreateCell(2).SetCellValue(dataHt.Rows[i]["max_value"].ToString());
|
|
|
dataRow.CreateCell(3).SetCellValue(dataHt.Rows[i]["min_value"].ToString());
|
|
|
dataRow.CreateCell(4).SetCellValue(dataHt.Rows[i]["max_tolerance"].ToString());
|
|
|
dataRow.CreateCell(5).SetCellValue(dataHt.Rows[i]["min_tolerance"].ToString());
|
|
|
dataRow.CreateCell(6).SetCellValue(dataHt.Rows[i]["seq"].ToString());
|
|
|
}
|
|
|
|
|
|
Response.Clear();
|
|
|
workbook.Write(outputStream);
|
|
|
|
|
|
Response.Buffer = true;
|
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=KeyData.xls");
|
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
|
Response.ContentType = "application/vnd.ms-excel";
|
|
|
Response.Flush();
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
workbook = null;
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 导入Excel文件
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult importKeyData()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
HttpPostedFileBase userDataFile = Request.Files[0];
|
|
|
UserInfo user = (UserInfo)Session["loginedUser"];
|
|
|
if (userDataFile == null)
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
result = service.ReadExcelFile(userDataFile.InputStream, user.empId);
|
|
|
return Json(result);
|
|
|
}
|
|
|
}
|
|
|
}
|