ExaminationRoomSettingController.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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.ExaminationManage;
  9. using Bowin.Web.Controls.Mvc;
  10. using Bowin.Common.Data;
  11. using Bowin.Common.Utility;
  12. namespace EMIS.Web.Controllers.ExaminationManage
  13. {
  14. [Authorization]
  15. public class ExaminationRoomSettingController : Controller
  16. {
  17. public IRoomSettingServices RoomSettingServices { get; set; }
  18. public ActionResult List()
  19. {
  20. return View();
  21. }
  22. /// <summary>
  23. /// 列表查询
  24. /// </summary>
  25. /// <param name="pararms"></param>
  26. /// <returns></returns>
  27. [HttpPost]
  28. public ActionResult List(QueryParamsModel pararms)
  29. {
  30. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  31. var campusID = pararms.getExtraGuid("CampusDropdown");
  32. var buildingID = pararms.getExtraGuid("BuildingsDropdown");
  33. var isSpecial = (!pararms.getExtraInt("IsSpecialDictionaryDropDown").HasValue || pararms.getExtraInt("IsSpecialDictionaryDropDown") == DropdownList.SELECT_ALL) ? null : (bool?)(pararms.getExtraInt("IsSpecialDictionaryDropDown") == (int)CF_GeneralPurpose.IsYes);
  34. if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  35. return base.Json(RoomSettingServices.GetClassroomViewList(configuretView, campusID, buildingID, isSpecial, (int)pararms.page, (int)pararms.rows));
  36. }
  37. /// <summary>
  38. /// 列表查询
  39. /// </summary>
  40. /// <param name="pararms"></param>
  41. /// <returns></returns>
  42. [HttpPost]
  43. public ActionResult AvailableList(Guid examinationPlanID, Guid? examinationRoomLayoutID, QueryParamsModel pararms)
  44. {
  45. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  46. if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  47. return base.Json(RoomSettingServices.GetAvailableClassroomViewList(configuretView, examinationPlanID, examinationRoomLayoutID, (int)pararms.page, (int)pararms.rows));
  48. }
  49. /// <summary>
  50. /// 列表查询
  51. /// </summary>
  52. /// <param name="pararms"></param>
  53. /// <returns></returns>
  54. [HttpPost]
  55. public ActionResult AvailableListGdss(Guid examinationPlanID, Guid? buildingsInfoID, DateTime examinationDate,
  56. TimeSpan startTime, TimeSpan endTime, int studentCount, QueryParamsModel pararms)
  57. {
  58. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  59. if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  60. return base.Json(RoomSettingServices.GetAvailableClassroomViewGdssList(configuretView, examinationPlanID, buildingsInfoID, examinationDate, startTime, endTime,
  61. studentCount, (int)pararms.page, (int)pararms.rows));
  62. }
  63. /// <summary>
  64. /// 列表查询
  65. /// </summary>
  66. /// <param name="pararms"></param>
  67. /// <returns></returns>
  68. [HttpPost]
  69. public ActionResult AddAvailableList(QueryParamsModel pararms)
  70. {
  71. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  72. if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  73. return base.Json(RoomSettingServices.GetAddAvailableClassroomViewList(configuretView, (int)pararms.page, (int)pararms.rows));
  74. }
  75. [HttpPost]
  76. public ActionResult Excel()
  77. {
  78. NpoiExcelHelper neh = new NpoiExcelHelper();
  79. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  80. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  81. var buildingID = Request.Form["BuildingsDropdown"].ParseStrTo<Guid>();
  82. var isSpecial = Request.Form["IsSpecialDictionaryDropDown"] == DropdownList.SELECT_ALL.ToString() ? null : (bool?)(Request.Form["IsSpecialDictionaryDropDown"] == ((int)CF_GeneralPurpose.IsYes).ToString());
  83. if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  84. var dt = RoomSettingServices.GetClassroomViewList(configuretView, campusID, buildingID, isSpecial).Select(x => new
  85. {
  86. x.Name,
  87. x.IsAvailableName,
  88. x.ClassroomTypeName,
  89. x.Totalseating,
  90. x.Effectiveseating,
  91. x.Examinationseating,
  92. x.IsWrittenExamName,
  93. x.IsMachinetestName,
  94. x.BuildingsInfoName
  95. }).ToTable();
  96. string[] liststring = { "教室", "是否可用", "教室类型", "总座位数", "有效座位数", "考试座位数", "笔试考试", "机试考试", "所在建筑物" };
  97. neh.Export(dt, liststring, "考场信息");
  98. return RedirectToAction("MsgShow", "Common", new
  99. {
  100. msg = "导出成功!",
  101. url = Url.Content("~/ExaminationRoomSetting/List").AddMenuParameter()
  102. });
  103. }
  104. /// <summary>
  105. /// 添加
  106. /// </summary>
  107. /// <param name="roleID"></param>
  108. /// <returns></returns>
  109. [HttpPost]
  110. public ActionResult Add(string classroomIDs)
  111. {
  112. try
  113. {
  114. var classroomIDList = classroomIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
  115. RoomSettingServices.Add(classroomIDList);
  116. return base.Json("添加成功");
  117. }
  118. catch (Exception ex)
  119. {
  120. return base.Json("添加失败,原因:" + ex.Message + "!");
  121. }
  122. }
  123. /// <summary>
  124. /// 删除
  125. /// </summary>
  126. /// <param name="roleID"></param>
  127. /// <returns></returns>
  128. [HttpPost]
  129. public ActionResult Delete(string classroomIDs)
  130. {
  131. try
  132. {
  133. var classroomIDList = classroomIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
  134. RoomSettingServices.Delete(classroomIDList);
  135. return base.Json("删除成功");
  136. }
  137. catch (Exception ex)
  138. {
  139. return base.Json("删除失败,原因:" + ex.Message + "!");
  140. }
  141. }
  142. }
  143. }