ClassroomExcessiveUseController.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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 EMIS.CommonLogic.EducationSchedule;
  10. using EMIS.ViewModel;
  11. using EMIS.Web.Controls;
  12. using EMIS.Utility;
  13. using EMIS.ViewModel.EducationSchedule;
  14. using Bowin.Common.Linq.Entity;
  15. using EMIS.CommonLogic.CalendarManage;
  16. namespace EMIS.Web.Controllers.EducationSchedule
  17. {
  18. [Authorization]
  19. public class ClassroomExcessiveUseController : Controller
  20. {
  21. public ISchoolYearServices SchoolYearServices { get; set; }
  22. public IClassroomExcessiveUseServices ClassroomExcessiveUseServices { get; set; }
  23. public ActionResult List()
  24. {
  25. return View();
  26. }
  27. public ActionResult Edit(Guid? classroomExecessiveUseID)
  28. {
  29. ClassroomExcessiveUseView model;
  30. if (classroomExecessiveUseID.HasValue)
  31. {
  32. model = ClassroomExcessiveUseServices.GetClassroomExcessiveUseView(classroomExecessiveUseID.Value);
  33. }
  34. else
  35. {
  36. model = new ClassroomExcessiveUseView();
  37. model.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID();
  38. }
  39. return View(model);
  40. }
  41. public ActionResult SchedulingEdit(Guid? schoolyearID, Guid? classroom)
  42. {
  43. var weekNumList = SchoolYearServices.GetCurrentSchoolyearWeekNumList();
  44. List<ListControlItem> lctWeekNum = new List<ListControlItem>();
  45. for (int i = 1; i <= weekNumList.Count; i++)
  46. {
  47. ListControlItem lt = new ListControlItem { Text = i.ToString(), Value = i, IsSelected = true };
  48. lctWeekNum.Add(lt);
  49. }
  50. ViewBag.WeekList = lctWeekNum;
  51. ViewBag.SchoolyearID = schoolyearID;
  52. ViewBag.ClassroomID = classroom;
  53. return View();
  54. }
  55. [HttpPost]
  56. public ActionResult List(QueryParamsModel pararms)
  57. {
  58. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  59. var schoolyearID = pararms.getExtraGuid("ddlSchoolyear");
  60. var weekNum = pararms.getExtraInt("ddlWeekNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekNum");
  61. var weekday = pararms.getExtraInt("ddlWeekday") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlWeekday");
  62. var courseTimeID = pararms.getExtraGuid("cbgCoursesTime");
  63. var collegeID= pararms.getExtraGuid("CollegeComboGrid");
  64. var buildingID = pararms.getExtraGuid("cbgBuilding");
  65. var classroomID = pararms.getExtraGuid("cbgClassroom");
  66. var result = ClassroomExcessiveUseServices.GetClassroomExcessiveUseViewList(configuretView, schoolyearID, weekNum, weekday,
  67. courseTimeID, buildingID, classroomID, collegeID, (int)pararms.page, (int)pararms.rows);
  68. return Json(result);
  69. }
  70. [HttpPost]
  71. public ActionResult Excel()
  72. {
  73. NpoiExcelHelper neh = new NpoiExcelHelper();
  74. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  75. var schoolyearID = Request.Form["ddlSchoolyear"].ParseStrTo<Guid>();
  76. var weekNum = Request.Form["ddlWeekNum"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlWeekNum"].ParseStrTo<int>();
  77. var weekday = Request.Form["ddlWeekday"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlWeekday"].ParseStrTo<int>();
  78. var courseTimeID = Request.Form["cbgCoursesTime"].ParseStrTo<Guid>();
  79. var buildingID = Request.Form["cbgBuilding"].ParseStrTo<Guid>();
  80. var classroomID = Request.Form["cbgClassroom"].ParseStrTo<Guid>();
  81. var collegeID = Request.Form["CollegeComboGrid"].ParseStrTo<Guid>();
  82. var dt = ClassroomExcessiveUseServices.GetClassroomExcessiveUseViewList(configuretView, schoolyearID, weekNum, weekday,
  83. courseTimeID, buildingID, classroomID, collegeID)
  84. .Select(x => new
  85. {
  86. x.SchoolyearCode,
  87. x.ClassroomName,
  88. x.CollegeName,
  89. x.UserName,
  90. x.Content,
  91. x.Scheduling
  92. }).ToTable();
  93. string[] liststring = { "学年学期", "教室", RSL.Get("UsingCollege"), "使用人", "活动内容", "时间安排" };
  94. neh.Export(dt, liststring, "课外教室使用登记表");
  95. return RedirectToAction("MsgShow", "Common", new
  96. {
  97. msg = "导出成功!",
  98. url = Url.Content("~/Students/List").AddMenuParameter()
  99. });
  100. }
  101. [HttpPost]
  102. public ActionResult Delete(string classroomExcessiveUseIDs)
  103. {
  104. try
  105. {
  106. List<Guid> idList = classroomExcessiveUseIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  107. ClassroomExcessiveUseServices.Delete(idList);
  108. return Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  109. }
  110. catch (Exception ex)
  111. {
  112. return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message });
  113. }
  114. }
  115. [HttpPost]
  116. public ActionResult SchedulingList(Guid? classroomExcessiveUseID)
  117. {
  118. if (!classroomExcessiveUseID.HasValue)
  119. {
  120. return Json(new GridResultSet<ClassroomExcessiveUseSchedulingView> { rows = new List<ClassroomExcessiveUseSchedulingView>(), total = 0 });
  121. }
  122. else
  123. {
  124. var schedulingList = ClassroomExcessiveUseServices.GetClassroomExcessiveUseSchedulingViewList(classroomExcessiveUseID.Value);
  125. return Json(new GridResultSet<ClassroomExcessiveUseSchedulingView> { rows = schedulingList, total = schedulingList.Count });
  126. }
  127. }
  128. [HttpPost]
  129. public ActionResult Edit(ClassroomExcessiveUseView model)
  130. {
  131. var schedulingList = DataGrid.GetTableData<ClassroomExcessiveUseSchedulingView>("dgSchedulingList");
  132. try
  133. {
  134. if (schedulingList.Count <= 0)
  135. {
  136. return Json(new ReturnMessage()
  137. {
  138. IsSuccess = false,
  139. Message = "保存失败,原因:时间安排不能为空。"
  140. });
  141. }
  142. else
  143. {
  144. ClassroomExcessiveUseServices.Save(model, schedulingList);
  145. return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" });
  146. }
  147. }
  148. catch (Exception ex)
  149. {
  150. return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message });
  151. }
  152. }
  153. [HttpPost]
  154. public ActionResult GetCourseTimeOnlyUsable(QueryParamsModel pararms)
  155. //, Guid schoolYearID,IList<int?> schedulingWeekList, int weekday, Guid classroomID)
  156. {
  157. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  158. var schoolYearID = pararms.getExtraGuid("schoolyearID");
  159. var weekNumList = pararms.getExtraString("weekNumList");
  160. var schedulingWeekList = weekNumList.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => x.ParseStrTo<int>()).ToList();
  161. var weekday = pararms.getExtraInt("weekDay") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("weekDay");
  162. var classroomID = pararms.getExtraGuid("classroomID");
  163. var result = ClassroomExcessiveUseServices.GetCoursesTimeViewGrid(configuretView, schoolYearID.Value, schedulingWeekList, weekday.Value, classroomID.Value, (int)pararms.page, (int)pararms.rows);
  164. return Json(result);
  165. }
  166. }
  167. }