using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.ViewModel; using EMIS.Web.Controls; using EMIS.CommonLogic.ExaminationManage; using Bowin.Common.Utility; using Bowin.Web.Controls.Mvc; using Bowin.Common.Data; using EMIS.Utility.FormValidate; namespace EMIS.Web.Controllers.ExaminationManage { [Authorization] public class StudentExaminationCourseController : Controller { public IStudentExaminationCourseServices studentExaminationCourseServices { get; set; } public ActionResult List() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var userID = CustomPrincipal.Current.UserID; var schoolyearID = pararms.getExtraGuid("ddlSchoolYear"); var examsCategoryID = pararms.getExtraInt("ddlExamsCategory") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlExamsCategory"); var examinationModeID = pararms.getExtraInt("ddlExaminationMode") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlExaminationMode"); var examinationStyleID = pararms.getExtraInt("ddlExaminationStyle") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlExaminationStyle"); return base.Json(studentExaminationCourseServices.GetStudentExaminationCourseViewList(configuretView, schoolyearID, examsCategoryID, examinationModeID, examinationStyleID, userID, (int)pararms.page, (int)pararms.rows)); } [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var userID = CustomPrincipal.Current.UserID; var schoolyearID = Request.Form["ddlSchoolYear"].ParseStrTo(); var examsCategoryID = Request.Form["ddlExamsCategory"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlExamsCategory"].ParseStrTo(); var examinationModeID = Request.Form["ddlExaminationMode"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlExaminationMode"].ParseStrTo(); var examinationStyleID = Request.Form["ddlExaminationStyle"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlExaminationStyle"].ParseStrTo(); if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; var examinationPlanIDString = Request.Form["SelectedID"]; List selectIDlist = new List(); selectIDlist = examinationPlanIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); var dt = studentExaminationCourseServices.GetStudentExaminationCourseViewList(configuretView, schoolyearID, examsCategoryID, examinationModeID, examinationStyleID, userID, selectIDlist).Select(x => new { x.SchoolyearCode, x.CoursematerialName, x.ExaminationModeName, x.ExamsCategoryName, x.ExaminationStyleName, ExaminationDate = x.ExaminationDate.HasValue ? x.ExaminationDate.Value.ToString("yyyy-MM-dd") : "", x.ExaminationTime, x.ClassroomNames, //x.RecordStatusDesc }).ToTable(); string[] liststring = { "学年学期", "考试科目", "考试方式", "考试性质", "考试形式", "考试日期", "考试时间", "考场" }; neh.Export(dt, liststring, "排考课程"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功。", url = Url.Content("~/StudentExaminationCourse/List").AddMenuParameter() }); } } }