123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.ViewModel;
- using EMIS.CommonLogic.ScoreManage;
- using EMIS.Entities;
- using Bowin.Common.Utility;
- using Bowin.Web.Controls.Mvc;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.ViewModel.ScoreManage;
- using EMIS.Utility;
- namespace EMIS.Web.Controllers.ScoreManage
- {
- [Authorization]
- public class ScoreParameterSettingController : Controller
- {
- public IParameterServices ParameterServices { get; set; }
- public IScoreParameterSettingServices ScoreParameterSettingServices { get; set; }
- public IExamsCategorySettingServices ExamsCategorySettingServices { get; set; }
- //
- // GET: /ScoreParameterSetting/
- public ActionResult List()
- {
- var scoreParameterSettingList = ScoreParameterSettingServices.GetScoreParameterSettingViewGrid();
- ViewData["scoreParameterSettingList"] = scoreParameterSettingList;
- return View();
- }
- [HttpPost]
- public ActionResult ExamsCategorySettingCheckList()
- {
- var examsCategorySettingViewList = ExamsCategorySettingServices.GetExamsCategorySettingViewList();
- var listControlItemList = examsCategorySettingViewList.Select(x => new ListControlItem
- {
- Text = x.ExamsCategoryDesc,
- Value = x.ExamsCategoryID,
- IsSelected = x.IsReadHistory
- }).ToList();
- return Json(listControlItemList);
- }
- [HttpPost]
- public ActionResult List(Guid? ScoreParameterSettingID, FormCollection collection)
- {
- try
- {
- //var isMisconductCanGraduateExam = collection.GetValue("IsMisconductCanGraduateExam").ConvertTo(typeof(bool?));
- //var isLoadScoreForResit = collection.GetValue("IsLoadScoreForResit").ConvertTo(typeof(bool?));
- var isScoreEditControlForCharge = collection.GetValue("IsScoreEditControlForCharge").ConvertTo(typeof(bool?));
- var examsCategorySettingList = new List<int>();
- if(collection.GetValues("chkIsReadScoreHistory") != null)
- {
- examsCategorySettingList = collection.GetValues("chkIsReadScoreHistory").Select(x => int.Parse(x)).ToList();
- }
-
-
- List<ScoreParameterSettingView> scoreParameterSettingList = new List<ScoreParameterSettingView>();
- #region 获取界面控件的值到detailViewList
- #region 通用设置
- var commonName = DropdownList.PLEASE_SELECT.ToString() + "_" + DropdownList.PLEASE_SELECT.ToString();
- var commonScoreFormula = collection.GetValue("ddlScoreFormula_" + commonName).AttemptedValue.ParseStrTo<Guid>();
- var commonIsScoreFormula = (bool?)collection.GetValue("chkScoreFormula_" + commonName).ConvertTo(typeof(bool?));
- var commonCreditFormula = (Guid?)collection.GetValue("ddlCreditFormula_" + commonName).AttemptedValue.ParseStrTo<Guid>();
- var commonIsCreditFormula = (bool?)collection.GetValue("chkCreditFormula_" + commonName).ConvertTo(typeof(bool?));
- var commonGradePointFormula = (Guid?)collection.GetValue("ddlGradePointFormula_" + commonName).AttemptedValue.ParseStrTo<Guid>();
- var commonIsGradePointFormula = (bool?)collection.GetValue("chkGradePointFormula_" + commonName).ConvertTo(typeof(bool?));
- if (commonScoreFormula == null || commonCreditFormula == null || commonGradePointFormula == null)
- {
- return Json(new ReturnMessage
- {
- IsSuccess = false,
- Message = "保存失败:必须填写通用设置的总分公式、学分公式、绩点公式。"
- });
- }
- var examsCategoryList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ExamsCategory);
- var courseTypeList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_CourseType);
- scoreParameterSettingList.Add(new ScoreParameterSettingView
- {
- ExamsTypeID = null,
- CourseTypeID = null,
- ScoreFormulaID = commonScoreFormula,
- IsTotalFormula = commonIsScoreFormula ?? false,
- CreditFormulaID = commonCreditFormula,
- IsCreditFormula = commonIsCreditFormula ?? false,
- GradePointFormulaID = commonGradePointFormula,
- IsGradePointFormula = commonIsGradePointFormula ?? false
- });
- #endregion
- #region 为了减少循环次数,按考试性质和详细设置一起来
- foreach (var examsCategory in examsCategoryList)
- {
- var examsCategoryName = (examsCategory.Value ?? DropdownList.PLEASE_SELECT).ToString() + "_" + DropdownList.PLEASE_SELECT.ToString();
- var examsCategoryScoreFormula = (Guid?)collection.GetValue("ddlScoreFormula_" + examsCategoryName).AttemptedValue.ParseStrTo<Guid>();
- var examsCategoryIsScoreFormula = (bool?)collection.GetValue("chkScoreFormula_" + examsCategoryName).ConvertTo(typeof(bool?));
- var examsCategoryCreditFormula = (Guid?)collection.GetValue("ddlCreditFormula_" + examsCategoryName).AttemptedValue.ParseStrTo<Guid>();
- var examsCategoryIsCreditFormula = (bool?)collection.GetValue("chkCreditFormula_" + examsCategoryName).ConvertTo(typeof(bool?));
- var examsCategoryGradePointFormula = (Guid?)collection.GetValue("ddlGradePointFormula_" + examsCategoryName).AttemptedValue.ParseStrTo<Guid>();
- var examsCategoryIsGradePointFormula = (bool?)collection.GetValue("chkGradePointFormula_" + examsCategoryName).ConvertTo(typeof(bool?));
- scoreParameterSettingList.Add(new ScoreParameterSettingView
- {
- ExamsTypeID = examsCategory.Value,
- CourseTypeID = null,
- ScoreFormulaID = examsCategoryScoreFormula,
- IsTotalFormula = examsCategoryIsScoreFormula ?? false,
- CreditFormulaID = examsCategoryCreditFormula,
- IsCreditFormula = examsCategoryIsCreditFormula ?? false,
- GradePointFormulaID = examsCategoryGradePointFormula,
- IsGradePointFormula = examsCategoryIsGradePointFormula ?? false
- });
- foreach (var courseType in courseTypeList)
- {
- var courseTypeName = (examsCategory.Value ?? DropdownList.PLEASE_SELECT).ToString() + "_" + (courseType.Value ?? DropdownList.PLEASE_SELECT).ToString();
- var courseTypeScoreFormula = (Guid?)collection.GetValue("ddlScoreFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
- var courseTypeIsScoreFormula = (bool?)collection.GetValue("chkScoreFormula_" + courseTypeName).ConvertTo(typeof(bool?));
- var courseTypeCreditFormula = (Guid?)collection.GetValue("ddlCreditFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
- var courseTypeIsCreditFormula = (bool?)collection.GetValue("chkCreditFormula_" + courseTypeName).ConvertTo(typeof(bool?));
- var courseTypeGradePointFormula = (Guid?)collection.GetValue("ddlGradePointFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
- var courseTypeIsGradePointFormula = (bool?)collection.GetValue("chkGradePointFormula_" + courseTypeName).ConvertTo(typeof(bool?));
- scoreParameterSettingList.Add(new ScoreParameterSettingView
- {
- ExamsTypeID = examsCategory.Value,
- CourseTypeID = courseType.Value,
- ScoreFormulaID = courseTypeScoreFormula,
- IsTotalFormula = courseTypeIsScoreFormula ?? false,
- CreditFormulaID = courseTypeCreditFormula,
- IsCreditFormula = courseTypeIsCreditFormula ?? false,
- GradePointFormulaID = courseTypeGradePointFormula,
- IsGradePointFormula = courseTypeIsGradePointFormula ?? false
- });
- }
- }
- #endregion
- foreach (var courseType in courseTypeList)
- {
- var courseTypeName = DropdownList.PLEASE_SELECT.ToString() + "_" + (courseType.Value ?? DropdownList.PLEASE_SELECT).ToString();
- var courseTypeScoreFormula = (Guid?)collection.GetValue("ddlScoreFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
- var courseTypeIsScoreFormula = (bool?)collection.GetValue("chkScoreFormula_" + courseTypeName).ConvertTo(typeof(bool?));
- var courseTypeCreditFormula = (Guid?)collection.GetValue("ddlCreditFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
- var courseTypeIsCreditFormula = (bool?)collection.GetValue("chkCreditFormula_" + courseTypeName).ConvertTo(typeof(bool?));
- var courseTypeGradePointFormula = (Guid?)collection.GetValue("ddlGradePointFormula_" + courseTypeName).AttemptedValue.ParseStrTo<Guid>();
- var courseTypeIsGradePointFormula = (bool?)collection.GetValue("chkGradePointFormula_" + courseTypeName).ConvertTo(typeof(bool?));
- scoreParameterSettingList.Add(new ScoreParameterSettingView
- {
- ExamsTypeID = null,
- CourseTypeID = courseType.Value,
- ScoreFormulaID = courseTypeScoreFormula,
- IsTotalFormula = courseTypeIsScoreFormula ?? false,
- CreditFormulaID = courseTypeCreditFormula,
- IsCreditFormula = courseTypeIsCreditFormula ?? false,
- GradePointFormulaID = courseTypeGradePointFormula,
- IsGradePointFormula = courseTypeIsGradePointFormula ?? false
- });
- }
- #endregion
- //ParameterServices.SaveTo(CF_ParameterType.IsMisconductCanGraduateExam, isMisconductCanGraduateExam);
- //ParameterServices.SaveTo(CF_ParameterType.LoadScoreForResit, isLoadScoreForResit);
- ExamsCategorySettingServices.SaveExamsCategorySetting(examsCategorySettingList);
- ParameterServices.SaveTo(CF_ParameterType.IsScoreEditControlForCharge, isScoreEditControlForCharge);
- ScoreParameterSettingServices.ScoreParameterSettingServicesAdd(scoreParameterSettingList);
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存成功!"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "保存失败,原因:" + ex.Message + "!"
- });
- }
- }
- }
- }
|