123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- 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.SchedulingManage;
- using EMIS.CommonLogic.SchedulingManage.SchedulingSettings;
- namespace EMIS.Web.Controllers.SchedulingManage.SchedulingSettings
- {
- [Authorization]
- public class CollegePriorityController : Controller
- {
- public ICollegePriorityServices CollegePriorityServices { 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 campusID = pararms.getExtraGuid("CampusDropdown");
- var collegeID = pararms.getExtraGuid("CollegeDropdown");
- var dateRange = pararms.getExtraDateTime("txtDateRange");
- return Json(CollegePriorityServices.GetCollegePriorityViewGrid(configuretView, campusID, collegeID,
- dateRange, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="collegePriorityID"></param>
- /// <returns></returns>
- public ActionResult CopyAdd(Guid collegePriorityID)
- {
- CollegePriorityView collegePriorityView = new CollegePriorityView();
- collegePriorityView = CollegePriorityServices.GetCollegePriorityView(collegePriorityID);
- return View("Edit", collegePriorityView);
- }
- /// <summary>
- /// 复制新增
- /// </summary>
- /// <param name="collegePriorityView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult CopyAdd(CollegePriorityView collegePriorityView)
- {
- collegePriorityView.CollegePriorityID = Guid.Empty;
- return this.Edit(collegePriorityView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="collegePriorityID"></param>
- /// <returns></returns>
- public ActionResult Edit(Guid? collegePriorityID)
- {
- CollegePriorityView collegePriorityView = new CollegePriorityView();
- if (collegePriorityID.HasValue && collegePriorityID != Guid.Empty)
- {
- collegePriorityView = CollegePriorityServices.GetCollegePriorityView(collegePriorityID);
- }
- else
- {
- collegePriorityView.Priority = 1;
- collegePriorityView.StartDate = DateTime.Now;
- collegePriorityView.EndDate = DateTime.Now.AddMonths(1);
- }
- return View(collegePriorityView);
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="collegePriorityView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(CollegePriorityView collegePriorityView)
- {
- try
- {
- CollegePriorityServices.CollegePriorityEdit(collegePriorityView);
- 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 CollegePriorityBatchAdd()
- {
- CollegePriorityView collegePriorityView = new CollegePriorityView();
- collegePriorityView.Priority = 1;
- collegePriorityView.StartDate = DateTime.Now;
- collegePriorityView.EndDate = DateTime.Now.AddMonths(1);
- return View(collegePriorityView);
- }
- /// <summary>
- /// 院系控制信息批量新增
- /// </summary>
- /// <param name="collegePriorityView"></param>
- /// <returns></returns>
- public ActionResult CollegePriorityBatchAdd(CollegePriorityView collegePriorityView)
- {
- try
- {
- var collegeIDList = Request["collegeIDList"].JsonToObject<List<Guid?>>();
- string result = CollegePriorityServices.CollegePriorityBatchAdd(collegeIDList, collegePriorityView);
- 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");
- return base.Json(CollegePriorityServices.GetCollegeViewNoAddGrid(configuretView, campusID, collegeID,
- unitCategoryID, (int)pararms.page, (int)pararms.rows));
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="collegePriorityIDs"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string collegePriorityIDs)
- {
- try
- {
- List<Guid?> list = collegePriorityIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => (Guid?)new Guid(x)).ToList();
- CollegePriorityServices.CollegePriorityDelete(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 campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
- var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
- var dateRange = Request.Form["txtDateRange"].ParseStrTo<DateTime>();
- var dt = CollegePriorityServices.GetCollegePriorityViewList(configuretView, campusID, collegeID, dateRange)
- .Select(x => new
- {
- x.CollegeNo,
- x.CollegeName,
- x.UnitCategoryName,
- x.Priority,
- 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 = "导出成功。"
- });
- }
- }
- }
|