EvaluationTableController.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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 EvaluationTableController : Controller
  19. {
  20. public Lazy<IEvaluationTableServices> EvaluationTableServices { 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 isStudent = pararms.getExtraInt("IsStudentDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsStudentDropdown");
  41. var isEnabled = pararms.getExtraInt("IsEnabledDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsEnabledDropdown");
  42. return base.Json(EvaluationTableServices.Value.GetEvaluationTableViewGrid(configuretView, evaluationParticipateTypeID, evaluationTypeID, isStudent, isEnabled, (int)pararms.page, (int)pararms.rows));
  43. }
  44. /// <summary>
  45. /// 评价表名列表查询(启用状态为是或已使用)
  46. /// </summary>
  47. /// <param name="pararms"></param>
  48. /// <returns></returns>
  49. [HttpPost]
  50. public ActionResult GetEvaluationTableEnabledAndUseList(QueryParamsModel pararms)
  51. {
  52. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  53. var evaluationTableID = Request["evaluationTableID"].ParseStrTo<Guid>();
  54. var evaluationParticipateTypeID = pararms.getExtraGuid("EvaluationParticipateTypeDropdown");
  55. var evaluationTypeID = pararms.getExtraGuid("EvaluationTypeDropdown");
  56. return base.Json(EvaluationTableServices.Value.GetEnabledAndUseEvaluationTableViewGrid(configuretView, evaluationTableID, evaluationParticipateTypeID, evaluationTypeID, (int)pararms.page, (int)pararms.rows));
  57. }
  58. /// <summary>
  59. /// 复制新增
  60. /// </summary>
  61. /// <param name="evaluationTableID"></param>
  62. /// <returns></returns>
  63. public ActionResult CopyAdd(Guid evaluationTableID)
  64. {
  65. var evaluationTableView = new EvaluationTableView();
  66. evaluationTableView = EvaluationTableServices.Value.GetEvaluationTableView(evaluationTableID);
  67. return View("Edit", evaluationTableView);
  68. }
  69. /// <summary>
  70. /// 复制新增
  71. /// </summary>
  72. /// <param name="evaluationTableView"></param>
  73. /// <returns></returns>
  74. [HttpPost]
  75. public ActionResult CopyAdd(EvaluationTableView evaluationTableView)
  76. {
  77. evaluationTableView.EvaluationTableID = Guid.Empty;
  78. return this.Edit(evaluationTableView);
  79. }
  80. /// <summary>
  81. /// 编辑(新增、修改)
  82. /// </summary>
  83. /// <param name="evaluationTableID"></param>
  84. /// <returns></returns>
  85. [HttpGet]
  86. public ActionResult Edit(Guid? evaluationTableID)
  87. {
  88. var evaluationTableView = new EvaluationTableView();
  89. if (evaluationTableID.HasValue && evaluationTableID != Guid.Empty)
  90. {
  91. evaluationTableView = EvaluationTableServices.Value.GetEvaluationTableView(evaluationTableID);
  92. }
  93. else
  94. {
  95. evaluationTableView.IsEnabled = true;
  96. }
  97. return View(evaluationTableView);
  98. }
  99. /// <summary>
  100. /// 编辑(新增、修改)
  101. /// </summary>
  102. /// <param name="evaluationTableView"></param>
  103. /// <returns></returns>
  104. [HttpPost]
  105. public ActionResult Edit(EvaluationTableView evaluationTableView)
  106. {
  107. try
  108. {
  109. EvaluationTableServices.Value.EvaluationTableEdit(evaluationTableView);
  110. return Json(new ReturnMessage()
  111. {
  112. IsSuccess = true,
  113. Message = "保存成功。"
  114. });
  115. }
  116. catch (Exception ex)
  117. {
  118. return Json(new ReturnMessage()
  119. {
  120. IsSuccess = false,
  121. Message = "保存失败,原因:" + ex.Message
  122. });
  123. }
  124. }
  125. /// <summary>
  126. /// 删除
  127. /// </summary>
  128. /// <param name="evaluationTableIDs"></param>
  129. /// <returns></returns>
  130. [HttpPost]
  131. public ActionResult Delete(string evaluationTableIDs)
  132. {
  133. try
  134. {
  135. List<Guid?> list = evaluationTableIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  136. EvaluationTableServices.Value.EvaluationTableDelete(list);
  137. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  138. }
  139. catch (Exception ex)
  140. {
  141. string mge = ex.Message;
  142. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  143. if (num != null)
  144. {
  145. if (num.Number == 547)
  146. {
  147. mge = "请先删除所有关联的数据,如:评价设定、评价项目、评价指标等。";
  148. }
  149. }
  150. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + mge });
  151. }
  152. }
  153. /// <summary>
  154. /// 评价表对应的评价指标
  155. /// </summary>
  156. /// <returns></returns>
  157. public ActionResult TargetList()
  158. {
  159. return View();
  160. }
  161. /// <summary>
  162. /// 评价表对应的评价指标
  163. /// </summary>
  164. /// <param name="pararms"></param>
  165. /// <returns></returns>
  166. [HttpPost]
  167. public ActionResult TargetList(QueryParamsModel pararms)
  168. {
  169. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  170. var collegeID = Request["collegeID"].ParseStrTo<Guid>();
  171. return null;
  172. //return Json(CollegeServices.GetDepartmentListViewGrid(configuretView, collegeID, (int)pararms.page, (int)pararms.rows));
  173. }
  174. /// <summary>
  175. /// 评价表对应的评价指标信息Excel导出
  176. /// </summary>
  177. /// <returns></returns>
  178. [HttpPost]
  179. public ActionResult TargetListExcel()
  180. {
  181. return null;
  182. }
  183. /// <summary>
  184. /// 评价表对应的评价项目
  185. /// </summary>
  186. /// <returns></returns>
  187. public ActionResult ProjectList()
  188. {
  189. return View();
  190. }
  191. /// <summary>
  192. /// 评价表对应的评价项目
  193. /// </summary>
  194. /// <param name="pararms"></param>
  195. /// <returns></returns>
  196. [HttpPost]
  197. public ActionResult ProjectList(QueryParamsModel pararms)
  198. {
  199. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  200. var collegeID = Request["collegeID"].ParseStrTo<Guid>();
  201. var departmentID = pararms.getExtraGuid("DepartmentDropdown");
  202. var isPhotoUrl = pararms.getExtraInt("IsPhotoUrlDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsPhotoUrlDropdown");
  203. var teacherTypeID = pararms.getExtraInt("DictionaryTeacherType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTeacherType");
  204. var incumbencyState = pararms.getExtraInt("DictionaryIncumbencyState") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIncumbencyState");
  205. var titleID = pararms.getExtraInt("DictionaryTitle") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTitle");
  206. var isDualTeacher = pararms.getExtraInt("IsDualTeacherDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsDualTeacherDropdown");
  207. return null;
  208. //return base.Json(CollegeServices.GetStaffListViewGrid(configuretView, collegeID, departmentID, isPhotoUrl, teacherTypeID, incumbencyState, titleID, isDualTeacher, (int)pararms.page, (int)pararms.rows));
  209. }
  210. /// <summary>
  211. /// 评价表对应的评价项目信息Excel导出
  212. /// </summary>
  213. /// <returns></returns>
  214. [HttpPost]
  215. public ActionResult ProjectListExcel()
  216. {
  217. return null;
  218. }
  219. /// <summary>
  220. /// Excel导出
  221. /// </summary>
  222. /// <returns></returns>
  223. [HttpPost]
  224. public ActionResult Excel()
  225. {
  226. NpoiExcelHelper neh = new NpoiExcelHelper();
  227. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  228. var evaluationParticipateTypeID = Request.Form["EvaluationParticipateTypeDropdown"].ParseStrTo<Guid>();
  229. var evaluationTypeID = Request.Form["EvaluationTypeDropdown"].ParseStrTo<Guid>();
  230. var isStudent = Request.Form["IsStudentDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsStudentDropdown"].ParseStrTo<int>();
  231. var isEnabled = Request.Form["IsEnabledDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsEnabledDropdown"].ParseStrTo<int>();
  232. var dt = EvaluationTableServices.Value.GetEvaluationTableViewList(configuretView, evaluationParticipateTypeID, evaluationTypeID, isStudent, isEnabled)
  233. .Select(x => new
  234. {
  235. x.Code,
  236. x.Name,
  237. x.ParticipateTypeCode,
  238. x.ParticipateTypeName,
  239. x.IsStudentName,
  240. x.EvaluationTypeCode,
  241. x.EvaluationTypeName,
  242. x.TeachingModeIDListName,
  243. x.Weight,
  244. x.TargetCount,
  245. x.ProjectCount,
  246. x.IsEnabledName,
  247. x.Remark,
  248. x.CreateUserName,
  249. x.ModifyUserName,
  250. ModifyTime = x.ModifyTime == null ? null : x.ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss")
  251. }).ToTable();
  252. string[] liststring = {
  253. "编号", "评价表名", "参评代码", "参评类型", "学生用", "评价类型编号", "评价类型", "授课方式",
  254. "权重", "指标个数", "项目个数", "是否启用", "备注", "创建人", "修改人", "修改时间"
  255. };
  256. neh.Export(dt, liststring, "评价表名信息" + DateTime.Now.ToString("yyyyMMdd"));
  257. return Json(new ReturnMessage()
  258. {
  259. IsSuccess = true,
  260. Message = "导出成功。"
  261. });
  262. }
  263. }
  264. }