EvaluationNormController.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Common.Data;
  7. using Bowin.Common.Exceptions;
  8. using Bowin.Common.Utility;
  9. using Bowin.Common.Cache;
  10. using Bowin.Web.Controls.Mvc;
  11. using EMIS.Web.Controls;
  12. using EMIS.Utility;
  13. using EMIS.ViewModel;
  14. using EMIS.ViewModel.EvaluationManage.EvaluationTable;
  15. using EMIS.CommonLogic.EvaluationManage.EvaluationTable;
  16. namespace EMIS.Web.Controllers.EvaluationManage.EvaluationTable
  17. {
  18. [Authorization]
  19. public class EvaluationNormController : Controller
  20. {
  21. public Lazy<IEvaluationNormServices> EvaluationNormServices { get; set; }
  22. /// <summary>
  23. /// 评分标准页面
  24. /// </summary>
  25. /// <returns></returns>
  26. public ActionResult List()
  27. {
  28. return View();
  29. }
  30. /// <summary>
  31. /// 评价表名列表查询
  32. /// </summary>
  33. /// <param name="pararms"></param>
  34. /// <returns></returns>
  35. [HttpPost]
  36. public ActionResult List(QueryParamsModel pararms)
  37. {
  38. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  39. var normTypeID = pararms.getExtraInt("DictionaryNormType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryNormType");
  40. return base.Json(EvaluationNormServices.Value.GetEvaluationNormViewGrid(configuretView, normTypeID, (int)pararms.page, (int)pararms.rows));
  41. }
  42. /// <summary>
  43. /// 复制新增
  44. /// </summary>
  45. /// <param name="evaluationNormID"></param>
  46. /// <returns></returns>
  47. public ActionResult CopyAdd(Guid evaluationNormID)
  48. {
  49. var evaluationNormView = new EvaluationNormView();
  50. evaluationNormView = EvaluationNormServices.Value.GetEvaluationNormView(evaluationNormID);
  51. ViewBag.NormTypeID = evaluationNormView.NormTypeID;
  52. return View("Edit", evaluationNormView);
  53. }
  54. /// <summary>
  55. /// 复制新增
  56. /// </summary>
  57. /// <param name="evaluationNormView"></param>
  58. /// <returns></returns>
  59. [HttpPost]
  60. public ActionResult CopyAdd(EvaluationNormView evaluationNormView)
  61. {
  62. evaluationNormView.EvaluationNormID = Guid.Empty;
  63. return this.Edit(evaluationNormView);
  64. }
  65. /// <summary>
  66. /// 编辑(新增、修改)
  67. /// </summary>
  68. /// <param name="evaluationNormID"></param>
  69. /// <returns></returns>
  70. [HttpGet]
  71. public ActionResult Edit(Guid? evaluationNormID)
  72. {
  73. var evaluationNormView = new EvaluationNormView();
  74. if (evaluationNormID.HasValue && evaluationNormID != Guid.Empty)
  75. {
  76. evaluationNormView = EvaluationNormServices.Value.GetEvaluationNormView(evaluationNormID);
  77. }
  78. else
  79. {
  80. evaluationNormView.NormTypeID = (int)EM_EvaluationNormType.CheckBox;
  81. }
  82. ViewBag.NormTypeID = evaluationNormView.NormTypeID;
  83. return View(evaluationNormView);
  84. }
  85. /// <summary>
  86. /// 编辑(新增、修改)
  87. /// </summary>
  88. /// <param name="evaluationNormView"></param>
  89. /// <returns></returns>
  90. [HttpPost]
  91. public ActionResult Edit(EvaluationNormView evaluationNormView)
  92. {
  93. try
  94. {
  95. var detailViewList = DataGrid.GetTableData<EvaluationNormDetailView>("dgEvaluationNormDetailList");
  96. EvaluationNormServices.Value.EvaluationNormEdit(evaluationNormView, detailViewList);
  97. return Json(new ReturnMessage()
  98. {
  99. IsSuccess = true,
  100. Message = "保存成功。"
  101. });
  102. }
  103. catch (Exception ex)
  104. {
  105. return Json(new ReturnMessage()
  106. {
  107. IsSuccess = false,
  108. Message = "保存失败,原因:" + ex.Message
  109. });
  110. }
  111. }
  112. /// <summary>
  113. /// 删除
  114. /// </summary>
  115. /// <param name="evaluationNormIDs"></param>
  116. /// <returns></returns>
  117. [HttpPost]
  118. public ActionResult Delete(string evaluationNormIDs)
  119. {
  120. try
  121. {
  122. List<Guid?> list = evaluationNormIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  123. EvaluationNormServices.Value.EvaluationNormDelete(list);
  124. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  125. }
  126. catch (Exception ex)
  127. {
  128. string mge = ex.Message;
  129. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  130. if (num != null)
  131. {
  132. if (num.Number == 547)
  133. {
  134. mge = "请先删除所有关联的数据,如:评价指标、评价项目、评价设定等。";
  135. }
  136. }
  137. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + mge });
  138. }
  139. }
  140. /// <summary>
  141. /// 复制新增明细
  142. /// </summary>
  143. /// <param name="evaluationNormDetailID"></param>
  144. /// <returns></returns>
  145. public ActionResult CopyAddDetail(Guid evaluationNormDetailID)
  146. {
  147. var evaluationNormDetailView = new EvaluationNormDetailView();
  148. evaluationNormDetailView = EvaluationNormServices.Value.GetEvaluationNormDetailView(evaluationNormDetailID);
  149. return View("DetailEdit", evaluationNormDetailView);
  150. }
  151. /// <summary>
  152. /// 复制新增明细
  153. /// </summary>
  154. /// <param name="evaluationNormDetailView"></param>
  155. /// <returns></returns>
  156. [HttpPost]
  157. public ActionResult CopyAddDetail(EvaluationNormDetailView evaluationNormDetailView)
  158. {
  159. evaluationNormDetailView.EvaluationNormDetailID = Guid.Empty;
  160. return this.DetailEdit(evaluationNormDetailView);
  161. }
  162. /// <summary>
  163. /// 明细编辑
  164. /// </summary>
  165. /// <param name="evaluationNormDetailID"></param>
  166. /// <returns></returns>
  167. [HttpGet]
  168. public ActionResult DetailEdit(Guid? evaluationNormDetailID)
  169. {
  170. var evaluationNormDetailView = new EvaluationNormDetailView();
  171. if (evaluationNormDetailID != null && evaluationNormDetailID != Guid.Empty)
  172. {
  173. evaluationNormDetailView = EvaluationNormServices.Value.GetEvaluationNormDetailView(evaluationNormDetailID);
  174. }
  175. return View(evaluationNormDetailView);
  176. }
  177. /// <summary>
  178. /// 明细编辑
  179. /// </summary>
  180. /// <param name="evaluationNormDetailView"></param>
  181. /// <returns></returns>
  182. [HttpPost]
  183. public ActionResult DetailEdit(EvaluationNormDetailView evaluationNormDetailView)
  184. {
  185. try
  186. {
  187. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  188. evaluationNormDetailView.EvaluationNormDetailID = Guid.NewGuid();
  189. CacheHelper.Set("evaluationNormDetailView" + user.UserID, evaluationNormDetailView);
  190. return View(evaluationNormDetailView);
  191. }
  192. catch (Exception ex)
  193. {
  194. return Json(new ReturnMessage()
  195. {
  196. IsSuccess = false,
  197. Message = "保存失败,原因:" + ex.Message
  198. });
  199. }
  200. }
  201. /// <summary>
  202. /// 查询对应的评分标准明细信息
  203. /// </summary>
  204. /// <param name="pararms"></param>
  205. /// <returns></returns>
  206. [HttpPost]
  207. public ActionResult EvaluationNormDetailViewList(QueryParamsModel pararms)
  208. {
  209. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  210. var evaluationNormID = Request["evaluationNormID"].ParseStrTo<Guid>();
  211. return base.Json(EvaluationNormServices.Value.GetEvaluationNormDetailViewGrid(configuretView, evaluationNormID, (int)pararms.page, (int)pararms.rows));
  212. }
  213. /// <summary>
  214. /// Excel导出
  215. /// </summary>
  216. /// <returns></returns>
  217. [HttpPost]
  218. public ActionResult Excel()
  219. {
  220. NpoiExcelHelper neh = new NpoiExcelHelper();
  221. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  222. var normTypeID = Request.Form["DictionaryNormType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryNormType"].ParseStrTo<int>();
  223. var dt = EvaluationNormServices.Value.GetEvaluationNormViewList(configuretView, normTypeID)
  224. .Select(x => new
  225. {
  226. x.Name,
  227. x.NormTypeName,
  228. x.SatisfyWeight,
  229. x.NormDetailListName,
  230. x.Remark,
  231. x.CreateUserName,
  232. x.ModifyUserName,
  233. ModifyTime = x.ModifyTime == null ? null : x.ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss")
  234. }).ToTable();
  235. string[] liststring = {
  236. "评分标准", "评分类型", "满意权重", "标准明细", "备注", "创建人", "修改人", "修改时间"
  237. };
  238. neh.Export(dt, liststring, "评分标准信息" + DateTime.Now.ToString("yyyyMMdd"));
  239. return Json(new ReturnMessage()
  240. {
  241. IsSuccess = true,
  242. Message = "导出成功。"
  243. });
  244. }
  245. }
  246. }