using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QMFrameWork.WebUI.Attribute;
using QMAPP.Common.Web.Controllers;
using QMAPP.FJC.Web.Models.Stocktaking;
using QMFrameWork.Data;
using QMAPP.ServicesAgent;
using QMAPP.FJC.Entity.Stocktaking;
using QMFrameWork.WebUI.DataSource;
using QMFrameWork.Common.Serialization;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.Web.Models.Basic;
using System.Data;
using QMAPP.MD.Entity;
using System.Runtime.Serialization.Json;
using QMAPP.Entity;
using QMAPP.MD.Web.Models;
namespace QMAPP.FJC.Web.Controllers
{
public class StocktakingManageController : QController
{
#region 主界面加载列表
///
/// 加载列表
///
/// 结果
[HandleException]
public ActionResult List(bool? callBack)
{
StocktakingSearchModel seachModel = new StocktakingSearchModel();
if (callBack == true)
TryGetSelectBuffer(out seachModel);
seachModel.rownumbers = false;
seachModel.url = "/StocktakingManage/GetList";
return View("List", seachModel);
}
#endregion
#region 主界面获取列表
///
/// 获取列表
///
/// 是否回调
/// 列表
[HandleException]
public ActionResult GetList(bool? callBack)
{
StocktakingSearchModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
Countingplaninfo 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.StocktakingManage.StocktakingBLL_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;
}
}
#endregion
#region 编辑载入(点击添加,修改)
///
/// 编辑载入
///
/// 处理结果
[HandleException]
public ActionResult Edit()
{
StocktakingSearchModel model = new StocktakingSearchModel();
Countingplaninfo entity = new Countingplaninfo();
string PID = Request.Params["PID"];
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult result = new DataResult();
try
{
if (string.IsNullOrEmpty(PID) == false)
{
//修改获取原数据
entity.PID = PID;
result = wcfAgent.InvokeServiceFunction>("StocktakingBLL_Get", entity);
if (result.IsSuccess == false)
{
SetMessage(result.Msg);
return View("E", model);
}
model = CopyToModel(result.Result);
return View("E", model);
}
else
{
return View("A", model);
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 保存(添加,编辑)
///
/// 新增界面保存
///
///
/// 处理结果
[HttpPost]
[HandleException]
[ValidateInput(false)]
public ActionResult StocktingPlanSave(StocktakingSearchModel saveModel)
{
Countingplaninfo entity = new Countingplaninfo();
QMAPP.MD.Entity.Material condition = new MD.Entity.Material();
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult result = new DataResult();
string materials = "('" + saveModel.MaterialCodes.Replace(";", "','") + "')";
condition.MaterialCodes = materials;
//获取物料信息
List machinelist = wcfAgent.InvokeServiceFunction>("MaterialBLL_GetMaterialInfoList", condition);
if (saveModel.EDITFLAG == null)
{
entity.PID = Guid.NewGuid().ToString();
entity.COUNTTYPE = saveModel.COUNTTYPE;
entity.PLAN_DATE = saveModel.PLAN_DATE;
entity.REMARK = saveModel.REMARK;
#region 计划单号
object PLAN_NO = wcfAgent.InvokeServiceFunction