SelectCourseOpenControlSettingController.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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.SelectCourse;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using Bowin.Web.Controls.Mvc;
  10. using Bowin.Common.Utility;
  11. using Bowin.Common.Data;
  12. using EMIS.ViewModel.SelectCourse;
  13. using EMIS.Utility;
  14. namespace EMIS.Web.Controllers.SelectCourseManage
  15. {
  16. [Authorization]
  17. public class SelectCourseOpenControlSettingController : Controller
  18. {
  19. public IOpenControlSettingServices OpenControlSettingServices { get; set; }
  20. /// <summary>
  21. /// 限选控制页面
  22. /// </summary>
  23. /// <returns></returns>
  24. public ActionResult List()
  25. {
  26. return View();
  27. }
  28. /// <summary>
  29. /// 列表查询
  30. /// </summary>
  31. /// <param name="pararms"></param>
  32. /// <returns></returns>
  33. [HttpPost]
  34. public ActionResult List(QueryParamsModel pararms)
  35. {
  36. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  37. //避开全选值
  38. var schoolYearID = pararms.getExtraGuid("SchoolyearDropdown");
  39. var campusID = pararms.getExtraGuid("CampusDropdown");
  40. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  41. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  42. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  43. if (yearID == DropdownList.SELECT_ALL) yearID = null;
  44. if (standardID == DropdownList.SELECT_ALL) standardID = null;
  45. if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  46. return base.Json(OpenControlSettingServices.GetOpenControlSettingViewList(configuretView, schoolYearID,
  47. campusID, collegeID, yearID, standardID, (int)pararms.page, (int)pararms.rows));
  48. }
  49. [HttpPost]
  50. public ActionResult Excel(QueryParamsModel pararms)
  51. {
  52. NpoiExcelHelper neh = new NpoiExcelHelper();
  53. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  54. //避开全选值
  55. var schoolYearID = Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
  56. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  57. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  58. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["Year"].ParseStrTo<int>();
  59. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["Standard"].ParseStrTo<int>();
  60. if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  61. var dt = OpenControlSettingServices.GetOpenControlSettingViewList(configuretView, schoolYearID,
  62. campusID, collegeID, yearID, standardID)
  63. .Select(x => new
  64. {
  65. x.SchoolyearCode,
  66. x.YearName,
  67. x.StandardDesc,
  68. x.CollegeName,
  69. StartTime = x.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
  70. EndTime = x.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
  71. x.MaxSelectCount,
  72. x.MinSelectCount,
  73. x.MaxCredit,
  74. x.MinCredit
  75. }).ToTable();
  76. string[] liststring = { "学年学期", "年级", "专业名称", RSL.Get("College"), "开始时间", "结束时间", "门数上限", "门数下限", "学分上限", "学分下限" };
  77. neh.Export(dt, liststring, "网上选课类型设定");
  78. return RedirectToAction("MsgShow", "Common", new
  79. {
  80. msg = "导出成功!",
  81. url = Url.Content("~/SelectCourseOpenControlSetting/List").AddMenuParameter()
  82. });
  83. }
  84. public ActionResult Edit(Guid? selectCourseOpenControlSettingID)
  85. {
  86. SelectCourseOpenControlSettingView openControlSettingView = new SelectCourseOpenControlSettingView();
  87. if (selectCourseOpenControlSettingID != null && selectCourseOpenControlSettingID != Guid.Empty)
  88. {
  89. openControlSettingView = OpenControlSettingServices.GetOpenControlSettingViewInfo(selectCourseOpenControlSettingID);
  90. }
  91. else
  92. {
  93. openControlSettingView.MaxSelectCount = 0;
  94. openControlSettingView.MinSelectCount = 0;
  95. openControlSettingView.MaxCredit = 0;
  96. openControlSettingView.MinCredit = 0;
  97. }
  98. return View(openControlSettingView);
  99. }
  100. /// <summary>
  101. /// 新增
  102. /// </summary>
  103. /// <returns></returns>
  104. [HttpPost]
  105. public ActionResult Edit(SelectCourseOpenControlSettingView openControlSettingView)
  106. {
  107. try
  108. {
  109. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  110. OpenControlSettingServices.Save(openControlSettingView);
  111. return Json(new ReturnMessage
  112. {
  113. IsSuccess = true,
  114. Message = "保存成功"
  115. });
  116. }
  117. catch (Exception ex)
  118. {
  119. return Json(new ReturnMessage
  120. {
  121. IsSuccess = false,
  122. Message = "保存失败:" + ex.Message
  123. });
  124. }
  125. }
  126. /// <summary>
  127. /// 删除
  128. /// </summary>
  129. /// <param name="roleID"></param>
  130. /// <returns></returns>
  131. [HttpPost]
  132. public ActionResult Delete(string openControlSettingIDs)
  133. {
  134. try
  135. {
  136. var openControlSettingIDList = openControlSettingIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
  137. OpenControlSettingServices.Delete(openControlSettingIDList);
  138. return base.Json("删除成功!");
  139. }
  140. catch (Exception ex)
  141. {
  142. return base.Json("删除失败,原因:" + ex.Message + "。");
  143. }
  144. }
  145. }
  146. }