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.
 
 
 
 
 
 

184 lines
5.6 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. #endregion
  100. #region 提交数据
  101. [HttpPost]
  102. [AjaxOnly]
  103. public ActionResult Lock(string keyValue)
  104. {
  105. lessonInfoIBLL.Lock(keyValue);
  106. return Success("审核成功!");
  107. }
  108. [HttpPost]
  109. [AjaxOnly]
  110. public ActionResult UnLock(string keyValue)
  111. {
  112. lessonInfoIBLL.UnLock(keyValue);
  113. return Success("去审成功!");
  114. }
  115. /// <summary>
  116. /// 删除实体数据
  117. /// <param name="keyValue">主键</param>
  118. /// <summary>
  119. /// <returns></returns>
  120. [HttpPost]
  121. [AjaxOnly]
  122. public ActionResult DeleteForm(string keyValue)
  123. {
  124. lessonInfoIBLL.DeleteEntity(keyValue);
  125. return Success("删除成功!");
  126. }
  127. /// <summary>
  128. /// 保存实体数据(新增、修改)
  129. /// <param name="keyValue">主键</param>
  130. /// <summary>
  131. /// <returns></returns>
  132. [HttpPost]
  133. [ValidateAntiForgeryToken]
  134. [AjaxOnly]
  135. [ValidateInput(false)]
  136. public ActionResult SaveForm(string keyValue, string strEntity)
  137. {
  138. LessonInfoEntity entity = strEntity.ToObject<LessonInfoEntity>();
  139. entity.Introduction = WebHelper.HtmlEncode(entity.Introduction);
  140. entity.SyncFlag = false;
  141. var model = lessonInfoIBLL.GetLessonInfoEntityByLessonNo(entity.LessonNo);
  142. if (string.IsNullOrEmpty(keyValue))
  143. {
  144. if (model != null)
  145. {
  146. return Fail("课程编号已存在!");
  147. }
  148. }
  149. else
  150. {
  151. if (model != null && model.LessonId != keyValue)
  152. {
  153. return Fail("课程编号已存在!");
  154. }
  155. entity.SyncFlag = true;
  156. //判断排课同步数据是否存在:若存在,清除同步数据;
  157. var arrangeLessonSyncList = arrangeLessonSyncIBLL.GetArrangeLessonSyncListByTableId(keyValue);
  158. if (arrangeLessonSyncList.Any())
  159. {
  160. arrangeLessonSyncIBLL.DeleteEntityByTableId(keyValue);
  161. }
  162. else
  163. {
  164. entity.SyncFlag = false;
  165. }
  166. }
  167. lessonInfoIBLL.SaveEntity(keyValue, entity);
  168. return Success("保存成功!");
  169. }
  170. #endregion
  171. }
  172. }