ExaminationOpenControlController.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.CommonLogic.ExaminationApply;
  7. using EMIS.ViewModel.ExaminationApply;
  8. using EMIS.ViewModel;
  9. using EMIS.Web.Controls;
  10. using Bowin.Common.Data;
  11. using Bowin.Common.Utility;
  12. using Bowin.Web.Controls.Mvc;
  13. namespace EMIS.Web.Controllers.ExaminationApply
  14. {
  15. [Authorization]
  16. public class ExaminationOpenControlController : Controller
  17. {
  18. public IOpenControlServices OpenControlServices { get; set; }
  19. /// <summary>
  20. /// 科目控制页面
  21. /// </summary>
  22. /// <returns></returns>
  23. public ActionResult List()
  24. {
  25. return View();
  26. }
  27. public ActionResult Edit(Guid? OpenControlID)
  28. {
  29. OpenControlView openControlView = new OpenControlView();
  30. if (OpenControlID != null && OpenControlID != Guid.Empty)
  31. {
  32. openControlView = OpenControlServices.GetOpenControlViewInfo(OpenControlID);
  33. }
  34. return View(openControlView);
  35. }
  36. /// <summary>
  37. /// 列表查询
  38. /// </summary>
  39. /// <param name="pararms"></param>
  40. /// <returns></returns>
  41. [HttpPost]
  42. public ActionResult List(QueryParamsModel pararms)
  43. {
  44. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  45. var examinationTypeID = pararms.getExtraGuid("ExaminationTypeDropdown");
  46. var examinationSubjectID = pararms.getExtraGuid("ExaminationSubjectDropdown");
  47. var yearNum = pararms.getExtraInt("YearNumDropdown") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YearNumDropdown");
  48. var studentType = pararms.getExtraInt("StudentTypeDropdown") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StudentTypeDropdown");
  49. if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  50. return base.Json(OpenControlServices.GetOpenControlViewList(configuretView, examinationTypeID, examinationSubjectID, yearNum, studentType,
  51. (int)pararms.page, (int)pararms.rows));
  52. }
  53. [HttpPost]
  54. public ActionResult Excel()
  55. {
  56. NpoiExcelHelper neh = new NpoiExcelHelper();
  57. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  58. var examinationTypeID = Request.Form["ExaminationTypeDropdown"].ParseStrTo<Guid>();
  59. var examinationSubjectID = Request.Form["ExaminationSubjectDropdown"].ParseStrTo<Guid>();
  60. var yearNum = Request.Form["YearNumDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["YearNumDropdown"].ParseStrTo<int>();
  61. var studentType = Request.Form["StudentTypeDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StudentTypeDropdown"].ParseStrTo<int>();
  62. if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  63. var dt = OpenControlServices.GetOpenControlViewList(configuretView, examinationTypeID, examinationSubjectID, yearNum, studentType).Select(x => new
  64. {
  65. x.ExaminationSubjectName,
  66. x.StudentTypeDesc,
  67. x.SchoolyearNumName,
  68. StartDate = (x.StartDate.HasValue ? x.StartDate.Value.ToString("yyyy-MM-dd") : ""),
  69. EndDate = (x.EndDate.HasValue ? x.EndDate.Value.ToString("yyyy-MM-dd") : ""),
  70. x.PeopleNumLimit
  71. }).ToTable();
  72. string[] liststring = { "考试科目", "学生类别", "年级数", "报名时间起", "报名时间止", "限定人数" };
  73. neh.Export(dt, liststring, "开放控制信息");
  74. return RedirectToAction("MsgShow", "Common", new
  75. {
  76. msg = "导出成功!",
  77. url = Url.Content("~/ExaminationOpenControl/List").AddMenuParameter()
  78. });
  79. }
  80. /// <summary>
  81. /// 删除
  82. /// </summary>
  83. /// <param name="roleID"></param>
  84. /// <returns></returns>
  85. [HttpPost]
  86. public ActionResult Delete(string openControlIDs)
  87. {
  88. try
  89. {
  90. var openControlIDList = openControlIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
  91. OpenControlServices.Delete(openControlIDList);
  92. return base.Json("删除成功");
  93. }
  94. catch (Exception ex)
  95. {
  96. return base.Json("删除失败,原因:" + ex.Message + "!");
  97. }
  98. }
  99. /// <summary>
  100. /// 修改
  101. /// </summary>
  102. /// <returns></returns>
  103. [HttpPost]
  104. public ActionResult Edit(OpenControlView openControlView)
  105. {
  106. try
  107. {
  108. if (openControlView.StudentTypeID == null && openControlView.ExaminationOpenControlID != null)
  109. {
  110. return Json(new ReturnMessage()
  111. {
  112. IsSuccess = false,
  113. Message = "请选择学生类别!"
  114. });
  115. }
  116. if (openControlView.StudentTypeID.Count > 1 && openControlView.ExaminationOpenControlID!=null)
  117. {
  118. return Json(new ReturnMessage()
  119. {
  120. IsSuccess = false,
  121. Message = "修改操作只能选择一种学生类别!"
  122. });
  123. }
  124. if (openControlView.StudentTypeID == null && openControlView.ExaminationOpenControlID==null)
  125. return Json(new ReturnMessage()
  126. {
  127. IsSuccess = false,
  128. Message = "请选择学生类别!"
  129. });
  130. if (openControlView.ExaminationSubjectEditID == null && openControlView.ExaminationOpenControlID != null)
  131. return Json(new ReturnMessage()
  132. {
  133. IsSuccess = false,
  134. Message = "请选择考试科目!"
  135. });
  136. OpenControlServices.Save(openControlView);
  137. return Json(new ReturnMessage()
  138. {
  139. IsSuccess = true,
  140. Message = "保存成功!"
  141. });
  142. }
  143. catch (Exception ex)
  144. {
  145. return Json(new ReturnMessage()
  146. {
  147. IsSuccess = false,
  148. Message = "保存失败:" + ex.Message
  149. });
  150. }
  151. }
  152. /// <summary>
  153. /// 获取已经存在在学生类别
  154. /// </summary>
  155. /// <param name="specialtyCourseID"></param>
  156. /// <returns></returns>
  157. [HttpPost]
  158. public ActionResult StudentType(Guid? openControlID)
  159. {
  160. List<string> list = new List<string>();
  161. if (openControlID.HasValue && openControlID != Guid.Empty)
  162. list = OpenControlServices.GetStudentType(openControlID);
  163. return base.Json(list);
  164. }
  165. }
  166. }