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.
 
 
 
 
 
 

196 lines
5.9 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.Linq;
  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-01-24 17:03
  14. /// 描 述:课程信息管理
  15. /// </summary>
  16. public class LessonInfoController : MvcControllerBase
  17. {
  18. private LessonInfoIBLL lessonInfoIBLL = new LessonInfoBLL();
  19. private ArrangeLessonSyncIBLL arrangeLessonSyncIBLL = new ArrangeLessonSyncBLL();
  20. #region 视图功能
  21. /// <summary>
  22. /// 主页面
  23. /// <summary>
  24. /// <returns></returns>
  25. [HttpGet]
  26. public ActionResult Index()
  27. {
  28. return View();
  29. }
  30. [HttpGet]
  31. public ActionResult IndexNoMajor()
  32. {
  33. return View();
  34. }
  35. /// <summary>
  36. /// 表单页
  37. /// <summary>
  38. /// <returns></returns>
  39. [HttpGet]
  40. public ActionResult Form()
  41. {
  42. return View();
  43. }
  44. [HttpGet]
  45. public ActionResult FormNoMajor()
  46. {
  47. return View();
  48. }
  49. #endregion
  50. #region 获取数据
  51. /// <summary>
  52. /// 获取页面显示列表数据
  53. /// <summary>
  54. /// <param name="queryJson">查询参数</param>
  55. /// <returns></returns>
  56. [HttpGet]
  57. [AjaxOnly]
  58. public ActionResult GetPageList(string pagination, string queryJson)
  59. {
  60. Pagination paginationobj = pagination.ToObject<Pagination>();
  61. var data = lessonInfoIBLL.GetPageList(paginationobj, queryJson);
  62. var jsonData = new
  63. {
  64. rows = data,
  65. total = paginationobj.total,
  66. page = paginationobj.page,
  67. records = paginationobj.records
  68. };
  69. return Success(jsonData);
  70. }
  71. /// <summary>
  72. /// 获取表单数据
  73. /// <summary>
  74. /// <returns></returns>
  75. [HttpGet]
  76. [AjaxOnly]
  77. public ActionResult GetFormData(string keyValue)
  78. {
  79. var LessonInfoData = lessonInfoIBLL.GetLessonInfoEntity(keyValue);
  80. LessonInfoData.Introduction = WebHelper.HtmlDecode(LessonInfoData.Introduction);
  81. var jsonData = new
  82. {
  83. LessonInfo = LessonInfoData,
  84. };
  85. return Success(jsonData);
  86. }
  87. /// <summary>
  88. /// 获取表单数据
  89. /// <summary>
  90. /// <returns></returns>
  91. [HttpGet]
  92. [AjaxOnly]
  93. public ActionResult GetLessonInfoEntityByLessonNo(string lessonNo)
  94. {
  95. var LessonInfoData = lessonInfoIBLL.GetLessonInfoEntityByLessonNo(lessonNo);
  96. LessonInfoData.Introduction = WebHelper.HtmlDecode(LessonInfoData.Introduction);
  97. return Success(LessonInfoData);
  98. }
  99. /// <summary>
  100. /// 获取表单数据
  101. /// <summary>
  102. /// <returns></returns>
  103. [HttpGet]
  104. [AjaxOnly]
  105. public ActionResult GetLessonByMajorNo(string majorNo)
  106. {
  107. var LessonInfoList = lessonInfoIBLL.GetLessonByMajorNo(majorNo);
  108. return Success(LessonInfoList);
  109. }
  110. #endregion
  111. #region 提交数据
  112. [HttpPost]
  113. [AjaxOnly]
  114. public ActionResult Lock(string keyValue)
  115. {
  116. lessonInfoIBLL.Lock(keyValue);
  117. return Success("操作成功!");
  118. }
  119. [HttpPost]
  120. [AjaxOnly]
  121. public ActionResult UnLock(string keyValue)
  122. {
  123. lessonInfoIBLL.UnLock(keyValue);
  124. return Success("操作成功!");
  125. }
  126. /// <summary>
  127. /// 删除实体数据
  128. /// <param name="keyValue">主键</param>
  129. /// <summary>
  130. /// <returns></returns>
  131. [HttpPost]
  132. [AjaxOnly]
  133. public ActionResult DeleteForm(string keyValue)
  134. {
  135. lessonInfoIBLL.DeleteEntity(keyValue);
  136. return Success("删除成功!");
  137. }
  138. /// <summary>
  139. /// 保存实体数据(新增、修改)
  140. /// <param name="keyValue">主键</param>
  141. /// <summary>
  142. /// <returns></returns>
  143. [HttpPost]
  144. [ValidateAntiForgeryToken]
  145. [AjaxOnly]
  146. [ValidateInput(false)]
  147. public ActionResult SaveForm(string keyValue, string strEntity)
  148. {
  149. LessonInfoEntity entity = strEntity.ToObject<LessonInfoEntity>();
  150. entity.Introduction = WebHelper.HtmlEncode(entity.Introduction);
  151. entity.SyncFlag = false;
  152. var model = lessonInfoIBLL.GetLessonInfoEntityByLessonNo(entity.LessonNo);
  153. if (string.IsNullOrEmpty(keyValue))
  154. {
  155. if (model != null)
  156. {
  157. return Fail("课程编号已存在!");
  158. }
  159. }
  160. else
  161. {
  162. if (model != null && model.LessonId != keyValue)
  163. {
  164. return Fail("课程编号已存在!");
  165. }
  166. entity.SyncFlag = true;
  167. //判断排课同步数据是否存在:若存在,清除同步数据;
  168. var arrangeLessonSyncList = arrangeLessonSyncIBLL.GetArrangeLessonSyncListByTableId(keyValue);
  169. if (arrangeLessonSyncList.Any())
  170. {
  171. arrangeLessonSyncIBLL.DeleteEntityByTableId(keyValue);
  172. }
  173. else
  174. {
  175. entity.SyncFlag = false;
  176. }
  177. }
  178. lessonInfoIBLL.SaveEntity(keyValue, entity);
  179. return Success("保存成功!");
  180. }
  181. #endregion
  182. }
  183. }