123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Bowin.Common.Data;
- using Bowin.Common.Exceptions;
- using Bowin.Common.Utility;
- using Bowin.Web.Controls.Mvc;
- using EMIS.Web.Controls;
- using EMIS.Utility;
- using EMIS.ViewModel;
- using EMIS.ViewModel.EvaluationManage.EvaluationSetting;
- using EMIS.CommonLogic.EvaluationManage.EvaluationSetting;
- namespace EMIS.Web.Controllers.EvaluationManage.EvaluationSetting
- {
- [Authorization]
- public class EvaluationNeedController : Controller
- {
- public Lazy<IEvaluationNeedServices> EvaluationNeedServices { get; set; }
- /// <summary>
- /// 评价需知页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- /// 评价需知列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var participateTypeID = pararms.getExtraInt("DictionaryParticipateType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryParticipateType");
- var isEnabled = pararms.getExtraInt("IsEnabledDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsEnabledDropdown");
- return base.Json(EvaluationNeedServices.Value.GetEvaluationNeedViewGrid(configuretView, participateTypeID, isEnabled, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="evaluationNeedID"></param>
- /// <returns></returns>
- public ActionResult CopyAdd(Guid evaluationNeedID)
- {
- var evaluationNeedView = new EvaluationNeedView();
- evaluationNeedView = EvaluationNeedServices.Value.GetEvaluationNeedView(evaluationNeedID);
- return View("Edit", evaluationNeedView);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="evaluationNeedView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(EvaluationNeedView evaluationNeedView)
- {
- evaluationNeedView.EvaluationNeedID = Guid.Empty;
- return this.Edit(evaluationNeedView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="evaluationNeedID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? evaluationNeedID)
- {
- var evaluationNeedView = new EvaluationNeedView();
- if (evaluationNeedID.HasValue && evaluationNeedID != Guid.Empty)
- {
- evaluationNeedView = EvaluationNeedServices.Value.GetEvaluationNeedView(evaluationNeedID);
- }
- else
- {
- evaluationNeedView.IsEnabled = true;
- }
- return View(evaluationNeedView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="evaluationNeedView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(EvaluationNeedView evaluationNeedView)
- {
- try
- {
- EvaluationNeedServices.Value.EvaluationNeedEdit(evaluationNeedView);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="evaluationNeedIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string evaluationNeedIDs)
- {
- try
- {
- List<Guid?> list = evaluationNeedIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
- EvaluationNeedServices.Value.EvaluationNeedDelete(list);
- return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
- }
- catch (Exception ex)
- {
- return base.Json(new ReturnMessage() { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
- }
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var participateTypeID = Request.Form["DictionaryParticipateType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryParticipateType"].ParseStrTo<int>();
- var isEnabled = Request.Form["IsEnabledDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsEnabledDropdown"].ParseStrTo<int>();
- var dt = EvaluationNeedServices.Value.GetEvaluationNeedViewList(configuretView, participateTypeID, isEnabled)
- .Select(x => new
- {
- x.Code,
- x.Title,
- x.ParticipateTypeName,
- x.Content,
- x.IsEnabledName,
- x.Remark,
- x.CreateUserName,
- x.ModifyUserName,
- ModifyTime = x.ModifyTime == null ? null : x.ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss")
- }).ToTable();
- string[] liststring = {
- "编号", "标题", "参评类型", "内容", "是否启用", "备注", "创建人", "修改人", "修改时间"
- };
- neh.Export(dt, liststring, "评价需知信息" + DateTime.Now.ToString("yyyyMMdd"));
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- }
- }
|