DegreeOpenControlController.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.CommonLogic.DegreeManage.DegreeSetting;
  8. using EMIS.Web.Controls;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMIS.ViewModel.DegreeManage.DegreeSetting;
  11. using Bowin.Common.Utility;
  12. using Bowin.Common.Data;
  13. namespace EMIS.Web.Controllers.DegreeManage.DegreeSetting
  14. {
  15. [Authorization]
  16. public class DegreeOpenControlController : Controller
  17. {
  18. public IDegreeOpenControlServices DegreeOpenControlServices { get; set; }
  19. /// <summary>
  20. /// 学位控制页面
  21. /// </summary>
  22. /// <returns></returns>
  23. public ActionResult List()
  24. {
  25. return View();
  26. }
  27. /// <summary>
  28. /// 学位控制列表查询
  29. /// </summary>
  30. /// <param name="pararms"></param>
  31. /// <returns></returns>
  32. [HttpPost]
  33. public ActionResult List(QueryParamsModel pararms)
  34. {
  35. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  36. var gradSchoolyearID = pararms.getExtraGuid("GradSchoolyearDropdown");
  37. var degreeBatchID = pararms.getExtraInt("DictionaryDegreeBatch") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryDegreeBatch");
  38. return base.Json(DegreeOpenControlServices.GetDegreeOpenControlViewGrid(configuretView, gradSchoolyearID, degreeBatchID, (int)pararms.page, (int)pararms.rows));
  39. }
  40. /// <summary>
  41. /// 复制新增
  42. /// </summary>
  43. /// <param name="degreeOpenControlID"></param>
  44. /// <returns></returns>
  45. public ActionResult CopyAdd(Guid degreeOpenControlID)
  46. {
  47. DegreeOpenControlView degreeOpenControlView = new DegreeOpenControlView();
  48. degreeOpenControlView = DegreeOpenControlServices.GetDegreeOpenControlView(degreeOpenControlID);
  49. return View("Edit", degreeOpenControlView);
  50. }
  51. /// <summary>
  52. /// 复制新增
  53. /// </summary>
  54. /// <param name="degreeOpenControlView"></param>
  55. /// <returns></returns>
  56. [HttpPost]
  57. public ActionResult CopyAdd(DegreeOpenControlView degreeOpenControlView)
  58. {
  59. degreeOpenControlView.DegreeOpenControlID = Guid.Empty;
  60. return this.Edit(degreeOpenControlView);
  61. }
  62. /// <summary>
  63. /// 编辑(新增、修改)
  64. /// </summary>
  65. /// <param name="degreeOpenControlID"></param>
  66. /// <returns></returns>
  67. [HttpGet]
  68. public ActionResult Edit(Guid? degreeOpenControlID)
  69. {
  70. DegreeOpenControlView degreeOpenControlView = new DegreeOpenControlView();
  71. if (degreeOpenControlID.HasValue)
  72. {
  73. degreeOpenControlView = DegreeOpenControlServices.GetDegreeOpenControlView(degreeOpenControlID);
  74. }
  75. else
  76. {
  77. degreeOpenControlView.StartDate = DateTime.Now;
  78. degreeOpenControlView.EndDate = DateTime.Now.AddMonths(+1);
  79. }
  80. return View(degreeOpenControlView);
  81. }
  82. /// <summary>
  83. /// 编辑(新增、修改)
  84. /// </summary>
  85. /// <param name="degreeOpenControlView"></param>
  86. /// <returns></returns>
  87. [HttpPost]
  88. public ActionResult Edit(DegreeOpenControlView degreeOpenControlView)
  89. {
  90. try
  91. {
  92. DegreeOpenControlServices.DegreeOpenControlViewEdit(degreeOpenControlView);
  93. return Json(new ReturnMessage()
  94. {
  95. IsSuccess = true,
  96. Message = "保存成功。"
  97. });
  98. }
  99. catch (Exception ex)
  100. {
  101. return Json(new ReturnMessage()
  102. {
  103. IsSuccess = false,
  104. Message = "保存失败:" + ex.Message
  105. });
  106. }
  107. }
  108. /// <summary>
  109. /// 删除
  110. /// </summary>
  111. /// <param name="degreeOpenControlIDs"></param>
  112. /// <returns></returns>
  113. [HttpPost]
  114. public ActionResult Delete(string degreeOpenControlIDs)
  115. {
  116. try
  117. {
  118. List<Guid?> list = degreeOpenControlIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  119. DegreeOpenControlServices.DegreeOpenControlDelete(list);
  120. return base.Json(new ReturnMessage()
  121. {
  122. IsSuccess = true,
  123. Message = "删除成功。"
  124. });
  125. }
  126. catch (Exception ex)
  127. {
  128. return base.Json(new ReturnMessage()
  129. {
  130. IsSuccess = false,
  131. Message = "删除失败:" + ex.Message
  132. });
  133. }
  134. }
  135. /// <summary>
  136. /// Excel导出
  137. /// </summary>
  138. /// <returns></returns>
  139. [HttpPost]
  140. public ActionResult Excel()
  141. {
  142. NpoiExcelHelper neh = new NpoiExcelHelper();
  143. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  144. var gradSchoolyearID = Request.Form["GradSchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["GradSchoolyearDropdown"].ParseStrTo<Guid>();
  145. var degreeBatchID = Request.Form["DictionaryDegreeBatch"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryDegreeBatch"].ParseStrTo<int>();
  146. var dt = DegreeOpenControlServices.GetDegreeOpenControlViewList(configuretView, gradSchoolyearID, degreeBatchID)
  147. .Select(x => new
  148. {
  149. x.GraduatingSemesterCode,
  150. x.DegreeBatchName,
  151. x.StartDate,
  152. x.EndDate
  153. }).ToTable();
  154. string[] liststring = {
  155. "毕业学期", "学位批次", "开始时间", "结束时间"
  156. };
  157. neh.Export(dt, liststring, "学位控制信息" + DateTime.Now.ToString("yyyyMMdd"));
  158. return Json(new ReturnMessage()
  159. {
  160. IsSuccess = true,
  161. Message = "导出成功。"
  162. });
  163. }
  164. }
  165. }