using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.ViewModel; using EMIS.Web.Controls; using Bowin.Web.Controls.Mvc; using EMIS.CommonLogic.MinorManage.MinorPlanManage; using EMIS.ViewModel.MinorManage.MinorPlanManage; using Bowin.Common.Utility; using EMIS.Utility; using Bowin.Common.Data; namespace EMIS.Web.Controllers.MinorManage.MinorPlanManage { [Authorization] public class MinorSpecialtyController : Controller { // // GET: /MinorSpecialty/ public IMinorSpecialtyServices MinorSpecialtyServices { get; set; } public ActionResult List() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var grademinorStatus = pararms.getExtraInt("GrademinorStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GrademinorStatusDictionaryDropDown"); return this.Json(MinorSpecialtyServices.GetMinorSpecialtyViewGrid(configuretView, yearID, standardID, collegeID, grademinorStatus, (int)pararms.page, (int)pararms.rows)); } /// /// 修改辅修计划的课程 /// /// [HttpGet] public ActionResult Edit(Guid? GrademinorID) { MinorSpecialtyView minorSpecialtyView = new MinorSpecialtyView(); minorSpecialtyView = MinorSpecialtyServices.GetMinorSpecialtyView(GrademinorID); return View(minorSpecialtyView); } /// /// 开放 /// /// /// [HttpPost] public ActionResult OpenMinorSpecialty(string GrademinorIDs) { try { List list = new List(); for (int i = 0; i < GrademinorIDs.Split(',').Length; i++) { string id = GrademinorIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid GrademinorID = new Guid(id); list.Add(GrademinorID); } } MinorSpecialtyServices.MinorSpecialtyOpen(list); return base.Json("开放成功"); } catch (Exception ex) { string mge = ex.Message; return base.Json("开放失败,原因:" + ex); } } /// /// 取消开放 /// /// /// [HttpPost] public ActionResult CancelMinorSpecialty(string GrademinorIDs) { try { List list = new List(); for (int i = 0; i < GrademinorIDs.Split(',').Length; i++) { string id = GrademinorIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid GrademinorID = new Guid(id); list.Add(GrademinorID); } } MinorSpecialtyServices.MinorSpecialtyCancel(list); return base.Json("取消开放成功"); } catch (Exception ex) { string mge = ex.Message; return base.Json("取消开放失败,原因:" + ex); } } [HttpPost] public ActionResult OpenClass(string grademinorIDs) { try { List list = new List(); for (int i = 0; i < grademinorIDs.Split(',').Length; i++) { string id = grademinorIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid grademinorID = new Guid(id); list.Add(grademinorID); } } MinorSpecialtyServices.OpenClass(list); return base.Json("开班成功"); } catch (Exception ex) { string mge = ex.Message; return base.Json("开班失败,原因:" + mge); } } [HttpPost] public ActionResult OpenCancel(string grademinorIDs) { try { List list = new List(); for (int i = 0; i < grademinorIDs.Split(',').Length; i++) { string id = grademinorIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid grademinorID = new Guid(id); list.Add(grademinorID); } } MinorSpecialtyServices.CancelClass(list); return base.Json("取消开班成功"); } catch (Exception ex) { string mge = ex.Message; return base.Json("取消开班失败,原因:" + mge); } } [HttpGet] public ActionResult StudentList(Guid grademinorID) { ViewBag.GrademinorID = grademinorID; return View(); } [HttpPost] public ActionResult GetStudentList() { var grademinorID = Request["grademinorID"].ParseStrTo(); return base.Json(MinorSpecialtyServices.GetStudentsByGrademinorID(grademinorID.Value)); } /// /// 导出Excel /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); var GrademinorID = Request.Form["GrademinorID"]; ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo(); var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo(); var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var grademinorStatus =Request.Form["GrademinorStatusDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["GrademinorStatusDictionaryDropDown"].ParseStrTo(); List GrademinorIDList = new List(); if (GrademinorID != "") { GrademinorIDList = GrademinorID.SplitIDString(); } else { GrademinorIDList = null; } var dt = MinorSpecialtyServices.GetMinorSpecialtyViewList(configuretView, yearID, standardID, collegeID, grademinorStatus, GrademinorIDList).Select(x => new { x.YearID, x.StandardCode, x.StandardName, x.CollegeName, x.StudentLimit, x.CreateTime, x.CreateUserName, x.OpenStatusStr }).ToTable(); string[] liststring = { "年级", "专业代码", "专业名称", RSL.Get("College"), "人数上限","申请时间", "申请人","状态"}; neh.Export(dt, liststring, "辅修专业信息"); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } } }