123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- 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; }
- /// <summary>
- /// 教学控制页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- /// 教学控制(教学任务)列表查询
- /// </summary>
- /// <returns></returns>
- [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));
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="educationMissionOpenControlID"></param>
- /// <returns></returns>
- public ActionResult CopyAdd(Guid educationMissionOpenControlID)
- {
- EducationMissionOpenControlView educationMissionOpenControlView = new EducationMissionOpenControlView();
- educationMissionOpenControlView = EducationMissionOpenControlServices
- .GetEducationMissionOpenControlView(educationMissionOpenControlID);
- return View("Edit", educationMissionOpenControlView);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="educationMissionOpenControlView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(EducationMissionOpenControlView educationMissionOpenControlView)
- {
- educationMissionOpenControlView.EducationMissionOpenControlID = Guid.Empty;
- return this.Edit(educationMissionOpenControlView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="educationMissionOpenControlID"></param>
- /// <returns></returns>
- [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);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="educationMissionOpenControlView"></param>
- /// <returns></returns>
- [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
- });
- }
- }
- /// <summary>
- /// 教学控制信息批量新增
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult EducationMissionOpenControlBatchAdd()
- {
- EducationMissionOpenControlView educationMissionOpenControlView = new EducationMissionOpenControlView();
- educationMissionOpenControlView.StartDate = DateTime.Now;
- educationMissionOpenControlView.EndDate = DateTime.Now.AddMonths(1);
- return View(educationMissionOpenControlView);
- }
- /// <summary>
- /// 教学控制信息批量新增
- /// </summary>
- /// <param name="educationMissionOpenControlView"></param>
- /// <returns></returns>
- public ActionResult EducationMissionOpenControlBatchAdd(EducationMissionOpenControlView educationMissionOpenControlView)
- {
- try
- {
- var collegeIDList = Request["collegeIDList"].JsonToObject<List<Guid?>>();
- 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
- });
- }
- }
- /// <summary>
- /// 查询对应的未新增院系所信息CollegeView
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [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));
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="educationMissionOpenControlIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string educationMissionOpenControlIDs)
- {
- try
- {
- List<Guid?> 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 });
- }
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
- var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
- var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
- var dateRange = Request.Form["txtDateRange"].ParseStrTo<DateTime>();
-
- 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 = "导出成功。"
- });
- }
- }
- }
|