MinorClassController.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 EMIS.CommonLogic.MinorManage.MinorClass;
  9. using Bowin.Web.Controls.Mvc;
  10. using Bowin.Common.Utility;
  11. using Bowin.Common.Data;
  12. namespace EMIS.Web.Controllers.MinorManage.MinorClass
  13. {
  14. [Authorization]
  15. public class MinorClassController : Controller
  16. {
  17. //
  18. // GET: /MinorClass/
  19. public IMinorClassServices minorClassServices { get; set; }
  20. public ActionResult List()
  21. {
  22. return View();
  23. }
  24. [HttpPost]
  25. public ActionResult List(QueryParamsModel pararms)
  26. {
  27. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  28. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  29. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  30. var standardID = pararms.getExtraInt("MinorStandardDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("MinorStandardDropDown");
  31. var classminorStatus = pararms.getExtraInt("DictionaryClassminorStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryClassminorStatus");
  32. return base.Json(minorClassServices.GetMinorClassViewGrid(configuretView, collegeID, yearID, standardID, classminorStatus, (int)pararms.page, (int)pararms.rows));
  33. }
  34. [HttpPost]
  35. public ActionResult Excel()
  36. {
  37. NpoiExcelHelper neh = new NpoiExcelHelper();
  38. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  39. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  40. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  41. var standardID = Request.Form["MinorStandardDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["MinorStandardDropDown"].ParseStrTo<int>();
  42. var classminorStatus = Request.Form["DictionaryClassminorStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryClassminorStatus"].ParseStrTo<int>();
  43. var minorClassIDString = Request.Form["SelectedID"];
  44. var minorClassIDList = minorClassIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  45. var dt = minorClassServices.GetMinorClassViewList(configuretView, collegeID, yearID, standardID, classminorStatus, minorClassIDList)
  46. .Select(x => new
  47. {
  48. x.SchoolyearCode,
  49. x.GradeYearID,
  50. x.StandardCode,
  51. x.StandardName,
  52. x.Name,
  53. x.StudentNum,
  54. x.RecordStatus,
  55. }).ToTable();
  56. string[] liststring = { "学年学期", "年级", "专业代码", "专业名称", "辅修班级", "学生人数", "状态" };
  57. neh.Export(dt, liststring, "辅修班级信息" + DateTime.Now.ToString("yyyyMMdd"));
  58. return Json(new ReturnMessage()
  59. {
  60. IsSuccess = true,
  61. Message = "导出成功。"
  62. });
  63. }
  64. [HttpPost]
  65. public ActionResult Delete(string minorClassIDs)
  66. {
  67. try
  68. {
  69. List<Guid?> list = minorClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  70. .Select(x => (Guid?)new Guid(x)).ToList();
  71. minorClassServices.MinorClassDelete(list);
  72. return base.Json("删除成功。");
  73. }
  74. catch (Exception ex)
  75. {
  76. return base.Json("删除失败,原因:" + ex.Message + "。");
  77. }
  78. }
  79. [HttpPost]
  80. public ActionResult Generate()
  81. {
  82. try
  83. {
  84. minorClassServices.GenerateMinorClass();
  85. return base.Json("生成成功。");
  86. }
  87. catch (Exception ex)
  88. {
  89. return base.Json("生成失败,原因:" + ex.Message + "。");
  90. }
  91. }
  92. [HttpGet]
  93. public ActionResult StudentList(Guid minorClassID)
  94. {
  95. ViewBag.MinorClassID = minorClassID;
  96. return View();
  97. }
  98. [HttpPost]
  99. public ActionResult GetStudentList()
  100. {
  101. var minorClassID = Request["minorClassID"].ParseStrTo<Guid>();
  102. return base.Json(minorClassServices.GetStudentsByMinorClassID(minorClassID.Value));
  103. }
  104. public ActionResult OpenClass(string minorClassIDs)
  105. {
  106. try
  107. {
  108. List<Guid?> list = minorClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  109. .Select(x => (Guid?)new Guid(x)).ToList();
  110. minorClassServices.OpenClassMinor(list);
  111. return base.Json("开班成功。");
  112. }
  113. catch (Exception ex)
  114. {
  115. return base.Json("开班失败,原因:" + ex.Message + "。");
  116. }
  117. }
  118. public ActionResult CancelOpenClass(string minorClassIDs)
  119. {
  120. try
  121. {
  122. List<Guid?> list = minorClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  123. .Select(x => (Guid?)new Guid(x)).ToList();
  124. minorClassServices.CancelOpenClassMinor(list);
  125. return base.Json("取消开班成功。");
  126. }
  127. catch (Exception ex)
  128. {
  129. return base.Json("取消开班失败,原因:" + ex.Message + "。");
  130. }
  131. }
  132. }
  133. }