DegreeConditionPackageController.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Common.Utility;
  7. using Bowin.Common.Data;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.Web.Controls;
  10. using EMIS.ViewModel;
  11. using EMIS.CommonLogic.DegreeManage.DegreeSetting;
  12. using EMIS.ViewModel.DegreeManage.DegreeSetting;
  13. using Bowin.Common.Linq.Entity;
  14. namespace EMIS.Web.Controllers.DegreeManage.DegreeSetting
  15. {
  16. [Authorization]
  17. public class DegreeConditionPackageController : Controller
  18. {
  19. public IDegreeConditionPackageServices DegreeConditionPackageServices { get; set; }
  20. public IDegreeConditionServices DegreeConditionServices { 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(DegreeConditionPackageServices.GetDegreeConditionPackageViewGrid(configuretView, isDefault, (int)pararms.page, (int)pararms.rows));
  41. }
  42. /// <summary>
  43. /// 复制新增
  44. /// </summary>
  45. /// <param name="DegreeConditionPackageID"></param>
  46. /// <returns></returns>
  47. public ActionResult CopyAdd(Guid DegreeConditionPackageID)
  48. {
  49. DegreeConditionPackageView degreeConditionPackageView = new DegreeConditionPackageView();
  50. degreeConditionPackageView = DegreeConditionPackageServices.GetDegreeConditionPackageView(DegreeConditionPackageID);
  51. return View("Edit", degreeConditionPackageView);
  52. }
  53. /// <summary>
  54. /// 复制新增
  55. /// </summary>
  56. /// <param name="degreeConditionPackageView"></param>
  57. /// <returns></returns>
  58. [HttpPost]
  59. public ActionResult CopyAdd(DegreeConditionPackageView degreeConditionPackageView)
  60. {
  61. degreeConditionPackageView.DegreeConditionPackageID = Guid.Empty;
  62. return this.Edit(degreeConditionPackageView);
  63. }
  64. /// <summary>
  65. /// 编辑(新增、修改)
  66. /// </summary>
  67. /// <param name="DegreeConditionPackageID"></param>
  68. /// <returns></returns>
  69. [HttpGet]
  70. public ActionResult Edit(Guid? DegreeConditionPackageID)
  71. {
  72. ViewBag.Type = Request.Params["Type"];//临时性加参数控制、屏蔽列表进入无保存按钮权限
  73. DegreeConditionPackageView degreeConditionPackageView = new DegreeConditionPackageView();
  74. if (DegreeConditionPackageID.HasValue && DegreeConditionPackageID != Guid.Empty)
  75. {
  76. degreeConditionPackageView = DegreeConditionPackageServices.GetDegreeConditionPackageView(DegreeConditionPackageID);
  77. }
  78. else
  79. {
  80. degreeConditionPackageView.StudentTypeID = (int)CF_STUDENTTYPE.DefaultType;
  81. degreeConditionPackageView.IsDefault = true;
  82. }
  83. return View(degreeConditionPackageView);
  84. }
  85. /// <summary>
  86. /// 编辑(新增、修改)
  87. /// 注:判断是否默认状态(同一种学生类别,只有一种默认公式)
  88. /// 暂时不考虑当公式被引用时,不可修改公式中条件的情况
  89. /// </summary>
  90. /// <param name="degreeConditionPackageView"></param>
  91. /// <returns></returns>
  92. [HttpPost]
  93. public ActionResult Edit(DegreeConditionPackageView degreeConditionPackageView)
  94. {
  95. try
  96. {
  97. var degreeConditionViewList = DataGrid.GetTableData<DegreeConditionView>("dgDegreeConditionList");
  98. DegreeConditionPackageServices.DegreeConditionPackageEdit(degreeConditionPackageView, degreeConditionViewList);
  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="degreeConditionPackageIDs"></param>
  118. /// <returns></returns>
  119. [HttpPost]
  120. public ActionResult Delete(string degreeConditionPackageIDs)
  121. {
  122. try
  123. {
  124. List<Guid?> list = degreeConditionPackageIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  125. .Select(x => (Guid?)new Guid(x)).ToList();
  126. DegreeConditionPackageServices.DegreeConditionPackageDelete(list);
  127. return base.Json("删除成功。");
  128. }
  129. catch (Exception ex)
  130. {
  131. return base.Json("删除失败,原因:" + ex.Message);
  132. }
  133. }
  134. /// <summary>
  135. /// 学位公式对应的学位条件列表页面(根据对应的学位公式ID查询)
  136. /// </summary>
  137. /// <param name="DegreeConditionPackageID"></param>
  138. /// <returns></returns>
  139. public ActionResult DegreeConditionViewList(Guid? DegreeConditionPackageID)
  140. {
  141. var degreeConditionPackageList = new List<DegreeConditionView>();
  142. if (DegreeConditionPackageID.HasValue && DegreeConditionPackageID != Guid.Empty)
  143. {
  144. degreeConditionPackageList = DegreeConditionPackageServices
  145. .GetDegreeConditionList(DegreeConditionPackageID);
  146. }
  147. return Json(new GridResultSet<DegreeConditionView>()
  148. {
  149. rows = degreeConditionPackageList,
  150. total = degreeConditionPackageList.Count
  151. });
  152. }
  153. /// <summary>
  154. /// 学位条件添加页面
  155. /// </summary>
  156. /// <returns></returns>
  157. public ActionResult DegreeConditionList()
  158. {
  159. return View();
  160. }
  161. /// <summary>
  162. /// 学位条件添加页面查询列表
  163. /// </summary>
  164. /// <param name="pararms"></param>
  165. /// <returns></returns>
  166. [HttpPost]
  167. public ActionResult DegreeConditionList(QueryParamsModel pararms)
  168. {
  169. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  170. var degreeConditionPackageID = Request["DegreeConditionPackageID"].ParseStrTo<Guid>();
  171. //启用状态(默认为启用)
  172. var isCurrent = (int)CF_GeneralPurpose.IsYes;
  173. return base.Json(DegreeConditionPackageServices.GetDegreeConditionNoViewGrid(configuretView, degreeConditionPackageID,
  174. isCurrent, (int)pararms.page, (int)pararms.rows));
  175. }
  176. /// <summary>
  177. /// Excel导出
  178. /// </summary>
  179. /// <returns></returns>
  180. [HttpPost]
  181. public ActionResult Excel()
  182. {
  183. NpoiExcelHelper neh = new NpoiExcelHelper();
  184. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  185. //是否默认
  186. int? isDefault = Request["IsDefaultDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["IsDefaultDropDown"].ParseStrTo<int>();
  187. var dt = DegreeConditionPackageServices.GetDegreeConditionPackageViewList(configuretView, isDefault)
  188. .Select(x => new
  189. {
  190. x.Title,
  191. x.StudentTypeName,
  192. x.IsDefaultName
  193. }).ToTable();
  194. string[] liststring = {
  195. "公式名称", "学生类别", "是否默认"
  196. };
  197. neh.Export(dt, liststring, "学位公式信息" + DateTime.Now.ToString("yyyyMMdd"));
  198. return Json(new ReturnMessage()
  199. {
  200. IsSuccess = true,
  201. Message = "导出成功。"
  202. });
  203. }
  204. }
  205. }