You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
188 lines
6.1 KiB
188 lines
6.1 KiB
4 years ago
|
using System.Collections.Generic;
|
||
|
using System.Web.Mvc;
|
||
|
using QMFrameWork.Common.Serialization;
|
||
|
using QMFrameWork.Data;
|
||
|
using QMFrameWork.WebUI.Attribute;
|
||
|
using QMFrameWork.WebUI.Util;
|
||
|
using QMAPP.ServicesAgent;
|
||
|
using QMAPP.Common.Web.Controllers;
|
||
|
using QMAPP.Entity;
|
||
|
using QMFrameWork.WebUI.DataSource;
|
||
|
using QMAPP.MD.Web.Models;
|
||
|
using QMAPP.MD.Entity;
|
||
|
|
||
|
namespace QMAPP.MD.Web.Controllers
|
||
|
{
|
||
|
/// 模块名称:采集数据借口
|
||
|
/// 作 者:QMMES
|
||
|
/// 编写日期:2017年09月05日
|
||
|
public class DaiController : QController
|
||
|
{
|
||
|
#region 获取列表
|
||
|
/// <summary>
|
||
|
/// 加载列表
|
||
|
/// </summary>
|
||
|
/// <returns>结果</returns>
|
||
|
[HandleException]
|
||
|
public ActionResult DaiList(bool? callBack)
|
||
|
{
|
||
|
DaiModel seachModel = new DaiModel();
|
||
|
if (callBack == false)
|
||
|
TryGetSelectBuffer(out seachModel);
|
||
|
seachModel.rownumbers = false;
|
||
|
seachModel.url = "/Dai/GetList";
|
||
|
return View("DaiList", seachModel);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取列表
|
||
|
/// </summary>
|
||
|
/// <param name="callBack">是否回调</param>
|
||
|
/// <returns>列表</returns>
|
||
|
[HandleException]
|
||
|
public ActionResult GetList(bool? callBack)
|
||
|
{
|
||
|
var wcfAgent = GetServiceAgent();
|
||
|
//获取查询对象
|
||
|
var seachModel = GetModel<DaiModel>();
|
||
|
|
||
|
#region 获取缓存值
|
||
|
if (callBack != null)
|
||
|
{
|
||
|
TryGetSelectBuffer(out seachModel);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//保存搜索条件
|
||
|
SetSelectBuffer(seachModel);
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
//获取前台分页设置信息
|
||
|
var page = GetDataPage(seachModel);
|
||
|
var condition = CopyToModel<Dai, DaiModel>(seachModel);
|
||
|
|
||
|
page = wcfAgent.InvokeServiceFunction<DataPage>("DaiBLL_GetList", condition, page);
|
||
|
DataGridResult<Dai> result = new DataGridResult<Dai>
|
||
|
{
|
||
|
Total = page.RecordCount,
|
||
|
Rows = JsonConvertHelper.GetDeserialize<List<Dai>>(page.Result.ToString())
|
||
|
};
|
||
|
|
||
|
return Content(result.GetJsonSource());
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 编辑
|
||
|
/// <summary>
|
||
|
/// 添加载入
|
||
|
/// </summary>
|
||
|
/// <returns>处理结果</returns>
|
||
|
[HandleException]
|
||
|
public ActionResult DaiAdd()
|
||
|
{
|
||
|
DaiModel model = new DaiModel();
|
||
|
return View("DaiEdit", model);
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 编辑载入
|
||
|
/// </summary>
|
||
|
/// <returns>处理结果</returns>
|
||
|
[HandleException]
|
||
|
public ActionResult DaiEdit()
|
||
|
{
|
||
|
DaiModel model = new DaiModel();
|
||
|
string id = Request.QueryString["PID"];
|
||
|
Dai info = new Dai();
|
||
|
ServiceAgent wcfAgent = GetServiceAgent();
|
||
|
if (!string.IsNullOrEmpty(id))
|
||
|
{
|
||
|
//修改获取原数据
|
||
|
info.PID = id;
|
||
|
info = wcfAgent.InvokeServiceFunction<Dai>("DaiBLL_Get", info);
|
||
|
model = CopyToModel<DaiModel, Dai>(info);
|
||
|
//QMFrameWork.WebUI.Util.SessionHelper.SetSession("Dai_Detail", info.Details);
|
||
|
}
|
||
|
return View(model);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取明细数据
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
[HandleException]
|
||
|
public ActionResult GetDetailList()
|
||
|
{
|
||
|
DataGridResult<DaiData> result = new DataGridResult<DaiData>
|
||
|
{
|
||
|
Total = 0,
|
||
|
Rows = SessionHelper.GetSession("Dai_Detail") as List<DaiData>
|
||
|
};
|
||
|
SessionHelper.SessionDispose("Dai_Detail");
|
||
|
if (result.Rows == null)
|
||
|
result.Rows = new List<DaiData>();
|
||
|
return Content(result.GetJsonSource());
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 保存
|
||
|
/// </summary>
|
||
|
/// <returns>处理结果</returns>
|
||
|
[HttpPost]
|
||
|
[HandleException]
|
||
|
public ActionResult DaiSave(DaiModel saveModel)
|
||
|
{
|
||
|
var wcfAgent = GetServiceAgent();
|
||
|
//如何MATERIAL_CODE==MATERIAL_TYPE说明页面选的是类型
|
||
|
//if (saveModel.MATERIAL_CODE == saveModel.MATERIAL_TYPE)
|
||
|
//{
|
||
|
// saveModel.MATERIAL_CODE = null;
|
||
|
//}
|
||
|
var info = CopyToModel<Dai, DaiModel>(saveModel);
|
||
|
|
||
|
//info.Details = JsonConvertHelper.DeserializeObject<List<DaiData>>(saveModel.DetailValue);
|
||
|
DataResult<int> serviceResult;
|
||
|
if (string.IsNullOrEmpty(info.PID))
|
||
|
{
|
||
|
//新增
|
||
|
info.DA_STATUS = "1";
|
||
|
serviceResult=wcfAgent.InvokeServiceFunction<DataResult<int>>("DaiBLL_Insert", info);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//修改
|
||
|
serviceResult=wcfAgent.InvokeServiceFunction<DataResult<int>>("DaiBLL_Update", info);
|
||
|
}
|
||
|
if (serviceResult.Ex != null)
|
||
|
throw serviceResult.Ex;
|
||
|
if (!serviceResult.IsSuccess)
|
||
|
{
|
||
|
//保存失败
|
||
|
SetMessage(serviceResult.Msg);
|
||
|
return View("DaiEdit", saveModel);
|
||
|
}
|
||
|
return GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();",AppResource.SaveMessge));
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 删除
|
||
|
/// <summary>
|
||
|
/// 删除
|
||
|
/// </summary>
|
||
|
/// <returns>结果</returns>
|
||
|
[HttpPost]
|
||
|
[HandleException]
|
||
|
public ActionResult DaiDelete()
|
||
|
{
|
||
|
string selectKey = Request.Form["selectKey"];
|
||
|
var wcfAgent = GetServiceAgent();
|
||
|
var serviceResult = wcfAgent.InvokeServiceFunction<DataResult<int>>("DaiBLL_DeleteArray", selectKey);
|
||
|
SetMessage(string.IsNullOrEmpty(serviceResult.Msg) ? AppResource.DeleteMessage : serviceResult.Msg);
|
||
|
return DaiList(true);
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|