StudentExaminationCourseController.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.ViewModel;
  7. using EMIS.Web.Controls;
  8. using EMIS.CommonLogic.ExaminationManage;
  9. using Bowin.Common.Utility;
  10. using Bowin.Web.Controls.Mvc;
  11. using Bowin.Common.Data;
  12. using EMIS.Utility.FormValidate;
  13. namespace EMIS.Web.Controllers.ExaminationManage
  14. {
  15. [Authorization]
  16. public class StudentExaminationCourseController : Controller
  17. {
  18. public IStudentExaminationCourseServices studentExaminationCourseServices { get; set; }
  19. public ActionResult List()
  20. {
  21. return View();
  22. }
  23. [HttpPost]
  24. public ActionResult List(QueryParamsModel pararms)
  25. {
  26. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  27. var userID = CustomPrincipal.Current.UserID;
  28. var schoolyearID = pararms.getExtraGuid("ddlSchoolYear");
  29. var examsCategoryID = pararms.getExtraInt("ddlExamsCategory") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlExamsCategory");
  30. var examinationModeID = pararms.getExtraInt("ddlExaminationMode") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlExaminationMode");
  31. var examinationStyleID = pararms.getExtraInt("ddlExaminationStyle") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlExaminationStyle");
  32. return base.Json(studentExaminationCourseServices.GetStudentExaminationCourseViewList(configuretView, schoolyearID, examsCategoryID,
  33. examinationModeID, examinationStyleID, userID, (int)pararms.page, (int)pararms.rows));
  34. }
  35. [HttpPost]
  36. public ActionResult Excel()
  37. {
  38. NpoiExcelHelper neh = new NpoiExcelHelper();
  39. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  40. var userID = CustomPrincipal.Current.UserID;
  41. var schoolyearID = Request.Form["ddlSchoolYear"].ParseStrTo<Guid>();
  42. var examsCategoryID = Request.Form["ddlExamsCategory"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlExamsCategory"].ParseStrTo<int>();
  43. var examinationModeID = Request.Form["ddlExaminationMode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlExaminationMode"].ParseStrTo<int>();
  44. var examinationStyleID = Request.Form["ddlExaminationStyle"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlExaminationStyle"].ParseStrTo<int>();
  45. if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  46. var examinationPlanIDString = Request.Form["SelectedID"];
  47. List<Guid?> selectIDlist = new List<Guid?>();
  48. selectIDlist = examinationPlanIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  49. var dt = studentExaminationCourseServices.GetStudentExaminationCourseViewList(configuretView, schoolyearID, examsCategoryID,
  50. examinationModeID, examinationStyleID, userID, selectIDlist).Select(x => new
  51. {
  52. x.SchoolyearCode,
  53. x.CoursematerialName,
  54. x.ExaminationModeName,
  55. x.ExamsCategoryName,
  56. x.ExaminationStyleName,
  57. ExaminationDate = x.ExaminationDate.HasValue ? x.ExaminationDate.Value.ToString("yyyy-MM-dd") : "",
  58. x.ExaminationTime,
  59. x.ClassroomNames,
  60. //x.RecordStatusDesc
  61. }).ToTable();
  62. string[] liststring = { "学年学期", "考试科目", "考试方式", "考试性质", "考试形式", "考试日期", "考试时间", "考场" };
  63. neh.Export(dt, liststring, "排考课程");
  64. return RedirectToAction("MsgShow", "Common", new
  65. {
  66. msg = "导出成功。",
  67. url = Url.Content("~/StudentExaminationCourse/List").AddMenuParameter()
  68. });
  69. }
  70. }
  71. }