天津投入产出系统后端
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.

397 lines
12 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QMFrameWork.WebUI.Attribute;
using QMAPP.Web.Models.Sys;
using QMAPP.Common.Web.Controllers;
using QMFrameWork.Data;
using QMAPP.Entity.Sys;
using QMFrameWork.WebUI.DataSource;
using QMFrameWork.Common.Serialization;
using System.Collections;
using System.Data;
using QMAPP.ServicesAgent;
namespace QMAPP.Web.Controllers
{
/// <summary>
/// 问题类型控制器
/// 创建人:wangyf
/// 创建时间:2015.03.30
/// </summary>
public class SIProblemTypeController : QController
{
#region 添加
/// <summary>
/// 添加载入
/// </summary>
/// <returns>处理结果</returns>
[HandleException]
public ActionResult SIProblemTypeAdd()
{
try
{
return View("SIProblemTypeEdit", new SIProblemTypeModel());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 编辑
/// <summary>
/// 编辑载入
/// </summary>
/// <returns>处理结果</returns>
[HandleException]
public ActionResult SIProblemTypeEdit()
{
SIProblemTypeModel model = new SIProblemTypeModel();
string id = Request.Params["PID"];
SIProblemType entity = new SIProblemType();
try
{
if (string.IsNullOrEmpty(id) == false)
{
//修改获取原数据
entity.PID = id;
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
entity = agent.InvokeServiceFunction<SIProblemType>("SIProblemTypeBLL_Get", entity);
model = CopyToModel<SIProblemTypeModel, SIProblemType>(entity);
}
return View("SIProblemTypeEdit", model);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 保存
/// </summary>
/// <param name="model"></param>
/// <returns>处理结果</returns>
[HttpPost]
[HandleException]
public ActionResult SIProblemTypeSave(SIProblemTypeModel saveModel)
{
SIProblemType info = null;
try
{
info = CopyToModel<SIProblemType, SIProblemTypeModel>(saveModel);
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
if (string.IsNullOrEmpty(info.PID) == true)
{
//新增
agent.InvokeServiceFunction("SIProblemTypeBLL_Insert", info);
}
else
{
//修改
agent.InvokeServiceFunction("SIProblemTypeBLL_Update", info);
}
return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();"
, AppResource.SaveMessge));
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 判断类型名称是否已经存在
/// <summary>
/// 判断类型名称是否已经存在
/// </summary>
/// <param name="model"></param>
/// <returns>处理结果</returns>
[HttpPost]
[HandleException]
public ActionResult CheckProblemTypeNameExist(SIProblemTypeModel saveModel)
{
SIProblemType info = null;
bool result = false;
try
{
info = CopyToModel<SIProblemType, SIProblemTypeModel>(saveModel);
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
result = agent.InvokeServiceFunction<bool>("SIProblemTypeBLL_CheckProblemTypeNameExist", info);
return Json(result);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 删除
/// <summary>
/// 删除
/// </summary>
/// <returns>结果</returns>
[HttpPost]
[HandleException]
public ActionResult SIProblemTypeDelete()
{
string selectKey = Request.Form["selectKey"];
try
{
if (!string.IsNullOrEmpty(selectKey))
{
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
agent.InvokeServiceFunction("SIProblemTypeBLL_Delete", selectKey);
SetMessage(AppResource.DeleteMessage);
}
return SIProblemTypeList();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取列表
/// <summary>
/// 加载列表
/// </summary>
/// <returns>结果</returns>
[HandleException]
public ActionResult SIProblemTypeList()
{
SIProblemTypeModel seachModel = new SIProblemTypeModel();
TryGetSelectBuffer<SIProblemTypeModel>(out seachModel);
seachModel.rownumbers = false;
seachModel.url = "/SIProblemType/GetList";
return View("SIProblemTypeList", seachModel);
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="callBack">是否回调</param>
/// <returns>列表</returns>
[HttpPost]
[HandleException]
public ActionResult GetList(bool? callBack)
{
List<SIProblemTypeModel> users = new List<SIProblemTypeModel>();
SIProblemTypeModel seachModel = null;
DataPage page = new DataPage();
SIProblemType condition = null;
try
{
//获取查询对象
seachModel = GetModel<SIProblemTypeModel>();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer<SIProblemTypeModel>(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer<SIProblemTypeModel>(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel<SIProblemType, SIProblemTypeModel>(seachModel);
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
page = agent.InvokeServiceFunction<DataPage>("SIProblemTypeBLL_GetList", condition, page);
DataGridResult<SIProblemType> result = new DataGridResult<SIProblemType>();
result.Total = page.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize<List<SIProblemType>>(page.Result.ToString());
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取部门下的人员
/// <summary>
/// 取得当前部门下的人员
/// </summary>
/// <returns>结果</returns>
[HttpPost]
[HandleException]
public ActionResult GetUserList()
{
string organId = Request["orgaID"].ToString();
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
List<User> userlist = agent.InvokeServiceFunction<List<User>>("UserManageBLL_GetOrgaUserList", organId);
//List<User> userlist = userBll.GetOrgaUserList(organId);
//插入第一行空行
if (userlist != null && userlist.Count > 0)
{
userlist.Insert(0, new User() { UserID = "", UserName = new DictController().EmptyItemTitle });
}
return Content(QMFrameWork.Common.Serialization.JsonConvertHelper.GetSerializes(userlist));
}
#endregion
#region 导出excel
/// <summary>
/// 导出excel
/// </summary>
/// <returns>结果</returns>
[HttpPost]
[HandleException]
public ActionResult ExportExcel()
{
SIProblemTypeModel seachModel = null;
SIProblemType seachEntity= null;
ServiceAgent wcfAgent = this.GetServiceAgent();
string selectKey = Request.Form["selectKey"];
DataTable exportDt = null;
try
{
//获取查询条件
TryGetSelectBuffer<SIProblemTypeModel>(out seachModel);
seachEntity = CopyToModel<SIProblemType, SIProblemTypeModel>(seachModel);
//获取数据
exportDt = wcfAgent.InvokeServiceFunction<DataTable>(QMAPP.ServicesAgent.SupportMutualService.SIProblemTypeBLL_GetExportData.ToString(), seachEntity);
//导出
if (selectKey != "")
{
DataView dv = new DataView(exportDt);
string strWhere = "";
string[] list = selectKey.Split(":".ToCharArray());
foreach (string pid in list)
{
strWhere += " PID='" + pid + "' or";
}
if (strWhere != "")
{
strWhere = strWhere.Remove((strWhere.Length - 2), 2);
}
dv.RowFilter = strWhere;
exportDt = dv.ToTable();
}
exportDt.Columns.Add("CD");
exportDt.Columns.Add("UP");
//设置问题状态
foreach (DataRow dr in exportDt.Rows)
{
string cd = dr["CREATEDATE"].ToString();
if (!string.IsNullOrEmpty(cd))
{
dr["CD"] = Convert.ToDateTime(cd).ToString("yyyy-MM-dd hh:mm:ss");
}
string ud = dr["UPDATEDATE"].ToString();
if (!string.IsNullOrEmpty(ud))
{
dr["UP"] = Convert.ToDateTime(cd).ToString("yyyy-MM-dd hh:mm:ss");
}
}
//导出
QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool();
return efTool.GetExcelFileResult("SIProblemType", "问题类型.xls", exportDt);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取问题类型下拉列表数据
/// <summary>
/// 获取问题类型下拉列表数据
/// </summary>
/// <returns></returns>
[HttpPost]
[HandleException]
public ActionResult GetPTypeList()
{
ComboboxResult model = new ComboboxResult();
return Content(model.ToString());
}
#endregion
#region 组织机构信息下拉菜单
///
[HttpPost]
[HandleException]
public ActionResult GetOrgaList()
{
try
{
Orgaization orgaModel = new Orgaization();
List<Orgaization> list = new List<Orgaization>();
//list = userBll.GetUserOrgaList("");
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
list = agent.InvokeServiceFunction<List<Orgaization>>("UserManageBLL_GetUserOrgaList", "");
ComboboxResult model = new ComboboxResult();
//添加第一行空行
if (list != null && list.Count > 0)
{
model.Add(new ComboboxItem { ID = "", Text = new DictController().EmptyItemTitle });
}
foreach (Orgaization o in list)
{
model.Add(new ComboboxItem { ID = o.OrgaID, Text = o.OrgaDESC });
}
return Content(model.ToString());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}