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.
 
 
 
 
 
 

192 lines
5.7 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-22 16:32
  14. /// 描 述:专业信息管理
  15. /// </summary>
  16. public class CdMajorController : MvcControllerBase
  17. {
  18. private CdMajorIBLL cdMajorIBLL = new CdMajorBLL();
  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. /// <summary>
  31. /// 表单页
  32. /// <summary>
  33. /// <returns></returns>
  34. [HttpGet]
  35. public ActionResult Form()
  36. {
  37. return View();
  38. }
  39. /// <summary>
  40. /// 主页面【设置选课专业】
  41. /// <summary>
  42. /// <returns></returns>
  43. [HttpGet]
  44. public ActionResult IndexOfElective()
  45. {
  46. return View();
  47. }
  48. #endregion
  49. #region 获取数据
  50. /// <summary>
  51. /// 获取页面显示列表数据
  52. /// <summary>
  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 = cdMajorIBLL.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. [HttpGet]
  71. [AjaxOnly]
  72. public ActionResult GetElectivePageList(string queryJson)
  73. {
  74. var data = cdMajorIBLL.GetElectivePageList(queryJson).OrderBy(x => x.MajorNo).ThenBy(x => x.Grade);
  75. return Success(data);
  76. }
  77. [HttpGet]
  78. [AjaxOnly]
  79. public ActionResult GetListByDeptNo(string DeptNo)
  80. {
  81. var data = cdMajorIBLL.GetListByDeptNo(DeptNo);
  82. return Success(data);
  83. }
  84. /// <summary>
  85. /// 获取表单数据
  86. /// <summary>
  87. /// <returns></returns>
  88. [HttpGet]
  89. [AjaxOnly]
  90. public ActionResult GetFormData(string keyValue)
  91. {
  92. var CdMajorData = cdMajorIBLL.GetCdMajorEntity(keyValue);
  93. var jsonData = new
  94. {
  95. CdMajor = CdMajorData,
  96. };
  97. return Success(jsonData);
  98. }
  99. /// <summary>
  100. /// 获取树形数据
  101. /// </summary>
  102. /// <param name="parentId">父级id</param>
  103. /// <returns></returns>
  104. [HttpGet]
  105. [AjaxOnly]
  106. public ActionResult GetTree(string parentId)
  107. {
  108. var data = cdMajorIBLL.GetTree(parentId);
  109. return JsonResult(data);
  110. }
  111. #endregion
  112. #region 提交数据
  113. [HttpPost]
  114. [AjaxOnly]
  115. public ActionResult Lock(string keyValue)
  116. {
  117. cdMajorIBLL.Lock(keyValue);
  118. return Success("审核成功!");
  119. }
  120. [HttpPost]
  121. [AjaxOnly]
  122. public ActionResult UnLock(string keyValue)
  123. {
  124. cdMajorIBLL.UnLock(keyValue);
  125. return Success("去审成功!");
  126. }
  127. /// <summary>
  128. /// 删除实体数据
  129. /// <param name="keyValue">主键</param>
  130. /// <summary>
  131. /// <returns></returns>
  132. [HttpPost]
  133. [AjaxOnly]
  134. public ActionResult DeleteForm(string keyValue)
  135. {
  136. cdMajorIBLL.DeleteEntity(keyValue);
  137. return Success("删除成功!");
  138. }
  139. /// <summary>
  140. /// 保存实体数据(新增、修改)
  141. /// <param name="keyValue">主键</param>
  142. /// <summary>
  143. /// <returns></returns>
  144. [HttpPost]
  145. [ValidateAntiForgeryToken]
  146. [AjaxOnly]
  147. public ActionResult SaveForm(string keyValue, string strEntity)
  148. {
  149. CdMajorEntity entity = strEntity.ToObject<CdMajorEntity>();
  150. entity.SyncFlag = false;
  151. var model = cdMajorIBLL.GetCdMajorEntityByMajorNo(entity.MajorNo);
  152. if (string.IsNullOrEmpty(keyValue))
  153. {
  154. if (model != null)
  155. {
  156. return Fail("专业编号已存在!");
  157. }
  158. }
  159. else
  160. {
  161. if (model != null && model.ID != keyValue)
  162. {
  163. return Fail("专业编号已存在!");
  164. }
  165. entity.SyncFlag = true;
  166. //判断排课同步数据是否存在:若存在,清除同步数据;
  167. var arrangeLessonSyncList = arrangeLessonSyncIBLL.GetArrangeLessonSyncListByTableId(keyValue);
  168. if (arrangeLessonSyncList.Any())
  169. {
  170. arrangeLessonSyncIBLL.DeleteEntityByTableId(keyValue);
  171. }
  172. else
  173. {
  174. entity.SyncFlag = false;
  175. }
  176. }
  177. cdMajorIBLL.SaveEntity(keyValue, entity);
  178. return Success("保存成功!");
  179. }
  180. #endregion
  181. }
  182. }