GradePointFormulaController.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.CommonLogic.ScoreManage;
  8. using EMIS.ViewModel.ScoreManage;
  9. using EMIS.Entities;
  10. using Bowin.Web.Controls.Mvc;
  11. using Bowin.Common.JSON;
  12. using Bowin.Common.Exceptions;
  13. namespace EMIS.Web.Controllers.ScoreManage
  14. {
  15. [Authorization]
  16. public class GradePointFormulaController : Controller
  17. {
  18. public IGradePointFormulaServices gradePointFormulaServices { get; set; }
  19. //
  20. // GET: /GradePointFormula/
  21. public ActionResult List()
  22. {
  23. return View();
  24. }
  25. /// <summary>
  26. /// 绩点公式设置列表
  27. /// </summary>
  28. /// <returns></returns>
  29. [HttpPost]
  30. public ActionResult List(QueryParamsModel pararms)
  31. {
  32. string name = pararms.getExtraString("textName");
  33. return Json(gradePointFormulaServices.GetGradePointFormulaGrid(name, (int)pararms.page, (int)pararms.rows));
  34. }
  35. /// <summary>
  36. /// 编辑
  37. /// </summary>
  38. /// <param name="gradePointFormulaID"></param>
  39. /// <returns></returns>
  40. public ActionResult Edit(Guid? gradePointFormulaID)
  41. {
  42. GradePointFormulaView gradePointFormulaView = new GradePointFormulaView();
  43. if (gradePointFormulaID != null && gradePointFormulaID.Value != Guid.Empty)
  44. {
  45. ER_GradePointFormula gradePointFormula = gradePointFormulaServices.GetGradePointFormula(gradePointFormulaID);
  46. if (gradePointFormula != null)
  47. {
  48. gradePointFormulaView.Name = gradePointFormula.Name;
  49. gradePointFormulaView.GradePointlimit = gradePointFormula.GradePointlimit;
  50. gradePointFormulaView.GradePointFloor = gradePointFormula.GradePointFloor;
  51. }
  52. }
  53. return View(gradePointFormulaView);
  54. }
  55. /// <summary>
  56. /// 编辑
  57. /// </summary>
  58. /// <param name="gradePointFormulaView"></param>
  59. /// <returns></returns>
  60. [HttpPost]
  61. public ActionResult Edit(GradePointFormulaView gradePointFormulaView)
  62. {
  63. try
  64. {
  65. gradePointFormulaServices.GradePointFormulaAdd(gradePointFormulaView);
  66. return Json(new ReturnMessage()
  67. {
  68. IsSuccess = true,
  69. Message = "保存成功!"
  70. });
  71. }
  72. catch (Exception ex)
  73. {
  74. return Json(new ReturnMessage()
  75. {
  76. IsSuccess = true,
  77. Message = "保存失败,原因:" + ex.Message + "!"
  78. });
  79. }
  80. }
  81. /// <summary>
  82. /// 删除
  83. /// </summary>
  84. /// <param name="gradePointFormulaIDs"></param>
  85. /// <returns></returns>
  86. [HttpPost]
  87. public ActionResult Delete(string gradePointFormulaIDs)
  88. {
  89. try
  90. {
  91. List<Guid> list = new List<Guid>();
  92. for (int i = 0; i < gradePointFormulaIDs.Split(',').Length; i++)
  93. {
  94. string id = gradePointFormulaIDs.Split(',')[i];
  95. if (!string.IsNullOrEmpty(id))
  96. {
  97. Guid gradePointFormulaID = new Guid(id);
  98. list.Add(gradePointFormulaID);
  99. }
  100. }
  101. gradePointFormulaServices.GradePointFormulaDelete(list);
  102. return Json("删除成功");
  103. }
  104. catch (Exception ex)
  105. {
  106. string mge = ex.Message;
  107. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  108. if (num != null)
  109. {
  110. if (num.Number == 547)
  111. mge = "请先删除所有关联的数据,如参数设置!";
  112. }
  113. return this.Json("删除失败,原因:" + mge);
  114. }
  115. }
  116. /// <summary>
  117. /// 绑定下拉
  118. /// </summary>
  119. /// <param name="bindType"></param>
  120. /// <returns></returns>
  121. [HttpPost]
  122. public ActionResult GradePointFormulaDataBind(DropdownListBindType? bindType)
  123. {
  124. List<DropdownListItem> list = gradePointFormulaServices.GetGradePointFormulaList("").Select(x => new DropdownListItem { Text = x.Name, Value = x.GradePointFormulaID.ToString() }).ToList();
  125. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  126. DropdownList.FormatDropdownItemList(dbt, list);
  127. return base.Json(list);
  128. }
  129. /// <summary>
  130. /// 绑定下拉
  131. /// </summary>
  132. /// <param name="bindType"></param>
  133. /// <returns></returns>
  134. [HttpPost]
  135. public ActionResult GradePointFormulaDataJsonBind(DropdownListBindType? bindType)
  136. {
  137. List<DropdownListItem> list = gradePointFormulaServices.GetGradePointFormulaList("").Select(x => new DropdownListItem { Text = x.Name, Value = new GradePointView { GradePointFormulaID = x.GradePointFormulaID, Name = x.Name, GradePointlimit = x.GradePointlimit, GradePointFloor = x.GradePointFloor }.ToJson() }).ToList();
  138. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  139. DropdownList.FormatDropdownItemList(dbt, list);
  140. return base.Json(list);
  141. }
  142. }
  143. }