ClassGroupingController.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.ViewModel;
  7. using EMIS.CommonLogic.EducationManagement;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel.EducationManagement;
  10. using Bowin.Common.Utility;
  11. using Bowin.Common.Data;
  12. using Bowin.Web.Controls.Mvc;
  13. using EMIS.Web.Controls;
  14. using Bowin.Common.Exceptions;
  15. namespace EMIS.Web.Controllers.TeachingManagement
  16. {
  17. [Authorization]
  18. public class ClassGroupingController : Controller
  19. {
  20. public IClassGroupingServices classGroupingService { get; set; }
  21. /// <summary>
  22. /// 上课类型页面
  23. /// </summary>
  24. /// <returns></returns>
  25. public ActionResult List()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 查询分班设置列表
  31. /// </summary>
  32. /// <param name="pararms"></param>
  33. /// <returns></returns>
  34. [HttpPost]
  35. public ActionResult List(QueryParamsModel pararms)
  36. {
  37. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  38. var className = pararms.getExtraString("ClassNameText").Trim();
  39. return this.Json(classGroupingService.GetClassGroupingGrid(configuretView,className, (int)pararms.page, (int)pararms.rows));
  40. }
  41. /// <summary>
  42. /// 编辑
  43. /// </summary>
  44. /// <param name="classGroupingID"></param>
  45. /// <returns></returns>
  46. public ActionResult Edit(Guid? classGroupingID)
  47. {
  48. ClassGroupingView classGroupingView = new ClassGroupingView();
  49. if (classGroupingID != null && classGroupingID != Guid.Empty)
  50. classGroupingView = classGroupingService.GetClassGroupingView(classGroupingID);
  51. else
  52. classGroupingView.IsEnable = true;
  53. return View(classGroupingView);
  54. }
  55. /// <summary>
  56. /// 编辑
  57. /// </summary>
  58. /// <param name="classGrouping"></param>
  59. /// <returns></returns>
  60. [HttpPost]
  61. public ActionResult Edit(ClassGroupingView classGroupingView)
  62. {
  63. try
  64. {
  65. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  66. EM_ClassGrouping classGrouping = null;
  67. var settingsList = DataGrid.GetTableData<ClassGroupingSettingsView>("dgClassGroupingSettingsList");
  68. classGroupingView.TeachingModeIDs = new List<string>();
  69. var isDuplicate = classGroupingService.IsNameDuplicate(classGroupingView.ClassName, classGroupingView.ClassGroupingID);
  70. if (isDuplicate)
  71. {
  72. return Json(new ReturnMessage()
  73. {
  74. IsSuccess = false,
  75. Message = "保存失败,原因:上课类型重复,请重新修改名称。"
  76. });
  77. }
  78. if (classGroupingView.ClassGroupingID == null || classGroupingView.ClassGroupingID == Guid.NewGuid())
  79. {
  80. classGrouping = new EM_ClassGrouping();
  81. classGrouping.ClassGroupingID = Guid.NewGuid();
  82. classGrouping.ClassName = classGroupingView.ClassName;
  83. classGrouping.Remarks = classGroupingView.Remarks;
  84. classGrouping.IsEnable = classGroupingView.IsEnable;
  85. classGrouping.RecordStatus = 1;
  86. classGrouping.CreateTime = DateTime.Now;
  87. classGrouping.CreateUserID = user.UserID;
  88. classGrouping.ModifyTime = DateTime.Now;
  89. classGrouping.ModifyUserID = user.UserID;
  90. classGroupingService.ClassGroupingAdd(classGrouping);
  91. foreach (var settings in settingsList)
  92. {
  93. if (settings.IsClassGrouping)
  94. classGroupingView.TeachingModeIDs.Add(settings.TeachingModeID.ToString());
  95. }
  96. if (classGroupingView.TeachingModeIDs != null)
  97. {
  98. classGroupingService.ClassGroupingSettingsAdd(classGrouping.ClassGroupingID, classGroupingView.TeachingModeIDs);
  99. }
  100. }
  101. else
  102. {
  103. classGrouping = classGroupingService.GetClassGrouping(classGroupingView.ClassGroupingID);
  104. classGrouping.ClassName = classGroupingView.ClassName;
  105. classGrouping.Remarks = classGroupingView.Remarks;
  106. classGrouping.IsEnable = classGroupingView.IsEnable;
  107. classGrouping.ModifyTime = DateTime.Now;
  108. classGrouping.ModifyUserID = user.UserID;
  109. classGroupingService.ClassGroupingUpdate(classGrouping);
  110. foreach (var settings in settingsList)
  111. {
  112. if (settings.IsClassGrouping)
  113. classGroupingView.TeachingModeIDs.Add(settings.TeachingModeID.ToString());
  114. }
  115. if (classGroupingView.TeachingModeIDs != null)
  116. {
  117. classGroupingService.ClassGroupingSettingsAdd(classGrouping.ClassGroupingID, classGroupingView.TeachingModeIDs);
  118. }
  119. }
  120. return Json(new ReturnMessage()
  121. {
  122. IsSuccess = true,
  123. Message = "保存成功!"
  124. });
  125. }
  126. catch (Exception ex)
  127. {
  128. return Json(new ReturnMessage()
  129. {
  130. IsSuccess = false,
  131. Message = "保存失败,原因:" + ex.Message + "!"
  132. });
  133. }
  134. }
  135. /// <summary>
  136. /// 删除
  137. /// </summary>
  138. /// <param name="coursematerialIDs"></param>
  139. /// <returns></returns>
  140. [HttpPost]
  141. public ActionResult Delete(string classGroupingIDs)
  142. {
  143. try
  144. {
  145. List<Guid?> list = new List<Guid?>();
  146. for (int i = 0; i < classGroupingIDs.Split(',').Length; i++)
  147. {
  148. string id = classGroupingIDs.Split(',')[i];
  149. if (!string.IsNullOrEmpty(id))
  150. {
  151. Guid classGroupingID = new Guid(id);
  152. list.Add(classGroupingID);
  153. }
  154. }
  155. classGroupingService.ClassGroupingDelete(list);
  156. return base.Json("删除成功");
  157. }
  158. catch (Exception ex)
  159. {
  160. string mge = ex.Message;
  161. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  162. if (num != null)
  163. {
  164. if (num.Number == 547)
  165. mge = "请先删除所有关联的数据,如:课程资料!";
  166. }
  167. return base.Json("删除失败,原因:" + mge);
  168. }
  169. }
  170. /// <summary>
  171. /// 获取已经存在在授课方式
  172. /// </summary>
  173. /// <param name="specialtyCourseID"></param>
  174. /// <returns></returns>
  175. [HttpPost]
  176. public ActionResult TeachingModeType(Guid? classGroupingID)
  177. {
  178. List<string> list = new List<string>();
  179. if (classGroupingID.HasValue && classGroupingID != Guid.Empty)
  180. list = classGroupingService.GetTeachingMode(classGroupingID);
  181. return base.Json(list);
  182. }
  183. /// <summary>
  184. /// 获取授课方式是否分班列表
  185. /// </summary>
  186. /// <param name="pararms"></param>
  187. /// <returns></returns>
  188. [HttpPost]
  189. public ActionResult ClassGroupingSettingsView(QueryParamsModel pararms)
  190. {
  191. var classGroupingID = Request.QueryString["classGroupingID"] == "" ? Guid.Empty : new Guid(Request.QueryString["classGroupingID"]);
  192. return this.Json(classGroupingService.GetClassGroupingSettingsViewGrid(classGroupingID));
  193. }
  194. /// <summary>
  195. /// 获取上课类型列表
  196. /// </summary>
  197. [HttpPost]
  198. public ActionResult ClassGroupingDropdownListBanid(DropdownListBindType? bindType)
  199. {
  200. List<DropdownListItem> list = new List<DropdownListItem>();
  201. list = classGroupingService.GetAvailableClassGroupingViewList().Select(x => new DropdownListItem { Text = x.ClassName, Value = x.ClassGroupingID.ToString() }).ToList();
  202. DropdownListBindType dbt = bindType == null ? DropdownListBindType.PleaseSelect : bindType.Value;
  203. DropdownList.FormatDropdownItemList(dbt, list);
  204. return base.Json(list);
  205. }
  206. }
  207. }