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.MinorManage.MinorClass; using Bowin.Web.Controls.Mvc; using Bowin.Common.Utility; using Bowin.Common.Data; namespace EMIS.Web.Controllers.MinorManage.MinorClass { [Authorization] public class MinorClassController : Controller { // // GET: /MinorClass/ public IMinorClassServices minorClassServices { get; set; } public ActionResult List() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var standardID = pararms.getExtraInt("MinorStandardDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("MinorStandardDropDown"); var classminorStatus = pararms.getExtraInt("DictionaryClassminorStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryClassminorStatus"); return base.Json(minorClassServices.GetMinorClassViewGrid(configuretView, collegeID, yearID, standardID, classminorStatus, (int)pararms.page, (int)pararms.rows)); } [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo(); var standardID = Request.Form["MinorStandardDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["MinorStandardDropDown"].ParseStrTo(); var classminorStatus = Request.Form["DictionaryClassminorStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryClassminorStatus"].ParseStrTo(); var minorClassIDString = Request.Form["SelectedID"]; var minorClassIDList = minorClassIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); var dt = minorClassServices.GetMinorClassViewList(configuretView, collegeID, yearID, standardID, classminorStatus, minorClassIDList) .Select(x => new { x.SchoolyearCode, x.GradeYearID, x.StandardCode, x.StandardName, x.Name, x.StudentNum, x.RecordStatus, }).ToTable(); string[] liststring = { "学年学期", "年级", "专业代码", "专业名称", "辅修班级", "学生人数", "状态" }; neh.Export(dt, liststring, "辅修班级信息" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } [HttpPost] public ActionResult Delete(string minorClassIDs) { try { List list = minorClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); minorClassServices.MinorClassDelete(list); return base.Json("删除成功。"); } catch (Exception ex) { return base.Json("删除失败,原因:" + ex.Message + "。"); } } [HttpPost] public ActionResult Generate() { try { minorClassServices.GenerateMinorClass(); return base.Json("生成成功。"); } catch (Exception ex) { return base.Json("生成失败,原因:" + ex.Message + "。"); } } [HttpGet] public ActionResult StudentList(Guid minorClassID) { ViewBag.MinorClassID = minorClassID; return View(); } [HttpPost] public ActionResult GetStudentList() { var minorClassID = Request["minorClassID"].ParseStrTo(); return base.Json(minorClassServices.GetStudentsByMinorClassID(minorClassID.Value)); } public ActionResult OpenClass(string minorClassIDs) { try { List list = minorClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); minorClassServices.OpenClassMinor(list); return base.Json("开班成功。"); } catch (Exception ex) { return base.Json("开班失败,原因:" + ex.Message + "。"); } } public ActionResult CancelOpenClass(string minorClassIDs) { try { List list = minorClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); minorClassServices.CancelOpenClassMinor(list); return base.Json("取消开班成功。"); } catch (Exception ex) { return base.Json("取消开班失败,原因:" + ex.Message + "。"); } } } }