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.

ClassroomInfoController.cs 7.8 KiB

преди 4 години
преди 4 години
преди 4 години
преди 2 години
преди 4 години
преди 2 години
преди 4 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. using Learun.Application.TwoDevelopment.LogisticsManagement;
  8. using Newtonsoft.Json;
  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-01-28 17:30
  16. /// 描 述:教室信息管理
  17. /// </summary>
  18. public class ClassroomInfoController : MvcControllerBase
  19. {
  20. private ClassroomInfoIBLL classroomInfoIBLL = new ClassroomInfoBLL();
  21. private ArrangeLessonSyncIBLL arrangeLessonSyncIBLL = new ArrangeLessonSyncBLL();
  22. #region 视图功能
  23. /// <summary>
  24. /// 主页面
  25. /// <summary>
  26. /// <returns></returns>
  27. [HttpGet]
  28. public ActionResult Index()
  29. {
  30. return View();
  31. }
  32. /// <summary>
  33. /// 表单页
  34. /// <summary>
  35. /// <returns></returns>
  36. [HttpGet]
  37. public ActionResult Form()
  38. {
  39. return View();
  40. }
  41. #endregion
  42. #region 获取数据
  43. /// <summary>
  44. /// 获取页面显示列表数据
  45. /// <summary>
  46. /// <param name="queryJson">查询参数</param>
  47. /// <returns></returns>
  48. [HttpGet]
  49. [AjaxOnly]
  50. public ActionResult GetPageList(string pagination, string queryJson)
  51. {
  52. Pagination paginationobj = pagination.ToObject<Pagination>();
  53. var data = classroomInfoIBLL.GetPageList(paginationobj, queryJson);
  54. var jsonData = new
  55. {
  56. rows = data,
  57. total = paginationobj.total,
  58. page = paginationobj.page,
  59. records = paginationobj.records
  60. };
  61. return Success(jsonData);
  62. }
  63. [HttpPost, ValidateInput(false)]
  64. public ActionResult ExportList(string queryJson)
  65. {
  66. var data = classroomInfoIBLL.GetList(queryJson).ToList();
  67. var result = new List<Dictionary<string, string>>();
  68. if (data.Any())
  69. {
  70. foreach (var item in data)
  71. {
  72. var aaa = new Dictionary<string, string>();
  73. aaa.Add("ClassroomName", item.ClassroomName);
  74. aaa.Add("ClassroomNo", item.ClassroomNo);
  75. aaa.Add("StrClassroomType", item.StrClassroomType);
  76. aaa.Add("StrCompany", item.StrCompany);
  77. aaa.Add("StrClassroomBuildingNo", item.StrClassroomBuildingNo);
  78. aaa.Add("ClassroomFloor", item.ClassroomFloor);
  79. aaa.Add("ContainStuNum", item.ContainStuNum.ToString());
  80. aaa.Add("TestContainStuNum", item.TestContainStuNum.ToString());
  81. aaa.Add("StrCheckMark", item.StrCheckMark);
  82. result.Add(aaa);
  83. }
  84. }
  85. var resultStr = JsonConvert.SerializeObject(result);
  86. //数据源
  87. var exportTable = resultStr.ToTable();
  88. //设置导出格式
  89. ExcelConfig excelconfig = new ExcelConfig();
  90. excelconfig.Title = "教室信息";
  91. excelconfig.TitleFont = "微软雅黑";
  92. excelconfig.TitlePoint = 20;
  93. excelconfig.FileName = "教室信息.xls";
  94. excelconfig.IsAllSizeColumn = true;
  95. //每一列的设置,没有设置的列信息,系统将按datatable中的列名导出
  96. excelconfig.ColumnEntity = new List<ColumnModel>();
  97. excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "ClassroomName", ExcelColumn = "教室名称" });
  98. excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "ClassroomNo", ExcelColumn = "教室编号" });
  99. excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "StrClassroomType", ExcelColumn = "教室类型" });
  100. excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "StrCompany", ExcelColumn = "校区" });
  101. excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "StrClassroomBuildingNo", ExcelColumn = "教学楼" });
  102. excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "ClassroomFloor", ExcelColumn = "所在楼层" });
  103. excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "ContainStuNum", ExcelColumn = "容纳人数" });
  104. excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "TestContainStuNum", ExcelColumn = "考试人数" });
  105. excelconfig.ColumnEntity.Add(new ColumnModel() { Column = "StrCheckMark", ExcelColumn = "是否启用" });
  106. //调用导出方法
  107. ExcelHelper.ExcelDownload(exportTable, excelconfig);
  108. return Success("导出成功!");
  109. }
  110. /// <summary>
  111. /// 获取表单数据
  112. /// <summary>
  113. /// <returns></returns>
  114. [HttpGet]
  115. [AjaxOnly]
  116. public ActionResult GetFormData(string keyValue)
  117. {
  118. var ClassroomInfoData = classroomInfoIBLL.GetClassroomInfoEntity(keyValue);
  119. var jsonData = new
  120. {
  121. ClassroomInfo = ClassroomInfoData,
  122. };
  123. return Success(jsonData);
  124. }
  125. #endregion
  126. #region 提交数据
  127. [HttpPost]
  128. [AjaxOnly]
  129. public ActionResult Lock(string keyValue)
  130. {
  131. classroomInfoIBLL.Lock(keyValue);
  132. return Success("操作成功!");
  133. }
  134. [HttpPost]
  135. [AjaxOnly]
  136. public ActionResult UnLock(string keyValue)
  137. {
  138. classroomInfoIBLL.UnLock(keyValue);
  139. return Success("操作成功!");
  140. }
  141. /// <summary>
  142. /// 删除实体数据
  143. /// <param name="keyValue">主键</param>
  144. /// <summary>
  145. /// <returns></returns>
  146. [HttpPost]
  147. [AjaxOnly]
  148. public ActionResult DeleteForm(string keyValue)
  149. {
  150. classroomInfoIBLL.DeleteEntity(keyValue);
  151. return Success("删除成功!");
  152. }
  153. /// <summary>
  154. /// 保存实体数据(新增、修改)
  155. /// <param name="keyValue">主键</param>
  156. /// <summary>
  157. /// <returns></returns>
  158. [HttpPost]
  159. [ValidateAntiForgeryToken]
  160. [AjaxOnly]
  161. public ActionResult SaveForm(string keyValue, string strEntity)
  162. {
  163. ClassroomInfoEntity entity = strEntity.ToObject<ClassroomInfoEntity>();
  164. entity.SyncFlag = false;
  165. var model = classroomInfoIBLL.GetClassroomInfoEntityByNo(entity.ClassroomNo);
  166. if (string.IsNullOrEmpty(keyValue))
  167. {
  168. if (model != null)
  169. {
  170. return Fail("教室编号已存在!");
  171. }
  172. }
  173. else
  174. {
  175. if (model != null && model.ClassroomId != keyValue)
  176. {
  177. return Fail("教室编号已存在!");
  178. }
  179. entity.SyncFlag = true;
  180. //判断排课同步数据是否存在:若存在,清除同步数据;
  181. var arrangeLessonSyncList = arrangeLessonSyncIBLL.GetArrangeLessonSyncListByTableId(keyValue);
  182. if (arrangeLessonSyncList.Any())
  183. {
  184. arrangeLessonSyncIBLL.DeleteEntityByTableId(keyValue);
  185. }
  186. else
  187. {
  188. entity.SyncFlag = false;
  189. }
  190. }
  191. classroomInfoIBLL.SaveEntity(keyValue, entity);
  192. return Success("保存成功!");
  193. }
  194. #endregion
  195. }
  196. }