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.
 
 
 
 
 
 

182 lines
5.4 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. ///// <summary>
  103. ///// 获取树形数据
  104. ///// </summary>
  105. ///// <param name="parentId">父级id</param>
  106. ///// <returns></returns>
  107. //[HttpGet]
  108. //[AjaxOnly]
  109. //public ActionResult GetTree(string parentId)
  110. //{
  111. // var data = cdDeptIBLL.GetTree(parentId);
  112. // return JsonResult(data);
  113. //}
  114. #endregion
  115. #region 提交数据
  116. /// <summary>
  117. /// 删除实体数据
  118. /// <param name="keyValue">主键</param>
  119. /// <summary>
  120. /// <returns></returns>
  121. [HttpPost]
  122. [AjaxOnly]
  123. public ActionResult DeleteForm(string keyValue)
  124. {
  125. cdDeptIBLL.DeleteEntity(keyValue);
  126. return Success("删除成功!");
  127. }
  128. /// <summary>
  129. /// 保存实体数据(新增、修改)
  130. /// <param name="keyValue">主键</param>
  131. /// <summary>
  132. /// <returns></returns>
  133. [HttpPost]
  134. [ValidateAntiForgeryToken]
  135. [AjaxOnly]
  136. public ActionResult SaveForm(string keyValue, string strEntity)
  137. {
  138. CdDeptEntity entity = strEntity.ToObject<CdDeptEntity>();
  139. entity.SyncFlag = false;
  140. var model = cdDeptIBLL.GetCdDeptEntityByNo(entity.DeptNo);
  141. if (string.IsNullOrEmpty(keyValue))
  142. {
  143. if (model != null)
  144. {
  145. return Fail("系部编号已存在!");
  146. }
  147. }
  148. else
  149. {
  150. if (model != null && model.DeptId != keyValue)
  151. {
  152. return Fail("系部编号已存在!");
  153. }
  154. entity.SyncFlag = true;
  155. //判断排课同步数据是否存在:若存在,清除同步数据;
  156. var arrangeLessonSyncList = arrangeLessonSyncIBLL.GetArrangeLessonSyncListByTableId(keyValue);
  157. if (arrangeLessonSyncList.Any())
  158. {
  159. arrangeLessonSyncIBLL.DeleteEntityByTableId(keyValue);
  160. }
  161. else
  162. {
  163. entity.SyncFlag = false;
  164. }
  165. }
  166. cdDeptIBLL.SaveEntity(keyValue, entity);
  167. return Success("保存成功!");
  168. }
  169. #endregion
  170. }
  171. }