123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.DataLogic.CultureplanManage.PlanManagement;
- using EMIS.ViewModel.SelectCourse;
- using EMIS.ViewModel;
- using EMIS.Entities;
- using EMIS.ViewModel.CultureplanManage.PlanManagement;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
- using Bowin.Common.DataTime;
- using Bowin.Common.Utility;
- using System.Text.RegularExpressions;
- using EMIS.ViewModel.CacheManage;
- using EMIS.DataLogic.UniversityManage.AdministrativeOrgan;
- using EMIS.DataLogic.Common.Cultureplan;
- using EMIS.DataLogic.Repositories;
- using EMIS.CommonLogic.UniversityManage.SpecialtyClassManage;
- namespace EMIS.CommonLogic.CultureplanManage.PlanManagement
- {
- public class OptionalCoursePlanServices : BaseServices, IOptionalCoursePlanServices
- {
- public OptionalCoursePlanDAL OptionalCoursePlanDAL { get; set; }
- public IGrademajorServices grademajorServices { get; set; }
- public IFacultymajorServices facultymajorServices { get; set; }
- public ISchoolYearServices schoolYearServices { get; set; }
- public ISpecialtyCourseServices specialtyCourseServices { get; set; }
- public DepartmentDAL departmentDAL { get; set; }
- public CoursematerialDAL coursematerialDAL { get; set; }
- public OptionalCoursePlanTeachingSettingRepository optionalCoursePlanTeachingSettingRepository { get; set; }
- /// <summary>
- /// 查询限选计划
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="standardID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="startYearID"></param>
- /// <param name="schoolcodeID"></param>
- /// <param name="isEnable"></param>
- /// <param name="isOpened"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<OptionalCoursePlanView> GetOptionalCourseSettingViewGrid(ConfiguretView configuretView, int? standardID, Guid? coursematerialID, int? schoolYearNumID, int? schoolCodeID, int? isEnable, int? isOpened, int? educationID, int? learningFormID, string LearnSystem, int pageIndex, int pageSize)
- {
- Expression<Func<EM_OptionalCoursePlan, bool>> exp = (x => true);
- var query = OptionalCoursePlanDAL.GetOptionalCourseSettingViewQueryable(exp);
- if (standardID.HasValue)
- query = query.Where(x => x.StandardID == standardID);
- if (coursematerialID.HasValue)
- query = query.Where(x => x.CoursematerialID == coursematerialID);
- if (schoolYearNumID.HasValue)
- query = query.Where(x => x.SchoolyearNumID == schoolYearNumID);
- if (schoolCodeID.HasValue)
- query = query.Where(x => x.SchoolcodeID == schoolCodeID);
- if (isEnable.HasValue)
- query = query.Where(x => x.IsEnable == (isEnable == 1 ? true : false));
- if (isOpened.HasValue)
- query = query.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
- if (educationID.HasValue)
- query = query.Where(x => x.EducationID == educationID);
- if (learningFormID.HasValue)
- query = query.Where(x => x.LearningformID == learningFormID);
- if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(LearnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- //var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x=>x.CollegeID).ToGridResultSet<OptionalCoursePlanView>(pageIndex, pageSize);
- var result = query.OrderBy(x => x.IsEnable).ThenByDescending(x => x.StandardCode).ThenBy(x => x.SchoolyearNumID).ThenBy(x => x.SchoolcodeID).ThenBy(x => x.CourseCode).ToGridResultSet<OptionalCoursePlanView>(pageIndex, pageSize);
- //return this.GetOptionalCourseSettingView(configuretView, exp, pageIndex, pageSize);
- return result;
- }
- public List<OptionalCoursePlanView> GetOptionalCourseSettingViewList(ConfiguretView configuretView, int? standardID, Guid? coursematerialID, int? schoolYearNumID, int? schoolCodeID, int? isEnable, int? isOpened, int? educationID, int? learningFormID, string LearnSystem)
- {
- Expression<Func<EM_OptionalCoursePlan, bool>> exp = (x => true);
- var query = OptionalCoursePlanDAL.GetOptionalCourseSettingViewQueryable(exp);
- if (standardID.HasValue)
- query = query.Where(x => x.StandardID == standardID);
- if (coursematerialID.HasValue)
- query = query.Where(x => x.CoursematerialID == coursematerialID);
- if (schoolYearNumID.HasValue)
- query = query.Where(x => x.SchoolyearNumID == schoolYearNumID);
- if (schoolCodeID.HasValue)
- query = query.Where(x => x.SchoolcodeID == schoolCodeID);
- if (isEnable.HasValue)
- query = query.Where(x => x.IsEnable == (isEnable == 1 ? true : false));
- if (isOpened.HasValue)
- query = query.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
- if (educationID.HasValue)
- query = query.Where(x => x.EducationID == educationID);
- if (learningFormID.HasValue)
- query = query.Where(x => x.LearningformID == learningFormID);
- if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(LearnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- //var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x=>x.CollegeID).ToGridResultSet<OptionalCoursePlanView>(pageIndex, pageSize);
- var result = query.OrderByDescending(x => x.StandardCode).ThenBy(x => x.SchoolyearNumID).ThenBy(x => x.SchoolcodeID).ThenBy(x => x.CourseCode).ToList();
- //return this.GetOptionalCourseSettingView(configuretView, exp, pageIndex, pageSize);
- return result;
- }
- /// <summary>
- /// 获取选修计划视图
- /// </summary>
- /// <param name="optionalCourseID"></param>
- /// <returns></returns>
- public OptionalCoursePlanView GetOptionalCourseSettingView(Guid? optionalCourseID)
- {
- return OptionalCoursePlanDAL.GetOptionalCourseSettingViewQueryable(x => x.OptionalCourseID == optionalCourseID).FirstOrDefault();
- }
- /// <summary>
- /// 添加选修计划
- /// </summary>
- /// <param name="optionalCourseSettingView"></param>
- /// <returns></returns>
- public void OptionalCourseAdd(OptionalCoursePlanView optionalCourseSettingView)
- {
- try
- {
- var repeatOptionalCoursePlan = OptionalCoursePlanDAL.OptionalCoursePlanRepository.Entities.Where(x =>
- x.CoursematerialID == optionalCourseSettingView.CoursematerialID &&
- x.CourseTypeID == optionalCourseSettingView.CourseTypeID &&
- x.SchoolcodeID == optionalCourseSettingView.SchoolcodeID &&
- x.SchoolyearNumID == optionalCourseSettingView.SchoolyearNumID &&
- x.SpecialtyID == optionalCourseSettingView.SpecialtyID).FirstOrDefault();
- if (repeatOptionalCoursePlan != null)
- { //同专业同学期同课程类型同课程ID是否有重复
- throw new Exception("已存在相同的限选计划,请核查。");
- }
- EM_OptionalCoursePlan optionalCoursePlan = new EM_OptionalCoursePlan();
- optionalCoursePlan.OptionalCourseID = Guid.NewGuid();
- optionalCoursePlan.DepartmentID = optionalCourseSettingView.DepartmentID;
- optionalCoursePlan.SpecialtyID = optionalCourseSettingView.SpecialtyID;
- optionalCoursePlan.CoursematerialID = optionalCourseSettingView.CoursematerialID;
- optionalCoursePlan.CourseStructureID = optionalCourseSettingView.CourseStructureID;
- optionalCoursePlan.CourseCategoryID = optionalCourseSettingView.CourseCategoryID;
- optionalCoursePlan.CourseTypeID = optionalCourseSettingView.CourseTypeID;
- optionalCoursePlan.CourseQualityID = optionalCourseSettingView.CourseQualityID;
- optionalCoursePlan.PracticeTypeID = optionalCourseSettingView.PracticeTypeID;
- optionalCoursePlan.ExaminationModeID = optionalCourseSettingView.ExaminationModeID;
- optionalCoursePlan.TeachinglanguageID = optionalCourseSettingView.TeachinglanguageID;
- optionalCoursePlan.SchoolyearNumID = optionalCourseSettingView.SchoolyearNumID;
- optionalCoursePlan.SchoolcodeID = optionalCourseSettingView.SchoolcodeID;
- optionalCoursePlan.IsEnable = optionalCourseSettingView.IsEnable;
- optionalCoursePlan.PeopleNumlower = optionalCourseSettingView.PeopleNumlower;
- optionalCoursePlan.PeopleNumlimit = optionalCourseSettingView.PeopleNumlimit;
- optionalCoursePlan.IsOpened = optionalCourseSettingView.IsOpened;
- optionalCoursePlan.ResultTypeID = optionalCourseSettingView.ResultTypeID;
- optionalCoursePlan.Remarks = optionalCourseSettingView.Remarks;
- SetNewStatus(optionalCoursePlan);
- UnitOfWork.Add(optionalCoursePlan);
- EM_OptionalCoursePlanTeachingSetting optionalCourseTeachingSetting = new EM_OptionalCoursePlanTeachingSetting();
- //教学设置表
- optionalCourseTeachingSetting.OptionalCourseID = optionalCoursePlan.OptionalCourseID;
- optionalCourseTeachingSetting.Credit = optionalCourseSettingView.Credit;
- optionalCourseTeachingSetting.TheoryCourse = optionalCourseSettingView.TheoryCourse;
- optionalCourseTeachingSetting.Practicehours = optionalCourseSettingView.Practicehours;
- optionalCourseTeachingSetting.Trialhours = optionalCourseSettingView.Trialhours;
- optionalCourseTeachingSetting.WeeklyNum = optionalCourseSettingView.WeeklyNum;
- //if (optionalCourseSettingView.WeeklyNum == 0 || optionalCourseSettingView.WeeklyNum == null)
- //{
- // var t = (optionalCourseSettingView.TheoryCourse.Value + optionalCourseSettingView.Practicehours.Value);
- // var w = (optionalCourseSettingView.TheoryWeeklyNum.Value + optionalCourseSettingView.PracticeWeeklyNum.Value);
- // if (w != 0 && t != 0)
- // optionalCourseTeachingSetting.WeeklyNum = t / w / 2;
- //}
- optionalCourseTeachingSetting.TheoryWeeklyNum = optionalCourseSettingView.TheoryWeeklyNum;
- optionalCourseTeachingSetting.PracticeWeeklyNum = optionalCourseSettingView.PracticeWeeklyNum;
- optionalCourseTeachingSetting.TrialWeeklyNum = optionalCourseSettingView.TrialWeeklyNum;
- optionalCourseTeachingSetting.StartWeeklyNum = optionalCourseSettingView.StartWeeklyNum;
- optionalCourseTeachingSetting.EndWeeklyNum = optionalCourseSettingView.EndWeeklyNum;
- optionalCourseTeachingSetting.WeeklyHours = optionalCourseSettingView.WeeklyHours;
- UnitOfWork.Add(optionalCourseTeachingSetting);
- //授课方式
- if (optionalCourseSettingView.TeachingModeID != null)
- {
- //UnitOfWork.Delete<EM_OptionalCoursePlanTeachingMode>(x => x.OptionalCourseID == optionalCourseSettingView.OptionalCourseID);
- foreach (var i in optionalCourseSettingView.TeachingModeID)
- {
- EM_OptionalCoursePlanTeachingMode optionalCourseTeachingMode = new EM_OptionalCoursePlanTeachingMode();
- optionalCourseTeachingMode.OptionalCoursePlanTeachingModeID = Guid.NewGuid();
- optionalCourseTeachingMode.OptionalCourseID = optionalCoursePlan.OptionalCourseID;
- optionalCourseTeachingMode.TeachingModeID = i;
- SetNewStatus(optionalCourseTeachingMode);
- UnitOfWork.Add(optionalCourseTeachingMode);
- }
- }
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 更新
- /// </summary>
- /// <param name="optionalCourseSettingView"></param>
- /// <returns></returns>
- public void OptionalCourseUpdate(OptionalCoursePlanView optionalCourseSettingView)
- {
- try
- {
- var repeatOptionalCoursePlan = OptionalCoursePlanDAL.OptionalCoursePlanRepository.Entities.Where(x =>
- x.CoursematerialID == optionalCourseSettingView.CoursematerialID &&
- x.CourseTypeID == optionalCourseSettingView.CourseTypeID &&
- x.SchoolcodeID == optionalCourseSettingView.SchoolcodeID &&
- x.SchoolyearNumID == optionalCourseSettingView.SchoolyearNumID &&
- x.SpecialtyID == optionalCourseSettingView.SpecialtyID).FirstOrDefault();
- if (repeatOptionalCoursePlan != null && repeatOptionalCoursePlan.OptionalCourseID != optionalCourseSettingView.OptionalCourseID)
- { //同专业同学期同课程类型同课程ID是否有重复
- throw new Exception("已存在相同的限选计划,请核查。");
- }
-
- EM_OptionalCoursePlan optionalCoursePlan = GetOptionalCoursePlan(optionalCourseSettingView.OptionalCourseID);
- EM_OptionalCoursePlanTeachingSetting optionalCourseTeachingSetting = optionalCoursePlanTeachingSettingRepository.Entities.Where(x => x.OptionalCourseID == optionalCoursePlan.OptionalCourseID).SingleOrDefault();
- if (optionalCoursePlan != null)
- {
- optionalCoursePlan.DepartmentID = optionalCourseSettingView.DepartmentID;
- optionalCoursePlan.SpecialtyID = optionalCourseSettingView.SpecialtyID;
- optionalCoursePlan.CoursematerialID = optionalCourseSettingView.CoursematerialID;
- optionalCoursePlan.CourseStructureID = optionalCourseSettingView.CourseStructureID;
- optionalCoursePlan.CourseCategoryID = optionalCourseSettingView.CourseCategoryID;
- optionalCoursePlan.CourseTypeID = optionalCourseSettingView.CourseTypeID;
- optionalCoursePlan.CourseQualityID = optionalCourseSettingView.CourseQualityID;
- optionalCoursePlan.PracticeTypeID = optionalCourseSettingView.PracticeTypeID;
- optionalCoursePlan.ExaminationModeID = optionalCourseSettingView.ExaminationModeID;
- optionalCoursePlan.TeachinglanguageID = optionalCourseSettingView.TeachinglanguageID;
- optionalCoursePlan.SchoolyearNumID = optionalCourseSettingView.SchoolyearNumID;
- optionalCoursePlan.SchoolcodeID = optionalCourseSettingView.SchoolcodeID;
- optionalCoursePlan.IsEnable = optionalCourseSettingView.IsEnable;
- //optionalCoursePlan.No = optionalCourseSettingView.No;
- //optionalCoursePlan.HandleModeID = optionalCourseSettingView.HandleModeID;
- //optionalCoursePlan.IsNeedMaterial = optionalCourseSettingView.IsNeedMaterial;
- optionalCoursePlan.PeopleNumlower = optionalCourseSettingView.PeopleNumlower;
- optionalCoursePlan.PeopleNumlimit = optionalCourseSettingView.PeopleNumlimit;
- optionalCoursePlan.IsOpened = optionalCourseSettingView.IsOpened;
- optionalCoursePlan.ResultTypeID = optionalCourseSettingView.ResultTypeID;
- optionalCoursePlan.Remarks = optionalCourseSettingView.Remarks;
- //教学设置表
- if (optionalCourseTeachingSetting != null)
- {
- UnitOfWork.Update(optionalCourseTeachingSetting);
- }
- else
- {
- optionalCourseTeachingSetting = new EM_OptionalCoursePlanTeachingSetting();
- optionalCourseTeachingSetting.OptionalCourseID = optionalCourseSettingView.OptionalCourseID;
- UnitOfWork.Add(optionalCourseTeachingSetting);
- }
- optionalCourseTeachingSetting.Credit = optionalCourseSettingView.Credit;
- optionalCourseTeachingSetting.TheoryCourse = optionalCourseSettingView.TheoryCourse;
- optionalCourseTeachingSetting.Practicehours = optionalCourseSettingView.Practicehours;
- optionalCourseTeachingSetting.Trialhours = optionalCourseSettingView.Trialhours;
- optionalCourseTeachingSetting.WeeklyNum = optionalCourseSettingView.WeeklyNum;
- if (optionalCourseSettingView.WeeklyNum == 0 || optionalCourseSettingView.WeeklyNum == null)
- {
- var t = (optionalCourseSettingView.TheoryCourse.Value + optionalCourseSettingView.Practicehours.Value);
- var w = (optionalCourseSettingView.TheoryWeeklyNum.Value + optionalCourseSettingView.PracticeWeeklyNum.Value);
- if (w != 0 && t != 0)
- optionalCourseTeachingSetting.WeeklyNum = t / w / 2;
- }
- optionalCourseTeachingSetting.TheoryWeeklyNum = optionalCourseSettingView.TheoryWeeklyNum;
- optionalCourseTeachingSetting.PracticeWeeklyNum = optionalCourseSettingView.PracticeWeeklyNum;
- optionalCourseTeachingSetting.TrialWeeklyNum = optionalCourseSettingView.TrialWeeklyNum;
- optionalCourseTeachingSetting.StartWeeklyNum = optionalCourseSettingView.StartWeeklyNum;
- optionalCourseTeachingSetting.EndWeeklyNum = optionalCourseSettingView.EndWeeklyNum;
- optionalCourseTeachingSetting.WeeklyHours = optionalCourseSettingView.WeeklyHours;
- //授课方式
- if (optionalCourseSettingView.TeachingModeID != null)
- {
- UnitOfWork.Delete<EM_OptionalCoursePlanTeachingMode>(x => x.OptionalCourseID == optionalCourseSettingView.OptionalCourseID);
- foreach (var i in optionalCourseSettingView.TeachingModeID)
- {
- EM_OptionalCoursePlanTeachingMode optionalCourseTeachingMode = new EM_OptionalCoursePlanTeachingMode();
- optionalCourseTeachingMode.OptionalCoursePlanTeachingModeID = Guid.NewGuid();
- optionalCourseTeachingMode.OptionalCourseID = optionalCoursePlan.OptionalCourseID;
- optionalCourseTeachingMode.TeachingModeID = i;
- SetNewStatus(optionalCourseTeachingMode);
- UnitOfWork.Add(optionalCourseTeachingMode);
- }
- }
- this.SetModifyStatus(optionalCoursePlan);
- UnitOfWork.Commit();
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- public List<string> GetTeachingModeType(Guid? OptionalCourseID)
- {
- return OptionalCoursePlanDAL.GetTeachingModeTypeQueryble(OptionalCourseID);
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="optionalCourseIDs"></param>
- /// <returns></returns>
- public bool OptionalCourseDelete(List<Guid> optionalCourseIDs)
- {
- try
- {
- if (optionalCourseIDs.Count > 0)
- {
- UnitOfWork.Delete<EM_OptionalCoursePlan>(x => optionalCourseIDs.Contains(x.OptionalCourseID));
- return true;
- }
- return false;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 获取选修计划实体
- /// </summary>
- /// <param name="optionalCourseID"></param>
- /// <returns></returns>
- public EM_OptionalCoursePlan GetOptionalCoursePlan(Guid? optionalCourseID)
- {
- return OptionalCoursePlanDAL.OptionalCoursePlanRepository.GetSingle(x => x.OptionalCourseID == optionalCourseID);
- }
- //public void OptionalCoursePlanImport(Dictionary<string, string> cellheader, out int OkCount, out List<OptionalCoursePlanView> errdataList, out int ErrCount, string sourcePhysicalPath)
- //{
- // StringBuilder errorMsg = new StringBuilder(); // 错误信息
- // List<OptionalCoursePlanView> errList = new List<OptionalCoursePlanView>(); //错误数据行
- // DataTimeHelper dth = new DataTimeHelper();
- // Sys_DictionaryItem standardID = null; //专业
- // Sys_DictionaryItem educationID = null; //所修学历
- // Sys_DictionaryItem learningformID = null; //学习形式
- // #region 1.1解析文件,存放到一个List集合里
- // // 1.1解析文件,存放到一个List集合里
- // cellheader.Remove("ErrorMessage");//去除异常列、导入操作不需要
- // List<OptionalCoursePlanView> enlist =
- // NpoiExcelHelper.ExcelToEntityList<OptionalCoursePlanView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- // cellheader.Add("ErrorMessage", "错误信息");//还原字典项
- // #endregion
- // #region 1.2 将Excel数据写入数据库中
- // #region 1.2.1 对List集合进行有效性校验
- // if (enlist.Count() <= 0)
- // {
- // throw new Exception("请填写Excel模板信息数据。");
- // }
- // #region 1.2.1.1数据逻辑验证
- // for (int i = 0; i < enlist.Count; i++)
- // {
- // OptionalCoursePlanView en = enlist[i];
- // string errorMsgStr = "第" + (i + 1) + "行数据检测异常:";
- // bool isHaveNoInputValue = false; // 是否含有未输入项
- // #region 检测必填项是否必填
- // if (Guid.Empty == en.CoursematerialID)
- // {
- // errorMsgStr += "课程资料不能为空;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- // }
- // #endregion
- // #region 验证数据格式
- // //
- // Regex reg = new Regex(@"^[0-9]*$");
- // if (!string.IsNullOrEmpty(en.PeopleNumlimit.ToString()))
- // {
- // if (!reg.IsMatch(en.PeopleNumlimit + ""))
- // {
- // errorMsgStr += "人数上限;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- // }
- // }
- // if (!string.IsNullOrEmpty(en.PeopleNumlimit.ToString()))
- // {
- // if (!reg.IsMatch(en.PeopleNumlower + ""))
- // {
- // errorMsgStr += "人数下限;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- // }
- // }
- // //实践类型名称
- // Sys_DictionaryItem practiceType;
- // if (!string.IsNullOrEmpty(en.PracticeTypeName))
- // {
- // practiceType = IdNameExt.GetDictionaryItem(DictionaryItem.EM_PracticeType.ToString())
- // .Where(x => x.Name == en.PracticeTypeName.Trim()).FirstOrDefault();
- // if (practiceType == null)
- // {
- // errorMsgStr += "实践类型名称不存在;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- // }
- // else
- // en.PracticeTypeID = practiceType.Value.Value;
- // }
- // //考试方式名称
- // Sys_DictionaryItem examinationMode;
- // if (!string.IsNullOrEmpty(en.ExaminationModeDesc))
- // {
- // examinationMode = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ExaminationMode.ToString())
- // .Where(x => x.Name == en.ExaminationModeDesc.Trim()).FirstOrDefault();
- // if (examinationMode == null)
- // {
- // errorMsgStr += "考试方式名称不存在;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- // }
- // else
- // en.PracticeTypeID = examinationMode.Value.Value;
- // }
- // //课程结构
- // Sys_DictionaryItem courseStructure;
- // if (!string.IsNullOrEmpty(en.CourseStructureName))
- // {
- // courseStructure = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseStructure.ToString())
- // .Where(x => x.Name == en.CourseStructureName.Trim()).FirstOrDefault();
- // if (courseStructure == null)
- // {
- // errorMsgStr += "课程结构不存在;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- // }
- // else
- // en.PracticeTypeID = courseStructure.Value.Value;
- // }
- // //课程类型
- // Sys_DictionaryItem courseType;
- // if (!string.IsNullOrEmpty(en.CourseTypeName))
- // {
- // courseType = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseType.ToString())
- // .Where(x => x.Name == en.CourseTypeName.Trim()).FirstOrDefault();
- // if (courseType == null)
- // {
- // errorMsgStr += "课程类型不存在;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- // }
- // else
- // en.PracticeTypeID = courseType.Value.Value;
- // }
- // //课程属性
- // Sys_DictionaryItem courseCategory;
- // if (!string.IsNullOrEmpty(en.CourseCategoryName))
- // {
- // courseCategory = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseCategory.ToString())
- // .Where(x => x.Name == en.CourseCategoryName.Trim()).FirstOrDefault();
- // if (courseCategory == null)
- // {
- // errorMsgStr += "课程属性不存在;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- // }
- // else
- // en.PracticeTypeID = courseCategory.Value.Value;
- // }
- // //授课语言
- // Sys_DictionaryItem teachinglanguage;
- // if (!string.IsNullOrEmpty(en.TeachinglanguageName))
- // {
- // teachinglanguage = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Teachinglanguage.ToString())
- // .Where(x => x.Name == en.TeachinglanguageName.Trim()).FirstOrDefault();
- // if (teachinglanguage == null)
- // {
- // errorMsgStr += "授课语言不存在;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- // }
- // else
- // en.PracticeTypeID = teachinglanguage.Value.Value;
- // }
- // //学年数
- // Sys_DictionaryItem schoolyearNum;
- // if (!string.IsNullOrEmpty(en.SchoolyearNumName))
- // {
- // schoolyearNum = IdNameExt.GetDictionaryItem(DictionaryItem.CF_SchoolyearNum.ToString())
- // .Where(x => x.Name == en.SchoolyearNumName.Trim()).FirstOrDefault();
- // if (schoolyearNum == null)
- // {
- // errorMsgStr += "学年数不存在;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- // }
- // else
- // en.PracticeTypeID = schoolyearNum.Value.Value;
- // }
- // //学期
- // Sys_DictionaryItem schoolcode;
- // if (!string.IsNullOrEmpty(en.SchoolcodeName))
- // {
- // schoolcode = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Semester.ToString())
- // .Where(x => x.Name == en.SchoolcodeName.Trim()).FirstOrDefault();
- // if (schoolcode == null)
- // {
- // errorMsgStr += "学期不存在;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- // }
- // else
- // en.PracticeTypeID = schoolcode.Value.Value;
- // }
- // //课程性质
- // Sys_DictionaryItem courseQuality;
- // if (!string.IsNullOrEmpty(en.CourseQualityName))
- // {
- // courseQuality = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseQuality.ToString())
- // .Where(x => x.Name == en.CourseQualityName.Trim()).FirstOrDefault();
- // if (courseQuality == null)
- // {
- // errorMsgStr += "课程性质不存在;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- // }
- // else
- // en.PracticeTypeID = courseQuality.Value.Value;
- // }
- // #region 信息是否存在
- // if (en.DepartmentID != Guid.Empty)
- // {
- // CF_Department department = departmentDAL.departmentRepository.GetSingle(x => x.DepartmentID == en.DepartmentID && x.RecordStatus > 0);
- // if (department == null)
- // {
- // errorMsgStr += "教研室不存在;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- // }
- // else
- // en.DepartmentID = department.DepartmentID;
- // }
- // if (en.CoursematerialID != Guid.Empty)
- // {
- // EM_Coursematerial coursematerial = coursematerialDAL.coursematerialRepository.GetSingle(x => x.CoursematerialID == en.CoursematerialID && x.RecordStatus > 0);
- // if (coursematerial == null)
- // {
- // errorMsgStr += "课程资料不存在;";
- // en.ErrorMessage = errorMsgStr;
- // isHaveNoInputValue = true;
- // }
- // else
- // en.CoursematerialID = coursematerial.CoursematerialID;
- // }
- // #endregion
- // if (isHaveNoInputValue) // 若必填项有值未填
- // {
- // en.IsExcelVaildateOK = false;
- // en.ErrorMessage = errorMsgStr;
- // errList.Add(en);
- // errorMsg.AppendLine(errorMsgStr);
- // }
- // }
- // #endregion
- // // TODO:其他检测
- // #region 1.2.1.3 循环写入验证成功的数据
- // List<EM_OptionalCoursePlan> newOptionalCoursePlanList = new List<EM_OptionalCoursePlan>();
- // for (int i = 0; i < enlist.Count; i++)
- // {
- // OptionalCoursePlanView enA = enlist[i];
- // if (enA.IsExcelVaildateOK == false) // 上面验证不通过,不进行此步验证
- // {
- // continue;
- // }
- // var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- // EM_OptionalCoursePlan optionalCoursePlan = new EM_OptionalCoursePlan();
- // optionalCoursePlan.OptionalCourseID = Guid.NewGuid();
- // optionalCoursePlan.DepartmentID = enA.DepartmentID;
- // optionalCoursePlan.SpecialtyID = enA.SpecialtyID;
- // optionalCoursePlan.CoursematerialID = enA.CoursematerialID;
- // optionalCoursePlan.CourseStructureID = enA.CourseStructureID;
- // optionalCoursePlan.CourseCategoryID = enA.CourseCategoryID;
- // optionalCoursePlan.CourseTypeID = enA.CourseTypeID;
- // optionalCoursePlan.CourseQualityID = enA.CourseQualityID;
- // optionalCoursePlan.PracticeTypeID = enA.PracticeTypeID;
- // optionalCoursePlan.ExaminationModeID = enA.ExaminationModeID;
- // optionalCoursePlan.TeachinglanguageID = enA.TeachinglanguageID;
- // optionalCoursePlan.SchoolyearNumID = enA.SchoolyearNumID;
- // optionalCoursePlan.SchoolcodeID = enA.SchoolcodeID;
- // optionalCoursePlan.IsEnable = enA.IsEnable;
- // optionalCoursePlan.PeopleNumlower = enA.PeopleNumlower;
- // optionalCoursePlan.PeopleNumlimit = enA.PeopleNumlimit;
- // optionalCoursePlan.IsOpened = enA.IsOpened;
- // optionalCoursePlan.Remarks = enA.Remarks;
- // SetNewStatus(optionalCoursePlan);
- // newOptionalCoursePlanList.Add(optionalCoursePlan);
- // }
- // #endregion
- // UnitOfWork.BulkInsert(newOptionalCoursePlanList);//统一写入
- // #endregion
- // #endregion
- // #endregion
- // #region 1.3 返回各项数据值
- // OkCount = enlist.Distinct().Count() - errList.Distinct().Count();//共条数减去失败条数
- // errdataList = errList.Distinct().ToList();
- // ErrCount = errList.Distinct().Count();
- // #endregion
- //}
- }
- }
|