using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.CommonLogic.SelectCourse; using EMIS.ViewModel; using EMIS.Web.Controls; using Bowin.Web.Controls.Mvc; using EMIS.ViewModel.SelectCourse; using Bowin.Common.Utility; using Bowin.Common.Data; namespace EMIS.Web.Controllers.SelectCourseManage { [Authorization] public class ExaminationSubjectCollegeControlController : Controller { // // GET: /ExaminationSubjectCollegeControl/ public IExaminationSubjectCollegeControlServices examinationSubjectCollegeControlServices { get; set; } public ActionResult List() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var examinationTypeID = pararms.getExtraGuid("ExaminationTypeDropdown"); var examinationSubjectID = pararms.getExtraGuid("ExaminationSubjectDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var facultymajorID = pararms.getExtraGuid("FacultymajorDropdown"); int? schoolyearNumID = pararms.getExtraInt("SchoolyearNumDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearNumDropDown"); return base.Json(examinationSubjectCollegeControlServices.GetExaminationSubjectCollegeControlViewGrid(configuretView, examinationTypeID, examinationSubjectID, collegeID, facultymajorID, schoolyearNumID, (int)pararms.page, (int)pararms.rows)); } [HttpGet] public ActionResult Add() { ExaminationSubjectCollegeControlView examinationSubjectCollegeControlView = new ExaminationSubjectCollegeControlView(); return View(examinationSubjectCollegeControlView); } [HttpPost] public ActionResult Add(ExaminationSubjectCollegeControlView examinationSubjectCollegeControlView) { try { var facultymajorString = Request.Form["selectFacultymajorIDs"]; if (facultymajorString == "" || facultymajorString == null) { throw new Exception("请选择院系专业信息"); } var facultymajorIDList = facultymajorString.Split(',').Where(x => x.IndexOf("-") >= 0).Select(x => new Guid(x)).ToList(); examinationSubjectCollegeControlServices.ExaminationSubjectCollegeControlAdd(examinationSubjectCollegeControlView, facultymajorIDList); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } /// /// 修改 /// /// /// [HttpGet] public ActionResult Edit(Guid? examinationSubjectCollegeControlID) { ExaminationSubjectCollegeControlView examinationSubjectCollegeControlView = new ExaminationSubjectCollegeControlView(); if (examinationSubjectCollegeControlID.HasValue) { examinationSubjectCollegeControlView = examinationSubjectCollegeControlServices.GetExaminationSubjectCollegeControlView(examinationSubjectCollegeControlID); } return View(examinationSubjectCollegeControlView); } /// /// 修改 /// /// /// [HttpPost] public ActionResult Edit(ExaminationSubjectCollegeControlView examinationSubjectCollegeControlView) { try { examinationSubjectCollegeControlServices.ExaminationSubjectCollegeControlEdit(examinationSubjectCollegeControlView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } [HttpPost] public ActionResult Delete(string examinationSubjectCollegeControlIDs) { try { List list = examinationSubjectCollegeControlIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); examinationSubjectCollegeControlServices.ExaminationSubjectCollegeControlDelete(list); return base.Json("删除成功。"); } catch (Exception ex) { return base.Json("删除失败,原因:" + ex.Message); } } [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 collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var facultymajorID = Request.Form["FacultymajorDropdown"].ParseStrTo(); int? schoolyearNumID = Request["SchoolyearNumDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request["SchoolyearNumDropDown"].ParseStrTo(); var examinationSubjectCollegeControlIDString = Request.Form["SelectedID"]; var examinationSubjectCollegeControlIDList = examinationSubjectCollegeControlIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); var dt = examinationSubjectCollegeControlServices.GetExaminationSubjectCollegeControlViewList(configuretView, examinationTypeID, examinationSubjectID, collegeID, facultymajorID, schoolyearNumID, examinationSubjectCollegeControlIDList) .Select(x => new { x.ExaminationTypeName, x.ExaminationSubjectName, x.CollegeName, x.FacultymajorName, x.SchoolyearNum }).ToTable(); string[] liststring = { "考试类型", "考试科目", @EMIS.Utility.RSL.Get("College"), "院系专业", "年级数" }; neh.Export(dt, liststring, "专业报考限制" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } } }