SpecialtyClassSettingController.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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.Common.JSON;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMIS.Web.Controls;
  11. using EMIS.Utility;
  12. using EMIS.ViewModel;
  13. using EMIS.ViewModel.EnrollManage.SpecialtyManage;
  14. using EMIS.CommonLogic.EnrollManage.SpecialtyManage;
  15. namespace EMIS.Web.Controllers.EnrollManage.SpecialtyManage
  16. {
  17. [Authorization]
  18. public class SpecialtyClassSettingController : Controller
  19. {
  20. public ISpecialtyClassSettingServices SpecialtyClassSettingServices { 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 standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  39. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  40. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  41. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  42. return base.Json(SpecialtyClassSettingServices.GetSpecialtyClassSettingViewGrid(configuretView, standardID, educationID, learningformID, learnSystem, (int)pararms.page, (int)pararms.rows));
  43. }
  44. /// <summary>
  45. /// 复制新增
  46. /// </summary>
  47. /// <param name="specialtyClassSettingID"></param>
  48. /// <returns></returns>
  49. public ActionResult CopyAdd(Guid specialtyClassSettingID)
  50. {
  51. SpecialtyClassSettingView specialtyClassSettingView = new SpecialtyClassSettingView();
  52. specialtyClassSettingView = SpecialtyClassSettingServices.GetSpecialtyClassSettingView(specialtyClassSettingID);
  53. return View("Edit", specialtyClassSettingView);
  54. }
  55. /// <summary>
  56. /// 复制新增
  57. /// </summary>
  58. /// <param name="specialtyClassSettingView"></param>
  59. /// <returns></returns>
  60. [HttpPost]
  61. public ActionResult CopyAdd(SpecialtyClassSettingView specialtyClassSettingView)
  62. {
  63. specialtyClassSettingView.SpecialtyClassSettingID = Guid.Empty;
  64. return this.Edit(specialtyClassSettingView);
  65. }
  66. /// <summary>
  67. /// 编辑(新增、修改,业务主键:专业信息ID)
  68. /// </summary>
  69. /// <param name="specialtyClassSettingID"></param>
  70. /// <returns></returns>
  71. [HttpGet]
  72. public ActionResult Edit(Guid? specialtyClassSettingID)
  73. {
  74. SpecialtyClassSettingView specialtyClassSettingView = new SpecialtyClassSettingView();
  75. if (specialtyClassSettingID.HasValue && specialtyClassSettingID != Guid.Empty)
  76. {
  77. specialtyClassSettingView = SpecialtyClassSettingServices.GetSpecialtyClassSettingView(specialtyClassSettingID);
  78. }
  79. else
  80. {
  81. specialtyClassSettingView.PlanRecruitStudentCount = 0;
  82. specialtyClassSettingView.ClassArrangeStudentCount = 0;
  83. specialtyClassSettingView.ClassMaxStudentCount = 0;
  84. specialtyClassSettingView.ClassNumber = 1;
  85. }
  86. return View(specialtyClassSettingView);
  87. }
  88. /// <summary>
  89. /// 编辑(新增、修改,业务主键:专业信息ID)
  90. /// </summary>
  91. /// <param name="specialtyClassSettingView"></param>
  92. /// <returns></returns>
  93. [HttpPost]
  94. public ActionResult Edit(SpecialtyClassSettingView specialtyClassSettingView)
  95. {
  96. try
  97. {
  98. SpecialtyClassSettingServices.SpecialtyClassSettingEdit(specialtyClassSettingView);
  99. return Json(new ReturnMessage()
  100. {
  101. IsSuccess = true,
  102. Message = "保存成功。"
  103. });
  104. }
  105. catch (Exception ex)
  106. {
  107. return Json(new ReturnMessage()
  108. {
  109. IsSuccess = false,
  110. Message = "保存失败,原因:" + ex.Message
  111. });
  112. }
  113. }
  114. /// <summary>
  115. /// 专业分班批量新增
  116. /// </summary>
  117. /// <returns></returns>
  118. [HttpGet]
  119. public ActionResult SpecialtyClassSettingBatchAdd()
  120. {
  121. SpecialtyClassSettingView specialtyClassSettingView = new SpecialtyClassSettingView();
  122. return View(specialtyClassSettingView);
  123. }
  124. /// <summary>
  125. /// 专业分班批量新增
  126. /// </summary>
  127. /// <param name="specialtyClassSettingView"></param>
  128. /// <returns></returns>
  129. public ActionResult SpecialtyClassSettingBatchAdd(SpecialtyClassSettingView specialtyClassSettingView)
  130. {
  131. try
  132. {
  133. var specialtyIDList = Request["specialtyIDs"].JsonToObject<List<Guid?>>();
  134. string result = SpecialtyClassSettingServices.SpecialtyClassSettingBatchAdd(specialtyIDList, specialtyClassSettingView);
  135. return Json(new ReturnMessage()
  136. {
  137. IsSuccess = true,
  138. Message = "新增成功" + result + "。"
  139. });
  140. }
  141. catch (Exception ex)
  142. {
  143. return Json(new ReturnMessage()
  144. {
  145. IsSuccess = false,
  146. Message = "新增失败,原因:" + ex.Message
  147. });
  148. }
  149. }
  150. /// <summary>
  151. /// 查询专业分班中未新增的专业信息SpecialtyView
  152. /// </summary>
  153. /// <param name="pararms"></param>
  154. /// <returns></returns>
  155. [HttpPost]
  156. public ActionResult SpecialtyNoAddList(QueryParamsModel pararms)
  157. {
  158. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  159. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  160. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  161. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  162. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  163. var scienceclassID = pararms.getExtraInt("DictionaryScienceclass") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryScienceclass");
  164. return base.Json(SpecialtyClassSettingServices.GetSpecialtyViewNoAdd(configuretView, standardID, educationID, learningformID, learnSystem, scienceclassID, (int)pararms.page, (int)pararms.rows));
  165. }
  166. /// <summary>
  167. /// 批量修改(计划招生人数、每班预招人数、每班最大人数)
  168. /// </summary>
  169. /// <param name="specialtyClassSettingIDs"></param>
  170. /// <param name="planRecruitStudentCount"></param>
  171. /// <param name="classArrangeStudentCount"></param>
  172. /// <param name="classMaxStudentCount"></param>
  173. /// <returns></returns>
  174. public ActionResult BatchModifyControl(string specialtyClassSettingIDs, int? planRecruitStudentCount, int? classArrangeStudentCount, int? classMaxStudentCount)
  175. {
  176. try
  177. {
  178. List<Guid?> list = specialtyClassSettingIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  179. string result = SpecialtyClassSettingServices.BatchModify(list, planRecruitStudentCount, classArrangeStudentCount, classMaxStudentCount);
  180. return Json(new ReturnMessage()
  181. {
  182. IsSuccess = true,
  183. Message = "批量修改成功" + result + "。"
  184. });
  185. }
  186. catch (Exception ex)
  187. {
  188. return Json(new ReturnMessage()
  189. {
  190. IsSuccess = false,
  191. Message = "批量修改失败,原因:" + ex.Message
  192. });
  193. }
  194. }
  195. /// <summary>
  196. /// 删除
  197. /// </summary>
  198. /// <param name="specialtyClassSettingIDs"></param>
  199. /// <returns></returns>
  200. [HttpPost]
  201. public ActionResult Delete(string specialtyClassSettingIDs)
  202. {
  203. try
  204. {
  205. List<Guid?> list = specialtyClassSettingIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  206. SpecialtyClassSettingServices.SpecialtyClassSettingDelete(list);
  207. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  208. }
  209. catch (Exception ex)
  210. {
  211. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
  212. }
  213. }
  214. /// <summary>
  215. /// Excel导出
  216. /// </summary>
  217. /// <param name="pararms"></param>
  218. /// <returns></returns>
  219. [HttpPost]
  220. public ActionResult Excel()
  221. {
  222. try
  223. {
  224. NpoiExcelHelper neh = new NpoiExcelHelper();
  225. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  226. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  227. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  228. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  229. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  230. var dt = SpecialtyClassSettingServices.GetSpecialtyClassSettingViewList(configuretView, standardID, educationID, learningformID, learnSystem)
  231. .Select(x => new
  232. {
  233. x.Code,
  234. x.StandardID,
  235. x.Name,
  236. x.EducationName,
  237. x.LearningformName,
  238. LearnSystem = x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : null,
  239. x.ScienceclassName,
  240. x.PropertyName,
  241. x.StandardTitleName,
  242. x.StandardLevelName,
  243. x.PlanRecruitStudentCount,
  244. x.ClassArrangeStudentCount,
  245. x.ClassMaxStudentCount,
  246. x.ClassNumber
  247. }).ToTable();
  248. string[] liststring = {
  249. "专业代码", "专业ID(Value)", "专业名称", RSL.Get("EducationID"),
  250. "学习形式", "学制", "专业科类", "专业属性", "专业称号", "称号级别",
  251. "计划招生人数", "每班预招人数", "每班最大人数", "班级个数"
  252. };
  253. neh.Export(dt, liststring, "专业分班信息" + DateTime.Now.ToString("yyyyMMdd"));
  254. return Json(new ReturnMessage()
  255. {
  256. IsSuccess = true,
  257. Message = "导出成功。"
  258. });
  259. }
  260. catch (Exception ex)
  261. {
  262. return Json(new ReturnMessage()
  263. {
  264. IsSuccess = false,
  265. Message = "导出失败,原因:" + ex.Message
  266. });
  267. }
  268. }
  269. }
  270. }