EvaluationProjectController.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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.Web.Controls.Mvc;
  10. using EMIS.Web.Controls;
  11. using EMIS.Utility;
  12. using EMIS.ViewModel;
  13. using EMIS.ViewModel.EvaluationManage.EvaluationTable;
  14. using EMIS.CommonLogic.EvaluationManage.EvaluationTable;
  15. namespace EMIS.Web.Controllers.EvaluationManage.EvaluationTable
  16. {
  17. [Authorization]
  18. public class EvaluationProjectController : Controller
  19. {
  20. public Lazy<IEvaluationProjectServices> EvaluationProjectServices { get; set; }
  21. /// <summary>
  22. /// 评价项目页面
  23. /// </summary>
  24. /// <returns></returns>
  25. public ActionResult List()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 评价项目列表查询
  31. /// </summary>
  32. /// <param name="pararms"></param>
  33. /// <returns></returns>
  34. [HttpPost]
  35. public ActionResult List(QueryParamsModel pararms)
  36. {
  37. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  38. var evaluationParticipateTypeID = pararms.getExtraGuid("EvaluationParticipateTypeDropdown");
  39. var evaluationTypeID = pararms.getExtraGuid("EvaluationTypeDropdown");
  40. var evaluationTableID = pararms.getExtraGuid("EvaluationTableDropdown");
  41. var evaluationTargetID = pararms.getExtraGuid("EvaluationTargetDropdown");
  42. return base.Json(EvaluationProjectServices.Value.GetEvaluationProjectViewGrid(configuretView, evaluationParticipateTypeID, evaluationTypeID, evaluationTableID, evaluationTargetID, (int)pararms.page, (int)pararms.rows));
  43. }
  44. /// <summary>
  45. /// 复制新增
  46. /// </summary>
  47. /// <param name="evaluationProjectID"></param>
  48. /// <returns></returns>
  49. public ActionResult CopyAdd(Guid evaluationProjectID)
  50. {
  51. EvaluationProjectView evaluationProjectView = new EvaluationProjectView();
  52. evaluationProjectView = EvaluationProjectServices.Value.GetEvaluationProjectView(evaluationProjectID);
  53. return View("Edit", evaluationProjectView);
  54. }
  55. /// <summary>
  56. /// 复制新增
  57. /// </summary>
  58. /// <param name="evaluationProjectView"></param>
  59. /// <returns></returns>
  60. [HttpPost]
  61. public ActionResult CopyAdd(EvaluationProjectView evaluationProjectView)
  62. {
  63. evaluationProjectView.EvaluationProjectID = Guid.Empty;
  64. return this.Edit(evaluationProjectView);
  65. }
  66. /// <summary>
  67. /// 编辑(新增、修改)
  68. /// </summary>
  69. /// <param name="evaluationProjectID"></param>
  70. /// <returns></returns>
  71. [HttpGet]
  72. public ActionResult Edit(Guid? evaluationProjectID)
  73. {
  74. EvaluationProjectView evaluationProjectView = new EvaluationProjectView();
  75. if (evaluationProjectID.HasValue && evaluationProjectID != Guid.Empty)
  76. {
  77. evaluationProjectView = EvaluationProjectServices.Value.GetEvaluationProjectView(evaluationProjectID);
  78. }
  79. return View(evaluationProjectView);
  80. }
  81. /// <summary>
  82. /// 编辑(新增、修改)
  83. /// </summary>
  84. /// <param name="evaluationProjectView"></param>
  85. /// <returns></returns>
  86. [HttpPost]
  87. public ActionResult Edit(EvaluationProjectView evaluationProjectView)
  88. {
  89. try
  90. {
  91. EvaluationProjectServices.Value.EvaluationProjectEdit(evaluationProjectView);
  92. return Json(new ReturnMessage()
  93. {
  94. IsSuccess = true,
  95. Message = "保存成功。"
  96. });
  97. }
  98. catch (Exception ex)
  99. {
  100. return Json(new ReturnMessage()
  101. {
  102. IsSuccess = false,
  103. Message = "保存失败,原因:" + ex.Message
  104. });
  105. }
  106. }
  107. /// <summary>
  108. /// 删除
  109. /// </summary>
  110. /// <param name="evaluationProjectIDs"></param>
  111. /// <returns></returns>
  112. [HttpPost]
  113. public ActionResult Delete(string evaluationProjectIDs)
  114. {
  115. try
  116. {
  117. List<Guid?> list = evaluationProjectIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  118. EvaluationProjectServices.Value.EvaluationProjectDelete(list);
  119. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  120. }
  121. catch (Exception ex)
  122. {
  123. string mge = ex.Message;
  124. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  125. if (num != null)
  126. {
  127. if (num.Number == 547)
  128. {
  129. mge = "请先删除所有关联的数据,如:评价记录等。";
  130. }
  131. }
  132. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + mge });
  133. }
  134. }
  135. /// <summary>
  136. /// Excel导出
  137. /// </summary>
  138. /// <returns></returns>
  139. [HttpPost]
  140. public ActionResult Excel()
  141. {
  142. NpoiExcelHelper neh = new NpoiExcelHelper();
  143. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  144. var evaluationParticipateTypeID = Request.Form["EvaluationParticipateTypeDropdown"].ParseStrTo<Guid>();
  145. var evaluationTypeID = Request.Form["EvaluationTypeDropdown"].ParseStrTo<Guid>();
  146. var evaluationTableID = Request.Form["EvaluationTableDropdown"].ParseStrTo<Guid>();
  147. var evaluationTargetID = Request.Form["EvaluationTargetDropdown"].ParseStrTo<Guid>();
  148. var dt = EvaluationProjectServices.Value.GetEvaluationProjectViewList(configuretView, evaluationParticipateTypeID, evaluationTypeID, evaluationTableID, evaluationTargetID)
  149. .Select(x => new
  150. {
  151. x.OrderNo,
  152. x.Code,
  153. x.Name,
  154. x.EvaluationTargetOrderNo,
  155. x.EvaluationTargetCode,
  156. x.EvaluationTargetName,
  157. x.EvaluationTableCode,
  158. x.EvaluationTableName,
  159. x.ParticipateTypeCode,
  160. x.ParticipateTypeName,
  161. x.IsStudentName,
  162. x.EvaluationTypeCode,
  163. x.EvaluationTypeName,
  164. x.TeachingModeIDListName,
  165. x.EvaluationNormName,
  166. x.NormTypeName,
  167. x.Weight,
  168. x.Remark,
  169. x.CreateUserName,
  170. x.ModifyUserName,
  171. ModifyTime = x.ModifyTime == null ? null : x.ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss")
  172. }).ToTable();
  173. string[] liststring = {
  174. "次序", "项目编号", "项目名称", "指标次序", "指标编号", "指标名称", "评价表编号", "评价表名", "参评代码", "参评类型",
  175. "学生用", "评价类型编号", "评价类型", "授课方式", "评分标准", "评分类型", "权重", "备注", "创建人", "修改人", "修改时间"
  176. };
  177. neh.Export(dt, liststring, "评价项目信息" + DateTime.Now.ToString("yyyyMMdd"));
  178. return Json(new ReturnMessage()
  179. {
  180. IsSuccess = true,
  181. Message = "导出成功。"
  182. });
  183. }
  184. }
  185. }