using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Web.Controls.Mvc; using Bowin.Common.Utility; using Bowin.Common.Data; using Bowin.Common.JSON; using EMIS.Utility; using EMIS.Web.Controls; using EMIS.ViewModel; using EMIS.ViewModel.EducationManage; using EMIS.CommonLogic.EducationManage; namespace EMIS.Web.Controllers.EducationManage { [Authorization] public class EducationMissionOpenControlController : Controller { public IEducationMissionOpenControlServices EducationMissionOpenControlServices { get; set; } /// /// 教学控制页面 /// /// public ActionResult List() { return View(); } /// /// 教学控制(教学任务)列表查询 /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown"); var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var dateRange = pararms.getExtraDateTime("txtDateRange"); return Json(EducationMissionOpenControlServices.GetEducationMissionOpenControlViewGrid(configuretView, schoolyearID, campusID, collegeID, dateRange, (int)pararms.page, (int)pararms.rows)); } /// /// 复制新增 /// /// /// public ActionResult CopyAdd(Guid educationMissionOpenControlID) { EducationMissionOpenControlView educationMissionOpenControlView = new EducationMissionOpenControlView(); educationMissionOpenControlView = EducationMissionOpenControlServices .GetEducationMissionOpenControlView(educationMissionOpenControlID); return View("Edit", educationMissionOpenControlView); } /// /// 复制新增 /// /// /// [HttpPost] public ActionResult CopyAdd(EducationMissionOpenControlView educationMissionOpenControlView) { educationMissionOpenControlView.EducationMissionOpenControlID = Guid.Empty; return this.Edit(educationMissionOpenControlView); } /// /// 编辑(新增、修改) /// /// /// [HttpGet] public ActionResult Edit(Guid? educationMissionOpenControlID) { EducationMissionOpenControlView educationMissionOpenControlView = new EducationMissionOpenControlView(); if (educationMissionOpenControlID.HasValue && educationMissionOpenControlID != Guid.Empty) { educationMissionOpenControlView = EducationMissionOpenControlServices .GetEducationMissionOpenControlView(educationMissionOpenControlID); } else { educationMissionOpenControlView.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID(); educationMissionOpenControlView.StartDate = DateTime.Now; educationMissionOpenControlView.EndDate = DateTime.Now.AddMonths(1); } return View(educationMissionOpenControlView); } /// /// 编辑(新增、修改) /// /// /// [HttpPost] public ActionResult Edit(EducationMissionOpenControlView educationMissionOpenControlView) { try { EducationMissionOpenControlServices.EducationMissionOpenControlEdit(educationMissionOpenControlView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } /// /// 教学控制信息批量新增 /// /// [HttpGet] public ActionResult EducationMissionOpenControlBatchAdd() { EducationMissionOpenControlView educationMissionOpenControlView = new EducationMissionOpenControlView(); educationMissionOpenControlView.StartDate = DateTime.Now; educationMissionOpenControlView.EndDate = DateTime.Now.AddMonths(1); return View(educationMissionOpenControlView); } /// /// 教学控制信息批量新增 /// /// /// public ActionResult EducationMissionOpenControlBatchAdd(EducationMissionOpenControlView educationMissionOpenControlView) { try { var collegeIDList = Request["collegeIDList"].JsonToObject>(); string result = EducationMissionOpenControlServices.EducationMissionOpenControlBatchAdd(collegeIDList, educationMissionOpenControlView); return Json(new ReturnMessage() { IsSuccess = true, Message = "新增成功" + result + "。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "新增失败,原因:" + ex.Message }); } } /// /// 查询对应的未新增院系所信息CollegeView /// /// /// [HttpPost] public ActionResult CollegeNoAddList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var unitCategoryID = pararms.getExtraInt("DictionaryUnitCategory") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryUnitCategory"); var schoolyearID = pararms.getExtraGuid("SchoolyearID"); return base.Json(EducationMissionOpenControlServices.GetCollegeViewNoAddGrid(configuretView, campusID, collegeID, unitCategoryID, schoolyearID, (int)pararms.page, (int)pararms.rows)); } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string educationMissionOpenControlIDs) { try { List list = educationMissionOpenControlIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); EducationMissionOpenControlServices.EducationMissionOpenControlDelete(list); return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" }); } catch (Exception ex) { return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message }); } } /// /// Excel导出 /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDropdown"].ParseStrTo(); var campusID = Request.Form["CampusDropdown"].ParseStrTo(); var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var dateRange = Request.Form["txtDateRange"].ParseStrTo(); var dt = EducationMissionOpenControlServices.GetEducationMissionOpenControlViewList(configuretView, schoolyearID, campusID, collegeID, dateRange) .Select(x => new { x.SchoolyearCode, x.CollegeNo, x.CollegeName, x.UnitCategoryName, x.CampusNo, x.CampusName, StartDate = x.StartDate == null ? null : x.StartDate.Value.ToString("yyyy-MM-dd"), EndDate = x.EndDate == null ? null : x.EndDate.Value.ToString("yyyy-MM-dd"), x.OpenDays, x.CreateUserName }).ToTable(); string[] liststring = { "学年学期", RSL.Get("CollegeCode"), RSL.Get("CollegeName"), "单位类别", RSL.Get("CampusCode"), RSL.Get("CampusName"), "开始日期", "结束日期", "开放天数", "创建人" }; neh.Export(dt, liststring, "教学控制信息" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } } }