ExamProjectControlController.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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 ExamProjectControlController : Controller
  17. {
  18. public IExamProjectControlServices IExamProjectControlService { get; set; }
  19. public IExamBatchProjectServices IExamBatchProjectService { get; set; }
  20. public IProjectFeeServices IProjectFeeService { get; set; }
  21. //
  22. // GET: /ExaminationBatch/
  23. public ActionResult List()
  24. {
  25. return View();
  26. }
  27. public ActionResult Select()
  28. {
  29. return View();
  30. }
  31. /// <summary>
  32. /// 项目列表查询
  33. /// </summary>
  34. /// <param name="pararms"></param>
  35. /// <returns></returns>
  36. [HttpPost]
  37. public ActionResult List(QueryParamsModel pararms)
  38. {
  39. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  40. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  41. configuretViews.AddRange(pararms.getConditions());
  42. var StartDate = configuretViews.Where(x => x.Attribute == "StartDate").SingleOrDefault();
  43. if (StartDate != null) StartDate.Condition = ">=";
  44. var EndDate = configuretViews.Where(x => x.Attribute == "EndDate").SingleOrDefault();
  45. if (EndDate != null) EndDate.Condition = "<=";
  46. return base.Json(IExamProjectControlService.GetListGridView((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
  47. }
  48. /// <summary>
  49. /// 控制考试类型列表查询
  50. /// </summary>
  51. /// <param name="pararms"></param>
  52. /// <returns></returns>
  53. [HttpPost]
  54. public ActionResult GetControlExamTypeListViewGrid(QueryParamsModel pararms)
  55. {
  56. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  57. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  58. configuretViews.AddRange(pararms.getConditions());
  59. return base.Json(IExamProjectControlService.GetControlExamTypeListViewGrid((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
  60. }
  61. /// <summary>
  62. /// 控制考试列表查询
  63. /// </summary>
  64. /// <param name="pararms"></param>
  65. /// <returns></returns>
  66. [HttpPost]
  67. public ActionResult GetControlProjectListViewGrid(QueryParamsModel pararms)
  68. {
  69. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  70. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  71. configuretViews.AddRange(pararms.getConditions());
  72. return base.Json(IExamProjectControlService.GetControlProjectListViewGrid((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
  73. }
  74. /// <summary>
  75. /// 控制收费项目列表查询
  76. /// </summary>
  77. /// <param name="pararms"></param>
  78. /// <returns></returns>
  79. [HttpPost]
  80. public ActionResult GetControlProjectFeeListViewGrid(QueryParamsModel pararms)
  81. {
  82. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  83. var ExaminationBatchProjectID = pararms.getExtraGuid("ExaminationBatchProjectID");
  84. var view = IExamBatchProjectService.GetView(x => x.ExaminationBatchProjectID == ExaminationBatchProjectID);
  85. if (view != null)
  86. {
  87. configuretViews.Add(new ConfiguretView()
  88. {
  89. Attribute = "ExaminationProjectID",
  90. Condition = "=",
  91. ConditionValue = view.ExaminationProjectID.ToString()
  92. });
  93. }
  94. else {
  95. configuretViews.Add(new ConfiguretView()
  96. {
  97. Attribute = "ExaminationProjectID",
  98. Condition = "=",
  99. ConditionValue = null
  100. });
  101. }
  102. return base.Json(IProjectFeeService.GetProjectFeeGrid((int)pararms.page, (int)pararms.rows, configuretViews.ToArray()));
  103. }
  104. /// <summary>
  105. /// 设置编辑页
  106. /// </summary>
  107. /// <param name="ExaminationProjectFeeID"></param>
  108. /// <returns></returns>
  109. [HttpGet]
  110. public ActionResult Edit(Guid? ViewID)
  111. {
  112. EMIS.ViewModel.ExamProjectControlView projectFeeView = new EMIS.ViewModel.ExamProjectControlView() { ExaminationBatchProjectControlID = Guid.NewGuid(), SchoolYearCode = BaseExtensions.GetCurrentSchoolYearID() };
  113. if (ViewID.HasValue && ViewID != Guid.Empty)
  114. {
  115. projectFeeView = IExamProjectControlService.GetView(ViewID);
  116. }
  117. return View(projectFeeView);
  118. }
  119. /// <summary>
  120. /// 设置编辑页提交
  121. /// </summary>
  122. /// <param name="campusView"></param>
  123. /// <returns></returns>
  124. [HttpPost]
  125. public ActionResult Edit(ExamProjectControlView view)
  126. {
  127. try
  128. {
  129. var standardList = DataGrid.GetTableData<EMIS.ViewModel.ExamProjectControlView>("dgStandardList");
  130. //新增时候是批量,修改为单条操作
  131. if (standardList == null || standardList.Count == 0)
  132. {
  133. IExamProjectControlService.Edit(view);
  134. }
  135. else
  136. {
  137. IExamProjectControlService.Edit(view, standardList);
  138. }
  139. return Json(new ReturnMessage()
  140. {
  141. IsSuccess = true,
  142. Message = "保存成功。"
  143. });
  144. }
  145. catch (Exception ex)
  146. {
  147. return Json(new ReturnMessage()
  148. {
  149. IsSuccess = false,
  150. Message = "保存失败,原因:" + ex.Message
  151. });
  152. }
  153. }
  154. /// <summary>
  155. /// 删除项目设置
  156. /// </summary>
  157. /// <param name="campusIDs"></param>
  158. /// <returns></returns>
  159. [HttpPost]
  160. public JsonResult Delete(string IDs)
  161. {
  162. try
  163. {
  164. List<Guid?> list = IDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  165. .Select(x => (Guid?)new Guid(x)).ToList();
  166. IExamProjectControlService.Delete(list);
  167. return base.Json("删除成功。");
  168. }
  169. catch (Exception ex)
  170. {
  171. string mge = ex.Message;
  172. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  173. if (num != null)
  174. {
  175. if (num.Number == 547)
  176. {
  177. mge = "请先删除与其有关联的数据";
  178. }
  179. }
  180. return base.Json("删除失败,原因:" + mge);
  181. }
  182. }
  183. [HttpPost]
  184. public ActionResult Excel(QueryParamsModel pararms)
  185. {
  186. List<ConfiguretView> configuretViews = new List<ConfiguretView>();
  187. configuretViews.Add(ConfiguretExtensions.GetConfiguretermsView(pararms));
  188. configuretViews.AddRange(pararms.getConditions());
  189. var StartDate = configuretViews.Where(x => x.Attribute == "StartDate").SingleOrDefault();
  190. if (StartDate != null) StartDate.Condition = ">=";
  191. var EndDate = configuretViews.Where(x => x.Attribute == "EndDate").SingleOrDefault();
  192. if (EndDate != null) EndDate.Condition = "<=";
  193. var query = IExamProjectControlService.GetList(configuretViews.ToArray());
  194. var SelectedID = Request.Form["SelectedID"];
  195. List<Guid?> selectIDlist = new List<Guid?>();
  196. if (SelectedID != "" && SelectedID != null)
  197. {
  198. selectIDlist = SelectedID.SplitIDString();
  199. query = query.Where(x => selectIDlist.Contains(x.ExaminationBatchProjectControlID));
  200. }
  201. var dt = query.ToList().Select(q =>
  202. new
  203. {
  204. q.Schoolyear,
  205. q.ExaminationBatchProject,
  206. q.ExaminationType,
  207. q.ProjectName,
  208. q.ExaminationProjectFee,
  209. q.SchoolyearID,
  210. q.CollegeName,
  211. q.StandardName,
  212. q.IsOnlinePayName,
  213. }).ToTable();
  214. NpoiExcelHelper neh = new NpoiExcelHelper();
  215. string[] liststring = {
  216. "学年学期","考试批次","考试类型","项目名称","收费标准名称","年级","院系所","专业","能否线上缴费"};
  217. neh.Export(dt, liststring, "批次报名控制列表" + DateTime.Now.ToString("yyyyMMddhhmmss"));
  218. return RedirectToAction("MsgShow", "Common", new
  219. {
  220. msg = "导出成功!",
  221. url = Url.Content("~/ExaminationBatc/List").AddMenuParameter()
  222. });
  223. }
  224. }
  225. }