ExaminationSubjectCountLimitController.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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.Common.Exceptions;
  13. namespace EMIS.Web.Controllers.ExaminationApply
  14. {
  15. [Authorization]
  16. public class ExaminationSubjectCountLimitController : Controller
  17. {
  18. public ISubjectCountLimitServices SubjectCountLimitServices { get; set; }
  19. /// <summary>
  20. /// 专业控制页面
  21. /// </summary>
  22. /// <returns></returns>
  23. public ActionResult List()
  24. {
  25. return View();
  26. }
  27. public ActionResult Add()
  28. {
  29. SubjectCountLimitView subjectCountLimitView = new SubjectCountLimitView();
  30. return View(subjectCountLimitView);
  31. }
  32. [HttpPost]
  33. public ActionResult Add(SubjectCountLimitView subjectCountLimitView)
  34. {
  35. try
  36. {
  37. if (subjectCountLimitView.FacultymajorID == null)
  38. return Json(new ReturnMessage()
  39. {
  40. IsSuccess = false,
  41. Message = "请选择院系专业!"
  42. });
  43. var facultymajorString = Request.Form["FacultymajorID"];
  44. var facultymajorIDList = facultymajorString.Split(',').Where(x => x.IndexOf("-") >= 0).Select(x => new Guid(x)).ToList();
  45. foreach (var facultymajorID in facultymajorIDList)
  46. {
  47. subjectCountLimitView.FacultymajorID = facultymajorID;
  48. SubjectCountLimitServices.Save(subjectCountLimitView);
  49. }
  50. return Json(new ReturnMessage()
  51. {
  52. IsSuccess = true,
  53. Message = "保存成功!"
  54. });
  55. }
  56. catch (Exception ex)
  57. {
  58. return Json(new ReturnMessage()
  59. {
  60. IsSuccess = false,
  61. Message = "保存失败:" + ex.Message
  62. });
  63. }
  64. }
  65. public ActionResult Edit(Guid? SubjectCountLimitID)
  66. {
  67. SubjectCountLimitView subjectCountLimitView = new SubjectCountLimitView();
  68. if (SubjectCountLimitID != null && SubjectCountLimitID != Guid.Empty)
  69. {
  70. subjectCountLimitView = SubjectCountLimitServices.GetSubjectCountLimitViewInfo(SubjectCountLimitID);
  71. }
  72. return View(subjectCountLimitView);
  73. }
  74. /// <summary>
  75. /// 列表查询
  76. /// </summary>
  77. /// <param name="pararms"></param>
  78. /// <returns></returns>
  79. [HttpPost]
  80. public ActionResult List(QueryParamsModel pararms)
  81. {
  82. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  83. var examinationTypeID = pararms.getExtraGuid("ExaminationTypeDropdown");
  84. var facultymajorID = pararms.getExtraGuid("FacultymajorDropdown");
  85. var yearNum = pararms.getExtraInt("YearNumDropdown") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YearNumDropdown");
  86. if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  87. return base.Json(SubjectCountLimitServices.GetSubjectCountLimitViewList(configuretView, examinationTypeID, facultymajorID, yearNum, (int)pararms.page, (int)pararms.rows));
  88. }
  89. [HttpPost]
  90. public ActionResult Excel()
  91. {
  92. NpoiExcelHelper neh = new NpoiExcelHelper();
  93. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  94. var examinationTypeID = Request.Form["ExaminationTypeDropdown"].ParseStrTo<Guid>();
  95. var facultymajorID = Request.Form["FacultymajorDropdown"].ParseStrTo<Guid>();
  96. if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  97. var dt = SubjectCountLimitServices.GetSubjectCountLimitViewList(configuretView, examinationTypeID, facultymajorID).Select(x => new
  98. {
  99. x.ExaminationTypeName,
  100. x.FacultymajorName,
  101. x.SchoolyearNumName,
  102. x.SubjectCountLimit
  103. }).ToTable();
  104. string[] liststring = { "考试类型", "院系专业", "年级数", "报名门数" };
  105. neh.Export(dt, liststring, "门数限定信息");
  106. return RedirectToAction("MsgShow", "Common", new
  107. {
  108. msg = "导出成功!",
  109. url = Url.Content("~/SubjectCountLimit/List").AddMenuParameter()
  110. });
  111. }
  112. /// <summary>
  113. /// 删除
  114. /// </summary>
  115. /// <param name="roleID"></param>
  116. /// <returns></returns>
  117. [HttpPost]
  118. public ActionResult Delete(string subjectCountLimitIDs)
  119. {
  120. try
  121. {
  122. var subjectCountLimitIDList = subjectCountLimitIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
  123. SubjectCountLimitServices.Delete(subjectCountLimitIDList);
  124. return base.Json("删除成功");
  125. }
  126. catch (Exception ex)
  127. {
  128. return base.Json("删除失败,原因:" + ex.Message + "!");
  129. }
  130. }
  131. /// <summary>
  132. /// 修改
  133. /// </summary>
  134. /// <returns></returns>
  135. [HttpPost]
  136. public ActionResult Edit(SubjectCountLimitView subjectCountLimitView)
  137. {
  138. try
  139. {
  140. if (subjectCountLimitView.FacultymajorID == null)
  141. return Json(new ReturnMessage()
  142. {
  143. IsSuccess = false,
  144. Message = "请选择院系专业!"
  145. });
  146. SubjectCountLimitServices.Save(subjectCountLimitView);
  147. return Json(new ReturnMessage()
  148. {
  149. IsSuccess = true,
  150. Message = "保存成功!"
  151. });
  152. }
  153. catch (Exception ex)
  154. {
  155. return Json(new ReturnMessage()
  156. {
  157. IsSuccess = false,
  158. Message = "保存失败:" + ex.Message
  159. });
  160. }
  161. }
  162. public ActionResult Validation(Guid? examinationType, string facultymajorIDs, string years)
  163. {
  164. List<Guid?> list = new List<Guid?>();
  165. foreach (var i in facultymajorIDs.Split(','))
  166. {
  167. list.Add(new Guid(i));
  168. }
  169. List<int?> list1 = new List<int?>();
  170. foreach (var i in years.Split(','))
  171. {
  172. list1.Add(Convert.ToInt32(i));
  173. }
  174. string [] result=SubjectCountLimitServices.Validation(examinationType, list, list1);
  175. return Json(new ReturnMessage()
  176. {
  177. IsSuccess = result[0] == "true" ? true : false,
  178. Message = result[1]
  179. });
  180. }
  181. }
  182. }