GraduationConditionPackageController.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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.GraduationManage.GraduationSetting;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using EMIS.ViewModel.GraduationManage.GraduationSetting;
  10. using Bowin.Common.Utility;
  11. using Bowin.Common.Data;
  12. using Bowin.Web.Controls.Mvc;
  13. using Bowin.Common.Linq.Entity;
  14. namespace EMIS.Web.Controllers.GraduationManage.GraduationSetting
  15. {
  16. [Authorization]
  17. public class GraduationConditionPackageController : Controller
  18. {
  19. public IGraduationConditionPackageServices GraduationConditionPackageServices { get; set; }
  20. public IGraduationConditionServices GraduationConditionServices { get; set; }
  21. /// <summary>
  22. /// 毕业公式页面
  23. /// </summary>
  24. /// <returns></returns>
  25. public ActionResult List()
  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. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  38. //是否默认
  39. var isDefault = pararms.getExtraInt("IsDefaultDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsDefaultDropDown");
  40. return base.Json(GraduationConditionPackageServices.GetGradConditionPackageViewGrid(configuretView, isDefault, (int)pararms.page, (int)pararms.rows));
  41. }
  42. /// <summary>
  43. /// 复制新增
  44. /// </summary>
  45. /// <param name="GraduationConditionPackageID"></param>
  46. /// <returns></returns>
  47. public ActionResult CopyAdd(Guid GraduationConditionPackageID)
  48. {
  49. GraduationConditionPackageView graduationConditionPackageView = new GraduationConditionPackageView();
  50. graduationConditionPackageView = GraduationConditionPackageServices.GetGraduationConditionPackageView(GraduationConditionPackageID);
  51. return View("Edit", graduationConditionPackageView);
  52. }
  53. /// <summary>
  54. /// 复制新增
  55. /// </summary>
  56. /// <param name="graduationConditionPackageView"></param>
  57. /// <returns></returns>
  58. [HttpPost]
  59. public ActionResult CopyAdd(GraduationConditionPackageView graduationConditionPackageView)
  60. {
  61. graduationConditionPackageView.GraduationConditionPackageID = Guid.Empty;
  62. return this.Edit(graduationConditionPackageView);
  63. }
  64. /// <summary>
  65. /// 编辑(新增、修改)
  66. /// </summary>
  67. /// <param name="GraduationConditionPackageID"></param>
  68. /// <returns></returns>
  69. [HttpGet]
  70. public ActionResult Edit(Guid? GraduationConditionPackageID)
  71. {
  72. ViewBag.Type = Request.Params["Type"];//临时性加参数控制、屏蔽列表进入无保存按钮权限
  73. GraduationConditionPackageView graduationConditionPackageView = new GraduationConditionPackageView();
  74. if (GraduationConditionPackageID.HasValue && GraduationConditionPackageID != Guid.Empty)
  75. {
  76. graduationConditionPackageView = GraduationConditionPackageServices.GetGraduationConditionPackageView(GraduationConditionPackageID);
  77. }
  78. else
  79. {
  80. graduationConditionPackageView.StudentTypeID = (int)CF_STUDENTTYPE.DefaultType;
  81. graduationConditionPackageView.IsDefault = true;
  82. }
  83. return View(graduationConditionPackageView);
  84. }
  85. /// <summary>
  86. /// 编辑(新增、修改)
  87. /// 注:判断是否默认状态(同一种学生类别,只有一种默认公式)
  88. /// 暂时不考虑当公式被引用时,不可修改公式中条件的情况
  89. /// </summary>
  90. /// <param name="graduationConditionPackageView"></param>
  91. /// <returns></returns>
  92. [HttpPost]
  93. public ActionResult Edit(GraduationConditionPackageView graduationConditionPackageView)
  94. {
  95. try
  96. {
  97. var graduationConditionViewList = DataGrid.GetTableData<GraduationConditionView>("dgGraduationConditionList");
  98. GraduationConditionPackageServices.GraduationConditionPackageEdit(graduationConditionPackageView, graduationConditionViewList);
  99. return Json(new ReturnMessage()
  100. {
  101. IsSuccess = true,
  102. Message = "保存成功。"
  103. });
  104. }
  105. catch (Exception ex)
  106. {
  107. return Json(new ReturnMessage()
  108. {
  109. IsSuccess = false,
  110. Message = "保存失败,原因:" + ex.Message + "。"
  111. });
  112. }
  113. }
  114. /// <summary>
  115. /// 删除(当对应的毕业公式被引用时,不可删除--毕业公式、对应的毕业条件)
  116. /// </summary>
  117. /// <param name="graduationConditionPackageIDs"></param>
  118. /// <returns></returns>
  119. [HttpPost]
  120. public ActionResult Delete(string graduationConditionPackageIDs)
  121. {
  122. try
  123. {
  124. List<Guid?> list = graduationConditionPackageIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  125. .Select(x => (Guid?)new Guid(x)).ToList();
  126. GraduationConditionPackageServices.GraduationConditionPackageDelete(list);
  127. return base.Json("删除成功。");
  128. }
  129. catch (Exception ex)
  130. {
  131. return base.Json("删除失败,原因:" + ex.Message);
  132. }
  133. }
  134. /// <summary>
  135. /// 毕业条件添加页面
  136. /// </summary>
  137. /// <returns></returns>
  138. public ActionResult GraduationConditionList()
  139. {
  140. return View();
  141. }
  142. /// <summary>
  143. /// 毕业条件添加页面查询列表
  144. /// </summary>
  145. /// <param name="pararms"></param>
  146. /// <returns></returns>
  147. [HttpPost]
  148. public ActionResult GraduationConditionList(QueryParamsModel pararms)
  149. {
  150. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  151. var graduationConditionPackageID = Request["GraduationConditionPackageID"].ParseStrTo<Guid>();
  152. var isCurrent = (int)CF_GeneralPurpose.IsYes;
  153. return base.Json(GraduationConditionPackageServices.GetGraduationConditionNoViewGrid(configuretView, graduationConditionPackageID, isCurrent, (int)pararms.page, (int)pararms.rows));
  154. }
  155. /// <summary>
  156. /// 毕业公式对应的毕业条件列表页面(根据对应的毕业公式ID查询)
  157. /// </summary>
  158. /// <param name="GraduationConditionPackageID"></param>
  159. /// <returns></returns>
  160. public ActionResult GraduationConditionViewList(Guid? GraduationConditionPackageID)
  161. {
  162. var graduationConditionPackageList = new List<GraduationConditionView>();
  163. if (GraduationConditionPackageID.HasValue && GraduationConditionPackageID != Guid.Empty)
  164. {
  165. graduationConditionPackageList = GraduationConditionPackageServices.GetGraduationConditionList(GraduationConditionPackageID);
  166. }
  167. return Json(new GridResultSet<GraduationConditionView>()
  168. {
  169. rows = graduationConditionPackageList,
  170. total = graduationConditionPackageList.Count
  171. });
  172. }
  173. /// <summary>
  174. /// Excel导出
  175. /// </summary>
  176. /// <returns></returns>
  177. [HttpPost]
  178. public ActionResult Excel()
  179. {
  180. NpoiExcelHelper neh = new NpoiExcelHelper();
  181. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  182. //是否默认
  183. int? isDefault = Request["IsDefaultDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["IsDefaultDropDown"].ParseStrTo<int>();
  184. var dt = GraduationConditionPackageServices.GetGradConditionPackageViewList(configuretView, isDefault)
  185. .Select(x => new
  186. {
  187. x.Title,
  188. x.StudentTypeName,
  189. x.IsDefaultName
  190. }).ToTable();
  191. string[] liststring = {
  192. "公式名称", "学生类别", "是否默认"
  193. };
  194. neh.Export(dt, liststring, "毕业公式信息" + DateTime.Now.ToString("yyyyMMdd"));
  195. return Json(new ReturnMessage()
  196. {
  197. IsSuccess = true,
  198. Message = "导出成功。"
  199. });
  200. }
  201. }
  202. }