MinorStandardSettingController.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.CommonLogic.MinorManage.MinorSetting;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMIS.ViewModel.MinorManage.MinorSetting;
  11. using Bowin.Common.Utility;
  12. using Bowin.Common.Data;
  13. namespace EMIS.Web.Controllers.MinorManage.MinorSetting
  14. {
  15. [Authorization]
  16. public class MinorStandardSettingController : Controller
  17. {
  18. //
  19. // GET: /MinorStandardSetting/
  20. public IMinorStandardSettingServices minorStandardSettingServices { get; set; }
  21. /// <summary>
  22. ///
  23. /// </summary>
  24. /// <returns></returns>
  25. [HttpGet]
  26. public ActionResult List()
  27. {
  28. return View();
  29. }
  30. /// <summary>
  31. /// 辅修专业设置列表
  32. /// </summary>
  33. /// <param name="pararms"></param>
  34. /// <returns></returns>
  35. [HttpPost]
  36. public ActionResult List(QueryParamsModel pararms)
  37. {
  38. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  39. int? minorStandardID = pararms.getExtraInt("MinorStandardDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("MinorStandardDropDown");
  40. int? standardID = pararms.getExtraInt("StandardDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDropDown");
  41. return base.Json(minorStandardSettingServices.GetMinorControlViewGrid(configuretView, minorStandardID, standardID, (int)pararms.page, (int)pararms.rows));
  42. }
  43. /// <summary>
  44. /// 复制新增
  45. /// </summary>
  46. /// <param name="graduationApplyID"></param>
  47. /// <returns></returns>
  48. //public ActionResult CopyAdd(Guid minorStandardSettingID)
  49. //{
  50. // MinorStandardSettingView minorStandardSettingView = new MinorStandardSettingView();
  51. // minorStandardSettingView = minorStandardSettingServices.GetMinorStandardSettingView(minorStandardSettingID);
  52. // return View("Edit", minorStandardSettingView);
  53. //}
  54. /// <summary>
  55. /// 复制新增
  56. /// </summary>
  57. /// <param name="graduationApplyView"></param>
  58. /// <returns></returns>
  59. //[HttpPost]
  60. //public ActionResult CopyAdd(MinorStandardSettingView minorStandardSettingView)
  61. //{
  62. // minorStandardSettingView.MinorStandardSettingID = Guid.Empty;
  63. // return this.Edit(minorStandardSettingView);
  64. //}
  65. [HttpGet]
  66. public ActionResult Edit(Guid? minorStandardSettingID)
  67. {
  68. MinorStandardSettingView minorStandardSettingView = new MinorStandardSettingView();
  69. //if (minorStandardSettingID.HasValue)
  70. //{
  71. // minorStandardSettingView = minorStandardSettingServices.GetMinorStandardSettingView(minorStandardSettingID);
  72. //}
  73. return View(minorStandardSettingView);
  74. }
  75. /// <summary>
  76. /// 新增
  77. /// </summary>
  78. /// <param name="graduationApplyView"></param>
  79. /// <returns></returns>
  80. [HttpPost]
  81. public ActionResult Edit(MinorStandardSettingView minorStandardSettingView)
  82. {
  83. try
  84. {
  85. var minorStandardString = Request.Form["selectMinorStandardIDs"];
  86. if (minorStandardString == "" || minorStandardString == null)
  87. {
  88. throw new Exception("请选择辅修专业信息");
  89. }
  90. var minorStandardIDList = minorStandardString.Split(',').Select(x => int.Parse(x)).ToList();
  91. foreach (int id in minorStandardIDList)
  92. {
  93. minorStandardSettingView.MinorStandardID = id;
  94. minorStandardSettingServices.MinorStandardSettingEdit(minorStandardSettingView);
  95. }
  96. return Json(new ReturnMessage()
  97. {
  98. IsSuccess = true,
  99. Message = "保存成功。"
  100. });
  101. }
  102. catch (Exception ex)
  103. {
  104. return Json(new ReturnMessage()
  105. {
  106. IsSuccess = false,
  107. Message = "保存失败,原因:" + ex.Message
  108. });
  109. }
  110. }
  111. /// <summary>
  112. /// 删除
  113. /// </summary>
  114. /// <param name="graduationApplyIDs"></param>
  115. /// <returns></returns>
  116. [HttpPost]
  117. public ActionResult Delete(string minorStandardSettingIDs)
  118. {
  119. try
  120. {
  121. List<Guid?> list = minorStandardSettingIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  122. .Select(x => (Guid?)new Guid(x)).ToList();
  123. minorStandardSettingServices.MinorStandardSettingDelete(list);
  124. return base.Json("删除成功。");
  125. }
  126. catch (Exception ex)
  127. {
  128. return base.Json("删除失败,原因:" + ex.Message + "。");
  129. }
  130. }
  131. /// <summary>
  132. /// 导出Excel
  133. /// </summary>
  134. /// <returns></returns>
  135. [HttpPost]
  136. public ActionResult Excel()
  137. {
  138. NpoiExcelHelper neh = new NpoiExcelHelper();
  139. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  140. var minorStandardID = Request.Form["ddlYear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlYear"].ParseStrTo<int>();
  141. var standardID = Request.Form["cbgStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["cbgStandard"].ParseStrTo<int>();
  142. var minorStandardSettingIDString = Request.Form["SelectedID"];
  143. var minorStandardSettingIDList = minorStandardSettingIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  144. var dt = minorStandardSettingServices.GetMinorControlViewList(configuretView, minorStandardID, standardID, minorStandardSettingIDList).Select(x => new
  145. {
  146. x.StandardName,
  147. x.MinorStandardName
  148. }).ToTable();
  149. string[] liststring = { "专业名称", "辅修专业名称" };
  150. neh.Export(dt, liststring, "辅修专业设置");
  151. return RedirectToAction("MsgShow", "Common", new
  152. {
  153. msg = "导出成功!",
  154. url = Url.Action("List").AddMenuParameter()
  155. });
  156. }
  157. [HttpPost]
  158. public ActionResult GetStandardNotSelectID(QueryParamsModel pararms)
  159. {
  160. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  161. int? selectstandardID = pararms.getExtraInt("StandardID") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardID");
  162. return base.Json(minorStandardSettingServices.GetStandardNotSelectID(selectstandardID, (int)pararms.page, (int)pararms.rows));
  163. }
  164. }
  165. }