CollegeClassroomController.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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.Utility;
  11. using EMIS.Web.Controls;
  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 CollegeClassroomController : Controller
  19. {
  20. public ICollegeClassroomServices CollegeClassroomServices { 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 collegeCampusID = pararms.getExtraGuid("CollegeCampusDropdown");
  39. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  40. var buildingsID = pararms.getExtraGuid("BuildingsDropdown");
  41. //教室名称
  42. var classroomName = pararms.getExtraString("ClassroomNameDropdown");
  43. //教室类型
  44. var classroomTypeID = pararms.getExtraInt("ClassroomTypeDictionary") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ClassroomTypeDictionary");
  45. //可否多班教学
  46. var isConcurrentUse = pararms.getExtraInt("IsConcurrentUseDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsConcurrentUseDropdown");
  47. //是否预留
  48. var isReserve = pararms.getExtraInt("IsReserveDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsReserveDropdown");
  49. //是否可用
  50. var isAvailable = pararms.getExtraInt("IsAvailableDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsAvailableDropdown");
  51. return Json(CollegeClassroomServices.GetCollegeClassroomViewGrid(configuretView, collegeCampusID, collegeID, buildingsID,
  52. classroomName, classroomTypeID, isConcurrentUse, isReserve, isAvailable, (int)pararms.page, (int)pararms.rows));
  53. }
  54. /// <summary>
  55. /// 院系教室下拉列表信息(仅查询预留为否、状态为可用的院系教室信息)
  56. /// </summary>
  57. /// <param name="pararms"></param>
  58. /// <returns></returns>
  59. [HttpPost]
  60. public ActionResult ClassroomListComboGrid(QueryParamsModel pararms)
  61. {
  62. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  63. var collegeCampusID = pararms.getExtraGuid("CollegeCampusDropdown");
  64. var collegeID = Request.Form["collegeID"].ParseStrTo<Guid>();
  65. var buildingsID = pararms.getExtraGuid("BuildingsDropdown");
  66. //教室名称
  67. var classroomName = pararms.getExtraString("ClassroomNameDropdown");
  68. //教室类型
  69. int? classroomTypeID = pararms.getExtraString("ClassroomTypeID").ParseStrTo<int>();
  70. //可否多班教学
  71. var isConcurrentUse = pararms.getExtraInt("IsConcurrentUseDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsConcurrentUseDropdown");
  72. //是否预留
  73. var isReserve = (int)CF_GeneralPurpose.IsNo;
  74. //是否可用
  75. var isAvailable = (int)CF_GeneralPurpose.IsYes;
  76. return Json(CollegeClassroomServices.GetCollegeClassroomViewGrid(configuretView, collegeCampusID, collegeID, buildingsID,
  77. classroomName, classroomTypeID, isConcurrentUse, isReserve, isAvailable, (int)pararms.page, (int)pararms.rows));
  78. }
  79. /// <summary>
  80. /// 复制新增
  81. /// </summary>
  82. /// <param name="collegeClassroomID"></param>
  83. /// <returns></returns>
  84. public ActionResult CopyAdd(Guid collegeClassroomID)
  85. {
  86. CollegeClassroomView collegeClassroomView = new CollegeClassroomView();
  87. collegeClassroomView = CollegeClassroomServices.GetCollegeClassroomView(collegeClassroomID);
  88. return View("Edit", collegeClassroomView);
  89. }
  90. /// <summary>
  91. /// 复制新增
  92. /// </summary>
  93. /// <param name="collegeClassroomView"></param>
  94. /// <returns></returns>
  95. [HttpPost]
  96. public ActionResult CopyAdd(CollegeClassroomView collegeClassroomView)
  97. {
  98. collegeClassroomView.CollegeClassroomID = Guid.Empty;
  99. return this.Edit(collegeClassroomView);
  100. }
  101. /// <summary>
  102. /// 编辑(新增、修改)
  103. /// </summary>
  104. /// <param name="collegeClassroomID"></param>
  105. /// <returns></returns>
  106. public ActionResult Edit(Guid? collegeClassroomID)
  107. {
  108. CollegeClassroomView collegeClassroomView = new CollegeClassroomView();
  109. if (collegeClassroomID.HasValue && collegeClassroomID != Guid.Empty)
  110. {
  111. collegeClassroomView = CollegeClassroomServices.GetCollegeClassroomView(collegeClassroomID);
  112. }
  113. return View(collegeClassroomView);
  114. }
  115. /// <summary>
  116. /// 编辑(新增、修改)
  117. /// </summary>
  118. /// <param name="collegeClassroomView"></param>
  119. /// <returns></returns>
  120. [HttpPost]
  121. public ActionResult Edit(CollegeClassroomView collegeClassroomView)
  122. {
  123. try
  124. {
  125. CollegeClassroomServices.CollegeClassroomEdit(collegeClassroomView);
  126. return Json(new ReturnMessage()
  127. {
  128. IsSuccess = true,
  129. Message = "保存成功。"
  130. });
  131. }
  132. catch (Exception ex)
  133. {
  134. return Json(new ReturnMessage()
  135. {
  136. IsSuccess = false,
  137. Message = "保存失败,原因:" + ex.Message
  138. });
  139. }
  140. }
  141. /// <summary>
  142. /// 院系教室信息批量新增(根据院系所信息选择教室信息新增)
  143. /// </summary>
  144. /// <returns></returns>
  145. [HttpGet]
  146. public ActionResult BatchAdd()
  147. {
  148. CollegeClassroomView collegeClassroomView = new CollegeClassroomView();
  149. return View(collegeClassroomView);
  150. }
  151. /// <summary>
  152. /// 院系教室信息批量新增(根据院系所信息选择教室信息新增)
  153. /// </summary>
  154. /// <param name="collegeClassroomView"></param>
  155. /// <returns></returns>
  156. public ActionResult BatchAdd(CollegeClassroomView collegeClassroomView)
  157. {
  158. try
  159. {
  160. var classroomIDList = Request["classroomIDList"].JsonToObject<List<Guid?>>();
  161. string result = CollegeClassroomServices.CollegeClassroomBatchAdd(classroomIDList, collegeClassroomView);
  162. return Json(new ReturnMessage()
  163. {
  164. IsSuccess = true,
  165. Message = "新增成功" + result + "。"
  166. });
  167. }
  168. catch (Exception ex)
  169. {
  170. return Json(new ReturnMessage()
  171. {
  172. IsSuccess = false,
  173. Message = "新增失败,原因:" + ex.Message
  174. });
  175. }
  176. }
  177. /// <summary>
  178. /// 查询对应的未新增教室信息ClassroomView
  179. /// </summary>
  180. /// <param name="pararms"></param>
  181. /// <returns></returns>
  182. [HttpPost]
  183. public ActionResult ClassroomNoAddList(QueryParamsModel pararms)
  184. {
  185. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  186. var campusID = pararms.getExtraGuid("CampusDropdown");
  187. var buildingsID = pararms.getExtraGuid("BuildingsDropdown");
  188. //教室名称
  189. var classroomName = pararms.getExtraString("ClassroomNameDropdown");
  190. //教室类型
  191. var classroomTypeID = pararms.getExtraInt("ClassroomTypeDictionary") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ClassroomTypeDictionary");
  192. //可否多班教学
  193. var isConcurrentUse = pararms.getExtraInt("IsConcurrentUseDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsConcurrentUseDropdown");
  194. //是否预留
  195. var isReserve = pararms.getExtraInt("IsReserveDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsReserveDropdown");
  196. //是否可用
  197. var isAvailable = pararms.getExtraInt("IsAvailableDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsAvailableDropdown");
  198. //分配的院系所ID(只能选择一个)
  199. var collegeID = pararms.getExtraGuid("CollegeID");
  200. return base.Json(CollegeClassroomServices.GetClassroomViewNoAddGrid(configuretView, campusID, buildingsID, classroomName,
  201. classroomTypeID, isConcurrentUse, isReserve, isAvailable, collegeID, (int)pararms.page, (int)pararms.rows));
  202. }
  203. /// <summary>
  204. /// 院系教室信息批量新增(根据院系教室信息新增)
  205. /// </summary>
  206. /// <returns></returns>
  207. [HttpGet]
  208. public ActionResult CollegeClassroomBatchAdd()
  209. {
  210. CollegeClassroomView collegeClassroomView = new CollegeClassroomView();
  211. return View(collegeClassroomView);
  212. }
  213. /// <summary>
  214. /// 院系教室信息批量新增(根据院系教室信息新增)
  215. /// </summary>
  216. /// <param name="collegeClassroomView"></param>
  217. /// <returns></returns>
  218. public ActionResult CollegeClassroomBatchAdd(CollegeClassroomView collegeClassroomView)
  219. {
  220. try
  221. {
  222. var collegeClassroomViewList = Request["collegeClassroomViewList"].JsonToObject<List<CollegeClassroomView>>();
  223. string result = CollegeClassroomServices.CollegeClassroomBatchAdd(collegeClassroomViewList, collegeClassroomView);
  224. return Json(new ReturnMessage()
  225. {
  226. IsSuccess = true,
  227. Message = "新增成功" + result + "。"
  228. });
  229. }
  230. catch (Exception ex)
  231. {
  232. return Json(new ReturnMessage()
  233. {
  234. IsSuccess = false,
  235. Message = "新增失败,原因:" + ex.Message
  236. });
  237. }
  238. }
  239. /// <summary>
  240. /// 查询对应的未新增院系教室信息
  241. /// </summary>
  242. /// <param name="pararms"></param>
  243. /// <returns></returns>
  244. [HttpPost]
  245. public ActionResult CollegeClassroomNoAddList(QueryParamsModel pararms)
  246. {
  247. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  248. var buildingsInfoCampusID = pararms.getExtraGuid("BuildingsInfoCampusDropdown");
  249. var buildingsID = pararms.getExtraGuid("BuildingsDropdown");
  250. //教室名称
  251. var classroomName = pararms.getExtraString("ClassroomNameDropdown");
  252. //教室类型
  253. var classroomTypeID = pararms.getExtraInt("ClassroomTypeDictionary") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ClassroomTypeDictionary");
  254. //可否多班教学
  255. var isConcurrentUse = pararms.getExtraInt("IsConcurrentUseDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsConcurrentUseDropdown");
  256. //是否预留
  257. var isReserve = pararms.getExtraInt("IsReserveDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsReserveDropdown");
  258. //是否可用
  259. var isAvailable = pararms.getExtraInt("IsAvailableDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsAvailableDropdown");
  260. //分配的院系所ID(可多选)
  261. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  262. return base.Json(CollegeClassroomServices.GetCollegeClassroomViewNoAddGrid(configuretView, buildingsInfoCampusID,
  263. buildingsID, classroomName, classroomTypeID, isConcurrentUse, isReserve, isAvailable, collegeID, (int)pararms.page, (int)pararms.rows));
  264. }
  265. /// <summary>
  266. /// 删除
  267. /// </summary>
  268. /// <param name="collegeClassroomIDs"></param>
  269. /// <returns></returns>
  270. public ActionResult Delete(string collegeClassroomIDs)
  271. {
  272. try
  273. {
  274. List<Guid?> list = collegeClassroomIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  275. .Select(x => (Guid?)new Guid(x)).ToList();
  276. CollegeClassroomServices.CollegeClassroomDelete(list);
  277. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  278. }
  279. catch (Exception ex)
  280. {
  281. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
  282. }
  283. }
  284. /// <summary>
  285. /// Excel导出
  286. /// </summary>
  287. /// <param name="pararms"></param>
  288. /// <returns></returns>
  289. [HttpPost]
  290. public ActionResult Excel()
  291. {
  292. try
  293. {
  294. NpoiExcelHelper neh = new NpoiExcelHelper();
  295. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  296. var collegeCampusID = Request.Form["CollegeCampusDropdown"].ParseStrTo<Guid>();
  297. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  298. var buildingsID = Request.Form["BuildingsDropdown"].ParseStrTo<Guid>();
  299. //教室名称
  300. var classroomName = Request.Form["ClassroomNameDropdown"].ToString();
  301. //教室类型
  302. var classroomTypeID = Request.Form["ClassroomTypeDictionary"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ClassroomTypeDictionary"].ParseStrTo<int>();
  303. //可否多班教学
  304. var isConcurrentUse = Request.Form["IsConcurrentUseDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsConcurrentUseDropdown"].ParseStrTo<int>();
  305. //是否预留
  306. var isReserve = Request.Form["IsReserveDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsReserveDropdown"].ParseStrTo<int>();
  307. //是否可用
  308. var isAvailable = Request.Form["IsAvailableDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsAvailableDropdown"].ParseStrTo<int>();
  309. var dt = CollegeClassroomServices.GetCollegeClassroomViewList(configuretView, collegeCampusID, collegeID, buildingsID,
  310. classroomName, classroomTypeID, isConcurrentUse, isReserve, isAvailable)
  311. .Select(x => new
  312. {
  313. x.CollegeNo,
  314. x.CollegeName,
  315. x.UnitCategoryName,
  316. x.CollegeCampusNo,
  317. x.CollegeCampusName,
  318. x.ClassroomCode,
  319. x.ClassroomName,
  320. x.ClassroomTypeName,
  321. x.RoomUseName,
  322. x.Totalseating,
  323. x.Effectiveseating,
  324. x.BuildingsInfoCode,
  325. x.BuildingsInfoName,
  326. x.CampusNo,
  327. x.CampusName,
  328. x.IsConcurrentUseName,
  329. x.IsReserveName,
  330. x.IsAvailableName,
  331. }).ToTable();
  332. string[] liststring = {
  333. RSL.Get("CollegeCode"), RSL.Get("CollegeName"), "单位类别", RSL.Get("CampusCode"),
  334. RSL.Get("CampusName"), "教室编号", "教室名称", "教室类型", "房间用途", "总座位数",
  335. "有效座位数", "建筑物编号", "建筑物名称", "所属" + RSL.Get("CampusCode"),
  336. "所属" + RSL.Get("CampusName"), "可否多班教学", "是否预留", "是否可用"
  337. };
  338. neh.Export(dt, liststring, "院系教室信息" + DateTime.Now.ToString("yyyyMMdd"));
  339. return Json(new ReturnMessage()
  340. {
  341. IsSuccess = true,
  342. Message = "导出成功。"
  343. });
  344. }
  345. catch (Exception ex)
  346. {
  347. return Json(new ReturnMessage()
  348. {
  349. IsSuccess = false,
  350. Message = "导出失败,原因:" + ex.Message
  351. });
  352. }
  353. }
  354. }
  355. }