ClubCourseController.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Common.Utility;
  7. using Bowin.Common.Data;
  8. using Bowin.Web.Controls.Mvc;
  9. using Bowin.Common.JSON;
  10. using EMIS.ViewModel;
  11. using EMIS.Web.Controls;
  12. using EMIS.CommonLogic.CultureplanManage.CourseMaterial;
  13. using EMIS.ViewModel.Cultureplan;
  14. using EMIS.ViewModel.CultureplanManage.CourseMaterial;
  15. namespace EMIS.Web.Controllers.CultureplanManage.CourseMaterial
  16. {
  17. [Authorization]
  18. public class ClubCourseController : Controller
  19. {
  20. public IClubCourseServices ClubCourseServices { 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. //课程级别
  39. var courseLevelID = pararms.getExtraInt("DictionaryCourseLevel") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryCourseLevel");
  40. //课程科类
  41. var courseScienceID = pararms.getExtraInt("DictionaryCourseScience") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryCourseScience");
  42. //上课类型
  43. var classGroupingID = pararms.getExtraGuid("TeachTypeDropdown");
  44. //是否启用
  45. var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable");
  46. return base.Json(ClubCourseServices.GetClubCourseViewGrid(configuretView, courseLevelID, courseScienceID, classGroupingID,
  47. isEnable, (int)pararms.page, (int)pararms.rows));
  48. }
  49. /// <summary>
  50. /// 批量新增
  51. /// </summary>
  52. /// <returns></returns>
  53. public ActionResult BatchAdd()
  54. {
  55. ClubCourseView clubCourseView = new ClubCourseView();
  56. return View(clubCourseView);
  57. }
  58. /// <summary>
  59. /// 批量新增
  60. /// </summary>
  61. /// <param name="clubCourseView"></param>
  62. /// <returns></returns>
  63. [HttpPost]
  64. public ActionResult BatchAdd(ClubCourseView clubCourseView)
  65. {
  66. try
  67. {
  68. var courseNoClubViewList = Request["CourseNoClubList"].JsonToObject<List<CoursematerialView>>();
  69. string result = ClubCourseServices.ClubCourseBatchAdd(clubCourseView, courseNoClubViewList);
  70. return Json(new ReturnMessage()
  71. {
  72. IsSuccess = true,
  73. Message = "保存成功" + result + "。"
  74. });
  75. }
  76. catch (Exception ex)
  77. {
  78. return Json(new ReturnMessage()
  79. {
  80. IsSuccess = false,
  81. Message = "保存失败,原因:" + ex.Message
  82. });
  83. }
  84. }
  85. /// <summary>
  86. /// 查询对应的课程信息View(课程信息表左连俱乐部课程表,排除对应的俱乐部课程信息)
  87. /// </summary>
  88. /// <param name="pararms"></param>
  89. /// <returns></returns>
  90. [HttpPost]
  91. public ActionResult CourseNoClubList(QueryParamsModel pararms)
  92. {
  93. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  94. //课程级别
  95. var courseLevelID = pararms.getExtraInt("DictionaryCourseLevel") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryCourseLevel");
  96. //课程科类
  97. var courseScienceID = pararms.getExtraInt("DictionaryCourseScience") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryCourseScience");
  98. //是否启用
  99. var isEnable = pararms.getExtraInt("DictionaryIsEnable") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryIsEnable");
  100. return base.Json(ClubCourseServices.GetCourseNoClubViewGrid(configuretView, courseLevelID, courseScienceID, isEnable, (int)pararms.page, (int)pararms.rows));
  101. }
  102. /// <summary>
  103. /// 编辑(新增、修改--暂时无效)
  104. /// </summary>
  105. /// <param name="clubCourseID"></param>
  106. /// <returns></returns>
  107. public ActionResult Edit(Guid? clubCourseID)
  108. {
  109. return null;
  110. }
  111. /// <summary>
  112. /// 编辑(新增、修改--暂时无效)
  113. /// </summary>
  114. /// <param name="clubCourseView"></param>
  115. /// <returns></returns>
  116. [HttpPost]
  117. public ActionResult Edit(ClubCourseView clubCourseView)
  118. {
  119. return null;
  120. }
  121. /// <summary>
  122. /// 删除
  123. /// </summary>
  124. /// <param name="clubCourseIDs"></param>
  125. /// <returns></returns>
  126. [HttpPost]
  127. public ActionResult Delete(string clubCourseIDs)
  128. {
  129. try
  130. {
  131. List<Guid?> list = clubCourseIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  132. .Select(x => (Guid?)new Guid(x)).ToList();
  133. ClubCourseServices.ClubCourseDelete(list);
  134. return base.Json("删除成功。");
  135. }
  136. catch (Exception ex)
  137. {
  138. return base.Json("删除失败,原因:" + ex.Message);
  139. }
  140. }
  141. /// <summary>
  142. /// Excel导出
  143. /// </summary>
  144. /// <returns></returns>
  145. [HttpPost]
  146. public ActionResult Excel()
  147. {
  148. NpoiExcelHelper neh = new NpoiExcelHelper();
  149. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  150. //课程级别
  151. var courseLevelID = Request.Form["DictionaryCourseLevel"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseLevel"].ParseStrTo<int>();
  152. //课程科类
  153. var courseScienceID = Request.Form["DictionaryCourseScience"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryCourseScience"].ParseStrTo<int>();
  154. //上课类型
  155. var classGroupingID = Request.Form["TeachTypeDropdown"].ParseStrTo<Guid>();
  156. //是否启用
  157. var isEnable = Request.Form["DictionaryIsEnable"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryIsEnable"].ParseStrTo<int>();
  158. var dt = ClubCourseServices.GetClubCourseViewList(configuretView, courseLevelID, courseScienceID, classGroupingID,isEnable)
  159. .Select(x => new
  160. {
  161. x.CourseCode,
  162. x.CourseName,
  163. x.Abbreviation,
  164. x.CourseLevelName,
  165. x.CourseScienceName,
  166. x.ClassName,
  167. x.IsEnableName
  168. }).ToTable();
  169. string[] liststring = {
  170. "课程代码", "课程名称", "课程简称", "课程级别", "课程科类", "上课类型", "是否启用"
  171. };
  172. neh.Export(dt, liststring, "俱乐部课程信息" + DateTime.Now.ToString("yyyyMMdd"));
  173. return Json(new ReturnMessage()
  174. {
  175. IsSuccess = true,
  176. Message = "导出成功。"
  177. });
  178. }
  179. }
  180. }