using BLL.DAL;
|
using Common;
|
using Json;
|
using Lib;
|
using Model;
|
using Model.WcsModel;
|
using System.Web.Mvc;
|
using System.Web.Script.Serialization;
|
using System;
|
using System.Collections;
|
|
namespace wms.Areas.BaseInfo.Controllers
|
{
|
public class PlcPosController : MasterPage
|
{
|
// GET: BaseInfo/PlcPos
|
[LoginFilter]
|
public ActionResult Index()
|
{
|
ViewBag.Title = "工位维护";
|
return View();
|
}
|
|
/// <summary>
|
/// 新增编辑工位对应的流程字
|
/// </summary>
|
/// <returns></returns>
|
[LoginFilter]
|
public ActionResult AddEditPlcPos()
|
{
|
try
|
{
|
string id = Request.QueryString.Get("Id");
|
DAL_PlcPos provider = new DAL_PlcPos();
|
|
if (id != null)
|
{
|
var model = provider.GetPlcPos(id);
|
ViewBag.StationNum = model.StationNum;
|
ViewBag.Name = model.Name;
|
ViewBag.PlcPos = model.PlcPos;
|
ViewBag.PosType = model.PosType;
|
ViewBag.LedIP = model.LedIP;
|
|
ViewBag.Type = provider.GetPlcPosHtml(model.PlcInfoId.ToString());
|
}
|
else
|
{
|
ViewBag.Type = provider.GetPlcPosHtml();
|
}
|
|
return View();
|
}
|
catch (System.Exception)
|
{
|
return View();
|
}
|
}
|
}
|
|
public class PlcPosAjaxController : AjaxPage
|
{
|
/// <summary>
|
/// 获取工位对应的流程字表
|
/// </summary>
|
/// <returns></returns>
|
[HttpPost]
|
public ActionResult GetPlcPosList()
|
{
|
var dd = Request["ajaxdata"];
|
|
var models = new JavaScriptSerializer().Deserialize<AjaxPlcPosList>(dd);
|
|
if (models != null)
|
{
|
PageInfo pageInfo = new PageInfo() { PageIndex = models.pageIndex, PageSize = models.pageSize };
|
|
DAL_PlcPos provider = new DAL_PlcPos();
|
var entity = provider.GetPlcPosList(models, ref pageInfo);
|
|
string json = JsonHelper.IListToJson<WCSPlcPos>(entity, "List");
|
string pjson = ConvertJson.Serializer(pageInfo);
|
|
ReturnJson.AddProperty("Result", new JsonObject(json));
|
ReturnJson.AddProperty("PageInfo", new JsonObject(pjson));
|
ReturnJson.AddProperty("Code", 1);
|
ReturnJson.AddProperty("Message", "响应成功");
|
|
return Content(this.ReturnJson.ToString());
|
}
|
return Content(null);
|
}
|
|
/// <summary>
|
/// 新增编辑工位流程字
|
/// </summary>
|
/// <returns></returns>
|
[HttpPost]
|
public ActionResult AddPlcPos()
|
{
|
var dd = Request["ajaxdata"];
|
var models = new JavaScriptSerializer().Deserialize<AjaxPlcPos>(dd);
|
string Operation = models.Operation;
|
|
if (models != null)
|
{
|
|
DAL_PlcPos provider = new DAL_PlcPos();
|
if (Operation == "Add")
|
{
|
models.CreateUser = this.LoginUser.ID;
|
string sqlWhere = " (PlcPos = '" + models.PlcPos + "') and isdel = '0' ";
|
if (provider.IsExist(sqlWhere))
|
{
|
bool value = provider.AddPlcPos(models);
|
|
if (value)
|
{
|
ReturnJson.AddProperty("Code", 1);
|
ReturnJson.AddProperty("Message", "新增工位流程字成功!");
|
}
|
else
|
{
|
ReturnJson.AddProperty("Code", -1);
|
ReturnJson.AddProperty("Message", "新增工位流程字失败!");
|
}
|
}
|
else
|
{
|
ReturnJson.AddProperty("Code", -1);
|
ReturnJson.AddProperty("Message", "该偏移量已存在!");
|
}
|
}
|
else if (Operation == "Edit")
|
{
|
bool value = provider.AddPlcPos(models);
|
|
if (value)
|
{
|
ReturnJson.AddProperty("Code", 1);
|
ReturnJson.AddProperty("Message", "编辑工位流程字成功!");
|
}
|
else
|
{
|
ReturnJson.AddProperty("Code", -1);
|
ReturnJson.AddProperty("Message", "编辑工位流程字失败!");
|
}
|
}
|
|
}
|
else
|
{
|
ReturnJson.AddProperty("Code", -1);
|
ReturnJson.AddProperty("Message", "工位流程字信息有误!!!");
|
}
|
return Content(this.ReturnJson.ToString());
|
}
|
|
/// <summary>
|
/// 删除工位流程字
|
/// </summary>
|
/// <returns></returns>
|
[HttpPost]
|
public ActionResult DeletePlcPos()
|
{
|
string dd = Request["list"];
|
ArrayList models = new JavaScriptSerializer().Deserialize<ArrayList>(dd);
|
string[] list = (string[])models.ToArray(typeof(string));
|
if (models != null)
|
{
|
DAL_PlcPos provider = new DAL_PlcPos();
|
bool value = provider.DeletePlcPos(list);
|
|
if (value)
|
{
|
ReturnJson.AddProperty("Code", 1);
|
ReturnJson.AddProperty("Message", "删除工位流程字成功");
|
}
|
else
|
{
|
ReturnJson.AddProperty("Code", -1);
|
ReturnJson.AddProperty("Message", "删除工位流程字失败");
|
}
|
|
return Content(this.ReturnJson.ToString());
|
}
|
return Content(null);
|
}
|
}
|
}
|