SelectCourseTypeSettingController.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 EMIS.CommonLogic.SelectCourse;
  10. using Bowin.Common.Data;
  11. using Bowin.Common.Utility;
  12. using EMIS.ViewModel.SelectCourse;
  13. namespace EMIS.Web.Controllers.SelectCourseManage
  14. {
  15. [Authorization]
  16. public class SelectCourseTypeSettingController : Controller
  17. {
  18. public ITypeSettingServices TypeSettingServices { 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. //避开全选值
  37. var schoolYearID = pararms.getExtraGuid("SchoolYear");
  38. var selectCourseTypeID = pararms.getExtraInt("SelectCourseType");
  39. if (selectCourseTypeID == DropdownList.SELECT_ALL) selectCourseTypeID = null;
  40. var recordStatus = pararms.getExtraInt("RecordStatus");
  41. if (recordStatus == DropdownList.SELECT_ALL) recordStatus = null;
  42. if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  43. return base.Json(TypeSettingServices.GetTypeSettingViewList(configuretView, schoolYearID, selectCourseTypeID, recordStatus,
  44. (int)pararms.page, (int)pararms.rows));
  45. }
  46. public ActionResult Edit(Guid? typeSettingID)
  47. {
  48. SelectCourseTypeSettingView typeSettingView = new SelectCourseTypeSettingView();
  49. if (typeSettingID != null && typeSettingID != Guid.Empty)
  50. {
  51. typeSettingView = TypeSettingServices.GetTypeSettingViewInfo(typeSettingID);
  52. }
  53. else
  54. {
  55. typeSettingView.MaxSelectCount = 2;
  56. typeSettingView.MinSelectCount = 0;
  57. typeSettingView.MaxCredit = 0;
  58. typeSettingView.MinCredit = 0;
  59. }
  60. return View(typeSettingView);
  61. }
  62. /// <summary>
  63. /// 新增
  64. /// </summary>
  65. /// <returns></returns>
  66. [HttpPost]
  67. public ActionResult Edit(SelectCourseTypeSettingView typeSettingView)
  68. {
  69. try
  70. {
  71. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  72. TypeSettingServices.Save(typeSettingView);
  73. return Json(new ReturnMessage
  74. {
  75. IsSuccess = true,
  76. Message = "保存成功"
  77. });
  78. }
  79. catch (Exception ex)
  80. {
  81. return Json(new ReturnMessage
  82. {
  83. IsSuccess = false,
  84. Message = "保存失败:" + ex.Message
  85. });
  86. }
  87. }
  88. /// <summary>
  89. /// 删除
  90. /// </summary>
  91. /// <param name="roleID"></param>
  92. /// <returns></returns>
  93. [HttpPost]
  94. public ActionResult Delete(string typeSettingIDs)
  95. {
  96. try
  97. {
  98. var typeSettingIDList = typeSettingIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
  99. TypeSettingServices.Delete(typeSettingIDList);
  100. return base.Json("删除成功!");
  101. }
  102. catch (Exception ex)
  103. {
  104. return base.Json("删除失败,原因:" + ex.Message + "。");
  105. }
  106. }
  107. [HttpPost]
  108. public ActionResult Excel(QueryParamsModel pararms)
  109. {
  110. NpoiExcelHelper neh = new NpoiExcelHelper();
  111. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  112. //避开全选值
  113. var schoolYearID = Request.Form["SchoolYear"].ParseStrTo<Guid>();
  114. var selectCourseTypeID = Request.Form["SelectCourseType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SelectCourseType"].ParseStrTo<int>();
  115. var recordStatus = Request.Form["RecordStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["RecordStatus"].ParseStrTo<int>();
  116. var dt = TypeSettingServices.GetTypeSettingViewList(configuretView, schoolYearID, selectCourseTypeID, recordStatus)
  117. .Select(x => new
  118. {
  119. x.SchoolyearCode,
  120. x.SelectCourseTypeDesc,
  121. StartTime = x.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
  122. EndTime = x.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
  123. x.MaxSelectCount,
  124. x.MinSelectCount,
  125. x.MaxCredit,
  126. x.MinCredit,
  127. x.RecordStatusDesc,
  128. x.Remark
  129. }).ToTable();
  130. string[] liststring = { "学年学期", "选修类型", "开始时间", "结束时间",
  131. "门数上限", "门数下限", "学分上限", "学分下限", "是否启用", "备注" };
  132. neh.Export(dt, liststring, "网上选课类型设定");
  133. return RedirectToAction("MsgShow", "Common", new
  134. {
  135. msg = "导出成功!",
  136. url = Url.Content("~/SelectCourseTypeSetting/List").AddMenuParameter()
  137. });
  138. }
  139. }
  140. }