123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- 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.Common.Cache;
- using Bowin.Web.Controls.Mvc;
- using EMIS.Web.Controls;
- using EMIS.Utility;
- using EMIS.ViewModel;
- using EMIS.ViewModel.EvaluationManage.EvaluationTable;
- using EMIS.CommonLogic.EvaluationManage.EvaluationTable;
- namespace EMIS.Web.Controllers.EvaluationManage.EvaluationTable
- {
- [Authorization]
- public class EvaluationNormController : Controller
- {
- public Lazy<IEvaluationNormServices> EvaluationNormServices { 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 normTypeID = pararms.getExtraInt("DictionaryNormType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryNormType");
- return base.Json(EvaluationNormServices.Value.GetEvaluationNormViewGrid(configuretView, normTypeID, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="evaluationNormID"></param>
- /// <returns></returns>
- public ActionResult CopyAdd(Guid evaluationNormID)
- {
- var evaluationNormView = new EvaluationNormView();
- evaluationNormView = EvaluationNormServices.Value.GetEvaluationNormView(evaluationNormID);
- ViewBag.NormTypeID = evaluationNormView.NormTypeID;
- return View("Edit", evaluationNormView);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="evaluationNormView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(EvaluationNormView evaluationNormView)
- {
- evaluationNormView.EvaluationNormID = Guid.Empty;
- return this.Edit(evaluationNormView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="evaluationNormID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Edit(Guid? evaluationNormID)
- {
- var evaluationNormView = new EvaluationNormView();
- if (evaluationNormID.HasValue && evaluationNormID != Guid.Empty)
- {
- evaluationNormView = EvaluationNormServices.Value.GetEvaluationNormView(evaluationNormID);
- }
- else
- {
- evaluationNormView.NormTypeID = (int)EM_EvaluationNormType.CheckBox;
- }
- ViewBag.NormTypeID = evaluationNormView.NormTypeID;
- return View(evaluationNormView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="evaluationNormView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(EvaluationNormView evaluationNormView)
- {
- try
- {
- var detailViewList = DataGrid.GetTableData<EvaluationNormDetailView>("dgEvaluationNormDetailList");
- EvaluationNormServices.Value.EvaluationNormEdit(evaluationNormView, detailViewList);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="evaluationNormIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string evaluationNormIDs)
- {
- try
- {
- List<Guid?> list = evaluationNormIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
- EvaluationNormServices.Value.EvaluationNormDelete(list);
- return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
- }
- catch (Exception ex)
- {
- string mge = ex.Message;
- System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
- if (num != null)
- {
- if (num.Number == 547)
- {
- mge = "请先删除所有关联的数据,如:评价指标、评价项目、评价设定等。";
- }
- }
- return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + mge });
- }
- }
- /// <summary>
- /// 复制新增明细
- /// </summary>
- /// <param name="evaluationNormDetailID"></param>
- /// <returns></returns>
- public ActionResult CopyAddDetail(Guid evaluationNormDetailID)
- {
- var evaluationNormDetailView = new EvaluationNormDetailView();
- evaluationNormDetailView = EvaluationNormServices.Value.GetEvaluationNormDetailView(evaluationNormDetailID);
- return View("DetailEdit", evaluationNormDetailView);
- }
- /// <summary>
- /// 复制新增明细
- /// </summary>
- /// <param name="evaluationNormDetailView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAddDetail(EvaluationNormDetailView evaluationNormDetailView)
- {
- evaluationNormDetailView.EvaluationNormDetailID = Guid.Empty;
- return this.DetailEdit(evaluationNormDetailView);
- }
- /// <summary>
- /// 明细编辑
- /// </summary>
- /// <param name="evaluationNormDetailID"></param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult DetailEdit(Guid? evaluationNormDetailID)
- {
- var evaluationNormDetailView = new EvaluationNormDetailView();
- if (evaluationNormDetailID != null && evaluationNormDetailID != Guid.Empty)
- {
- evaluationNormDetailView = EvaluationNormServices.Value.GetEvaluationNormDetailView(evaluationNormDetailID);
- }
- return View(evaluationNormDetailView);
- }
- /// <summary>
- /// 明细编辑
- /// </summary>
- /// <param name="evaluationNormDetailView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult DetailEdit(EvaluationNormDetailView evaluationNormDetailView)
- {
- try
- {
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- evaluationNormDetailView.EvaluationNormDetailID = Guid.NewGuid();
- CacheHelper.Set("evaluationNormDetailView" + user.UserID, evaluationNormDetailView);
- return View(evaluationNormDetailView);
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = false,
- Message = "保存失败,原因:" + ex.Message
- });
- }
- }
- /// <summary>
- /// 查询对应的评分标准明细信息
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult EvaluationNormDetailViewList(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var evaluationNormID = Request["evaluationNormID"].ParseStrTo<Guid>();
- return base.Json(EvaluationNormServices.Value.GetEvaluationNormDetailViewGrid(configuretView, evaluationNormID, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var normTypeID = Request.Form["DictionaryNormType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryNormType"].ParseStrTo<int>();
- var dt = EvaluationNormServices.Value.GetEvaluationNormViewList(configuretView, normTypeID)
- .Select(x => new
- {
- x.Name,
- x.NormTypeName,
- x.SatisfyWeight,
- x.NormDetailListName,
- 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 = "导出成功。"
- });
- }
- }
- }
|