MinorSpecialtyController.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.ViewModel;
  7. using EMIS.Web.Controls;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.CommonLogic.MinorManage.MinorPlanManage;
  10. using EMIS.ViewModel.MinorManage.MinorPlanManage;
  11. using Bowin.Common.Utility;
  12. using EMIS.Utility;
  13. using Bowin.Common.Data;
  14. namespace EMIS.Web.Controllers.MinorManage.MinorPlanManage
  15. {
  16. [Authorization]
  17. public class MinorSpecialtyController : Controller
  18. {
  19. //
  20. // GET: /MinorSpecialty/
  21. public IMinorSpecialtyServices MinorSpecialtyServices { get; set; }
  22. public ActionResult List()
  23. {
  24. return View();
  25. }
  26. [HttpPost]
  27. public ActionResult List(QueryParamsModel pararms)
  28. {
  29. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  30. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  31. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  32. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  33. var grademinorStatus = pararms.getExtraInt("GrademinorStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GrademinorStatusDictionaryDropDown");
  34. return this.Json(MinorSpecialtyServices.GetMinorSpecialtyViewGrid(configuretView, yearID, standardID, collegeID, grademinorStatus, (int)pararms.page, (int)pararms.rows));
  35. }
  36. /// <summary>
  37. /// 修改辅修计划的课程
  38. /// </summary>
  39. /// <returns></returns>
  40. [HttpGet]
  41. public ActionResult Edit(Guid? GrademinorID)
  42. {
  43. MinorSpecialtyView minorSpecialtyView = new MinorSpecialtyView();
  44. minorSpecialtyView = MinorSpecialtyServices.GetMinorSpecialtyView(GrademinorID);
  45. return View(minorSpecialtyView);
  46. }
  47. /// <summary>
  48. /// 开放
  49. /// </summary>
  50. /// <param name="MinorCourseIDs"></param>
  51. /// <returns></returns>
  52. [HttpPost]
  53. public ActionResult OpenMinorSpecialty(string GrademinorIDs)
  54. {
  55. try
  56. {
  57. List<Guid?> list = new List<Guid?>();
  58. for (int i = 0; i < GrademinorIDs.Split(',').Length; i++)
  59. {
  60. string id = GrademinorIDs.Split(',')[i];
  61. if (!string.IsNullOrEmpty(id))
  62. {
  63. Guid GrademinorID = new Guid(id);
  64. list.Add(GrademinorID);
  65. }
  66. }
  67. MinorSpecialtyServices.MinorSpecialtyOpen(list);
  68. return base.Json("开放成功");
  69. }
  70. catch (Exception ex)
  71. {
  72. string mge = ex.Message;
  73. return base.Json("开放失败,原因:" + ex);
  74. }
  75. }
  76. /// <summary>
  77. /// 取消开放
  78. /// </summary>
  79. /// <param name="MinorCourseIDs"></param>
  80. /// <returns></returns>
  81. [HttpPost]
  82. public ActionResult CancelMinorSpecialty(string GrademinorIDs)
  83. {
  84. try
  85. {
  86. List<Guid?> list = new List<Guid?>();
  87. for (int i = 0; i < GrademinorIDs.Split(',').Length; i++)
  88. {
  89. string id = GrademinorIDs.Split(',')[i];
  90. if (!string.IsNullOrEmpty(id))
  91. {
  92. Guid GrademinorID = new Guid(id);
  93. list.Add(GrademinorID);
  94. }
  95. }
  96. MinorSpecialtyServices.MinorSpecialtyCancel(list);
  97. return base.Json("取消开放成功");
  98. }
  99. catch (Exception ex)
  100. {
  101. string mge = ex.Message;
  102. return base.Json("取消开放失败,原因:" + ex);
  103. }
  104. }
  105. [HttpPost]
  106. public ActionResult OpenClass(string grademinorIDs)
  107. {
  108. try
  109. {
  110. List<Guid?> list = new List<Guid?>();
  111. for (int i = 0; i < grademinorIDs.Split(',').Length; i++)
  112. {
  113. string id = grademinorIDs.Split(',')[i];
  114. if (!string.IsNullOrEmpty(id))
  115. {
  116. Guid grademinorID = new Guid(id);
  117. list.Add(grademinorID);
  118. }
  119. }
  120. MinorSpecialtyServices.OpenClass(list);
  121. return base.Json("开班成功");
  122. }
  123. catch (Exception ex)
  124. {
  125. string mge = ex.Message;
  126. return base.Json("开班失败,原因:" + mge);
  127. }
  128. }
  129. [HttpPost]
  130. public ActionResult OpenCancel(string grademinorIDs)
  131. {
  132. try
  133. {
  134. List<Guid?> list = new List<Guid?>();
  135. for (int i = 0; i < grademinorIDs.Split(',').Length; i++)
  136. {
  137. string id = grademinorIDs.Split(',')[i];
  138. if (!string.IsNullOrEmpty(id))
  139. {
  140. Guid grademinorID = new Guid(id);
  141. list.Add(grademinorID);
  142. }
  143. }
  144. MinorSpecialtyServices.CancelClass(list);
  145. return base.Json("取消开班成功");
  146. }
  147. catch (Exception ex)
  148. {
  149. string mge = ex.Message;
  150. return base.Json("取消开班失败,原因:" + mge);
  151. }
  152. }
  153. [HttpGet]
  154. public ActionResult StudentList(Guid grademinorID)
  155. {
  156. ViewBag.GrademinorID = grademinorID;
  157. return View();
  158. }
  159. [HttpPost]
  160. public ActionResult GetStudentList()
  161. {
  162. var grademinorID = Request["grademinorID"].ParseStrTo<Guid>();
  163. return base.Json(MinorSpecialtyServices.GetStudentsByGrademinorID(grademinorID.Value));
  164. }
  165. /// <summary>
  166. /// 导出Excel
  167. /// </summary>
  168. /// <returns></returns>
  169. [HttpPost]
  170. public ActionResult Excel()
  171. {
  172. NpoiExcelHelper neh = new NpoiExcelHelper();
  173. var GrademinorID = Request.Form["GrademinorID"];
  174. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  175. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  176. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  177. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  178. var grademinorStatus =Request.Form["GrademinorStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["GrademinorStatusDictionaryDropDown"].ParseStrTo<int>();
  179. List<Guid?> GrademinorIDList = new List<Guid?>();
  180. if (GrademinorID != "")
  181. {
  182. GrademinorIDList = GrademinorID.SplitIDString();
  183. }
  184. else
  185. {
  186. GrademinorIDList = null;
  187. }
  188. var dt = MinorSpecialtyServices.GetMinorSpecialtyViewList(configuretView, yearID, standardID, collegeID, grademinorStatus, GrademinorIDList).Select(x => new
  189. {
  190. x.YearID,
  191. x.StandardCode,
  192. x.StandardName,
  193. x.CollegeName,
  194. x.StudentLimit,
  195. x.CreateTime,
  196. x.CreateUserName,
  197. x.OpenStatusStr
  198. }).ToTable();
  199. string[] liststring = { "年级", "专业代码", "专业名称", RSL.Get("College"), "人数上限","申请时间",
  200. "申请人","状态"};
  201. neh.Export(dt, liststring, "辅修专业信息");
  202. return Json(new ReturnMessage()
  203. {
  204. IsSuccess = true,
  205. Message = "导出成功。"
  206. });
  207. }
  208. }
  209. }