using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Collections;
using Estsh.Web.Service;
using Estsh.Web.Util;
using System.Data;
using ApServerProvider;
namespace Estsh.Core.Web.Controllers
{
public class HourController : Controller
{
private HourService service = new HourService();
private RemotingProxy.RecordStatus _recordStatus = RemotingProxy.RecordStatus.Enable;
//
// GET: /Hour/
public ActionResult Index()
{
return View();
}
///
/// 保存数据
///
///
public ActionResult saveHour()
{
String editType = Request["editType"].ToString();
String pdline_id = Request["pdline_id"].ToString();
String ruid = Request["ruid"].ToString();
String stop_line_length = Request["stop_line_length"].ToString();
String stop_line_working_hours_name = Request["stop_line_working_hours_name"].ToString();
String shift_id = Request["shift_id"].ToString();
String hour = Request["hour"].ToString();
Hashtable htParams = new Hashtable();
htParams.Add("@shift_id", shift_id);
htParams.Add("@stop_line_working_hours_name", stop_line_working_hours_name);
htParams.Add("@stop_line_length", stop_line_length);
htParams.Add("@hour", hour);
String message = "";
String flag = "";
if (editType != null && editType.Trim().Equals("edit"))
{
try
{
htParams.Add("@ruid", ruid);
htParams.Add("@pdline_id", pdline_id);
this.service.updateHour(htParams);
message = "修改成功";
flag = "OK";
}
catch (Exception e)
{
message = "修改失败!";
flag = "Fail";
throw;
}
}
else
{
try
{
htParams.Add("@pdline_id", pdline_id);
this.service.insertHour(htParams);
message = "添加成功!";
flag = "OK";
}
catch (Exception e)
{
message = "添加失败!";
flag = "Fail";
throw;
}
}
Hashtable result = new Hashtable();
result.Add("message", message);
result.Add("flag", flag);
return Json(result);
}
///
/// 获取产线名称
///
///
public ActionResult GetPdlineName()
{
Hashtable reault = new Hashtable();
ArrayList list = service.GetPdlineName();
reault.Add("list", list);
return Json(reault, JsonRequestBehavior.AllowGet);
}
///
/// 获取列表数据
///
///
///
///
///
///
public ActionResult getHourListByPage(String cbPDLine, Pager pager, String direction, String sort)
{
if (string.IsNullOrEmpty(cbPDLine) || cbPDLine == "null")
{
cbPDLine = "0";
}
Hashtable result = new Hashtable();
result.Add("pager.pageNo", pager.pageNo);
Hashtable dataHt = this.service.getHourListByPage(pager, direction, sort, cbPDLine);
result.Add("rows", dataHt["dataList"]);
result.Add("pager.totalRows", dataHt["totalCount"]);
result.Add("sort", sort);
result.Add("direction", direction);
return Json(result);
}
///
/// 查看菜单详情
///
///
///
///
public ActionResult getHourDetail(String pdline_id)
{
Hashtable ht = this.service.getHourDetail(pdline_id);
ViewData.Add("editType", "edit");
ViewData.Add("ruid", "ruid");
ViewData.Add("pdline_id", ht["pdline_id"]);
ViewData.Add("shift_id", ht["shift_id"]);
ViewData.Add("stop_line_working_hours_name", ht["stop_line_working_hours_name"]);
ViewData.Add("stop_line_length", ht["stop_line_length"]);
ViewData.Add("hour", ht["hour"]);
return View("~/Views/Hour/Editkanban.aspx");
}
///
/// 编辑数据
///
///
///
public ActionResult editHour(String ruid)
{
Hashtable ht = this.service.getHourDetail(ruid);
ViewData.Add("editType", "edit");
ViewData.Add("ruid", ht["ruid"]);
ViewData.Add("pdline_id", ht["pdline_id"]);
ViewData.Add("shift_id", ht["shift_id"]);
ViewData.Add("stop_line_working_hours_name", ht["stop_line_working_hours_name"]);
ViewData.Add("stop_line_length", ht["stop_line_length"]);
ViewData.Add("hour", ht["hour"]);
return View("~/Views/Hour/Editkanban.aspx");
}
///
/// 删除数据
///
///
///
public ActionResult deleteHour(String ids)
{
int delCount = 0;
try
{
delCount = this.service.deleteHour(ids);
}
catch (Exception e)
{
delCount = -1;
}
Hashtable result = new Hashtable();
result.Add("status", delCount);
return Json(result);
}
}
}