LessonRecordController.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Common.Data;
  7. using Bowin.Common.Utility;
  8. using EMIS.ViewModel;
  9. using EMIS.Web.Controls;
  10. using EMIS.CommonLogic.SupervisionManage;
  11. using EMIS.ViewModel.SupervisionManage;
  12. using EMIS.Utility.FormValidate;
  13. using EMIS.Utility;
  14. namespace EMIS.Web.Controllers.SupervisionManage
  15. {
  16. [Authorization]
  17. public class LessonRecordController : Controller
  18. {
  19. public ILessonRecordServices LessonRecordServices { get; set; }
  20. public ISupervisionCollegeServices SupervisionCollegeServices { get; set; }
  21. public ActionResult List()
  22. {
  23. return View();
  24. }
  25. public ActionResult Edit(Guid? lessonRecordID, int? isShow)
  26. {
  27. var lessonRecordView = new LessonRecordView();
  28. if (lessonRecordID.HasValue)
  29. {
  30. lessonRecordView = LessonRecordServices.GetLessonRecordView(lessonRecordID.Value);
  31. }
  32. else
  33. {
  34. var curUser = CustomPrincipal.Current;
  35. var supervisionCollege = SupervisionCollegeServices.GetSupervisionCollegeViewByCollegeID(curUser.CollegeID ?? Guid.Empty);
  36. lessonRecordView.CreateUserID = curUser.UserID;
  37. lessonRecordView.CreateUserName = curUser.Name;
  38. if (supervisionCollege != null)
  39. {
  40. lessonRecordView.SupervisionCollegeID = supervisionCollege.SupervisionCollegeID;
  41. }
  42. }
  43. return View(lessonRecordView);
  44. }
  45. [HttpPost]
  46. public ActionResult Edit(LessonRecordView lessonRecordView)
  47. {
  48. var sessionName = FileUploadHelper.GetFileUploadSessionName(lessonRecordView.LessonRecordID);
  49. var fileList = (List<FileUploadView>)Session[sessionName];
  50. try
  51. {
  52. LessonRecordServices.Save(lessonRecordView, fileList);
  53. return Json(new ReturnMessage()
  54. {
  55. IsSuccess = true,
  56. Message = "保存成功。"
  57. });
  58. }
  59. catch (Exception ex)
  60. {
  61. return Json(new ReturnMessage()
  62. {
  63. IsSuccess = false,
  64. Message = "保存失败:" + ex.Message
  65. });
  66. }
  67. }
  68. [HttpPost]
  69. public ActionResult List(QueryParamsModel pararms)
  70. {
  71. ConfiguretView conditionView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  72. var schoolyearID = pararms.getExtraGuid("Schoolyear");
  73. var collegeID = pararms.getExtraGuid("College");
  74. var supervisionCollegeID = pararms.getExtraGuid("SupervisionCollege");
  75. var startDate = pararms.getExtraDateTime("StartDate");
  76. var endDate = pararms.getExtraDateTime("EndDate");
  77. return base.Json(LessonRecordServices.GetLessonRecordViewGrid(conditionView, schoolyearID, collegeID, supervisionCollegeID,
  78. startDate, endDate, pararms.page, pararms.rows));
  79. }
  80. [HttpPost]
  81. public ActionResult Delete(string lessonRecordIDs)
  82. {
  83. try
  84. {
  85. var lessonRecordIDList = lessonRecordIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  86. LessonRecordServices.Delete(lessonRecordIDList);
  87. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功" });
  88. }
  89. catch (Exception ex)
  90. {
  91. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
  92. }
  93. }
  94. [HttpPost]
  95. public ActionResult Excel()
  96. {
  97. NpoiExcelHelper neh = new NpoiExcelHelper();
  98. ConfiguretView conditionView = ConfiguretExtensions.GetConfiguretermsView(null);
  99. var selectedID = Request.Form["LessonRecordIDs"] ?? "";
  100. var schoolyearID = Request.Form["Schoolyear"].ParseStrTo<Guid>();
  101. var collegeID = Request.Form["College"].ParseStrTo<Guid>();
  102. var supervisionCollegeID = Request.Form["SupervisionCollege"].ParseStrTo<Guid>();
  103. var startDate = Request.Form["StartDate"].ParseStrTo<DateTime>();
  104. var endDate = Request.Form["EndDate"].ParseStrTo<DateTime>();
  105. List<LessonRecordView> result;
  106. if (!string.IsNullOrEmpty(selectedID))
  107. {
  108. var adjustmentIDList = selectedID.Split(',')
  109. .Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  110. result = LessonRecordServices.GetLessonRecordViewList(conditionView, schoolyearID, collegeID, supervisionCollegeID,
  111. startDate, endDate);
  112. }
  113. else
  114. {
  115. result = LessonRecordServices.GetLessonRecordViewList(conditionView, schoolyearID, collegeID, supervisionCollegeID,
  116. startDate, endDate);
  117. }
  118. var dt = result.Select(x => new
  119. {
  120. x.SchoolyearCode,
  121. x.SupervisionTypeDesc,
  122. x.LessonDateDesc,
  123. x.SupervisionCollegeName,
  124. x.Location,
  125. x.UserName,
  126. x.ClassmajorName,
  127. x.CourseName,
  128. TotalScore = (x.TotalScore ?? 0).ToString("#0.##")
  129. }).ToTable();
  130. string[] liststring = { "学年学期", "督导类型", "督导时间", "督导院系", "督导地点", "督导对象","授课班级",
  131. "课程名称", "评分" };
  132. neh.Export(dt, liststring, "督导听课记录");
  133. return Json(new ReturnMessage()
  134. {
  135. IsSuccess = true,
  136. Message = "保存成功!"
  137. });
  138. }
  139. }
  140. }