ExamSubjectLimitController.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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.ExamManage;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using Bowin.Common.Exceptions;
  10. using Bowin.Common.Utility;
  11. using Bowin.Common.Data;
  12. using Bowin.Web.Controls.Mvc;
  13. namespace EMIS.Web.Controllers.ExamManage
  14. {
  15. [Authorization]
  16. public class ExamSubjectLimitController : Controller
  17. {
  18. public IExamSubjectLimitServices IExamSubjectLimitService { get; set; }
  19. //
  20. // GET: /ExaminationBatch/
  21. public ActionResult List()
  22. {
  23. return View();
  24. }
  25. public ActionResult Select()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 列表查询
  31. /// </summary>
  32. /// <param name="pararms"></param>
  33. /// <returns></returns>
  34. [HttpPost]
  35. public ActionResult List(QueryParamsModel pararms)
  36. {
  37. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  38. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  39. configuretViews.AddRange(pararms.getConditions());
  40. var StartDate = configuretViews.Where(x => x.Attribute == "StartDate").SingleOrDefault();
  41. if (StartDate != null) StartDate.Condition = ">=";
  42. var EndDate = configuretViews.Where(x => x.Attribute == "EndDate").SingleOrDefault();
  43. if (EndDate != null) EndDate.Condition = "<=";
  44. return base.Json(IExamSubjectLimitService.GetListGridView((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
  45. }
  46. /// <summary>
  47. /// 编辑页列表查询
  48. /// </summary>
  49. /// <param name="pararms"></param>
  50. /// <returns></returns>
  51. [HttpPost]
  52. public ActionResult EditList(QueryParamsModel pararms)
  53. {
  54. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  55. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  56. configuretViews.AddRange(pararms.getConditions());
  57. var ExaminationSubjectCountLimitID = Guid.Parse(Request.QueryString["ExaminationSubjectCountLimitID"]);
  58. configuretViews.Add(new ConfiguretView()
  59. {
  60. Attribute = "ExaminationSubjectCountLimitID",
  61. Condition = "=",
  62. ConditionValue = ExaminationSubjectCountLimitID.ToString()
  63. });
  64. return base.Json(IExamSubjectLimitService.GetListGridView((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
  65. }
  66. /// <summary>
  67. /// 设置编辑页
  68. /// </summary>
  69. /// <param name="ExaminationProjectFeeID"></param>
  70. /// <returns></returns>
  71. [HttpGet]
  72. public ActionResult Edit(Guid? ViewID)
  73. {
  74. EMIS.ViewModel.ExamSubjectLimitView projectFeeView = new EMIS.ViewModel.ExamSubjectLimitView() { ExaminationSubjectCountLimitID = Guid.NewGuid() };
  75. if (ViewID.HasValue && ViewID != Guid.Empty)
  76. {
  77. projectFeeView = IExamSubjectLimitService.GetView(ViewID);
  78. }
  79. return View(projectFeeView);
  80. }
  81. /// <summary>
  82. /// 设置编辑页提交
  83. /// </summary>
  84. /// <param name="campusView"></param>
  85. /// <returns></returns>
  86. [HttpPost]
  87. public ActionResult Edit(ExamSubjectLimitView view)
  88. {
  89. try
  90. {
  91. var listData = DataGrid.GetTableData<EMIS.ViewModel.ExamSubjectLimitView>("dgStandardList");
  92. IExamSubjectLimitService.Edit(view, listData);
  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="campusIDs"></param>
  112. /// <returns></returns>
  113. [HttpPost]
  114. public JsonResult Delete(string IDs)
  115. {
  116. try
  117. {
  118. List<Guid?> list = IDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  119. .Select(x => (Guid?)new Guid(x)).ToList();
  120. IExamSubjectLimitService.Delete(list);
  121. return base.Json("删除成功。");
  122. }
  123. catch (Exception ex)
  124. {
  125. string mge = ex.Message;
  126. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  127. if (num != null)
  128. {
  129. if (num.Number == 547)
  130. {
  131. mge = "请先删除与其有关联的数据";
  132. }
  133. }
  134. return base.Json("删除失败,原因:" + mge);
  135. }
  136. }
  137. [HttpPost]
  138. public ActionResult Excel(QueryParamsModel pararms)
  139. {
  140. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  141. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  142. configuretViews.AddRange(pararms.getConditions());
  143. var StartDate = configuretViews.Where(x => x.Attribute == "StartDate").SingleOrDefault();
  144. if (StartDate != null) StartDate.Condition = ">=";
  145. var EndDate = configuretViews.Where(x => x.Attribute == "EndDate").SingleOrDefault();
  146. if (EndDate != null) EndDate.Condition = "<=";
  147. var query = IExamSubjectLimitService.GetList(configuretViews.ToArray());
  148. var SelectedID = Request.Form["SelectedID"];
  149. List<Guid?> selectIDlist = new List<Guid?>();
  150. if (SelectedID != "" && SelectedID != null)
  151. {
  152. selectIDlist = SelectedID.SplitIDString();
  153. query = query.Where(x => selectIDlist.Contains(x.ExaminationSubjectCountLimitID));
  154. }
  155. var dt = query.ToList().Select(q =>
  156. new
  157. {
  158. q.ExaminationTypeName,
  159. q.StandardName,
  160. q.SchoolyearNumName,
  161. q.SubjectCountLimit
  162. }).ToTable();
  163. NpoiExcelHelper neh = new NpoiExcelHelper();
  164. string[] liststring = {
  165. "考试类型","标准专业","年级","报名门数"};
  166. neh.Export(dt, liststring, "考试类型控制设置列表" + DateTime.Now.ToString("yyyyMMddhhmmss"));
  167. return RedirectToAction("MsgShow", "Common", new
  168. {
  169. msg = "导出成功!",
  170. url = Url.Content("~/ExaminationBatc/List").AddMenuParameter()
  171. });
  172. }
  173. }
  174. }