using System;
using System.Collections.Generic;
using System.Web.Mvc;
using QMAPP.Common.Web.Controllers;
using QMAPP.Entity;
using QMAPP.FJC.Entity.ProduceManage;
using QMAPP.FJC.Web.Models.ProduceManage;
using QMAPP.ServicesAgent;
using QMFrameWork.Common.Serialization;
using QMFrameWork.Data;
using QMFrameWork.WebUI.Attribute;
using QMFrameWork.WebUI.DataSource;
using QMAPP.FJC.Entity.Basic;
namespace QMAPP.FJC.Web.Controllers
{
///
/// 模块编号:M4-1
/// 作 用:生产记录维护控制层
/// 作 者:张敬贺
/// 编写日期:2015年06月04日
///
public class ProducePlanController : QController
{
#region 获取列表
///
/// 加载列表
///
/// 结果
[HandleException]
public ActionResult List(bool? callBack)
{
ProducePlanModel seachModel = new ProducePlanModel();
seachModel.STARTCREATEDATE = DateTime.Now.AddDays(-10).ToString("yyyy-MM-dd");
seachModel.ENDCREATEDATE = DateTime.Now.ToString("yyyy-MM-dd");
seachModel.ImmediateSearch = false;
if (callBack == true)
TryGetSelectBuffer(out seachModel);
seachModel.rownumbers = false;
seachModel.url = "/ProducePlan/GetList";
return View("List", seachModel);
}
///
/// 获取列表
///
/// 是否回调
/// 列表
[HandleException]
public ActionResult GetList(bool? callBack)
{
ProducePlanModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
ProducePlan condition = null;
try
{
//获取查询对象
seachModel = GetModel();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel(seachModel);
#region wcf服务统一接口
var dataResult = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.ProduceManage.ProducePlanBLL_GetList.ToString(), condition, page);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (dataResult.IsSuccess)
{
page = dataResult.Result;
}
DateGridResult result = new DateGridResult();
result.Total = page.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize>(page.Result.ToString());
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 加载列表
///
/// 结果
[HandleException]
public ActionResult Total(bool? callBack)
{
ProducePlanModel seachModel = new ProducePlanModel();
seachModel.STARTCREATEDATE = DateTime.Now.AddDays(-10).ToString("yyyy-MM-dd");
seachModel.ENDCREATEDATE = DateTime.Now.ToString("yyyy-MM-dd");
seachModel.ImmediateSearch = false;
if (callBack == true)
TryGetSelectBuffer(out seachModel);
seachModel.rownumbers = false;
seachModel.url = "/ProducePlan/GetTotal";
return View("Total", seachModel);
}
///
/// 获取列表
///
/// 是否回调
/// 列表
[HandleException]
public ActionResult GetTotal(bool? callBack)
{
ProducePlanModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
ProducePlan condition = null;
try
{
//获取查询对象
seachModel = GetModel();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel(seachModel);
#region wcf服务统一接口
var list = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.ProduceManage.ProducePlanBLL_GetTotal.ToString(), condition);
DateGridResult result = new DateGridResult();
result.Total = page.RecordCount;
result.Rows = list;
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 编辑
///
/// 编辑载入
///
/// 处理结果
[HandleException]
public ActionResult Edit()
{
ProducePlanModel model = new ProducePlanModel();
string ID = Request.Params["PID"];
ProducePlan Entity = new ProducePlan();
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
model.PLANDATE = DateTime.Now;
if (string.IsNullOrEmpty(ID) == false)
{
//修改获取原数据
Entity.PID = ID;
var dataResult = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.ProduceManage.ProducePlanBLL_Get.ToString(), Entity);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (dataResult.IsSuccess)
{
Entity = dataResult.Result;
}
else
{
SetMessage(dataResult.Msg);
return View("Edit", Entity);
}
model = CopyToModel(Entity);
}
return View("Edit", model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 保存
///
/// 保存
///
///
/// 处理结果
[HttpPost]
[HandleException]
[ValidateInput(false)]
public ActionResult Save(ProducePlanModel saveModel)
{
ProducePlan Entity = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
Entity = CopyToModel(saveModel);
if (string.IsNullOrEmpty(Entity.PID) == true)
{
//新增
var dataResult = wcfAgent.InvokeServiceFunction(QMAPP.ServicesAgent.ProduceManage.ProducePlanBLL_Insert.ToString(), Entity);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (!dataResult.IsSuccess)
{
SetMessage(dataResult.Msg);
return View("Edit", saveModel);
}
}
else
{
//修改
var dataResult = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.ProduceManage.ProducePlanBLL_Update.ToString(), Entity);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (!dataResult.IsSuccess)
{
SetMessage(dataResult.Msg);
return View("Edit", saveModel);
}
}
return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();", AppResource.SaveMessge));
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 删除
///
/// 删除
///
/// 结果
[HttpPost]
[HandleException]
public ActionResult Delete(ProducePlanModel saveMode)
{
string selectKey = Request.Form["selectKey"];
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
var dataResult = wcfAgent.InvokeServiceFunction(QMAPP.ServicesAgent.ProduceManage.ProducePlanBLL_Delete.ToString(), selectKey);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (!dataResult.IsSuccess)
{
SetMessage(dataResult.Msg);
}
else
{
SetMessage(AppResource.DeleteMessage);
}
return List(true);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 完成计划
///
/// 完成计划
///
///
/// 处理结果
[HttpPost]
[HandleException]
[ValidateInput(false)]
public ActionResult ProductOver(ProducePlanModel saveModel)
{
string selectKey = Request.Form["selectKey"];
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
//新增
var dataResult = wcfAgent.InvokeServiceFunction(QMAPP.ServicesAgent.ProduceManage.ProducePlanBLL_ProductOver.ToString(), selectKey);
//通过返回dataResult判断
if (dataResult.Ex != null)
{
throw dataResult.Ex;
}
else if (!dataResult.IsSuccess)
{
SetMessage(dataResult.Msg);
}
else
{
SetMessage(AppResource.ProductOverSeccess);
}
return List(true);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region
public ActionResult GetMachineNo()
{
ServiceAgent wcfAgent = this.GetServiceAgent();
MachineInfo condition=new MachineInfo();
try
{
ComboboxResult model = new ComboboxResult();
//查询仓库信息表
condition.PROCESSTYPE=Request.Params["PROCESSTYPE"];
var listWareHouse = wcfAgent.InvokeServiceFunction>(QMAPP.ServicesAgent.DictService.DictManageBLL_GetMachineListByProcessType.ToString(), condition);
List