MinorGraduationConditionPackageController.cs 9.2 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 EMIS.ViewModel;
  7. using EMIS.Web.Controls;
  8. using Bowin.Web.Controls.Mvc;
  9. using EMIS.CommonLogic.MinorGraduation.MinorGraduationSetting;
  10. using EMIS.ViewModel.MinorGraduation.MinorGraduationSetting;
  11. using Bowin.Common.Linq.Entity;
  12. using Bowin.Common.Utility;
  13. using Bowin.Common.Data;
  14. namespace EMIS.Web.Controllers.MinorGraduation.MinorGraduationSetting
  15. {
  16. [Authorization]
  17. public class MinorGraduationConditionPackageController : Controller
  18. {
  19. //
  20. // GET: /MinorGraduationConditionPackage/
  21. public IMinorGraduationConditionPackageServices minorGraduationConditionPackageServices { get; set; }
  22. public IMinorGraduationConditionServices minorGraduationConditionServices { get; set; }
  23. /// <summary>
  24. /// 毕业公式页面
  25. /// </summary>
  26. /// <returns></returns>
  27. public ActionResult List()
  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. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  40. //是否默认
  41. var isDefault = pararms.getExtraInt("IsDefaultDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsDefaultDropDown");
  42. return base.Json(minorGraduationConditionPackageServices.GetMinorGraduationConditionPackageViewGrid(configuretView, isDefault, (int)pararms.page, (int)pararms.rows));
  43. }
  44. /// <summary>
  45. /// 复制新增
  46. /// </summary>
  47. /// <param name="GraduationConditionPackageID"></param>
  48. /// <returns></returns>
  49. public ActionResult CopyAdd(Guid minorGraduationConditionPackageID)
  50. {
  51. MinorGraduationConditionPackageView minorGraduationConditionPackageView = new MinorGraduationConditionPackageView();
  52. minorGraduationConditionPackageView = minorGraduationConditionPackageServices.GetMinorGraduationConditionPackageView(minorGraduationConditionPackageID);
  53. return View("Edit", minorGraduationConditionPackageView);
  54. }
  55. /// <summary>
  56. /// 复制新增
  57. /// </summary>
  58. /// <param name="graduationConditionPackageView"></param>
  59. /// <returns></returns>
  60. [HttpPost]
  61. public ActionResult CopyAdd(MinorGraduationConditionPackageView minorGraduationConditionPackageView)
  62. {
  63. minorGraduationConditionPackageView.MinorGraduationConditionPackageID = Guid.Empty;
  64. return this.Edit(minorGraduationConditionPackageView);
  65. }
  66. /// <summary>
  67. /// 编辑(新增、修改)
  68. /// </summary>
  69. /// <param name="GraduationConditionPackageID"></param>
  70. /// <returns></returns>
  71. [HttpGet]
  72. public ActionResult Edit(Guid? minorGraduationConditionPackageID)
  73. {
  74. ViewBag.Type = Request.Params["Type"];
  75. MinorGraduationConditionPackageView minorGraduationConditionPackageView = new MinorGraduationConditionPackageView();
  76. if (minorGraduationConditionPackageID.HasValue && minorGraduationConditionPackageID != Guid.Empty)
  77. {
  78. minorGraduationConditionPackageView = minorGraduationConditionPackageServices.GetMinorGraduationConditionPackageView(minorGraduationConditionPackageID);
  79. }
  80. else
  81. {
  82. minorGraduationConditionPackageView.StudentTypeID = (int)CF_STUDENTTYPE.DefaultType;
  83. minorGraduationConditionPackageView.IsDefault = true;
  84. }
  85. return View(minorGraduationConditionPackageView);
  86. }
  87. /// <summary>
  88. /// 编辑(新增、修改)
  89. /// 注:判断是否默认状态(同一种学生类别,只有一种默认公式)
  90. /// 暂时不考虑当公式被引用时,不可修改公式中条件的情况
  91. /// </summary>
  92. /// <param name="graduationConditionPackageView"></param>
  93. /// <returns></returns>
  94. [HttpPost]
  95. public ActionResult Edit(MinorGraduationConditionPackageView minorGraduationConditionPackageView)
  96. {
  97. try
  98. {
  99. var minorGraduationConditionViewList = DataGrid.GetTableData<MinorGraduationConditionView>("dgMinorGraduationConditionList");
  100. minorGraduationConditionPackageServices.MinorGraduationConditionPackageEdit(minorGraduationConditionPackageView, minorGraduationConditionViewList);
  101. return Json(new ReturnMessage()
  102. {
  103. IsSuccess = true,
  104. Message = "保存成功。"
  105. });
  106. }
  107. catch (Exception ex)
  108. {
  109. return Json(new ReturnMessage()
  110. {
  111. IsSuccess = false,
  112. Message = "保存失败,原因:" + ex.Message + "。"
  113. });
  114. }
  115. }
  116. /// <summary>
  117. /// 删除(当对应的毕业公式被引用时,不可删除--毕业公式、对应的毕业条件)
  118. /// </summary>
  119. /// <param name="graduationConditionPackageIDs"></param>
  120. /// <returns></returns>
  121. [HttpPost]
  122. public ActionResult Delete(string minorGraduationConditionPackageIDs)
  123. {
  124. try
  125. {
  126. List<Guid?> list = minorGraduationConditionPackageIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  127. .Select(x => (Guid?)new Guid(x)).ToList();
  128. minorGraduationConditionPackageServices.MinorGraduationConditionPackageDelete(list);
  129. return base.Json("删除成功。");
  130. }
  131. catch (Exception ex)
  132. {
  133. return base.Json("删除失败,原因:" + ex.Message);
  134. }
  135. }
  136. /// <summary>
  137. /// 毕业条件列表(根据对应的毕业公式ID查询)
  138. /// </summary>
  139. /// <param name="GraduationConditionPackageID"></param>
  140. /// <returns></returns>
  141. public ActionResult MinorGraduationConditionViewList(Guid? minorGraduationConditionPackageID)
  142. {
  143. var minorGraduationConditionPackageList = new List<MinorGraduationConditionView>();
  144. if (minorGraduationConditionPackageID.HasValue)
  145. {
  146. minorGraduationConditionPackageList = minorGraduationConditionPackageServices
  147. .GetMinorGraduationConditionViewList(minorGraduationConditionPackageID);
  148. }
  149. return Json(new GridResultSet<MinorGraduationConditionView>()
  150. {
  151. rows = minorGraduationConditionPackageList,
  152. total = minorGraduationConditionPackageList.Count
  153. });
  154. }
  155. /// <summary>
  156. /// 毕业条件添加页面
  157. /// </summary>
  158. /// <returns></returns>
  159. public ActionResult MinorGraduationConditionList()
  160. {
  161. return View();
  162. }
  163. /// <summary>
  164. /// 毕业条件添加页面查询列表
  165. /// </summary>
  166. /// <param name="pararms"></param>
  167. /// <returns></returns>
  168. [HttpPost]
  169. public ActionResult MinorGraduationConditionList(QueryParamsModel pararms)
  170. {
  171. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  172. //启用状态(默认为启用)
  173. var isCurrent = (int)CF_GeneralPurpose.IsYes;
  174. return base.Json(minorGraduationConditionServices.GetMinorGraduationConditionViewGrid(configuretView, 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 minorGraduationConditionPackageIDString = Request.Form["SelectedID"];
  188. var minorGraduationConditionPackageIDList = minorGraduationConditionPackageIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  189. var dt = minorGraduationConditionPackageServices.GetMinorGraduationConditionPackageViewList(configuretView, isDefault, minorGraduationConditionPackageIDList)
  190. .Select(x => new
  191. {
  192. x.Title,
  193. x.StudentTypeName,
  194. x.IsDefaultName
  195. }).ToTable();
  196. string[] liststring = { "公式名称", "学生类别", "是否默认" };
  197. neh.Export(dt, liststring, "辅修毕业公式信息" + DateTime.Now.ToString("yyyyMMdd"));
  198. return Json(new ReturnMessage()
  199. {
  200. IsSuccess = true,
  201. Message = "导出成功。"
  202. });
  203. }
  204. }
  205. }