ClassroomReserveController.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Web.Controls.Mvc;
  7. using Bowin.Common.Utility;
  8. using Bowin.Common.Data;
  9. using Bowin.Common.JSON;
  10. using EMIS.Web.Controls;
  11. using EMIS.Utility;
  12. using EMIS.ViewModel;
  13. using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
  14. using EMIS.CommonLogic.SchedulingManage.SchedulingSettings;
  15. namespace EMIS.Web.Controllers.SchedulingManage.SchedulingSettings
  16. {
  17. [Authorization]
  18. public class ClassroomReserveController : Controller
  19. {
  20. public IClassroomReserveServices ClassroomReserveServices { get; set; }
  21. /// <summary>
  22. /// 教室预留页面
  23. /// </summary>
  24. /// <returns></returns>
  25. public ActionResult List()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 教室预留查询列表
  31. /// </summary>
  32. /// <param name="pararms"></param>
  33. /// <returns></returns>
  34. [HttpPost]
  35. public ActionResult List(QueryParamsModel pararms)
  36. {
  37. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  38. var campusID = pararms.getExtraGuid("CampusDropdown");
  39. var buildingsID = pararms.getExtraGuid("BuildingsDropdown");
  40. //教室名称
  41. var classroomName = pararms.getExtraString("ClassroomNameDropdown");
  42. //教室类型
  43. var classroomTypeID = pararms.getExtraInt("ClassroomTypeDictionary") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ClassroomTypeDictionary");
  44. //可否多班教学
  45. var isConcurrentUse = pararms.getExtraInt("IsConcurrentUseDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsConcurrentUseDropdown");
  46. //是否可用
  47. var isAvailable = pararms.getExtraInt("IsAvailableDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsAvailableDropdown");
  48. return base.Json(ClassroomReserveServices.GetClassroomReserveViewGrid(configuretView, campusID, buildingsID, classroomName,
  49. classroomTypeID, isConcurrentUse, isAvailable, (int)pararms.page, (int)pararms.rows));
  50. }
  51. /// <summary>
  52. /// 编辑(新增、修改)
  53. /// </summary>
  54. /// <param name="classroomReserveID"></param>
  55. /// <returns></returns>
  56. public ActionResult Edit(Guid? classroomReserveID)
  57. {
  58. ClassroomReserveView classroomReserveView = new ClassroomReserveView();
  59. if (classroomReserveID.HasValue && classroomReserveID != Guid.Empty)
  60. {
  61. classroomReserveView = ClassroomReserveServices.GetClassroomReserveView(classroomReserveID);
  62. }
  63. else
  64. {
  65. classroomReserveView.IsReserve = true;
  66. }
  67. return View(classroomReserveView);
  68. }
  69. /// <summary>
  70. /// 编辑(新增、修改)
  71. /// </summary>
  72. /// <param name="classroomReserveView"></param>
  73. /// <returns></returns>
  74. [HttpPost]
  75. public ActionResult Edit(ClassroomReserveView classroomReserveView)
  76. {
  77. try
  78. {
  79. ClassroomReserveServices.ClassroomReserveEdit(classroomReserveView);
  80. return Json(new ReturnMessage()
  81. {
  82. IsSuccess = true,
  83. Message = "保存成功。"
  84. });
  85. }
  86. catch (Exception ex)
  87. {
  88. return Json(new ReturnMessage()
  89. {
  90. IsSuccess = false,
  91. Message = "保存失败,原因:" + ex.Message
  92. });
  93. }
  94. }
  95. /// <summary>
  96. /// 教室预留批量新增
  97. /// </summary>
  98. /// <returns></returns>
  99. [HttpGet]
  100. public ActionResult ClassroomReserveBatchAdd()
  101. {
  102. ClassroomReserveView classroomReserveView = new ClassroomReserveView();
  103. return View(classroomReserveView);
  104. }
  105. /// <summary>
  106. /// 教室预留批量新增
  107. /// </summary>
  108. /// <param name="collegeClassroomView"></param>
  109. /// <returns></returns>
  110. public ActionResult ClassroomReserveBatchAdd(ClassroomReserveView classroomReserveView)
  111. {
  112. try
  113. {
  114. var classroomIDList = Request["classroomIDList"].JsonToObject<List<Guid?>>();
  115. string result = ClassroomReserveServices.ClassroomReserveBatchAdd(classroomIDList, classroomReserveView);
  116. return Json(new ReturnMessage()
  117. {
  118. IsSuccess = true,
  119. Message = "预留成功" + result + "。"
  120. });
  121. }
  122. catch (Exception ex)
  123. {
  124. return Json(new ReturnMessage()
  125. {
  126. IsSuccess = false,
  127. Message = "预留失败,原因:" + ex.Message
  128. });
  129. }
  130. }
  131. /// <summary>
  132. /// 查询未预留的教室信息ClassroomView
  133. /// </summary>
  134. /// <param name="pararms"></param>
  135. /// <returns></returns>
  136. [HttpPost]
  137. public ActionResult ClassroomNoReserveList(QueryParamsModel pararms)
  138. {
  139. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  140. var campusID = pararms.getExtraGuid("CampusDropdown");
  141. var buildingsID = pararms.getExtraGuid("BuildingsDropdown");
  142. //教室名称
  143. var classroomName = pararms.getExtraString("ClassroomNameDropdown");
  144. //教室类型
  145. var classroomTypeID = pararms.getExtraInt("ClassroomTypeDictionary") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ClassroomTypeDictionary");
  146. //可否多班教学
  147. var isConcurrentUse = pararms.getExtraInt("IsConcurrentUseDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsConcurrentUseDropdown");
  148. //是否可用
  149. var isAvailable = pararms.getExtraInt("IsAvailableDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsAvailableDropdown");
  150. return base.Json(ClassroomReserveServices.GetClassroomViewNoReserveGrid(configuretView, campusID, buildingsID,
  151. classroomName, classroomTypeID, isConcurrentUse, isAvailable, (int)pararms.page, (int)pararms.rows));
  152. }
  153. /// <summary>
  154. /// 删除
  155. /// </summary>
  156. /// <param name="classroomReserveIDs"></param>
  157. /// <returns></returns>
  158. [HttpPost]
  159. public ActionResult Delete(string classroomReserveIDs)
  160. {
  161. try
  162. {
  163. List<Guid?> list = classroomReserveIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  164. .Select(x => (Guid?)new Guid(x)).ToList();
  165. ClassroomReserveServices.ClassroomReserveDelete(list);
  166. return base.Json(new ReturnMessage { IsSuccess = true, Message = "解除成功。" });
  167. }
  168. catch (Exception ex)
  169. {
  170. return base.Json(new ReturnMessage { IsSuccess = false, Message = "解除失败,原因:" + ex.Message });
  171. }
  172. }
  173. /// <summary>
  174. /// Excel导出
  175. /// </summary>
  176. /// <param name="pararms"></param>
  177. /// <returns></returns>
  178. [HttpPost]
  179. public ActionResult Excel()
  180. {
  181. try
  182. {
  183. NpoiExcelHelper neh = new NpoiExcelHelper();
  184. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  185. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  186. var buildingsID = Request.Form["BuildingsDropdown"].ParseStrTo<Guid>();
  187. //教室名称
  188. var classroomName = Request.Form["ClassroomNameDropdown"].ToString();
  189. //教室类型
  190. var classroomTypeID = Request.Form["ClassroomTypeDictionary"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ClassroomTypeDictionary"].ParseStrTo<int>();
  191. //可否多班教学
  192. var isConcurrentUse = Request.Form["IsConcurrentUseDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsConcurrentUseDropdown"].ParseStrTo<int>();
  193. //是否可用
  194. var isAvailable = Request.Form["IsAvailableDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsAvailableDropdown"].ParseStrTo<int>();
  195. var dt = ClassroomReserveServices.GetClassroomReserveViewList(configuretView, campusID, buildingsID,
  196. classroomName, classroomTypeID, isConcurrentUse, isAvailable)
  197. .Select(x => new
  198. {
  199. x.ClassroomCode,
  200. x.ClassroomName,
  201. x.BuildingsInfoCode,
  202. x.BuildingsInfoName,
  203. x.CampusNo,
  204. x.CampusName,
  205. x.ClassroomTypeName,
  206. x.RoomUseName,
  207. x.Totalseating,
  208. x.Effectiveseating,
  209. x.CollegeCode,
  210. x.CollegeName,
  211. x.CollegeCampusCode,
  212. x.CollegeCampusName,
  213. x.IsConcurrentUseName,
  214. x.ScheduleCollegeCount,
  215. x.IsAvailableName
  216. }).ToTable();
  217. string[] liststring = {
  218. "教室编号", "教室名称", "建筑物编号", "建筑物名称", RSL.Get("CampusCode"),
  219. RSL.Get("Campus"), "教室类型", "房间用途", "总座位数", "有效座位数",
  220. "所属" + RSL.Get("CollegeCode"), "所属" + RSL.Get("College"),
  221. "所属" + RSL.Get("CampusCode"), "所属" + RSL.Get("Campus"),
  222. "可否多班教学", "排课院系个数", "是否可用"
  223. };
  224. neh.Export(dt, liststring, "教室预留信息" + DateTime.Now.ToString("yyyyMMdd"));
  225. return Json(new ReturnMessage()
  226. {
  227. IsSuccess = true,
  228. Message = "导出成功。"
  229. });
  230. }
  231. catch (Exception ex)
  232. {
  233. return Json(new ReturnMessage()
  234. {
  235. IsSuccess = false,
  236. Message = "导出失败,原因:" + ex.Message
  237. });
  238. }
  239. }
  240. }
  241. }