You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

197 lines
6.2 KiB

  1. using Learun.Util;
  2. using System.Data;
  3. using Learun.Application.TwoDevelopment.EducationalAdministration;
  4. using System.Web.Mvc;
  5. using System.Collections.Generic;
  6. using System.Collections;
  7. namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
  8. {
  9. /// <summary>
  10. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  11. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  12. /// 创 建:超级管理员
  13. /// 日 期:2019-07-03 14:31
  14. /// 描 述:校历管理
  15. /// </summary>
  16. public class SchoolCalendarController : MvcControllerBase
  17. {
  18. private SchoolCalendarIBLL schoolCalendarIBLL = new SchoolCalendarBLL();
  19. #region 视图功能
  20. /// <summary>
  21. /// 主页面
  22. /// <summary>
  23. /// <returns></returns>
  24. [HttpGet]
  25. public ActionResult Index()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 表单页
  31. /// <summary>
  32. /// <returns></returns>
  33. [HttpGet]
  34. public ActionResult Form()
  35. {
  36. return View();
  37. }
  38. /// <summary>
  39. /// 主页面
  40. /// <summary>
  41. /// <returns></returns>
  42. [HttpGet]
  43. public ActionResult ScheduleIndex()
  44. {
  45. return View();
  46. }
  47. #endregion
  48. #region 获取数据
  49. /// <summary>
  50. /// 获取页面显示列表分页数据
  51. /// <summary>
  52. /// <param name="pagination">分页参数</param>
  53. /// <param name="queryJson">查询参数</param>
  54. /// <returns></returns>
  55. [HttpGet]
  56. [AjaxOnly]
  57. public ActionResult GetPageList(string pagination, string queryJson)
  58. {
  59. Pagination paginationobj = pagination.ToObject<Pagination>();
  60. var data = schoolCalendarIBLL.GetPageList(paginationobj, queryJson);
  61. var jsonData = new
  62. {
  63. rows = data,
  64. total = paginationobj.total,
  65. page = paginationobj.page,
  66. records = paginationobj.records
  67. };
  68. return Success(jsonData);
  69. }
  70. /// <summary>
  71. /// 获取日程数据
  72. /// </summary>
  73. /// <returns></returns>
  74. [HttpGet]
  75. public ActionResult GetListForSchedule()
  76. {
  77. var userInfo = LoginUserInfo.Get();
  78. List<Hashtable> data = new List<Hashtable>();
  79. foreach (SchoolCalendarEntity entity in schoolCalendarIBLL.GetList())
  80. {
  81. Hashtable ht = new Hashtable();
  82. ht["id"] = entity.ID;
  83. ht["academicYearNo"] = "【" + entity.AcademicYearNo + "】";
  84. ht["title"] = entity.Content;
  85. ht["end"] = (entity.EndTime.ToDate().ToString("yyyy-MM-dd") + " " + entity.EndTime.ToString().Substring(0, 2) + ":" + entity.EndTime.ToString().Substring(2, 2)).ToDate().ToString("yyyy-MM-dd HH:mm:ss");
  86. ht["start"] = (entity.StartTime.ToDate().ToString("yyyy-MM-dd") + " " + entity.StartTime.ToString().Substring(0, 2) + ":" + entity.StartTime.ToString().Substring(2, 2)).ToDate().ToString("yyyy-MM-dd HH:mm:ss");
  87. ht["allDay"] = false;
  88. data.Add(ht);
  89. }
  90. return ToJsonResult(data);
  91. }
  92. /// <summary>
  93. /// 获取页面显示列表数据
  94. /// <summary>
  95. /// <param name="queryJson">查询参数</param>
  96. /// <returns></returns>
  97. [HttpGet]
  98. [AjaxOnly]
  99. public ActionResult GetList(string queryJson)
  100. {
  101. var data = schoolCalendarIBLL.GetList(queryJson);
  102. return Success(data);
  103. }
  104. /// <summary>
  105. /// 获取表单数据
  106. /// <summary>
  107. /// <returns></returns>
  108. [HttpGet]
  109. [AjaxOnly]
  110. public ActionResult GetFormData(string keyValue)
  111. {
  112. var SchoolCalendarData = schoolCalendarIBLL.GetSchoolCalendarEntity(keyValue);
  113. var jsonData = new
  114. {
  115. SchoolCalendar = SchoolCalendarData,
  116. };
  117. return Success(jsonData);
  118. }
  119. #endregion
  120. #region 提交数据
  121. /// <summary>
  122. /// 删除实体数据
  123. /// <param name="keyValue">主键</param>
  124. /// <summary>
  125. /// <returns></returns>
  126. [HttpPost]
  127. [AjaxOnly]
  128. public ActionResult DeleteForm(string keyValue)
  129. {
  130. schoolCalendarIBLL.DeleteEntity(keyValue);
  131. return Success("删除成功!");
  132. }
  133. /// <summary>
  134. /// 保存实体数据(新增、修改)
  135. /// <param name="keyValue">主键</param>
  136. /// <summary>
  137. /// <returns></returns>
  138. [HttpPost]
  139. [ValidateAntiForgeryToken]
  140. [AjaxOnly]
  141. public ActionResult SaveForm(string keyValue, string strEntity)
  142. {
  143. UserInfo userInfo = LoginUserInfo.Get();
  144. SchoolCalendarEntity entity = strEntity.ToObject<SchoolCalendarEntity>();
  145. //根据学年和学期查询
  146. var model = schoolCalendarIBLL.GetSchoolCalendarEntityByNo(entity.AcademicYearNo, entity.Semester);
  147. if (string.IsNullOrEmpty(keyValue))
  148. {
  149. if (model != null)
  150. {
  151. return Fail("当前学期已存在!");
  152. }
  153. }
  154. else
  155. {
  156. if (model != null && model.ID != keyValue)
  157. {
  158. return Fail("当前学期已存在!");
  159. }
  160. }
  161. schoolCalendarIBLL.SaveEntity(userInfo, keyValue, entity);
  162. return Success("保存成功!");
  163. }
  164. #endregion
  165. #region 扩展数据
  166. /// <summary>
  167. /// 学年
  168. /// </summary>
  169. /// <returns></returns>
  170. [HttpGet]
  171. public ActionResult GenerateNearByAcademic()
  172. {
  173. return Success(Learun.Util.WebHelper.GenerateNearByAcademic());
  174. }
  175. /// <summary>
  176. /// 学期
  177. /// </summary>
  178. /// <returns></returns>
  179. [HttpGet]
  180. public ActionResult GenerateNearBySemeter()
  181. {
  182. return Success(Learun.Util.WebHelper.GenerateNearBySemeter());
  183. }
  184. #endregion
  185. }
  186. }