EvaluationTargetController.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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 EvaluationTargetController : Controller
  19. {
  20. public Lazy<IEvaluationTargetServices> EvaluationTargetServices { 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 evaluationNormID = pararms.getExtraGuid("EvaluationNormDropdown");
  42. return base.Json(EvaluationTargetServices.Value.GetEvaluationTargetViewGrid(configuretView, evaluationParticipateTypeID, evaluationTypeID, evaluationTableID, evaluationNormID, (int)pararms.page, (int)pararms.rows));
  43. }
  44. /// <summary>
  45. /// 复制新增
  46. /// </summary>
  47. /// <param name="evaluationTargetID"></param>
  48. /// <returns></returns>
  49. public ActionResult CopyAdd(Guid evaluationTargetID)
  50. {
  51. EvaluationTargetView evaluationTargetView = new EvaluationTargetView();
  52. evaluationTargetView = EvaluationTargetServices.Value.GetEvaluationTargetView(evaluationTargetID);
  53. return View("Edit", evaluationTargetView);
  54. }
  55. /// <summary>
  56. /// 复制新增
  57. /// </summary>
  58. /// <param name="evaluationTargetView"></param>
  59. /// <returns></returns>
  60. [HttpPost]
  61. public ActionResult CopyAdd(EvaluationTargetView evaluationTargetView)
  62. {
  63. evaluationTargetView.EvaluationTargetID = Guid.Empty;
  64. return this.Edit(evaluationTargetView);
  65. }
  66. /// <summary>
  67. /// 编辑(新增、修改)
  68. /// </summary>
  69. /// <param name="evaluationTargetID"></param>
  70. /// <returns></returns>
  71. [HttpGet]
  72. public ActionResult Edit(Guid? evaluationTargetID)
  73. {
  74. EvaluationTargetView evaluationTargetView = new EvaluationTargetView();
  75. if (evaluationTargetID.HasValue && evaluationTargetID != Guid.Empty)
  76. {
  77. evaluationTargetView = EvaluationTargetServices.Value.GetEvaluationTargetView(evaluationTargetID);
  78. }
  79. return View(evaluationTargetView);
  80. }
  81. /// <summary>
  82. /// 编辑(新增、修改)
  83. /// </summary>
  84. /// <param name="evaluationTargetView"></param>
  85. /// <returns></returns>
  86. [HttpPost]
  87. public ActionResult Edit(EvaluationTargetView evaluationTargetView)
  88. {
  89. try
  90. {
  91. EvaluationTargetServices.Value.EvaluationTargetEdit(evaluationTargetView);
  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="evaluationTargetIDs"></param>
  111. /// <returns></returns>
  112. [HttpPost]
  113. public ActionResult Delete(string evaluationTargetIDs)
  114. {
  115. try
  116. {
  117. List<Guid?> list = evaluationTargetIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  118. EvaluationTargetServices.Value.EvaluationTargetDelete(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. /// 评价指标对应的评价项目
  137. /// </summary>
  138. /// <returns></returns>
  139. public ActionResult ProjectList()
  140. {
  141. return View();
  142. }
  143. /// <summary>
  144. /// 评价指标对应的评价项目
  145. /// </summary>
  146. /// <param name="pararms"></param>
  147. /// <returns></returns>
  148. [HttpPost]
  149. public ActionResult ProjectList(QueryParamsModel pararms)
  150. {
  151. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  152. var collegeID = Request["collegeID"].ParseStrTo<Guid>();
  153. var departmentID = pararms.getExtraGuid("DepartmentDropdown");
  154. var isPhotoUrl = pararms.getExtraInt("IsPhotoUrlDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsPhotoUrlDropdown");
  155. var teacherTypeID = pararms.getExtraInt("DictionaryTeacherType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTeacherType");
  156. var incumbencyState = pararms.getExtraInt("DictionaryIncumbencyState") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIncumbencyState");
  157. var titleID = pararms.getExtraInt("DictionaryTitle") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTitle");
  158. var isDualTeacher = pararms.getExtraInt("IsDualTeacherDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsDualTeacherDropdown");
  159. return null;
  160. //return base.Json(CollegeServices.GetStaffListViewGrid(configuretView, collegeID, departmentID, isPhotoUrl, teacherTypeID, incumbencyState, titleID, isDualTeacher, (int)pararms.page, (int)pararms.rows));
  161. }
  162. /// <summary>
  163. /// 评价指标对应的评价项目信息Excel导出
  164. /// </summary>
  165. /// <returns></returns>
  166. [HttpPost]
  167. public ActionResult ProjectListExcel()
  168. {
  169. return null;
  170. }
  171. /// <summary>
  172. /// Excel导出
  173. /// </summary>
  174. /// <returns></returns>
  175. [HttpPost]
  176. public ActionResult Excel()
  177. {
  178. NpoiExcelHelper neh = new NpoiExcelHelper();
  179. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  180. var evaluationParticipateTypeID = Request.Form["EvaluationParticipateTypeDropdown"].ParseStrTo<Guid>();
  181. var evaluationTypeID = Request.Form["EvaluationTypeDropdown"].ParseStrTo<Guid>();
  182. var evaluationTableID = Request.Form["EvaluationTableDropdown"].ParseStrTo<Guid>();
  183. var evaluationNormID = Request.Form["EvaluationNormDropdown"].ParseStrTo<Guid>();
  184. var dt = EvaluationTargetServices.Value.GetEvaluationTargetViewList(configuretView, evaluationParticipateTypeID, evaluationTypeID, evaluationTableID, evaluationNormID)
  185. .Select(x => new
  186. {
  187. x.OrderNo,
  188. x.Code,
  189. x.Name,
  190. x.EvaluationTableCode,
  191. x.EvaluationTableName,
  192. x.ParticipateTypeCode,
  193. x.ParticipateTypeName,
  194. x.IsStudentName,
  195. x.EvaluationTypeCode,
  196. x.EvaluationTypeName,
  197. x.TeachingModeIDListName,
  198. x.EvaluationNormName,
  199. x.NormTypeName,
  200. x.Weight,
  201. x.ProjectCount,
  202. x.Remark,
  203. x.CreateUserName,
  204. x.ModifyUserName,
  205. ModifyTime = x.ModifyTime == null ? null : x.ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss")
  206. }).ToTable();
  207. string[] liststring = {
  208. "次序", "指标编号", "指标名称", "评价表编号", "评价表名", "参评代码", "参评类型", "学生用", "评价类型编号",
  209. "评价类型", "授课方式", "评分标准", "评分类型", "权重", "项目个数", "备注", "创建人", "修改人", "修改时间"
  210. };
  211. neh.Export(dt, liststring, "评价指标信息" + DateTime.Now.ToString("yyyyMMdd"));
  212. return Json(new ReturnMessage()
  213. {
  214. IsSuccess = true,
  215. Message = "导出成功。"
  216. });
  217. }
  218. }
  219. }