EducationMissionOpenControlController.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Web.Controls.Mvc;
  7. using Bowin.Common.Utility;
  8. using Bowin.Common.Data;
  9. using Bowin.Common.JSON;
  10. using EMIS.Utility;
  11. using EMIS.Web.Controls;
  12. using EMIS.ViewModel;
  13. using EMIS.ViewModel.EducationManage;
  14. using EMIS.CommonLogic.EducationManage;
  15. namespace EMIS.Web.Controllers.EducationManage
  16. {
  17. [Authorization]
  18. public class EducationMissionOpenControlController : Controller
  19. {
  20. public IEducationMissionOpenControlServices EducationMissionOpenControlServices { get; set; }
  21. /// <summary>
  22. /// 教学控制页面
  23. /// </summary>
  24. /// <returns></returns>
  25. public ActionResult List()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 教学控制(教学任务)列表查询
  31. /// </summary>
  32. /// <returns></returns>
  33. [HttpPost]
  34. public ActionResult List(QueryParamsModel pararms)
  35. {
  36. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  37. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  38. var campusID = pararms.getExtraGuid("CampusDropdown");
  39. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  40. var dateRange = pararms.getExtraDateTime("txtDateRange");
  41. return Json(EducationMissionOpenControlServices.GetEducationMissionOpenControlViewGrid(configuretView, schoolyearID,
  42. campusID, collegeID, dateRange, (int)pararms.page, (int)pararms.rows));
  43. }
  44. /// <summary>
  45. /// 复制新增
  46. /// </summary>
  47. /// <param name="educationMissionOpenControlID"></param>
  48. /// <returns></returns>
  49. public ActionResult CopyAdd(Guid educationMissionOpenControlID)
  50. {
  51. EducationMissionOpenControlView educationMissionOpenControlView = new EducationMissionOpenControlView();
  52. educationMissionOpenControlView = EducationMissionOpenControlServices
  53. .GetEducationMissionOpenControlView(educationMissionOpenControlID);
  54. return View("Edit", educationMissionOpenControlView);
  55. }
  56. /// <summary>
  57. /// 复制新增
  58. /// </summary>
  59. /// <param name="educationMissionOpenControlView"></param>
  60. /// <returns></returns>
  61. [HttpPost]
  62. public ActionResult CopyAdd(EducationMissionOpenControlView educationMissionOpenControlView)
  63. {
  64. educationMissionOpenControlView.EducationMissionOpenControlID = Guid.Empty;
  65. return this.Edit(educationMissionOpenControlView);
  66. }
  67. /// <summary>
  68. /// 编辑(新增、修改)
  69. /// </summary>
  70. /// <param name="educationMissionOpenControlID"></param>
  71. /// <returns></returns>
  72. [HttpGet]
  73. public ActionResult Edit(Guid? educationMissionOpenControlID)
  74. {
  75. EducationMissionOpenControlView educationMissionOpenControlView = new EducationMissionOpenControlView();
  76. if (educationMissionOpenControlID.HasValue && educationMissionOpenControlID != Guid.Empty)
  77. {
  78. educationMissionOpenControlView = EducationMissionOpenControlServices
  79. .GetEducationMissionOpenControlView(educationMissionOpenControlID);
  80. }
  81. else
  82. {
  83. educationMissionOpenControlView.SchoolyearID = BaseExtensions.GetCurrentSchoolYearID();
  84. educationMissionOpenControlView.StartDate = DateTime.Now;
  85. educationMissionOpenControlView.EndDate = DateTime.Now.AddMonths(1);
  86. }
  87. return View(educationMissionOpenControlView);
  88. }
  89. /// <summary>
  90. /// 编辑(新增、修改)
  91. /// </summary>
  92. /// <param name="educationMissionOpenControlView"></param>
  93. /// <returns></returns>
  94. [HttpPost]
  95. public ActionResult Edit(EducationMissionOpenControlView educationMissionOpenControlView)
  96. {
  97. try
  98. {
  99. EducationMissionOpenControlServices.EducationMissionOpenControlEdit(educationMissionOpenControlView);
  100. return Json(new ReturnMessage()
  101. {
  102. IsSuccess = true,
  103. Message = "保存成功。"
  104. });
  105. }
  106. catch (Exception ex)
  107. {
  108. return Json(new ReturnMessage()
  109. {
  110. IsSuccess = false,
  111. Message = "保存失败,原因:" + ex.Message
  112. });
  113. }
  114. }
  115. /// <summary>
  116. /// 教学控制信息批量新增
  117. /// </summary>
  118. /// <returns></returns>
  119. [HttpGet]
  120. public ActionResult EducationMissionOpenControlBatchAdd()
  121. {
  122. EducationMissionOpenControlView educationMissionOpenControlView = new EducationMissionOpenControlView();
  123. educationMissionOpenControlView.StartDate = DateTime.Now;
  124. educationMissionOpenControlView.EndDate = DateTime.Now.AddMonths(1);
  125. return View(educationMissionOpenControlView);
  126. }
  127. /// <summary>
  128. /// 教学控制信息批量新增
  129. /// </summary>
  130. /// <param name="educationMissionOpenControlView"></param>
  131. /// <returns></returns>
  132. public ActionResult EducationMissionOpenControlBatchAdd(EducationMissionOpenControlView educationMissionOpenControlView)
  133. {
  134. try
  135. {
  136. var collegeIDList = Request["collegeIDList"].JsonToObject<List<Guid?>>();
  137. string result = EducationMissionOpenControlServices.EducationMissionOpenControlBatchAdd(collegeIDList, educationMissionOpenControlView);
  138. return Json(new ReturnMessage()
  139. {
  140. IsSuccess = true,
  141. Message = "新增成功" + result + "。"
  142. });
  143. }
  144. catch (Exception ex)
  145. {
  146. return Json(new ReturnMessage()
  147. {
  148. IsSuccess = false,
  149. Message = "新增失败,原因:" + ex.Message
  150. });
  151. }
  152. }
  153. /// <summary>
  154. /// 查询对应的未新增院系所信息CollegeView
  155. /// </summary>
  156. /// <param name="pararms"></param>
  157. /// <returns></returns>
  158. [HttpPost]
  159. public ActionResult CollegeNoAddList(QueryParamsModel pararms)
  160. {
  161. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  162. var campusID = pararms.getExtraGuid("CampusDropdown");
  163. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  164. var unitCategoryID = pararms.getExtraInt("DictionaryUnitCategory") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryUnitCategory");
  165. var schoolyearID = pararms.getExtraGuid("SchoolyearID");
  166. return base.Json(EducationMissionOpenControlServices.GetCollegeViewNoAddGrid(configuretView, campusID, collegeID,
  167. unitCategoryID, schoolyearID, (int)pararms.page, (int)pararms.rows));
  168. }
  169. /// <summary>
  170. /// 删除
  171. /// </summary>
  172. /// <param name="educationMissionOpenControlIDs"></param>
  173. /// <returns></returns>
  174. [HttpPost]
  175. public ActionResult Delete(string educationMissionOpenControlIDs)
  176. {
  177. try
  178. {
  179. List<Guid?> list = educationMissionOpenControlIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  180. .Select(x => (Guid?)new Guid(x)).ToList();
  181. EducationMissionOpenControlServices.EducationMissionOpenControlDelete(list);
  182. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  183. }
  184. catch (Exception ex)
  185. {
  186. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
  187. }
  188. }
  189. /// <summary>
  190. /// Excel导出
  191. /// </summary>
  192. /// <returns></returns>
  193. [HttpPost]
  194. public ActionResult Excel()
  195. {
  196. NpoiExcelHelper neh = new NpoiExcelHelper();
  197. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  198. var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  199. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  200. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  201. var dateRange = Request.Form["txtDateRange"].ParseStrTo<DateTime>();
  202. var dt = EducationMissionOpenControlServices.GetEducationMissionOpenControlViewList(configuretView, schoolyearID, campusID,
  203. collegeID, dateRange)
  204. .Select(x => new
  205. {
  206. x.SchoolyearCode,
  207. x.CollegeNo,
  208. x.CollegeName,
  209. x.UnitCategoryName,
  210. x.CampusNo,
  211. x.CampusName,
  212. StartDate = x.StartDate == null ? null : x.StartDate.Value.ToString("yyyy-MM-dd"),
  213. EndDate = x.EndDate == null ? null : x.EndDate.Value.ToString("yyyy-MM-dd"),
  214. x.OpenDays,
  215. x.CreateUserName
  216. }).ToTable();
  217. string[] liststring = {
  218. "学年学期", RSL.Get("CollegeCode"), RSL.Get("CollegeName"), "单位类别",
  219. RSL.Get("CampusCode"), RSL.Get("CampusName"), "开始日期", "结束日期",
  220. "开放天数", "创建人"
  221. };
  222. neh.Export(dt, liststring, "教学控制信息" + DateTime.Now.ToString("yyyyMMdd"));
  223. return Json(new ReturnMessage()
  224. {
  225. IsSuccess = true,
  226. Message = "导出成功。"
  227. });
  228. }
  229. }
  230. }