GraduationSchoolYearController.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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.Web.Controls;
  8. using Bowin.Web.Controls.Mvc;
  9. using Bowin.Common.Utility;
  10. using Bowin.Common.Data;
  11. using EMIS.CommonLogic.GraduationManage.GraduationSetting;
  12. using EMIS.ViewModel.GraduationManage.GraduationSetting;
  13. namespace EMIS.Web.Controllers.GraduationManage.GraduationSetting
  14. {
  15. [Authorization]
  16. public class GraduationSchoolYearController : Controller
  17. {
  18. public IGraduationSchoolYearServices GraduationSchoolYearServices { 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 years = pararms.getExtraInt("DictionarySchoolyear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolyear");
  37. var schoolcodeID = pararms.getExtraInt("DictionarySchoolcode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionarySchoolcode");
  38. var isCurrent = pararms.getExtraInt("IsCurrentDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsCurrentDropDown");
  39. //启用状态
  40. var isEnable = pararms.getExtraInt("IsEnableDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsEnableDropDown");
  41. return base.Json(GraduationSchoolYearServices.GetGradSchoolYearViewGrid(configuretView, years, schoolcodeID, isCurrent,
  42. isEnable, (int)pararms.page, (int)pararms.rows));
  43. }
  44. /// <summary>
  45. /// 复制新增
  46. /// </summary>
  47. /// <param name="graduationSchoolYearSettingID"></param>
  48. /// <returns></returns>
  49. public ActionResult CopyAdd(Guid graduationSchoolYearSettingID)
  50. {
  51. GraduationSchoolYearView graduationSchoolYearView = new GraduationSchoolYearView();
  52. graduationSchoolYearView = GraduationSchoolYearServices.GetGradSchoolYearView(graduationSchoolYearSettingID);
  53. return View("Edit", graduationSchoolYearView);
  54. }
  55. /// <summary>
  56. /// 复制新增
  57. /// </summary>
  58. /// <param name="graduationSchoolYearView"></param>
  59. /// <returns></returns>
  60. [HttpPost]
  61. public ActionResult CopyAdd(GraduationSchoolYearView graduationSchoolYearView)
  62. {
  63. graduationSchoolYearView.GraduationSchoolYearSettingID = Guid.Empty;
  64. return this.Edit(graduationSchoolYearView);
  65. }
  66. /// <summary>
  67. /// 编辑(新增、修改)
  68. /// </summary>
  69. /// <param name="graduationSchoolYearSettingID"></param>
  70. /// <returns></returns>
  71. [HttpGet]
  72. public ActionResult Edit(Guid? graduationSchoolYearSettingID)
  73. {
  74. GraduationSchoolYearView graduationSchoolYearView = new GraduationSchoolYearView();
  75. if (graduationSchoolYearSettingID.HasValue && graduationSchoolYearSettingID != Guid.Empty)
  76. {
  77. graduationSchoolYearView = GraduationSchoolYearServices.GetGradSchoolYearView(graduationSchoolYearSettingID);
  78. }
  79. else
  80. {
  81. graduationSchoolYearView.GraduatingSemesterID = BaseExtensions.GetCurrentSchoolYearID();
  82. graduationSchoolYearView.IsEnable = true;
  83. }
  84. return View(graduationSchoolYearView);
  85. }
  86. /// <summary>
  87. /// 编辑(新增、修改)
  88. /// </summary>
  89. /// <param name="graduationSchoolYearView"></param>
  90. /// <returns></returns>
  91. [HttpPost]
  92. public ActionResult Edit(GraduationSchoolYearView graduationSchoolYearView)
  93. {
  94. try
  95. {
  96. GraduationSchoolYearServices.GraduationSchoolYearEdit(graduationSchoolYearView);
  97. return Json(new ReturnMessage()
  98. {
  99. IsSuccess = true,
  100. Message = "保存成功。"
  101. });
  102. }
  103. catch (Exception ex)
  104. {
  105. return Json(new ReturnMessage()
  106. {
  107. IsSuccess = false,
  108. Message = "保存失败,原因:" + ex.Message
  109. });
  110. }
  111. }
  112. /// <summary>
  113. /// 删除(注:需对设置的毕业学期进行处理)
  114. /// </summary>
  115. /// <param name="graduationSchoolYearSettingIDs"></param>
  116. /// <returns></returns>
  117. [HttpPost]
  118. public ActionResult Delete(string graduationSchoolYearSettingIDs)
  119. {
  120. try
  121. {
  122. List<Guid?> list = graduationSchoolYearSettingIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  123. .Select(x => (Guid?)new Guid(x)).ToList();
  124. GraduationSchoolYearServices.GraduationSchoolYearDelete(list);
  125. return base.Json("删除成功。");
  126. }
  127. catch (Exception ex)
  128. {
  129. return base.Json("删除失败,原因:" + ex.Message);
  130. }
  131. }
  132. /// <summary>
  133. /// Excel导出
  134. /// </summary>
  135. /// <returns></returns>
  136. [HttpPost]
  137. public ActionResult Excel()
  138. {
  139. NpoiExcelHelper neh = new NpoiExcelHelper();
  140. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  141. var years = Request.Form["DictionarySchoolyear"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolyear"].ParseStrTo<int>();
  142. var schoolcodeID = Request.Form["DictionarySchoolcode"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionarySchoolcode"].ParseStrTo<int>();
  143. var isCurrent = Request.Form["IsCurrentDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsCurrentDropDown"].ParseStrTo<int>();
  144. var isEnable = Request.Form["IsEnableDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsEnableDropDown"].ParseStrTo<int>();
  145. var dt = GraduationSchoolYearServices.GetGradSchoolYearViewList(configuretView, years, schoolcodeID, isCurrent, isEnable)
  146. .Select(x => new
  147. {
  148. x.GraduatingSemesterCode,
  149. x.Years,
  150. x.SchoolcodeName,
  151. x.WeeksNum,
  152. GraduateDate = x.GraduateDate.HasValue ? x.GraduateDate.Value.ToLongDateString() : "",
  153. x.IsCurrentName,
  154. x.IsEnableName
  155. }).ToTable();
  156. string[] liststring = {
  157. "毕业学期", "学年", "学期", "周数", "毕业日期", "是否当前学期", "启用状态"
  158. };
  159. neh.Export(dt, liststring, "毕业学期信息" + DateTime.Now.ToString("yyyyMMdd"));
  160. return Json(new ReturnMessage()
  161. {
  162. IsSuccess = true,
  163. Message = "导出成功。"
  164. });
  165. }
  166. }
  167. }