123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- 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.Web.Controls;
- using EMIS.ViewModel.ScoreManage;
- using Bowin.Common.Utility;
- using Bowin.Web.Controls.Mvc;
- using EMIS.Utility;
- namespace EMIS.Web.Controllers.ScoreManage
- {
- [Authorization]
- public class ScoreParameterCollegeSettingController : Controller
- {
- public IScoreParamterCollegeSettingServices ScoreParamterCollegeSettingServices { get; set; }
- public ActionResult List()
- {
- return View();
- }
- public ActionResult Edit(string action, Guid? scoreParameterCollegeSettingID)
- {
- ScoreParameterCollegeSettingView entity;
- if (scoreParameterCollegeSettingID.HasValue)
- {
- entity = ScoreParamterCollegeSettingServices.GetScoreParameterCollegeSettingView(scoreParameterCollegeSettingID.Value);
- }
- else
- {
- entity = new ScoreParameterCollegeSettingView();
- }
- var scoreParameterCollegeSettingDetailList = ScoreParamterCollegeSettingServices.GetScoreParameterSettingViewForDetail(scoreParameterCollegeSettingID);
- ViewData["scoreParameterCollegeSettingDetailList"] = scoreParameterCollegeSettingDetailList;
- return View(entity);
- }
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var collegeID = pararms.getExtraGuid("cbgCollege");
- var years = pararms.getExtraInt("ddlGradeYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlGradeYear");
- return Json(ScoreParamterCollegeSettingServices.GetScoreParameterCollegeSettingViewGrid(configuretView, collegeID, years, pararms.page, pararms.rows));
- }
- [HttpPost]
- public ActionResult Delete(string scoreParameterCollegeSettingIDString)
- {
- var deleteIDList = scoreParameterCollegeSettingIDString.Split(',')
- .Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
- try
- {
- this.ScoreParamterCollegeSettingServices.Delete(deleteIDList);
- return Json(new ReturnMessage
- {
- IsSuccess = true,
- Message = "删除成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage
- {
- IsSuccess = false,
- Message = "删除失败:" + ex.Message
- });
- }
- }
- [HttpPost]
- public ActionResult Edit(ScoreParameterCollegeSettingView scoreParameterCollegeSettingView, FormCollection collection)
- {
- List<ScoreParameterSettingView> detailViewList = 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);
- detailViewList.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?));
- detailViewList.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?));
- detailViewList.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?));
- detailViewList.Add(new ScoreParameterSettingView
- {
- ExamsTypeID = null,
- CourseTypeID = courseType.Value,
- ScoreFormulaID = courseTypeScoreFormula,
- IsTotalFormula = courseTypeIsScoreFormula ?? false,
- CreditFormulaID = courseTypeCreditFormula,
- IsCreditFormula = courseTypeIsCreditFormula ?? false,
- GradePointFormulaID = courseTypeGradePointFormula,
- IsGradePointFormula = courseTypeIsGradePointFormula ?? false
- });
- }
- #endregion
- try
- {
- if (scoreParameterCollegeSettingView.Years == DropdownList.PLEASE_SELECT)
- {
- scoreParameterCollegeSettingView.Years = null;
- }
- if (scoreParameterCollegeSettingView.ScoreTypeID == DropdownList.PLEASE_SELECT)
- {
- scoreParameterCollegeSettingView.ScoreTypeID = null;
- }
- this.ScoreParamterCollegeSettingServices.Save(scoreParameterCollegeSettingView, detailViewList);
- return Json(new ReturnMessage
- {
- IsSuccess = true,
- Message = "保存成功。"
- });
- }
- catch (Exception ex)
- {
- return Json(new ReturnMessage
- {
- IsSuccess = false,
- Message = "保存失败:" + ex.Message
- });
- }
- }
- }
- }
|