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.
 
 
 
 
 
 

172 lines
5.0 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 10:53
  14. /// 描 述:系部信息管理
  15. /// </summary>
  16. public class CdDeptController : MvcControllerBase
  17. {
  18. private CdDeptIBLL cdDeptIBLL = new CdDeptBLL();
  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. #endregion
  40. #region 获取数据
  41. /// <summary>
  42. /// 获取树形数据
  43. /// </summary>
  44. /// <param name="parentId">父级id</param>
  45. /// <returns></returns>
  46. [HttpGet]
  47. [AjaxOnly]
  48. public ActionResult GetTree(string parentId)
  49. {
  50. var data = cdDeptIBLL.GetTree(parentId);
  51. return JsonResult(data);
  52. }
  53. /// <summary>
  54. /// 获取页面显示列表数据
  55. /// <summary>
  56. /// <param name="queryJson">查询参数</param>
  57. /// <returns></returns>
  58. [HttpGet]
  59. [AjaxOnly]
  60. public ActionResult GetPageList(string pagination, string queryJson)
  61. {
  62. Pagination paginationobj = pagination.ToObject<Pagination>();
  63. var data = cdDeptIBLL.GetPageList(paginationobj, queryJson);
  64. var jsonData = new
  65. {
  66. rows = data,
  67. total = paginationobj.total,
  68. page = paginationobj.page,
  69. records = paginationobj.records
  70. };
  71. return Success(jsonData);
  72. }
  73. /// <summary>
  74. /// 获取表单数据
  75. /// <summary>
  76. /// <returns></returns>
  77. [HttpGet]
  78. [AjaxOnly]
  79. public ActionResult GetFormData(string keyValue)
  80. {
  81. var CdDeptData = cdDeptIBLL.GetCdDeptEntity(keyValue);
  82. var jsonData = new
  83. {
  84. CdDept = CdDeptData,
  85. };
  86. return Success(jsonData);
  87. }
  88. [HttpGet]
  89. [AjaxOnly]
  90. public ActionResult GetListBySchoolId(string F_SchoolId)
  91. {
  92. var data = cdDeptIBLL.GetListBySchoolId(F_SchoolId);
  93. return Success(data);
  94. }
  95. [HttpGet]
  96. [AjaxOnly]
  97. public ActionResult GetDeptInfo()
  98. {
  99. var data = cdDeptIBLL.GetAllList();
  100. return Success(data);
  101. }
  102. #endregion
  103. #region 提交数据
  104. /// <summary>
  105. /// 删除实体数据
  106. /// <param name="keyValue">主键</param>
  107. /// <summary>
  108. /// <returns></returns>
  109. [HttpPost]
  110. [AjaxOnly]
  111. public ActionResult DeleteForm(string keyValue)
  112. {
  113. cdDeptIBLL.DeleteEntity(keyValue);
  114. return Success("删除成功!");
  115. }
  116. /// <summary>
  117. /// 保存实体数据(新增、修改)
  118. /// <param name="keyValue">主键</param>
  119. /// <summary>
  120. /// <returns></returns>
  121. [HttpPost]
  122. [ValidateAntiForgeryToken]
  123. [AjaxOnly]
  124. public ActionResult SaveForm(string keyValue, string strEntity)
  125. {
  126. CdDeptEntity entity = strEntity.ToObject<CdDeptEntity>();
  127. entity.SyncFlag = false;
  128. var model = cdDeptIBLL.GetCdDeptEntityByNo(entity.DeptNo);
  129. if (string.IsNullOrEmpty(keyValue))
  130. {
  131. if (model != null)
  132. {
  133. return Fail("系部编号已存在!");
  134. }
  135. }
  136. else
  137. {
  138. if (model != null && model.DeptId != keyValue)
  139. {
  140. return Fail("系部编号已存在!");
  141. }
  142. entity.SyncFlag = true;
  143. //判断排课同步数据是否存在:若存在,清除同步数据;
  144. var arrangeLessonSyncList = arrangeLessonSyncIBLL.GetArrangeLessonSyncListByTableId(keyValue);
  145. if (arrangeLessonSyncList.Any())
  146. {
  147. arrangeLessonSyncIBLL.DeleteEntityByTableId(keyValue);
  148. }
  149. else
  150. {
  151. entity.SyncFlag = false;
  152. }
  153. }
  154. cdDeptIBLL.SaveEntity(keyValue, entity);
  155. return Success("保存成功!");
  156. }
  157. #endregion
  158. }
  159. }