ExamPersonControlController.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. using EMIS.ViewModel.Students;
  14. namespace EMIS.Web.Controllers.ExamManage
  15. {
  16. [Authorization]
  17. public class ExamPersonControlController : Controller
  18. {
  19. public IExamPersonControlServices IPersonControlServices { get; set; }
  20. //
  21. // GET: /ExaminationBatch/
  22. public ActionResult List()
  23. {
  24. return View();
  25. }
  26. /// <summary>
  27. /// 项目列表查询
  28. /// </summary>
  29. /// <param name="pararms"></param>
  30. /// <returns></returns>
  31. [HttpPost]
  32. public ActionResult List(QueryParamsModel pararms)
  33. {
  34. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  35. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  36. configuretViews.AddRange(pararms.getConditions());
  37. var ExaminationBatchProjectID = Request.QueryString["ExaminationBatchProjectID"];
  38. if (!string.IsNullOrEmpty(ExaminationBatchProjectID))
  39. {
  40. configuretViews.Add(new ConfiguretView()
  41. {
  42. Attribute = "ExaminationBatchProjectID",
  43. Condition = "=",
  44. ConditionValue = ExaminationBatchProjectID
  45. });
  46. }
  47. var UserID = Request.QueryString["UserID"];
  48. if (!string.IsNullOrEmpty(UserID))
  49. {
  50. configuretViews.Add(new ConfiguretView()
  51. {
  52. Attribute = "UserID",
  53. Condition = "=",
  54. ConditionValue = UserID
  55. });
  56. }
  57. var StartDate = configuretViews.Where(x => x.Attribute == "StartDate").SingleOrDefault();
  58. if (StartDate != null) StartDate.Condition = ">=";
  59. var EndDate = configuretViews.Where(x => x.Attribute == "EndDate").SingleOrDefault();
  60. if (EndDate != null) EndDate.Condition = "<=";
  61. return base.Json(IPersonControlServices.GetListGridView((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
  62. }
  63. /// <summary>
  64. /// 控制考试类型列表查询
  65. /// </summary>
  66. /// <param name="pararms"></param>
  67. /// <returns></returns>
  68. [HttpPost]
  69. public ActionResult GetControlExamTypeListViewGrid(QueryParamsModel pararms)
  70. {
  71. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  72. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  73. configuretViews.AddRange(pararms.getConditions());
  74. return base.Json(IPersonControlServices.GetControlExamTypeListViewGrid((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
  75. }
  76. /// <summary>
  77. /// 控制考试列表查询
  78. /// </summary>
  79. /// <param name="pararms"></param>
  80. /// <returns></returns>
  81. [HttpPost]
  82. public ActionResult GetControlProjectListViewGrid(QueryParamsModel pararms)
  83. {
  84. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  85. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  86. configuretViews.AddRange(pararms.getConditions());
  87. return base.Json(IPersonControlServices.GetControlProjectListViewGrid((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
  88. }
  89. /// <summary>
  90. /// 设置编辑页
  91. /// </summary>
  92. /// <param name="ExaminationProjectFeeID"></param>
  93. /// <returns></returns>
  94. [HttpGet]
  95. public ActionResult Edit(Guid? ViewID)
  96. {
  97. EMIS.ViewModel.ExamPersonControlView projectFeeView = new EMIS.ViewModel.ExamPersonControlView() { ExaminationBatchProjectPersonControlID = Guid.NewGuid(), ExaminationBatchProjectID = Guid.Empty, SchoolYearCode = BaseExtensions.GetCurrentSchoolYearID() };
  98. if (ViewID.HasValue && ViewID != Guid.Empty)
  99. {
  100. projectFeeView = IPersonControlServices.GetView(ViewID);
  101. }
  102. return View(projectFeeView);
  103. }
  104. /// <summary>
  105. /// 设置编辑页提交
  106. /// </summary>
  107. /// <param name="campusView"></param>
  108. /// <returns></returns>
  109. [HttpPost]
  110. public ActionResult Edit(ExamPersonControlView view)
  111. {
  112. try
  113. {
  114. var studentList = DataGrid.GetTableData<StudentsView>("dgStudentList");
  115. IPersonControlServices.Edit(view, studentList);
  116. return Json(new ReturnMessage()
  117. {
  118. IsSuccess = true,
  119. Message = "保存成功。"
  120. });
  121. }
  122. catch (Exception ex)
  123. {
  124. return Json(new ReturnMessage()
  125. {
  126. IsSuccess = false,
  127. Message = "保存失败,原因:" + ex.Message
  128. });
  129. }
  130. }
  131. /// <summary>
  132. /// 删除项目设置
  133. /// </summary>
  134. /// <param name="campusIDs"></param>
  135. /// <returns></returns>
  136. [HttpPost]
  137. public JsonResult Delete(string IDs)
  138. {
  139. try
  140. {
  141. List<Guid?> list = IDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  142. .Select(x => (Guid?)new Guid(x)).ToList();
  143. IPersonControlServices.Delete(list);
  144. return base.Json("删除成功。");
  145. }
  146. catch (Exception ex)
  147. {
  148. string mge = ex.Message;
  149. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  150. if (num != null)
  151. {
  152. if (num.Number == 547)
  153. {
  154. mge = "请先删除与其有关联的数据";
  155. }
  156. }
  157. return base.Json("删除失败,原因:" + mge);
  158. }
  159. }
  160. [HttpPost]
  161. public ActionResult Excel(QueryParamsModel pararms)
  162. {
  163. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  164. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  165. configuretViews.AddRange(pararms.getConditions());
  166. var StartDate = configuretViews.Where(x => x.Attribute == "StartDate").SingleOrDefault();
  167. if (StartDate != null) StartDate.Condition = ">=";
  168. var EndDate = configuretViews.Where(x => x.Attribute == "EndDate").SingleOrDefault();
  169. if (EndDate != null) EndDate.Condition = "<=";
  170. var query = IPersonControlServices.GetList(configuretViews.ToArray());
  171. var SelectedID = Request.Form["SelectedID"];
  172. List<Guid?> selectIDlist = new List<Guid?>();
  173. if (SelectedID != "" && SelectedID != null)
  174. {
  175. selectIDlist = SelectedID.SplitIDString();
  176. query = query.Where(x => selectIDlist.Contains(x.ExaminationBatchProjectPersonControlID));
  177. }
  178. var dt = query.ToList().Select(q =>
  179. new
  180. {
  181. q.Schoolyear,
  182. q.ExaminationBatchProject,
  183. q.ExaminationType,
  184. q.ProjectName,
  185. q.UserID,
  186. q.IsOnlinePayName,
  187. EndDate = q.EndDate.HasValue ? q.EndDate.Value.ToString("yyyy-MM-dd") : ""
  188. }).ToTable();
  189. NpoiExcelHelper neh = new NpoiExcelHelper();
  190. string[] liststring = {
  191. "学年学期","考试批次项目","项目类型","项目名称","用户ID","是否线上缴费","报名截止时间"};
  192. neh.Export(dt, liststring, "个人报名控制列表" + DateTime.Now.ToString("yyyyMMddhhmmss"));
  193. return RedirectToAction("MsgShow", "Common", new
  194. {
  195. msg = "导出成功!",
  196. url = Url.Content("~/ExaminationBatc/List").AddMenuParameter()
  197. });
  198. }
  199. }
  200. }