MinorGraduationStandardController.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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.MinorGraduation.MinorGraduationSetting;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using Bowin.Common.Data;
  10. using Bowin.Web.Controls.Mvc;
  11. using EMIS.ViewModel.MinorGraduation.MinorGraduationSetting;
  12. using Bowin.Common.Exceptions;
  13. using Bowin.Common.Utility;
  14. using EMIS.Utility;
  15. namespace EMIS.Web.Controllers.MinorGraduation.MinorGraduationSetting
  16. {
  17. [Authorization]
  18. public class MinorGraduationStandardController : Controller
  19. {
  20. //
  21. // GET: /MinorGraduationStandard/
  22. public IMinorGraduationStandardServices minorGraduationStandardServices { get; set; }
  23. public ActionResult List()
  24. {
  25. return View();
  26. }
  27. [HttpPost]
  28. public ActionResult List(QueryParamsModel pararms)
  29. {
  30. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  31. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  32. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  33. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  34. return base.Json(minorGraduationStandardServices.GetMinorGraduationStandardViewGrid(configuretView, collegeID, yearID,
  35. standardID, (int)pararms.page, (int)pararms.rows));
  36. }
  37. /// <summary>
  38. /// 生成
  39. /// </summary>
  40. /// <returns></returns>
  41. [HttpGet]
  42. public ActionResult Generate()
  43. {
  44. return View();
  45. }
  46. /// <summary>
  47. /// 生成
  48. /// </summary>
  49. /// <param name="graduationStandard"></param>
  50. /// <returns></returns>
  51. [HttpPost]
  52. public ActionResult Generate(QueryParamsModel pararms)
  53. {
  54. try
  55. {
  56. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  57. var yearID = Request.Form["YearDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["YearDropDown"].ParseStrTo<int>();
  58. minorGraduationStandardServices.MinorGraduationStandardGenerate(yearID, collegeID);
  59. return Json(new ReturnMessage()
  60. {
  61. IsSuccess = true,
  62. Message = "生成成功。"
  63. });
  64. }
  65. catch (Exception ex)
  66. {
  67. return Json(new ReturnMessage()
  68. {
  69. IsSuccess = false,
  70. Message = "生成失败,原因:" + ex.Message + "。"
  71. });
  72. }
  73. }
  74. /// <summary>
  75. /// 编辑(新增、修改)
  76. /// </summary>
  77. /// <param name="GraduationStandardID"></param>
  78. /// <returns></returns>
  79. [HttpGet]
  80. public ActionResult Edit(Guid? minorGraduationStandardID)
  81. {
  82. MinorGraduationStandardView minorGraduationStandardView = new MinorGraduationStandardView();
  83. if (minorGraduationStandardID.HasValue && minorGraduationStandardID != Guid.Empty)
  84. {
  85. minorGraduationStandardView = minorGraduationStandardServices.GetMinorGraduationStandardView(minorGraduationStandardID);
  86. }
  87. return View(minorGraduationStandardView);
  88. }
  89. /// <summary>
  90. /// 编辑(新增、修改)
  91. /// </summary>
  92. /// <param name="graduationStandardView"></param>
  93. /// <returns></returns>
  94. [HttpPost]
  95. public ActionResult Edit(MinorGraduationStandardView minorGraduationStandardView)
  96. {
  97. try
  98. {
  99. minorGraduationStandardServices.MinorGraduationStandardEdit(minorGraduationStandardView);
  100. return Json(new ReturnMessage()
  101. {
  102. IsSuccess = true,
  103. Message = "保存成功。"
  104. });
  105. }
  106. catch (Exception ex)
  107. {
  108. return Json(new ReturnMessage()
  109. {
  110. IsSuccess = false,
  111. Message = "保存失败,原因:" + ex.Message + "。"
  112. });
  113. }
  114. }
  115. [HttpPost]
  116. public ActionResult Delete(string minorGraduationStandardIDs)
  117. {
  118. try
  119. {
  120. List<Guid?> list = minorGraduationStandardIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  121. .Select(x => (Guid?)new Guid(x)).ToList();
  122. minorGraduationStandardServices.MinorGraduationStandardDelete(list);
  123. return base.Json("删除成功。");
  124. }
  125. catch (Exception ex)
  126. {
  127. return base.Json("删除失败,原因:" + ex.Message);
  128. }
  129. }
  130. [HttpPost]
  131. public ActionResult Excel()
  132. {
  133. NpoiExcelHelper neh = new NpoiExcelHelper();
  134. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  135. //var gradSchoolyearID = Request.Form["GradSchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["GradSchoolyearDropdown"].ParseStrTo<Guid>();
  136. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  137. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  138. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  139. var minorGraduationStandardIDString = Request.Form["SelectedID"];
  140. var minorGraduationStandardIDList = minorGraduationStandardIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  141. var dt = minorGraduationStandardServices.GetMinorGraduationStandardViewList(configuretView, collegeID, yearID,
  142. standardID, minorGraduationStandardIDList)
  143. .Select(x => new
  144. {
  145. x.YearID,
  146. x.CollegeName,
  147. x.StandardName,
  148. x.GraduationCredit
  149. }).ToTable();
  150. string[] liststring = {
  151. "年级", "院系所", "专业名称", "毕业学分"
  152. };
  153. neh.Export(dt, liststring, "辅修毕业标准信息" + DateTime.Now.ToString("yyyyMMdd"));
  154. return Json(new ReturnMessage()
  155. {
  156. IsSuccess = true,
  157. Message = "导出成功。"
  158. });
  159. }
  160. }
  161. }