ScoreParameterCollegeSettingController.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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.Web.Controls;
  9. using EMIS.ViewModel.ScoreManage;
  10. using Bowin.Common.Utility;
  11. using Bowin.Web.Controls.Mvc;
  12. using EMIS.Utility;
  13. namespace EMIS.Web.Controllers.ScoreManage
  14. {
  15. [Authorization]
  16. public class ScoreParameterCollegeSettingController : Controller
  17. {
  18. public IScoreParamterCollegeSettingServices ScoreParamterCollegeSettingServices { get; set; }
  19. public ActionResult List()
  20. {
  21. return View();
  22. }
  23. public ActionResult Edit(string action, Guid? scoreParameterCollegeSettingID)
  24. {
  25. ScoreParameterCollegeSettingView entity;
  26. if (scoreParameterCollegeSettingID.HasValue)
  27. {
  28. entity = ScoreParamterCollegeSettingServices.GetScoreParameterCollegeSettingView(scoreParameterCollegeSettingID.Value);
  29. }
  30. else
  31. {
  32. entity = new ScoreParameterCollegeSettingView();
  33. }
  34. var scoreParameterCollegeSettingDetailList = ScoreParamterCollegeSettingServices.GetScoreParameterSettingViewForDetail(scoreParameterCollegeSettingID);
  35. ViewData["scoreParameterCollegeSettingDetailList"] = scoreParameterCollegeSettingDetailList;
  36. return View(entity);
  37. }
  38. [HttpPost]
  39. public ActionResult List(QueryParamsModel pararms)
  40. {
  41. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  42. var collegeID = pararms.getExtraGuid("cbgCollege");
  43. var years = pararms.getExtraInt("ddlGradeYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlGradeYear");
  44. return Json(ScoreParamterCollegeSettingServices.GetScoreParameterCollegeSettingViewGrid(configuretView, collegeID, years, pararms.page, pararms.rows));
  45. }
  46. [HttpPost]
  47. public ActionResult Delete(string scoreParameterCollegeSettingIDString)
  48. {
  49. var deleteIDList = scoreParameterCollegeSettingIDString.Split(',')
  50. .Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  51. try
  52. {
  53. this.ScoreParamterCollegeSettingServices.Delete(deleteIDList);
  54. return Json(new ReturnMessage
  55. {
  56. IsSuccess = true,
  57. Message = "删除成功。"
  58. });
  59. }
  60. catch (Exception ex)
  61. {
  62. return Json(new ReturnMessage
  63. {
  64. IsSuccess = false,
  65. Message = "删除失败:" + ex.Message
  66. });
  67. }
  68. }
  69. [HttpPost]
  70. public ActionResult Edit(ScoreParameterCollegeSettingView scoreParameterCollegeSettingView, FormCollection collection)
  71. {
  72. List<ScoreParameterSettingView> detailViewList = new List<ScoreParameterSettingView>();
  73. #region 获取界面控件的值到detailViewList
  74. #region 通用设置
  75. var commonName = DropdownList.PLEASE_SELECT.ToString() + "_" + DropdownList.PLEASE_SELECT.ToString();
  76. var commonScoreFormula = collection.GetValue("ddlScoreFormula_" + commonName).AttemptedValue.ParseStrTo<Guid>();
  77. var commonIsScoreFormula = (bool?)collection.GetValue("chkScoreFormula_" + commonName).ConvertTo(typeof(bool?));
  78. var commonCreditFormula = (Guid?)collection.GetValue("ddlCreditFormula_" + commonName).AttemptedValue.ParseStrTo<Guid>();
  79. var commonIsCreditFormula = (bool?)collection.GetValue("chkCreditFormula_" + commonName).ConvertTo(typeof(bool?));
  80. var commonGradePointFormula = (Guid?)collection.GetValue("ddlGradePointFormula_" + commonName).AttemptedValue.ParseStrTo<Guid>();
  81. var commonIsGradePointFormula = (bool?)collection.GetValue("chkGradePointFormula_" + commonName).ConvertTo(typeof(bool?));
  82. //if (commonScoreFormula == null || commonCreditFormula == null || commonGradePointFormula == null)
  83. //{
  84. // return Json(new ReturnMessage
  85. // {
  86. // IsSuccess = false,
  87. // Message = "保存失败:必须填写通用设置的总分公式、学分公式、绩点公式。"
  88. // });
  89. //}
  90. var examsCategoryList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ExamsCategory);
  91. var courseTypeList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_CourseType);
  92. detailViewList.Add(new ScoreParameterSettingView
  93. {
  94. ExamsTypeID = null,
  95. CourseTypeID = null,
  96. ScoreFormulaID = commonScoreFormula,
  97. IsTotalFormula = commonIsScoreFormula ?? false,
  98. CreditFormulaID = commonCreditFormula,
  99. IsCreditFormula = commonIsCreditFormula ?? false,
  100. GradePointFormulaID = commonGradePointFormula,
  101. IsGradePointFormula = commonIsGradePointFormula ?? false
  102. });
  103. #endregion
  104. #region 为了减少循环次数,按考试性质和详细设置一起来
  105. foreach (var examsCategory in examsCategoryList)
  106. {
  107. var examsCategoryName = (examsCategory.Value ?? DropdownList.PLEASE_SELECT).ToString() + "_" + DropdownList.PLEASE_SELECT.ToString();
  108. var examsCategoryScoreFormula = (Guid?)collection.GetValue("ddlScoreFormula_" + examsCategoryName).AttemptedValue.ParseStrTo<Guid>();
  109. var examsCategoryIsScoreFormula = (bool?)collection.GetValue("chkScoreFormula_" + examsCategoryName).ConvertTo(typeof(bool?));
  110. var examsCategoryCreditFormula = (Guid?)collection.GetValue("ddlCreditFormula_" + examsCategoryName).AttemptedValue.ParseStrTo<Guid>();
  111. var examsCategoryIsCreditFormula = (bool?)collection.GetValue("chkCreditFormula_" + examsCategoryName).ConvertTo(typeof(bool?));
  112. var examsCategoryGradePointFormula = (Guid?)collection.GetValue("ddlGradePointFormula_" + examsCategoryName).AttemptedValue.ParseStrTo<Guid>();
  113. var examsCategoryIsGradePointFormula = (bool?)collection.GetValue("chkGradePointFormula_" + examsCategoryName).ConvertTo(typeof(bool?));
  114. detailViewList.Add(new ScoreParameterSettingView
  115. {
  116. ExamsTypeID = examsCategory.Value,
  117. CourseTypeID = null,
  118. ScoreFormulaID = examsCategoryScoreFormula,
  119. IsTotalFormula = examsCategoryIsScoreFormula ?? false,
  120. CreditFormulaID = examsCategoryCreditFormula,
  121. IsCreditFormula = examsCategoryIsCreditFormula ?? false,
  122. GradePointFormulaID = examsCategoryGradePointFormula,
  123. IsGradePointFormula = examsCategoryIsGradePointFormula ?? false
  124. });
  125. foreach (var courseType in courseTypeList)
  126. {
  127. var courseTypeName = (examsCategory.Value ?? DropdownList.PLEASE_SELECT).ToString() + "_" + (courseType.Value ?? DropdownList.PLEASE_SELECT).ToString();
  128. var courseTypeScoreFormula = (Guid?)collection.GetValue("ddlScoreFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
  129. var courseTypeIsScoreFormula = (bool?)collection.GetValue("chkScoreFormula_" + courseTypeName).ConvertTo(typeof(bool?));
  130. var courseTypeCreditFormula = (Guid?)collection.GetValue("ddlCreditFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
  131. var courseTypeIsCreditFormula = (bool?)collection.GetValue("chkCreditFormula_" + courseTypeName).ConvertTo(typeof(bool?));
  132. var courseTypeGradePointFormula = (Guid?)collection.GetValue("ddlGradePointFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
  133. var courseTypeIsGradePointFormula = (bool?)collection.GetValue("chkGradePointFormula_" + courseTypeName).ConvertTo(typeof(bool?));
  134. detailViewList.Add(new ScoreParameterSettingView
  135. {
  136. ExamsTypeID = examsCategory.Value,
  137. CourseTypeID = courseType.Value,
  138. ScoreFormulaID = courseTypeScoreFormula,
  139. IsTotalFormula = courseTypeIsScoreFormula ?? false,
  140. CreditFormulaID = courseTypeCreditFormula,
  141. IsCreditFormula = courseTypeIsCreditFormula ?? false,
  142. GradePointFormulaID = courseTypeGradePointFormula,
  143. IsGradePointFormula = courseTypeIsGradePointFormula ?? false
  144. });
  145. }
  146. }
  147. #endregion
  148. foreach (var courseType in courseTypeList)
  149. {
  150. var courseTypeName = DropdownList.PLEASE_SELECT.ToString() + "_" + (courseType.Value ?? DropdownList.PLEASE_SELECT).ToString();
  151. var courseTypeScoreFormula = (Guid?)collection.GetValue("ddlScoreFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
  152. var courseTypeIsScoreFormula = (bool?)collection.GetValue("chkScoreFormula_" + courseTypeName).ConvertTo(typeof(bool?));
  153. var courseTypeCreditFormula = (Guid?)collection.GetValue("ddlCreditFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
  154. var courseTypeIsCreditFormula = (bool?)collection.GetValue("chkCreditFormula_" + courseTypeName).ConvertTo(typeof(bool?));
  155. var courseTypeGradePointFormula = (Guid?)collection.GetValue("ddlGradePointFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
  156. var courseTypeIsGradePointFormula = (bool?)collection.GetValue("chkGradePointFormula_" + courseTypeName).ConvertTo(typeof(bool?));
  157. detailViewList.Add(new ScoreParameterSettingView
  158. {
  159. ExamsTypeID = null,
  160. CourseTypeID = courseType.Value,
  161. ScoreFormulaID = courseTypeScoreFormula,
  162. IsTotalFormula = courseTypeIsScoreFormula ?? false,
  163. CreditFormulaID = courseTypeCreditFormula,
  164. IsCreditFormula = courseTypeIsCreditFormula ?? false,
  165. GradePointFormulaID = courseTypeGradePointFormula,
  166. IsGradePointFormula = courseTypeIsGradePointFormula ?? false
  167. });
  168. }
  169. #endregion
  170. try
  171. {
  172. if (scoreParameterCollegeSettingView.Years == DropdownList.PLEASE_SELECT)
  173. {
  174. scoreParameterCollegeSettingView.Years = null;
  175. }
  176. if (scoreParameterCollegeSettingView.ScoreTypeID == DropdownList.PLEASE_SELECT)
  177. {
  178. scoreParameterCollegeSettingView.ScoreTypeID = null;
  179. }
  180. this.ScoreParamterCollegeSettingServices.Save(scoreParameterCollegeSettingView, detailViewList);
  181. return Json(new ReturnMessage
  182. {
  183. IsSuccess = true,
  184. Message = "保存成功。"
  185. });
  186. }
  187. catch (Exception ex)
  188. {
  189. return Json(new ReturnMessage
  190. {
  191. IsSuccess = false,
  192. Message = "保存失败:" + ex.Message
  193. });
  194. }
  195. }
  196. }
  197. }