ExecutableMinorPlanController.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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.Web.Controls;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.CommonLogic.CalendarManage;
  10. using EMIS.CommonLogic.EducationManage;
  11. using EMIS.ViewModel.EducationManage;
  12. using Bowin.Common.Exceptions;
  13. namespace EMIS.Web.Controllers.EducationManage
  14. {
  15. [Authorization]
  16. public class ExecutableMinorPlanController : Controller
  17. {
  18. //
  19. // GET: /ExecutableMinorPlan/
  20. public ISchoolYearServices SchoolYearServices { get; set; }
  21. public IExecutableMinorPlanServices ExecutableMinorPlanServices { get; set; }
  22. public ActionResult List()
  23. {
  24. var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
  25. ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年
  26. return View();
  27. }
  28. /// <summary>
  29. /// 查询列表
  30. /// </summary>
  31. /// <param name="pararms"></param>
  32. /// <returns></returns>
  33. [HttpPost]
  34. public ActionResult List(QueryParamsModel pararms)
  35. {
  36. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  37. var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  38. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  39. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  40. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  41. var coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo");
  42. var schoolyearNum = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  43. var schoolcode = pararms.getExtraInt("DictionarySchoolcode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolcode");
  44. var approvalStatus = pararms.getExtraInt("ApprovalStatusDropdownList") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ApprovalStatusDropdownList");
  45. return Json(ExecutableMinorPlanServices.GetExecutableMinorPlanViewGrid(configuretView, schoolyearID, collegeID, yearID, standardID, coursematerialID, schoolyearNum, schoolcode, approvalStatus, (int)pararms.page, (int)pararms.rows));
  46. }
  47. public ActionResult GenerateExecutablePlan()
  48. {
  49. return View(new ExecutablePlanGenerateView());
  50. }
  51. [HttpPost]
  52. public ActionResult GenerateExecutablePlan(ExecutablePlanGenerateView executablePlanGenerateView)
  53. {
  54. try
  55. {
  56. ExecutableMinorPlanServices.GenerateExecutablePlan(executablePlanGenerateView.StandardID, executablePlanGenerateView.SchoolyearID, executablePlanGenerateView.IsOverwrite, executablePlanGenerateView.CampusID, executablePlanGenerateView.CollegeID, executablePlanGenerateView.YearID);
  57. return Json(new ReturnMessage()
  58. {
  59. IsSuccess = true,
  60. Message = "操作成功。"
  61. });
  62. }
  63. catch (SuccessException ex)
  64. {
  65. return Json(new ReturnMessage()
  66. {
  67. IsSuccess = true,
  68. Message = ex.Message
  69. });
  70. }
  71. catch (Exception ex)
  72. {
  73. return Json(new ReturnMessage()
  74. {
  75. IsSuccess = false,
  76. Message = "操作失败," + ex.Message
  77. });
  78. }
  79. }
  80. /// <summary>
  81. /// 编辑
  82. /// </summary>
  83. /// <param name="MinorCourseID"></param>
  84. /// <returns></returns>
  85. public ActionResult Edit(Guid? ExecutableMinorPlanID)
  86. {
  87. ExecutableMinorPlanView executableMinorPlanView = new ExecutableMinorPlanView();
  88. if (ExecutableMinorPlanID.HasValue)
  89. {
  90. executableMinorPlanView = ExecutableMinorPlanServices.GetExecutableMinorPlanView(ExecutableMinorPlanID);
  91. }
  92. else
  93. {
  94. executableMinorPlanView.ResultTypeID = (int)CF_ResultType.Percentage;
  95. executableMinorPlanView.Credit = 0;
  96. executableMinorPlanView.TheoryCourse = 0;
  97. executableMinorPlanView.Practicehours = 0;
  98. executableMinorPlanView.Trialhours = 0;
  99. executableMinorPlanView.Totalhours = 0;
  100. executableMinorPlanView.TheoryWeeklyNum = 0;
  101. executableMinorPlanView.PracticeWeeklyNum = 0;
  102. executableMinorPlanView.TrialWeeklyNum = 0;
  103. executableMinorPlanView.SchoolweeksNum = 0;
  104. executableMinorPlanView.WeeklyHours = 0;
  105. executableMinorPlanView.WeeklyNum = 0;
  106. }
  107. return View(executableMinorPlanView);
  108. }
  109. /// <summary>
  110. /// 编辑
  111. /// </summary>
  112. /// <param name="minorSpecialtyCourseView"></param>
  113. /// <returns></returns>
  114. [HttpPost]
  115. public ActionResult Edit(ExecutableMinorPlanView executableMinorPlanView)
  116. {
  117. try
  118. {
  119. ExecutableMinorPlanServices.ExecutableMinorPlanEdit(executableMinorPlanView);
  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="MinorCourseIDs"></param>
  139. /// <returns></returns>
  140. [HttpPost]
  141. public ActionResult Delete(string ExecutableMinorPlanIDs)
  142. {
  143. try
  144. {
  145. List<Guid?> list = new List<Guid?>();
  146. for (int i = 0; i < ExecutableMinorPlanIDs.Split(',').Length; i++)
  147. {
  148. string id = ExecutableMinorPlanIDs.Split(',')[i];
  149. if (!string.IsNullOrEmpty(id))
  150. {
  151. Guid ExecutableMinorPlanID = new Guid(id);
  152. list.Add(ExecutableMinorPlanID);
  153. }
  154. }
  155. ExecutableMinorPlanServices.ExecutableMinorPlanDelete(list);
  156. return Json(new ReturnMessage
  157. {
  158. IsSuccess = true,
  159. Message = "删除成功。"
  160. });
  161. }
  162. catch (Exception ex)
  163. {
  164. string mge = ex.Message;
  165. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  166. if (num != null)
  167. {
  168. if (num.Number == 547)
  169. mge = "请先删除所有关联的数据,如:计划申请、专业计划、选修计划等!";
  170. }
  171. return base.Json("删除失败,原因:" + mge);
  172. }
  173. }
  174. /// <summary>
  175. /// 获取已经存在在授课方式
  176. /// </summary>
  177. /// <param name="MinorCourseID"></param>
  178. /// <returns></returns>
  179. [HttpPost]
  180. public ActionResult TeachingModeType(Guid? ExecutableMinorPlanID)
  181. {
  182. List<string> list = new List<string>();
  183. if (ExecutableMinorPlanID.HasValue && ExecutableMinorPlanID != Guid.Empty)
  184. list = ExecutableMinorPlanServices.GetTeachingModeType(ExecutableMinorPlanID);
  185. else
  186. list.Add(((int)EMIS.ViewModel.CF_TeachingMode.Theory).ToString());
  187. return base.Json(list);
  188. }
  189. /// <summary>
  190. /// 获取已经存在在授课地点
  191. /// </summary>
  192. /// <param name="MinorCourseID"></param>
  193. /// <returns></returns>
  194. [HttpPost]
  195. public ActionResult TeachingPlace(Guid? ExecutableMinorPlanID)
  196. {
  197. List<string> list = new List<string>();
  198. if (ExecutableMinorPlanID.HasValue && ExecutableMinorPlanID != Guid.Empty)
  199. list = ExecutableMinorPlanServices.GetTeachingPlace(ExecutableMinorPlanID);
  200. return base.Json(list);
  201. }
  202. /// <summary>
  203. /// 生成任务班
  204. /// </summary>
  205. /// <returns></returns>
  206. [HttpPost]
  207. public ActionResult GenerateEducationMissionClassSubminit(string ExecutableMinorPlanIDs)
  208. {
  209. try
  210. {
  211. List<Guid?> list = new List<Guid?>();
  212. for (int i = 0; i < ExecutableMinorPlanIDs.Split(',').Length; i++)
  213. {
  214. string id = ExecutableMinorPlanIDs.Split(',')[i];
  215. if (!string.IsNullOrEmpty(id))
  216. {
  217. Guid ExecutableMinorPlanID = new Guid(id);
  218. list.Add(ExecutableMinorPlanID);
  219. }
  220. }
  221. ExecutableMinorPlanServices.GenerateEducationMissionClassOptionalCourse(list);
  222. return Json("成功");
  223. }
  224. catch (Exception ex)
  225. {
  226. return Json("生成教学任务班失败,原因:" + ex.Message);
  227. }
  228. }
  229. }
  230. }