ExaminationSubjectCollegeControlController.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.SelectCourse;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMIS.ViewModel.SelectCourse;
  11. using Bowin.Common.Utility;
  12. using Bowin.Common.Data;
  13. namespace EMIS.Web.Controllers.SelectCourseManage
  14. {
  15. [Authorization]
  16. public class ExaminationSubjectCollegeControlController : Controller
  17. {
  18. //
  19. // GET: /ExaminationSubjectCollegeControl/
  20. public IExaminationSubjectCollegeControlServices examinationSubjectCollegeControlServices { get; set; }
  21. public ActionResult List()
  22. {
  23. return View();
  24. }
  25. [HttpPost]
  26. public ActionResult List(QueryParamsModel pararms)
  27. {
  28. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  29. var examinationTypeID = pararms.getExtraGuid("ExaminationTypeDropdown");
  30. var examinationSubjectID = pararms.getExtraGuid("ExaminationSubjectDropdown");
  31. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  32. var facultymajorID = pararms.getExtraGuid("FacultymajorDropdown");
  33. int? schoolyearNumID = pararms.getExtraInt("SchoolyearNumDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearNumDropDown");
  34. return base.Json(examinationSubjectCollegeControlServices.GetExaminationSubjectCollegeControlViewGrid(configuretView, examinationTypeID, examinationSubjectID, collegeID, facultymajorID, schoolyearNumID, (int)pararms.page, (int)pararms.rows));
  35. }
  36. [HttpGet]
  37. public ActionResult Add()
  38. {
  39. ExaminationSubjectCollegeControlView examinationSubjectCollegeControlView = new ExaminationSubjectCollegeControlView();
  40. return View(examinationSubjectCollegeControlView);
  41. }
  42. [HttpPost]
  43. public ActionResult Add(ExaminationSubjectCollegeControlView examinationSubjectCollegeControlView)
  44. {
  45. try
  46. {
  47. var facultymajorString = Request.Form["selectFacultymajorIDs"];
  48. if (facultymajorString == "" || facultymajorString == null)
  49. {
  50. throw new Exception("请选择院系专业信息");
  51. }
  52. var facultymajorIDList = facultymajorString.Split(',').Where(x => x.IndexOf("-") >= 0).Select(x => new Guid(x)).ToList();
  53. examinationSubjectCollegeControlServices.ExaminationSubjectCollegeControlAdd(examinationSubjectCollegeControlView, facultymajorIDList);
  54. return Json(new ReturnMessage()
  55. {
  56. IsSuccess = true,
  57. Message = "保存成功!"
  58. });
  59. }
  60. catch (Exception ex)
  61. {
  62. return Json(new ReturnMessage()
  63. {
  64. IsSuccess = false,
  65. Message = "保存失败:" + ex.Message
  66. });
  67. }
  68. }
  69. /// <summary>
  70. /// 修改
  71. /// </summary>
  72. /// <param name="examinationSubjectCollegeControlID"></param>
  73. /// <returns></returns>
  74. [HttpGet]
  75. public ActionResult Edit(Guid? examinationSubjectCollegeControlID)
  76. {
  77. ExaminationSubjectCollegeControlView examinationSubjectCollegeControlView = new ExaminationSubjectCollegeControlView();
  78. if (examinationSubjectCollegeControlID.HasValue)
  79. {
  80. examinationSubjectCollegeControlView = examinationSubjectCollegeControlServices.GetExaminationSubjectCollegeControlView(examinationSubjectCollegeControlID);
  81. }
  82. return View(examinationSubjectCollegeControlView);
  83. }
  84. /// <summary>
  85. /// 修改
  86. /// </summary>
  87. /// <param name="graduationApplyView"></param>
  88. /// <returns></returns>
  89. [HttpPost]
  90. public ActionResult Edit(ExaminationSubjectCollegeControlView examinationSubjectCollegeControlView)
  91. {
  92. try
  93. {
  94. examinationSubjectCollegeControlServices.ExaminationSubjectCollegeControlEdit(examinationSubjectCollegeControlView);
  95. return Json(new ReturnMessage()
  96. {
  97. IsSuccess = true,
  98. Message = "保存成功。"
  99. });
  100. }
  101. catch (Exception ex)
  102. {
  103. return Json(new ReturnMessage()
  104. {
  105. IsSuccess = false,
  106. Message = "保存失败,原因:" + ex.Message
  107. });
  108. }
  109. }
  110. [HttpPost]
  111. public ActionResult Delete(string examinationSubjectCollegeControlIDs)
  112. {
  113. try
  114. {
  115. List<Guid?> list = examinationSubjectCollegeControlIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  116. .Select(x => (Guid?)new Guid(x)).ToList();
  117. examinationSubjectCollegeControlServices.ExaminationSubjectCollegeControlDelete(list);
  118. return base.Json("删除成功。");
  119. }
  120. catch (Exception ex)
  121. {
  122. return base.Json("删除失败,原因:" + ex.Message);
  123. }
  124. }
  125. [HttpPost]
  126. public ActionResult Excel()
  127. {
  128. NpoiExcelHelper neh = new NpoiExcelHelper();
  129. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  130. var examinationTypeID = Request.Form["ExaminationTypeDropdown"].ParseStrTo<Guid>();
  131. var examinationSubjectID = Request.Form["ExaminationSubjectDropdown"].ParseStrTo<Guid>();
  132. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  133. var facultymajorID = Request.Form["FacultymajorDropdown"].ParseStrTo<Guid>();
  134. int? schoolyearNumID = Request["SchoolyearNumDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["SchoolyearNumDropDown"].ParseStrTo<int>();
  135. var examinationSubjectCollegeControlIDString = Request.Form["SelectedID"];
  136. var examinationSubjectCollegeControlIDList = examinationSubjectCollegeControlIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  137. var dt = examinationSubjectCollegeControlServices.GetExaminationSubjectCollegeControlViewList(configuretView, examinationTypeID, examinationSubjectID, collegeID, facultymajorID, schoolyearNumID, examinationSubjectCollegeControlIDList)
  138. .Select(x => new
  139. {
  140. x.ExaminationTypeName,
  141. x.ExaminationSubjectName,
  142. x.CollegeName,
  143. x.FacultymajorName,
  144. x.SchoolyearNum
  145. }).ToTable();
  146. string[] liststring = { "考试类型", "考试科目", @EMIS.Utility.RSL.Get("College"), "院系专业", "年级数" };
  147. neh.Export(dt, liststring, "专业报考限制" + DateTime.Now.ToString("yyyyMMdd"));
  148. return Json(new ReturnMessage()
  149. {
  150. IsSuccess = true,
  151. Message = "导出成功。"
  152. });
  153. }
  154. }
  155. }