CourseGradeController.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.CommonLogic.Students;
  7. using EMIS.CommonLogic.SystemSetting;
  8. using EMIS.ViewModel;
  9. using EMIS.Web.Controls;
  10. using Bowin.Web.Controls.Mvc;
  11. using Bowin.Common.Utility;
  12. using Bowin.Common.Data;
  13. using EMIS.CommonLogic.SystemServices;
  14. using EMIS.Utility;
  15. namespace EMIS.Web.Controllers.StudentSystem.MyGrade
  16. {
  17. [Authorization]
  18. public class CourseGradeController : Controller
  19. {
  20. public IStudentRecordServices StudentRecordService { get; set; }
  21. public Lazy<IDictionaryServices> DictionaryServices { get; set; }
  22. public Lazy<ICourseGradeServices> CourseGradeServices { get; set; }
  23. public IMenuServices menuServices { get; set; }
  24. //
  25. // GET: /CourseGrade/
  26. public ActionResult ViewGrade()
  27. {
  28. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  29. decimal ScoreCredit = 0;
  30. var Student = CourseGradeServices.Value.GetStudentInfo(user.UserID);
  31. var Grade = CourseGradeServices.Value.GetStudentCourseGrade(user.UserID);
  32. //Student.AverageGrade = Grade.Sum(x => x.TotalScore) / Grade.Count;
  33. foreach (var starttermIDS in Grade.GroupBy(q => q.StarttermID).Select(q => q.Key))
  34. {
  35. var YearGradeS = Grade.Where(q => q.StarttermID == starttermIDS).ToList();
  36. foreach (var Grades in YearGradeS)
  37. {
  38. ScoreCredit += Grades.ScoreCredit??0;
  39. }
  40. }
  41. Student.ScoreCredit = ScoreCredit;
  42. string menuNo = HttpContext.Request["MNU"];
  43. string path = menuServices.GetFullMenuPath(menuNo);
  44. ViewBag.Path = path;
  45. ViewBag.CurseGrade = Grade;
  46. return View(Student);
  47. }
  48. public ActionResult GTViewGrade()
  49. {
  50. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  51. decimal ScoreCredit = 0;
  52. var Student = CourseGradeServices.Value.GetStudentInfo(user.UserID);
  53. var Grade = CourseGradeServices.Value.GetStudentCourseGrade(user.UserID);
  54. //Student.AverageGrade = Grade.Sum(x => x.TotalScore) / Grade.Count;
  55. foreach (var starttermIDS in Grade.GroupBy(q => q.StarttermID).Select(q => q.Key))
  56. {
  57. var YearGradeS = Grade.Where(q => q.StarttermID == starttermIDS).ToList();
  58. foreach (var Grades in YearGradeS)
  59. {
  60. ScoreCredit += Grades.ScoreCredit ?? 0;
  61. }
  62. }
  63. Student.ScoreCredit = ScoreCredit;
  64. string menuNo = HttpContext.Request["MNU"];
  65. string path = menuServices.GetFullMenuPath(menuNo);
  66. ViewBag.Path = path;
  67. ViewBag.CurseGrade = Grade;
  68. return View(Student);
  69. }
  70. public ActionResult StudentScoreReport()
  71. {
  72. return View();
  73. }
  74. /// <summary>
  75. /// 学生个人成绩明细列表查询
  76. /// </summary>
  77. /// <param name="pararms"></param>
  78. /// <returns></returns>
  79. [HttpPost]
  80. public ActionResult GetSubmitedScoreList(Guid? CoursematerialID, int? StartTermID, Guid? UserID)
  81. {
  82. return base.Json(CourseGradeServices.Value.GetSubmitedScoreList(CoursematerialID, StartTermID, UserID));
  83. }
  84. /// <summary>
  85. /// 导出
  86. /// </summary>
  87. /// <returns></returns>
  88. [HttpPost]
  89. public ActionResult Excel()
  90. {
  91. NpoiExcelHelper neh = new NpoiExcelHelper();
  92. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  93. Guid? CoursematerialID = Request.Form["CoursematerialID"].ParseStrTo<Guid>();
  94. int? StarTermID = Request.Form["StarTermID"].ParseStrTo<int>();
  95. Guid? UserID = Request.Form["UserID"].ParseStrTo<Guid>();
  96. var dt = CourseGradeServices.Value.GetStudentPersonalScoreViewList(configuretView, CoursematerialID, StarTermID, UserID).Select(x => new
  97. {
  98. x.LoginID,
  99. x.UserName,
  100. x.SchoolyearCode,
  101. x.CourseCode,
  102. x.CourseName,
  103. x.TotalScore,
  104. x.Pingshi,
  105. x.Jishu,
  106. x.Lilun,
  107. x.ScoreCredit,
  108. x.CreateTime,
  109. x.OperaUser,
  110. x.ExamsCategoryName,
  111. x.ExamsStateName,
  112. x.Remarks
  113. }).ToTable();
  114. string[] liststring = { "学号", "姓名", "学年学期", "课程代码", "课程名称", "总成绩", @EMIS.Utility.RSL.Get("Peacetime"), @EMIS.Utility.RSL.Get("Technique"), @EMIS.Utility.RSL.Get("Theoretical"),
  115. "课程学分", "课程类型", "录入时间", "录入人", "考试性质", "考试状态", "备注" };
  116. neh.Export(dt, liststring, "成绩详细信息");
  117. return RedirectToAction("MsgShow", "Common", new
  118. {
  119. msg = "导出成功!",
  120. url = Url.Action("List").AddMenuParameter()
  121. });
  122. }
  123. }
  124. }