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.
 
 
 
 
 
 

179 lines
5.3 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. #endregion
  100. #region 提交数据
  101. [HttpPost]
  102. [AjaxOnly]
  103. public ActionResult Lock(string keyValue)
  104. {
  105. cdMajorIBLL.Lock(keyValue);
  106. return Success("审核成功!");
  107. }
  108. [HttpPost]
  109. [AjaxOnly]
  110. public ActionResult UnLock(string keyValue)
  111. {
  112. cdMajorIBLL.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. cdMajorIBLL.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. public ActionResult SaveForm(string keyValue, string strEntity)
  136. {
  137. CdMajorEntity entity = strEntity.ToObject<CdMajorEntity>();
  138. entity.SyncFlag = false;
  139. var model = cdMajorIBLL.GetCdMajorEntityByMajorNo(entity.MajorNo);
  140. if (string.IsNullOrEmpty(keyValue))
  141. {
  142. if (model != null)
  143. {
  144. return Fail("专业编号已存在!");
  145. }
  146. }
  147. else
  148. {
  149. if (model != null && model.ID != keyValue)
  150. {
  151. return Fail("专业编号已存在!");
  152. }
  153. entity.SyncFlag = true;
  154. //判断排课同步数据是否存在:若存在,清除同步数据;
  155. var arrangeLessonSyncList = arrangeLessonSyncIBLL.GetArrangeLessonSyncListByTableId(keyValue);
  156. if (arrangeLessonSyncList.Any())
  157. {
  158. arrangeLessonSyncIBLL.DeleteEntityByTableId(keyValue);
  159. }
  160. else
  161. {
  162. entity.SyncFlag = false;
  163. }
  164. }
  165. cdMajorIBLL.SaveEntity(keyValue, entity);
  166. return Success("保存成功!");
  167. }
  168. #endregion
  169. }
  170. }