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.
 
 
 
 
 
 

185 lines
6.2 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;
  7. using System.Linq;
  8. using DocumentFormat.OpenXml.Office.CustomUI;
  9. namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2019-08-21 17:28
  16. /// 描 述:成绩比例设置
  17. /// </summary>
  18. public class ClassPlanController : MvcControllerBase
  19. {
  20. private ClassPlanIBLL classPlanIBLL = new ClassPlanBLL();
  21. private ClassInfoIBLL classInfoIBLL = new ClassInfoBLL();
  22. private TeachClassIBLL teachClassIBLL = new TeachClassBLL();
  23. #region 视图功能
  24. /// <summary>
  25. /// 主页面
  26. /// <summary>
  27. /// <returns></returns>
  28. [HttpGet]
  29. public ActionResult Index()
  30. {
  31. return View();
  32. }
  33. /// <summary>
  34. /// 表单页
  35. /// <summary>
  36. /// <returns></returns>
  37. [HttpGet]
  38. public ActionResult Form()
  39. {
  40. return View();
  41. }
  42. #endregion
  43. #region 获取数据
  44. /// <summary>
  45. /// 获取页面显示列表数据
  46. /// </summary>
  47. /// <param name="pagination">分页参数</param>
  48. /// <param name="queryJson">查询参数</param>
  49. /// <returns></returns>
  50. [HttpGet]
  51. [AjaxOnly]
  52. public ActionResult GetPageList(string pagination, string queryJson)
  53. {
  54. Pagination paginationobj = pagination.ToObject<Pagination>();
  55. var data = classPlanIBLL.GetPageList(paginationobj, queryJson);
  56. var jsonData = new
  57. {
  58. rows = data,
  59. total = paginationobj.total,
  60. page = paginationobj.page,
  61. records = paginationobj.records
  62. };
  63. return Success(jsonData);
  64. }
  65. /// <summary>
  66. /// 获取表单数据
  67. /// </summary>
  68. /// <param name="keyValue">主键</param>
  69. /// <returns></returns>
  70. [HttpGet]
  71. [AjaxOnly]
  72. public ActionResult GetFormData(string keyValue)
  73. {
  74. var ClassPlanData = classPlanIBLL.GetClassPlanEntity(keyValue);
  75. var jsonData = new
  76. {
  77. ClassPlan = ClassPlanData,
  78. };
  79. return Success(jsonData);
  80. }
  81. #endregion
  82. #region 提交数据
  83. /// <summary>
  84. /// 删除实体数据
  85. /// </summary>
  86. /// <param name="keyValue">主键</param>
  87. /// <returns></returns>
  88. [HttpPost]
  89. [AjaxOnly]
  90. public ActionResult DeleteForm(string keyValue)
  91. {
  92. classPlanIBLL.DeleteEntity(keyValue);
  93. return Success("删除成功!");
  94. }
  95. /// <summary>
  96. /// 保存实体数据(新增、修改)
  97. /// </summary>
  98. /// <param name="keyValue">主键</param>
  99. /// <param name="strEntity">实体</param>
  100. /// <returns></returns>
  101. [HttpPost]
  102. [ValidateAntiForgeryToken]
  103. [AjaxOnly]
  104. public ActionResult SaveForm(string keyValue, string strEntity)
  105. {
  106. OpenLessonPlanEntity entity = strEntity.ToObject<OpenLessonPlanEntity>();
  107. if (!string.IsNullOrEmpty(keyValue))
  108. {
  109. entity.AmendDate = DateTime.Now;
  110. }
  111. entity.State = 0;
  112. entity.IsAllowEdit = true;
  113. entity.MakeDate = DateTime.Now;
  114. var model = classPlanIBLL.GetRepetitions(entity.F_SchoolId, entity.AcademicYearNo, entity.Semester, entity.DeptNo, entity.MajorNo, entity.Grade, entity.LessonNo);
  115. if (model != null)
  116. {
  117. if (keyValue != model.ID.ToString())
  118. {
  119. return Fail("此课程已重复!不可再次添加此课程");
  120. }
  121. }
  122. classPlanIBLL.SaveEntity(keyValue, entity);
  123. return Success("保存成功!");
  124. }
  125. #endregion
  126. #region 扩展数据
  127. /// <summary>
  128. /// 排课
  129. /// </summary>
  130. /// <param name="keyValue">主键</param>
  131. /// <returns></returns>
  132. [HttpPost]
  133. [AjaxOnly]
  134. public ActionResult CourseArranging(string keyValue)
  135. {
  136. var entity = classPlanIBLL.GetListById(keyValue);
  137. List<TeachClassEntity> TeachList = new List<TeachClassEntity>();
  138. for (int i = 0; i < entity.Count; i++)
  139. {
  140. var lessonList = classInfoIBLL.GetAllClass().
  141. Where(x => x.DeptNo == entity[i].DeptNo && x.MajorNo == entity[i].MajorNo && x.Grade == entity[i].Grade)
  142. .OrderBy(x => x.ClassNo).Select(x => x.ClassNo).ToList();
  143. if (lessonList.Count > 0)
  144. {
  145. for (int j = 0; j < lessonList.Count; j++)
  146. {
  147. TeachClassEntity TeachEntity = new TeachClassEntity();
  148. TeachEntity.TeachClassNo = lessonList[j];
  149. TeachEntity.AcademicYearNo = entity[i].AcademicYearNo;
  150. TeachEntity.DeptNo = entity[i].DeptNo;
  151. TeachEntity.MajorNo = entity[i].MajorNo;
  152. TeachEntity.Grade = entity[i].Grade;
  153. TeachEntity.Semester = entity[i].Semester;
  154. TeachEntity.LessonNo = entity[i].LessonNo;
  155. TeachEntity.StuNum = entity[i].StuNum;
  156. TeachEntity.LessonSortNo = entity[i].LessonSortNo;
  157. TeachEntity.F_SchoolId = entity[i].F_SchoolId;
  158. TeachList.Add(TeachEntity);
  159. }
  160. }
  161. else
  162. {
  163. return Fail("排课失败!暂无排课班级");
  164. }
  165. }
  166. teachClassIBLL.SaveEntityList(TeachList);
  167. classPlanIBLL.SaveEntityList(keyValue, entity);
  168. return Success("排课成功");
  169. }
  170. #endregion
  171. }
  172. }