CourseworkController_wufs.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMISOnline.CommonLogic.CourseworkServices;
  7. using EMISOnline.CommonLogic.StudentServices;
  8. using EMISOnline.Entities;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMISOnline.ViewModel.Coursework;
  11. namespace EMISOnline.Web.Controllers.Manage
  12. {
  13. [Authorization]
  14. public partial class CourseworkController : Controller
  15. {
  16. public ITeacherScoreServices TeacherScoreServices { get; set; }
  17. public ISchoolyearServices SchoolyearServices { get; set; }
  18. public ActionResult CourseScoreList()
  19. {
  20. return View();
  21. }
  22. public JsonResult getConrseScoreJson(int page, int rows, string CoursematerialName, string StudentName)
  23. {
  24. var teacher = HttpContext.User as EMISOnline.Utility.FormValidate.CustomPrincipal;
  25. var schoolyear = SchoolyearServices.GetStudentSchollyear(teacher.UserID);
  26. var list = TeacherScoreServices.ConrseScoreList(page, rows, CoursematerialName, StudentName, teacher.UserID, schoolyear.SchoolyearID);
  27. return Json(list, JsonRequestBehavior.AllowGet);
  28. }
  29. [HttpPost]
  30. public JsonResult setConrseScore(string models)
  31. {
  32. try
  33. {
  34. var strmodels = models.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
  35. var teacher = HttpContext.User as EMISOnline.Utility.FormValidate.CustomPrincipal;
  36. var schoolyear = SchoolyearServices.GetStudentSchollyear(teacher.UserID);
  37. List<ER_TeacherScore> teas = new List<ER_TeacherScore>();
  38. string result = "";
  39. strmodels.ToList().ForEach(strm =>
  40. {
  41. var strdatas=strm.Split(',');
  42. var tea = new ER_TeacherScore();
  43. teas.Add(tea);
  44. tea.TeacherScoreID = strdatas[1].Contains("null") ? Guid.Empty : new Guid(strdatas[1].Trim());
  45. tea.UserID = new Guid(strdatas[0].Trim());
  46. tea.CoursematerialID = new Guid(strdatas[2].Trim());
  47. tea.Score = strdatas[3].Contains("null") ? 0 : decimal.Parse(strdatas[3].Trim());
  48. tea.CreateTime = DateTime.Now;
  49. tea.ModifyTime = DateTime.Now;
  50. tea.CreateUserID = teacher.UserID;
  51. tea.ModifyUserID = teacher.UserID;
  52. tea.SchoolyearID = schoolyear.SchoolyearID;
  53. tea.RecordStatus = 1;
  54. });
  55. result = TeacherScoreServices.SetStudentScore(teas);
  56. if (string.IsNullOrEmpty(result))
  57. {
  58. return Json(new { IsSuccess = true, msg = "修改成功!" }, JsonRequestBehavior.AllowGet);
  59. }
  60. else
  61. {
  62. return Json(new { IsSuccess = false, msg = "失败:" + result }, JsonRequestBehavior.AllowGet);
  63. }
  64. }
  65. catch (Exception ex)
  66. {
  67. return Json(new { IsSuccess = false, msg = "失败:" + ex.Message }, JsonRequestBehavior.AllowGet);
  68. }
  69. }
  70. }
  71. }