ScoreParameterSettingController.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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.Entities;
  9. using Bowin.Common.Utility;
  10. using Bowin.Web.Controls.Mvc;
  11. using EMIS.CommonLogic.SystemServices;
  12. using EMIS.ViewModel.ScoreManage;
  13. using EMIS.Utility;
  14. namespace EMIS.Web.Controllers.ScoreManage
  15. {
  16. [Authorization]
  17. public class ScoreParameterSettingController : Controller
  18. {
  19. public IParameterServices ParameterServices { get; set; }
  20. public IScoreParameterSettingServices ScoreParameterSettingServices { get; set; }
  21. public IExamsCategorySettingServices ExamsCategorySettingServices { get; set; }
  22. //
  23. // GET: /ScoreParameterSetting/
  24. public ActionResult List()
  25. {
  26. var scoreParameterSettingList = ScoreParameterSettingServices.GetScoreParameterSettingViewGrid();
  27. ViewData["scoreParameterSettingList"] = scoreParameterSettingList;
  28. return View();
  29. }
  30. [HttpPost]
  31. public ActionResult ExamsCategorySettingCheckList()
  32. {
  33. var examsCategorySettingViewList = ExamsCategorySettingServices.GetExamsCategorySettingViewList();
  34. var listControlItemList = examsCategorySettingViewList.Select(x => new ListControlItem
  35. {
  36. Text = x.ExamsCategoryDesc,
  37. Value = x.ExamsCategoryID,
  38. IsSelected = x.IsReadHistory
  39. }).ToList();
  40. return Json(listControlItemList);
  41. }
  42. [HttpPost]
  43. public ActionResult List(Guid? ScoreParameterSettingID, FormCollection collection)
  44. {
  45. try
  46. {
  47. //var isMisconductCanGraduateExam = collection.GetValue("IsMisconductCanGraduateExam").ConvertTo(typeof(bool?));
  48. //var isLoadScoreForResit = collection.GetValue("IsLoadScoreForResit").ConvertTo(typeof(bool?));
  49. var isScoreEditControlForCharge = collection.GetValue("IsScoreEditControlForCharge").ConvertTo(typeof(bool?));
  50. var examsCategorySettingList = new List<int>();
  51. if(collection.GetValues("chkIsReadScoreHistory") != null)
  52. {
  53. examsCategorySettingList = collection.GetValues("chkIsReadScoreHistory").Select(x => int.Parse(x)).ToList();
  54. }
  55. List<ScoreParameterSettingView> scoreParameterSettingList = new List<ScoreParameterSettingView>();
  56. #region 获取界面控件的值到detailViewList
  57. #region 通用设置
  58. var commonName = DropdownList.PLEASE_SELECT.ToString() + "_" + DropdownList.PLEASE_SELECT.ToString();
  59. var commonScoreFormula = collection.GetValue("ddlScoreFormula_" + commonName).AttemptedValue.ParseStrTo<Guid>();
  60. var commonIsScoreFormula = (bool?)collection.GetValue("chkScoreFormula_" + commonName).ConvertTo(typeof(bool?));
  61. var commonCreditFormula = (Guid?)collection.GetValue("ddlCreditFormula_" + commonName).AttemptedValue.ParseStrTo<Guid>();
  62. var commonIsCreditFormula = (bool?)collection.GetValue("chkCreditFormula_" + commonName).ConvertTo(typeof(bool?));
  63. var commonGradePointFormula = (Guid?)collection.GetValue("ddlGradePointFormula_" + commonName).AttemptedValue.ParseStrTo<Guid>();
  64. var commonIsGradePointFormula = (bool?)collection.GetValue("chkGradePointFormula_" + commonName).ConvertTo(typeof(bool?));
  65. if (commonScoreFormula == null || commonCreditFormula == null || commonGradePointFormula == null)
  66. {
  67. return Json(new ReturnMessage
  68. {
  69. IsSuccess = false,
  70. Message = "保存失败:必须填写通用设置的总分公式、学分公式、绩点公式。"
  71. });
  72. }
  73. var examsCategoryList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ExamsCategory);
  74. var courseTypeList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_CourseType);
  75. scoreParameterSettingList.Add(new ScoreParameterSettingView
  76. {
  77. ExamsTypeID = null,
  78. CourseTypeID = null,
  79. ScoreFormulaID = commonScoreFormula,
  80. IsTotalFormula = commonIsScoreFormula ?? false,
  81. CreditFormulaID = commonCreditFormula,
  82. IsCreditFormula = commonIsCreditFormula ?? false,
  83. GradePointFormulaID = commonGradePointFormula,
  84. IsGradePointFormula = commonIsGradePointFormula ?? false
  85. });
  86. #endregion
  87. #region 为了减少循环次数,按考试性质和详细设置一起来
  88. foreach (var examsCategory in examsCategoryList)
  89. {
  90. var examsCategoryName = (examsCategory.Value ?? DropdownList.PLEASE_SELECT).ToString() + "_" + DropdownList.PLEASE_SELECT.ToString();
  91. var examsCategoryScoreFormula = (Guid?)collection.GetValue("ddlScoreFormula_" + examsCategoryName).AttemptedValue.ParseStrTo<Guid>();
  92. var examsCategoryIsScoreFormula = (bool?)collection.GetValue("chkScoreFormula_" + examsCategoryName).ConvertTo(typeof(bool?));
  93. var examsCategoryCreditFormula = (Guid?)collection.GetValue("ddlCreditFormula_" + examsCategoryName).AttemptedValue.ParseStrTo<Guid>();
  94. var examsCategoryIsCreditFormula = (bool?)collection.GetValue("chkCreditFormula_" + examsCategoryName).ConvertTo(typeof(bool?));
  95. var examsCategoryGradePointFormula = (Guid?)collection.GetValue("ddlGradePointFormula_" + examsCategoryName).AttemptedValue.ParseStrTo<Guid>();
  96. var examsCategoryIsGradePointFormula = (bool?)collection.GetValue("chkGradePointFormula_" + examsCategoryName).ConvertTo(typeof(bool?));
  97. scoreParameterSettingList.Add(new ScoreParameterSettingView
  98. {
  99. ExamsTypeID = examsCategory.Value,
  100. CourseTypeID = null,
  101. ScoreFormulaID = examsCategoryScoreFormula,
  102. IsTotalFormula = examsCategoryIsScoreFormula ?? false,
  103. CreditFormulaID = examsCategoryCreditFormula,
  104. IsCreditFormula = examsCategoryIsCreditFormula ?? false,
  105. GradePointFormulaID = examsCategoryGradePointFormula,
  106. IsGradePointFormula = examsCategoryIsGradePointFormula ?? false
  107. });
  108. foreach (var courseType in courseTypeList)
  109. {
  110. var courseTypeName = (examsCategory.Value ?? DropdownList.PLEASE_SELECT).ToString() + "_" + (courseType.Value ?? DropdownList.PLEASE_SELECT).ToString();
  111. var courseTypeScoreFormula = (Guid?)collection.GetValue("ddlScoreFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
  112. var courseTypeIsScoreFormula = (bool?)collection.GetValue("chkScoreFormula_" + courseTypeName).ConvertTo(typeof(bool?));
  113. var courseTypeCreditFormula = (Guid?)collection.GetValue("ddlCreditFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
  114. var courseTypeIsCreditFormula = (bool?)collection.GetValue("chkCreditFormula_" + courseTypeName).ConvertTo(typeof(bool?));
  115. var courseTypeGradePointFormula = (Guid?)collection.GetValue("ddlGradePointFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
  116. var courseTypeIsGradePointFormula = (bool?)collection.GetValue("chkGradePointFormula_" + courseTypeName).ConvertTo(typeof(bool?));
  117. scoreParameterSettingList.Add(new ScoreParameterSettingView
  118. {
  119. ExamsTypeID = examsCategory.Value,
  120. CourseTypeID = courseType.Value,
  121. ScoreFormulaID = courseTypeScoreFormula,
  122. IsTotalFormula = courseTypeIsScoreFormula ?? false,
  123. CreditFormulaID = courseTypeCreditFormula,
  124. IsCreditFormula = courseTypeIsCreditFormula ?? false,
  125. GradePointFormulaID = courseTypeGradePointFormula,
  126. IsGradePointFormula = courseTypeIsGradePointFormula ?? false
  127. });
  128. }
  129. }
  130. #endregion
  131. foreach (var courseType in courseTypeList)
  132. {
  133. var courseTypeName = DropdownList.PLEASE_SELECT.ToString() + "_" + (courseType.Value ?? DropdownList.PLEASE_SELECT).ToString();
  134. var courseTypeScoreFormula = (Guid?)collection.GetValue("ddlScoreFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
  135. var courseTypeIsScoreFormula = (bool?)collection.GetValue("chkScoreFormula_" + courseTypeName).ConvertTo(typeof(bool?));
  136. var courseTypeCreditFormula = (Guid?)collection.GetValue("ddlCreditFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
  137. var courseTypeIsCreditFormula = (bool?)collection.GetValue("chkCreditFormula_" + courseTypeName).ConvertTo(typeof(bool?));
  138. var courseTypeGradePointFormula = (Guid?)collection.GetValue("ddlGradePointFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
  139. var courseTypeIsGradePointFormula = (bool?)collection.GetValue("chkGradePointFormula_" + courseTypeName).ConvertTo(typeof(bool?));
  140. scoreParameterSettingList.Add(new ScoreParameterSettingView
  141. {
  142. ExamsTypeID = null,
  143. CourseTypeID = courseType.Value,
  144. ScoreFormulaID = courseTypeScoreFormula,
  145. IsTotalFormula = courseTypeIsScoreFormula ?? false,
  146. CreditFormulaID = courseTypeCreditFormula,
  147. IsCreditFormula = courseTypeIsCreditFormula ?? false,
  148. GradePointFormulaID = courseTypeGradePointFormula,
  149. IsGradePointFormula = courseTypeIsGradePointFormula ?? false
  150. });
  151. }
  152. #endregion
  153. //ParameterServices.SaveTo(CF_ParameterType.IsMisconductCanGraduateExam, isMisconductCanGraduateExam);
  154. //ParameterServices.SaveTo(CF_ParameterType.LoadScoreForResit, isLoadScoreForResit);
  155. ExamsCategorySettingServices.SaveExamsCategorySetting(examsCategorySettingList);
  156. ParameterServices.SaveTo(CF_ParameterType.IsScoreEditControlForCharge, isScoreEditControlForCharge);
  157. ScoreParameterSettingServices.ScoreParameterSettingServicesAdd(scoreParameterSettingList);
  158. return Json(new ReturnMessage()
  159. {
  160. IsSuccess = true,
  161. Message = "保存成功!"
  162. });
  163. }
  164. catch (Exception ex)
  165. {
  166. return Json(new ReturnMessage()
  167. {
  168. IsSuccess = true,
  169. Message = "保存失败,原因:" + ex.Message + "!"
  170. });
  171. }
  172. }
  173. }
  174. }