using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.CommonLogic.Students; using EMIS.CommonLogic.SystemSetting; using EMIS.ViewModel; using EMIS.Web.Controls; using Bowin.Web.Controls.Mvc; using Bowin.Common.Utility; using Bowin.Common.Data; using EMIS.CommonLogic.SystemServices; using EMIS.Utility; namespace EMIS.Web.Controllers.StudentSystem.MyGrade { [Authorization] public class CourseGradeController : Controller { public IStudentRecordServices StudentRecordService { get; set; } public Lazy DictionaryServices { get; set; } public Lazy CourseGradeServices { get; set; } public IMenuServices menuServices { get; set; } // // GET: /CourseGrade/ public ActionResult ViewGrade() { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; decimal ScoreCredit = 0; var Student = CourseGradeServices.Value.GetStudentInfo(user.UserID); var Grade = CourseGradeServices.Value.GetStudentCourseGrade(user.UserID); //Student.AverageGrade = Grade.Sum(x => x.TotalScore) / Grade.Count; foreach (var starttermIDS in Grade.GroupBy(q => q.StarttermID).Select(q => q.Key)) { var YearGradeS = Grade.Where(q => q.StarttermID == starttermIDS).ToList(); foreach (var Grades in YearGradeS) { ScoreCredit += Grades.ScoreCredit??0; } } Student.ScoreCredit = ScoreCredit; string menuNo = HttpContext.Request["MNU"]; string path = menuServices.GetFullMenuPath(menuNo); ViewBag.Path = path; ViewBag.CurseGrade = Grade; return View(Student); } public ActionResult GTViewGrade() { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; decimal ScoreCredit = 0; var Student = CourseGradeServices.Value.GetStudentInfo(user.UserID); var Grade = CourseGradeServices.Value.GetStudentCourseGrade(user.UserID); //Student.AverageGrade = Grade.Sum(x => x.TotalScore) / Grade.Count; foreach (var starttermIDS in Grade.GroupBy(q => q.StarttermID).Select(q => q.Key)) { var YearGradeS = Grade.Where(q => q.StarttermID == starttermIDS).ToList(); foreach (var Grades in YearGradeS) { ScoreCredit += Grades.ScoreCredit ?? 0; } } Student.ScoreCredit = ScoreCredit; string menuNo = HttpContext.Request["MNU"]; string path = menuServices.GetFullMenuPath(menuNo); ViewBag.Path = path; ViewBag.CurseGrade = Grade; return View(Student); } public ActionResult StudentScoreReport() { return View(); } /// /// 学生个人成绩明细列表查询 /// /// /// [HttpPost] public ActionResult GetSubmitedScoreList(Guid? CoursematerialID, int? StartTermID, Guid? UserID) { return base.Json(CourseGradeServices.Value.GetSubmitedScoreList(CoursematerialID, StartTermID, UserID)); } /// /// 导出 /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); Guid? CoursematerialID = Request.Form["CoursematerialID"].ParseStrTo(); int? StarTermID = Request.Form["StarTermID"].ParseStrTo(); Guid? UserID = Request.Form["UserID"].ParseStrTo(); var dt = CourseGradeServices.Value.GetStudentPersonalScoreViewList(configuretView, CoursematerialID, StarTermID, UserID).Select(x => new { x.LoginID, x.UserName, x.SchoolyearCode, x.CourseCode, x.CourseName, x.TotalScore, x.Pingshi, x.Jishu, x.Lilun, x.ScoreCredit, x.CreateTime, x.OperaUser, x.ExamsCategoryName, x.ExamsStateName, x.Remarks }).ToTable(); string[] liststring = { "学号", "姓名", "学年学期", "课程代码", "课程名称", "总成绩", @EMIS.Utility.RSL.Get("Peacetime"), @EMIS.Utility.RSL.Get("Technique"), @EMIS.Utility.RSL.Get("Theoretical"), "课程学分", "课程类型", "录入时间", "录入人", "考试性质", "考试状态", "备注" }; neh.Export(dt, liststring, "成绩详细信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Action("List").AddMenuParameter() }); } } }