using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.CommonLogic.ExaminationApply; using EMIS.ViewModel.ExaminationApply; using EMIS.ViewModel; using EMIS.Web.Controls; using Bowin.Common.Data; using Bowin.Common.Utility; using Bowin.Web.Controls.Mvc; namespace EMIS.Web.Controllers.ExaminationApply { [Authorization] public class ExaminationOpenControlController : Controller { public IOpenControlServices OpenControlServices { get; set; } /// /// 科目控制页面 /// /// public ActionResult List() { return View(); } public ActionResult Edit(Guid? OpenControlID) { OpenControlView openControlView = new OpenControlView(); if (OpenControlID != null && OpenControlID != Guid.Empty) { openControlView = OpenControlServices.GetOpenControlViewInfo(OpenControlID); } return View(openControlView); } /// /// 列表查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var examinationTypeID = pararms.getExtraGuid("ExaminationTypeDropdown"); var examinationSubjectID = pararms.getExtraGuid("ExaminationSubjectDropdown"); var yearNum = pararms.getExtraInt("YearNumDropdown") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YearNumDropdown"); var studentType = pararms.getExtraInt("StudentTypeDropdown") == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StudentTypeDropdown"); if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; return base.Json(OpenControlServices.GetOpenControlViewList(configuretView, examinationTypeID, examinationSubjectID, yearNum, studentType, (int)pararms.page, (int)pararms.rows)); } [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var examinationTypeID = Request.Form["ExaminationTypeDropdown"].ParseStrTo(); var examinationSubjectID = Request.Form["ExaminationSubjectDropdown"].ParseStrTo(); var yearNum = Request.Form["YearNumDropdown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["YearNumDropdown"].ParseStrTo(); var studentType = Request.Form["StudentTypeDropdown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StudentTypeDropdown"].ParseStrTo(); if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; var dt = OpenControlServices.GetOpenControlViewList(configuretView, examinationTypeID, examinationSubjectID, yearNum, studentType).Select(x => new { x.ExaminationSubjectName, x.StudentTypeDesc, x.SchoolyearNumName, StartDate = (x.StartDate.HasValue ? x.StartDate.Value.ToString("yyyy-MM-dd") : ""), EndDate = (x.EndDate.HasValue ? x.EndDate.Value.ToString("yyyy-MM-dd") : ""), x.PeopleNumLimit }).ToTable(); string[] liststring = { "考试科目", "学生类别", "年级数", "报名时间起", "报名时间止", "限定人数" }; neh.Export(dt, liststring, "开放控制信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Content("~/ExaminationOpenControl/List").AddMenuParameter() }); } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string openControlIDs) { try { var openControlIDList = openControlIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList(); OpenControlServices.Delete(openControlIDList); return base.Json("删除成功"); } catch (Exception ex) { return base.Json("删除失败,原因:" + ex.Message + "!"); } } /// /// 修改 /// /// [HttpPost] public ActionResult Edit(OpenControlView openControlView) { try { if (openControlView.StudentTypeID == null && openControlView.ExaminationOpenControlID != null) { return Json(new ReturnMessage() { IsSuccess = false, Message = "请选择学生类别!" }); } if (openControlView.StudentTypeID.Count > 1 && openControlView.ExaminationOpenControlID!=null) { return Json(new ReturnMessage() { IsSuccess = false, Message = "修改操作只能选择一种学生类别!" }); } if (openControlView.StudentTypeID == null && openControlView.ExaminationOpenControlID==null) return Json(new ReturnMessage() { IsSuccess = false, Message = "请选择学生类别!" }); if (openControlView.ExaminationSubjectEditID == null && openControlView.ExaminationOpenControlID != null) return Json(new ReturnMessage() { IsSuccess = false, Message = "请选择考试科目!" }); OpenControlServices.Save(openControlView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } /// /// 获取已经存在在学生类别 /// /// /// [HttpPost] public ActionResult StudentType(Guid? openControlID) { List list = new List(); if (openControlID.HasValue && openControlID != Guid.Empty) list = OpenControlServices.GetStudentType(openControlID); return base.Json(list); } } }