SelectCourseListController.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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.SelectCourseResult;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using Bowin.Web.Controls.Mvc;
  10. using Bowin.Common.Utility;
  11. using Bowin.Common.Data;
  12. namespace EMIS.Web.Controllers.SelectCourseManage.SelectCourseResult
  13. {
  14. [Authorization]
  15. public class SelectCourseListController : Controller
  16. {
  17. public ISelectCourseListServices SelectCourseListServices { get; set; }
  18. /// <summary>
  19. /// 选课结果学生名单页面
  20. /// </summary>
  21. /// <returns></returns>
  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 schoolyearID = pararms.getExtraGuid("SchoolYear");
  31. var collegeID = pararms.getExtraGuid("CollegeComboGrid");
  32. var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid");
  33. var courseTypeID = pararms.getExtraInt("DictionaryCourseType") == -1 ? null : pararms.getExtraInt("DictionaryCourseType");
  34. var selectCourseTypeID = pararms.getExtraInt("DictionarySelectCourseType") == -1 ? null : pararms.getExtraInt("DictionarySelectCourseType");
  35. var isCreated = pararms.getExtraInt("DictionaryIsCreated") == -1 ? null : pararms.getExtraInt("DictionaryIsCreated");
  36. var isOpen = pararms.getExtraInt("DictionaryIsOpen") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsOpen");
  37. var result = SelectCourseListServices.GetSelectCourseViewList(configuretView, schoolyearID, collegeID, coursematerialID, courseTypeID, selectCourseTypeID, isCreated, isOpen, (int)pararms.page, (int)pararms.rows);
  38. return Json(result);
  39. }
  40. [HttpPost]
  41. public ActionResult Excel()
  42. {
  43. //return View();
  44. NpoiExcelHelper neh = new NpoiExcelHelper();
  45. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  46. //避开全选值
  47. if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  48. var schoolyearID = Request.Form["SchoolYear"].ParseStrTo<Guid>();
  49. var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo<Guid>();
  50. var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo<Guid>();
  51. var courseTypeID = Request.Form["DictionaryCourseType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseType"].ParseStrTo<int>();
  52. var selectCourseTypeID = Request.Form["DictionarySelectCourseType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySelectCourseType"].ParseStrTo<int>();
  53. var isCreated = Request.Form["DictionaryIsCreated"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsCreated"].ParseStrTo<int>();
  54. var isOpen = Request.Form["DictionaryIsOpen"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsOpen"].ParseStrTo<int>();
  55. var dt = SelectCourseListServices.GetSelectCourseList(configuretView, schoolyearID, collegeID, coursematerialID, courseTypeID, selectCourseTypeID, isCreated, isOpen)
  56. .Select(x => new
  57. {
  58. x.SchoolYearCode,
  59. x.DefaultClassName,
  60. x.CourseCode,
  61. //x.CourseName,
  62. x.CourseTypeName,
  63. //x.CourseCategoryName,
  64. //x.CourseQualityName,
  65. //x.Credit,
  66. //x.Totalhours,
  67. //x.PeopleNumlower,
  68. //x.PeopleNumlimit,
  69. //x.StudentTotalNum,
  70. //x.SelectCourseTypeName,
  71. x.LoginID,
  72. x.UserName,
  73. x.ClassMajorName,
  74. //x.TeachingModeName,
  75. //x.SchoolcodeName,
  76. //x.TeacherName,
  77. //x.IsOpenedDesc
  78. x.RecordStatusName
  79. }).ToTable();
  80. string[] liststring = { "学年学期",
  81. "选修任务班名称",
  82. "课程代码",
  83. //"课程名称",
  84. "课程类型",
  85. "选修类型",
  86. //"课程性质",
  87. //"学分",
  88. //"总学时", "人数下限", "人数上限",
  89. //"已选人数",
  90. "学号","姓名","学籍班",
  91. //"教研室", RSL.Get("College"),
  92. //"授课方式",
  93. //"开课学期",
  94. //"教师姓名",
  95. //"是否开放"
  96. "状态"
  97. };
  98. neh.Export(dt, liststring, "选课结果学生名单");
  99. return RedirectToAction("MsgShow", "Common", new
  100. {
  101. msg = "导出成功!",
  102. url = Url.Content("~/SelectCourseList/List").AddMenuParameter()
  103. });
  104. }
  105. /// <summary>
  106. /// 删除
  107. /// </summary>
  108. /// <param name="ExecutableFreeSelectionCouseIDs"></param>
  109. /// <returns></returns>
  110. [HttpPost]
  111. public ActionResult Delete(string IDs, string Types, string UserIDs)
  112. {
  113. try
  114. {
  115. List<Guid?> list = new List<Guid?>();
  116. for (int i = 0; i < IDs.Split(',').Length; i++)
  117. {
  118. string id = IDs.Split(',')[i];
  119. if (!string.IsNullOrEmpty(id))
  120. {
  121. Guid ID = new Guid(id);
  122. list.Add(ID);
  123. }
  124. }
  125. List<int?> list1 = new List<int?>();
  126. for (int i = 0; i < Types.Split(',').Length; i++)
  127. {
  128. string type = Types.Split(',')[i];
  129. if (!string.IsNullOrEmpty(type))
  130. {
  131. int Type = Convert.ToInt32(type);
  132. list1.Add(Type);
  133. }
  134. }
  135. List<Guid?> list2 = new List<Guid?>();
  136. for (int i = 0; i < UserIDs.Split(',').Length; i++)
  137. {
  138. string id = UserIDs.Split(',')[i];
  139. if (!string.IsNullOrEmpty(id))
  140. {
  141. Guid ID = new Guid(id);
  142. list2.Add(ID);
  143. }
  144. }
  145. SelectCourseListServices.SelectCourseListDelete(list, list1, list2);
  146. return Json(new ReturnMessage()
  147. {
  148. IsSuccess = true,
  149. Message = "删除成功!"
  150. });
  151. }
  152. catch (Exception ex)
  153. {
  154. string mge = ex.Message;
  155. return Json(new ReturnMessage()
  156. {
  157. IsSuccess = false,
  158. Message = "删除失败,原因:" + mge
  159. });
  160. }
  161. }
  162. }
  163. }