1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.MinorManage.MinorCourseManage;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.MinorManage.MinorCourseManage;
- using Bowin.Common.Utility;
- using EMIS.ViewModel.CacheManage;
- using EMIS.DataLogic.Common.Cultureplan;
- using EMIS.DataLogic.Repositories;
- using System.Text.RegularExpressions;
- using EMIS.DataLogic.MinorManage.MinorPlanManage;
- namespace EMIS.CommonLogic.MinorManage
- {
- public class MinorSpecialtyCourseServices : BaseServices, IMinorSpecialtyCourseServices
- {
- public MinorSpecialtyCourseDAL minorSpecialtyCourseDAL { get; set; }
- public Lazy<CoursematerialDAL> CoursematerialDAL { get; set; }
- public MinorPlanApplyDAL MinorPlanApplyDAL { get; set; }
- public Lazy<DepartmentRepository> DepartmentRepository { get; set; }
- /// <summary>
- /// 查询所有辅修专业课程
- /// </summary>
- /// <param name="configuretView">查询条件实体</param>
- /// <param name="standardID">专业名称</param>
- /// <param name="CoursematerialID">课程名称</param>
- /// <param name="SchoolyearNumID">开课学年</param>
- /// <param name="StarttermID">开课学期</param>
- /// <param name="DepartmentID">教研室</param>
- /// <param name="IsEnable">是否启用</param>
- /// <param name="pageIndex">页码</param>
- /// <param name="pageSize">显示条数</param>
- /// <returns></returns>
- public IGridResultSet<MinorSpecialtyCourseView> GetMinorSpecialtyCourseViewGrid(ConfiguretView configuretView, int? standardID, Guid? CoursematerialID, int? SchoolyearNumID, int? SchoolcodeID, Guid? DepartmentID, int? IsEnable, int pageIndex, int pageSize)
- {
- Expression<Func<EM_MinorCourse, bool>> exp = (x => true);
- if (standardID.HasValue)
- exp = exp.And(x =>x.StandardID==standardID);
- if (CoursematerialID.HasValue)
- exp = exp.And(x => x.CoursematerialID == CoursematerialID);
- if (SchoolyearNumID.HasValue)
- exp = exp.And(x => x.SchoolyearNumID == SchoolyearNumID);
- if (SchoolcodeID.HasValue)
- exp = exp.And(x => x.SchoolcodeID == SchoolcodeID);
- if (DepartmentID.HasValue)
- exp = exp.And(x => x.DepartmentID == DepartmentID);
- if (IsEnable.HasValue)
- {
- bool Enable = true;
- if(IsEnable==0)
- {
- Enable = false;
- }
- exp = exp.And(x => x.IsEnable == Enable);
- }
- var query = minorSpecialtyCourseDAL.GetMinorSpecialtyCourseViewQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).OrderBy(x=>x.SchoolyearNumID)
- .OrderBy(x => x.SchoolcodeID).ToGridResultSet<MinorSpecialtyCourseView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询所有辅修专业课程
- /// </summary>
- /// <param name="configuretView">查询条件实体</param>
- /// <param name="standardID">专业名称</param>
- /// <param name="CoursematerialID">课程名称</param>
- /// <param name="SchoolyearNumID">开课学年</param>
- /// <param name="StarttermID">开课学期</param>
- /// <param name="DepartmentID">教研室</param>
- /// <param name="IsEnable">是否启用</param>
- /// <param name="MinorCourseIDList">辅修课程ID</param>
- /// <returns></returns>
- public List<MinorSpecialtyCourseView> GetMinorCourseViewList(ConfiguretView configuretView, int? standardID, Guid? CoursematerialID, int? SchoolyearNumID, int? SchoolcodeID, Guid? DepartmentID, int? IsEnable, List<Guid?> MinorCourseIDList)
- {
- Expression<Func<EM_MinorCourse, bool>> exp = (x => true);
- if (MinorCourseIDList != null)
- exp = exp.And(x => MinorCourseIDList.Contains(x.MinorCourseID));
- if (standardID.HasValue)
- exp = exp.And(x => x.StandardID == standardID);
- if (CoursematerialID.HasValue)
- exp = exp.And(x => x.CoursematerialID == CoursematerialID);
- if (SchoolyearNumID.HasValue)
- exp = exp.And(x => x.SchoolyearNumID == SchoolyearNumID);
- if (SchoolcodeID.HasValue)
- exp = exp.And(x => x.SchoolcodeID == SchoolcodeID);
- if (DepartmentID.HasValue)
- exp = exp.And(x => x.DepartmentID == DepartmentID);
- if (IsEnable.HasValue)
- {
- bool Enable = true;
- if (IsEnable == 0)
- {
- Enable = false;
- }
- exp = exp.And(x => x.IsEnable == Enable);
- }
- var query = minorSpecialtyCourseDAL.GetMinorSpecialtyCourseViewQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).OrderBy(x => x.SchoolyearNumID)
- .OrderBy(x => x.SchoolcodeID).ToList();
- }
- /// <summary>
- /// 查询辅修课程信息
- /// </summary>
- /// <param name="MinorCourseID">辅修课程ID</param>
- /// <returns></returns>
- public MinorSpecialtyCourseView GetMinorSpecialtyCourseView(Guid? MinorCourseID)
- {
- Expression<Func<EM_MinorCourse, bool>> exp = (x =>x.MinorCourseID==MinorCourseID);
- var MinorSpecialtyCourse = minorSpecialtyCourseDAL.GetMinorSpecialtyCourseViewQueryable(exp).FirstOrDefault();
- return MinorSpecialtyCourse;
- }
- /// <summary>
- /// 根据专业课程获取授课方式
- /// </summary>
- /// <param name="MinorCourseID">辅修课程</param>
- /// <returns></returns>
- public List<string> GetTeachingModeType(Guid? MinorCourseID)
- {
- return minorSpecialtyCourseDAL.GetTeachingModeTypeQueryble(MinorCourseID);
- }
- /// <summary>
- /// 获取课程资料信息
- /// </summary>
- /// <param name="MinorCourseID">辅修课程</param>
- /// <returns></returns>
- public Entities.EM_MinorCourse GetMinorSpecialtyCourse(Guid? MinorCourseID)
- {
- //查询条件
- System.Linq.Expressions.Expression<Func<EM_MinorCourse, bool>> expression = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expression = (x => x.MinorCourseID == MinorCourseID);
- return minorSpecialtyCourseDAL.MinorCourseRepository.GetSingle(expression, (x => x.CF_Department),(x => x.EM_Coursematerial), (x => x.EM_MinorCourseTeachingSetting));
- }
- /// <summary>
- /// 专业课程教学设置表
- /// </summary>
- /// <param name="MinorCourseID">辅修课程ID</param>
- /// <returns></returns>
- public EM_MinorCourseTeachingSetting GetSpecialtyCourseTeachingSetting(Guid? MinorCourseID)
- {
- //查询条件
- System.Linq.Expressions.Expression<Func<EM_MinorCourseTeachingSetting, bool>> expression = (x => true);
- expression = (x => x.MinorCourseID == MinorCourseID);
- return minorSpecialtyCourseDAL.MinorCourseTeachingSettingRepository.GetSingle(expression);
- }
- /// <summary>
- /// 根据专业课程获取授课地点
- /// </summary>
- /// <param name="MinorCourseID">辅修课程ID</param>
- /// <returns></returns>
- public List<string> GetTeachingPlace(Guid? MinorCourseID)
- {
- return minorSpecialtyCourseDAL.GetTeachingPlaceQueryble(MinorCourseID);
- }
- public void MinorSpecialtyCourseAdd(MinorSpecialtyCourseView minorSpecialtyCourseView)
- {
- try
- {
- if (minorSpecialtyCourseDAL.MinorCourseRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
- && x.StandardID == minorSpecialtyCourseView.StandardID && x.CoursematerialID == minorSpecialtyCourseView.CoursematerialID
- && x.SchoolyearNumID == minorSpecialtyCourseView.SchoolyearNumID && x.SchoolcodeID == minorSpecialtyCourseView.SchoolcodeID
- &&x.MinorCourseID!=minorSpecialtyCourseView.MinorCourseID).Count() > 0)
- {
- throw new Exception("该标准专业课程已经存在,请重新输入!");
- }
- EM_MinorCourse MinorCourse = null;
- EM_MinorCourseTeachingSetting MinorCourseTeachingSetting = null;
- if (minorSpecialtyCourseView.MinorCourseID == null || minorSpecialtyCourseView.MinorCourseID == Guid.Empty)
- {
- MinorCourse = new EM_MinorCourse();
- MinorCourse.MinorCourseID = Guid.NewGuid();
- MinorCourse.StandardID = minorSpecialtyCourseView.StandardID;
- MinorCourse.DepartmentID = minorSpecialtyCourseView.DepartmentID;
- MinorCourse.CoursematerialID = minorSpecialtyCourseView.CoursematerialID;
- MinorCourse.CourseStructureID = minorSpecialtyCourseView.CourseStructureID;
- MinorCourse.CourseCategoryID = minorSpecialtyCourseView.CourseCategoryID;
- MinorCourse.CourseTypeID = minorSpecialtyCourseView.CourseTypeID;
- MinorCourse.CourseQualityID = minorSpecialtyCourseView.CourseQualityID;
- MinorCourse.PracticeTypeID = minorSpecialtyCourseView.PracticeTypeID;
- MinorCourse.ExaminationModeID = minorSpecialtyCourseView.ExaminationModeID;
- MinorCourse.TeachinglanguageID = minorSpecialtyCourseView.TeachinglanguageID;
- MinorCourse.SchoolyearNumID = minorSpecialtyCourseView.SchoolyearNumID;
- MinorCourse.SchoolcodeID = minorSpecialtyCourseView.SchoolcodeID;
- MinorCourse.CourseFineID = minorSpecialtyCourseView.CourseFineID;
- MinorCourse.IsSpecialtycore = minorSpecialtyCourseView.IsSpecialtycore;
- MinorCourse.IsCooperation = minorSpecialtyCourseView.IsCooperation;
- MinorCourse.IsRequired = minorSpecialtyCourseView.IsRequired;
- MinorCourse.IsElective = minorSpecialtyCourseView.IsElective;
- MinorCourse.IsNetworkCourse = minorSpecialtyCourseView.IsNetworkCourse;
- MinorCourse.IsMainCourse = minorSpecialtyCourseView.IsMainCourse;
- MinorCourse.IsEnable = minorSpecialtyCourseView.IsEnable;
- MinorCourse.ResultTypeID = minorSpecialtyCourseView.ResultTypeID;
- MinorCourse.Remarks = minorSpecialtyCourseView.Remarks;
- SetNewStatus(MinorCourse);
- UnitOfWork.Add(MinorCourse);
- MinorCourseTeachingSetting = new EM_MinorCourseTeachingSetting();
- MinorCourseTeachingSetting.MinorCourseID = MinorCourse.MinorCourseID;
- MinorCourseTeachingSetting.Credit = minorSpecialtyCourseView.Credit;
- MinorCourseTeachingSetting.TheoryCourse = minorSpecialtyCourseView.TheoryCourse;
- MinorCourseTeachingSetting.Practicehours = minorSpecialtyCourseView.Practicehours;
- MinorCourseTeachingSetting.Trialhours = minorSpecialtyCourseView.Trialhours;
- MinorCourseTeachingSetting.WeeklyNum = minorSpecialtyCourseView.WeeklyNum;
- MinorCourseTeachingSetting.TheoryWeeklyNum = minorSpecialtyCourseView.TheoryWeeklyNum;
- MinorCourseTeachingSetting.PracticeWeeklyNum = minorSpecialtyCourseView.PracticeWeeklyNum;
- MinorCourseTeachingSetting.TrialWeeklyNum = minorSpecialtyCourseView.TrialWeeklyNum;
- MinorCourseTeachingSetting.StartWeeklyNum = minorSpecialtyCourseView.StartWeeklyNum;
- MinorCourseTeachingSetting.EndWeeklyNum = minorSpecialtyCourseView.EndWeeklyNum;
- MinorCourseTeachingSetting.WeeklyHours = minorSpecialtyCourseView.WeeklyHours;
- UnitOfWork.Add(MinorCourseTeachingSetting);
- if (minorSpecialtyCourseView.TeachingModeID != null)
- {
- UnitOfWork.Delete<EM_MinorCourseTeachingModeType>(x => x.MinorCourseID == MinorCourse.MinorCourseID);
- foreach (var i in minorSpecialtyCourseView.TeachingModeID)
- {
- EM_MinorCourseTeachingModeType MinorCourseTeachingModeType = new EM_MinorCourseTeachingModeType();
- MinorCourseTeachingModeType.MinorCourseTeachingModeTypeID = Guid.NewGuid();
- MinorCourseTeachingModeType.MinorCourseID = MinorCourse.MinorCourseID;
- MinorCourseTeachingModeType.TeachingModeID = i;
- SetNewStatus(MinorCourseTeachingModeType);
- UnitOfWork.Add(MinorCourseTeachingModeType);
- }
- }
- if (minorSpecialtyCourseView.TeachingPlaceID != null)
- {
- UnitOfWork.Delete<EMIS.Entities.EM_MinorCourseTeachingPlace>(x => x.MinorCourseID == MinorCourse.MinorCourseID);
- foreach (var i in minorSpecialtyCourseView.TeachingPlaceID)
- {
- EMIS.Entities.EM_MinorCourseTeachingPlace MinorCourseTeachingPlace = new EMIS.Entities.EM_MinorCourseTeachingPlace();
- MinorCourseTeachingPlace.MinorCourseTeachingPlaceID = Guid.NewGuid();
- MinorCourseTeachingPlace.MinorCourseID = MinorCourse.MinorCourseID;
- MinorCourseTeachingPlace.TeachingPlace = i;
- SetNewStatus(MinorCourseTeachingPlace);
- UnitOfWork.Add(MinorCourseTeachingPlace);
- }
- }
- }
- else
- {
- MinorCourse = GetMinorSpecialtyCourse(minorSpecialtyCourseView.MinorCourseID);
- MinorCourseTeachingSetting = GetSpecialtyCourseTeachingSetting(minorSpecialtyCourseView.MinorCourseID);
- MinorCourse.StandardID = minorSpecialtyCourseView.StandardID;
- MinorCourse.DepartmentID = minorSpecialtyCourseView.DepartmentID;
- MinorCourse.CoursematerialID = minorSpecialtyCourseView.CoursematerialID;
- MinorCourse.CourseStructureID = minorSpecialtyCourseView.CourseStructureID;
- MinorCourse.CourseCategoryID = minorSpecialtyCourseView.CourseCategoryID;
- MinorCourse.CourseTypeID = minorSpecialtyCourseView.CourseTypeID;
- MinorCourse.CourseQualityID = minorSpecialtyCourseView.CourseQualityID;
- MinorCourse.PracticeTypeID = minorSpecialtyCourseView.PracticeTypeID;
- MinorCourse.ExaminationModeID = minorSpecialtyCourseView.ExaminationModeID;
- MinorCourse.TeachinglanguageID = minorSpecialtyCourseView.TeachinglanguageID;
- MinorCourse.SchoolyearNumID = minorSpecialtyCourseView.SchoolyearNumID;
- MinorCourse.SchoolcodeID = minorSpecialtyCourseView.SchoolcodeID;
- MinorCourse.CourseFineID = minorSpecialtyCourseView.CourseFineID;
- MinorCourse.IsSpecialtycore = minorSpecialtyCourseView.IsSpecialtycore;
- MinorCourse.IsCooperation = minorSpecialtyCourseView.IsCooperation;
- MinorCourse.IsRequired = minorSpecialtyCourseView.IsRequired;
- MinorCourse.IsElective = minorSpecialtyCourseView.IsElective;
- MinorCourse.IsNetworkCourse = minorSpecialtyCourseView.IsNetworkCourse;
- MinorCourse.IsMainCourse = minorSpecialtyCourseView.IsMainCourse;
- MinorCourse.IsEnable = minorSpecialtyCourseView.IsEnable;
- MinorCourse.ResultTypeID = minorSpecialtyCourseView.ResultTypeID;
- MinorCourse.Remarks = minorSpecialtyCourseView.Remarks;
- SetModifyStatus(MinorCourse);
- MinorCourseTeachingSetting.Credit = minorSpecialtyCourseView.Credit;
- MinorCourseTeachingSetting.TheoryCourse = minorSpecialtyCourseView.TheoryCourse;
- MinorCourseTeachingSetting.Practicehours = minorSpecialtyCourseView.Practicehours;
- MinorCourseTeachingSetting.Trialhours = minorSpecialtyCourseView.Trialhours;
- MinorCourseTeachingSetting.WeeklyNum = minorSpecialtyCourseView.WeeklyNum;
- MinorCourseTeachingSetting.TheoryWeeklyNum = minorSpecialtyCourseView.TheoryWeeklyNum;
- MinorCourseTeachingSetting.PracticeWeeklyNum = minorSpecialtyCourseView.PracticeWeeklyNum;
- MinorCourseTeachingSetting.TrialWeeklyNum = minorSpecialtyCourseView.TrialWeeklyNum;
- MinorCourseTeachingSetting.StartWeeklyNum = minorSpecialtyCourseView.StartWeeklyNum;
- MinorCourseTeachingSetting.EndWeeklyNum = minorSpecialtyCourseView.EndWeeklyNum;
- MinorCourseTeachingSetting.WeeklyHours = minorSpecialtyCourseView.WeeklyHours;
- UnitOfWork.Update(MinorCourseTeachingSetting);
- if (minorSpecialtyCourseView.TeachingModeID != null)
- {
- UnitOfWork.Delete<EM_MinorCourseTeachingModeType>(x => x.MinorCourseID == MinorCourse.MinorCourseID);
- foreach (var i in minorSpecialtyCourseView.TeachingModeID)
- {
- EM_MinorCourseTeachingModeType MinorCourseTeachingModeType = new EM_MinorCourseTeachingModeType();
- MinorCourseTeachingModeType.MinorCourseTeachingModeTypeID = Guid.NewGuid();
- MinorCourseTeachingModeType.MinorCourseID = MinorCourse.MinorCourseID;
- MinorCourseTeachingModeType.TeachingModeID = i;
- SetNewStatus(MinorCourseTeachingModeType);
- UnitOfWork.Add(MinorCourseTeachingModeType);
- }
- }
- if (minorSpecialtyCourseView.TeachingPlaceID != null)
- {
- UnitOfWork.Delete<EMIS.Entities.EM_MinorCourseTeachingPlace>(x => x.MinorCourseID == MinorCourse.MinorCourseID);
- foreach (var i in minorSpecialtyCourseView.TeachingPlaceID)
- {
- EMIS.Entities.EM_MinorCourseTeachingPlace MinorCourseTeachingPlace = new EMIS.Entities.EM_MinorCourseTeachingPlace();
- MinorCourseTeachingPlace.MinorCourseTeachingPlaceID = Guid.NewGuid();
- MinorCourseTeachingPlace.MinorCourseID = MinorCourse.MinorCourseID;
- MinorCourseTeachingPlace.TeachingPlace = i;
- SetNewStatus(MinorCourseTeachingPlace);
- UnitOfWork.Add(MinorCourseTeachingPlace);
- }
- }
- }
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="MinorCourseIDList"></param>
- /// <returns></returns>
- public bool MinorCourseDelete(List<Guid?> MinorCourseIDList)
- {
- try
- {
- var CourseIDList = minorSpecialtyCourseDAL.MinorCourseRepository.GetList(x => MinorCourseIDList.Contains(x.MinorCourseID)).Select(w=>w.CoursematerialID).ToList();
- var useCourseList = MinorPlanApplyDAL.MinorPlanApplicationRepository.GetList(x => CourseIDList.Contains(x.CoursematerialID)).FirstOrDefault();
- if (useCourseList!=null)
- {
- throw new Exception("删除失败,已存在关联数据,如不使用该课程,可修改是否启用字段。");
- }
- if (MinorCourseIDList.Count > 0)
- {
- UnitOfWork.Delete<EM_MinorCourseTeachingSetting>(x => MinorCourseIDList.Contains(x.MinorCourseID));
- UnitOfWork.Delete<EM_MinorCourseTeachingModeType>(x => MinorCourseIDList.Contains(x.MinorCourseID));
- UnitOfWork.Delete<EM_MinorCourseTeachingPlace>(x => MinorCourseIDList.Contains(x.MinorCourseID));
- UnitOfWork.Delete<EM_MinorCourse>(x => MinorCourseIDList.Contains(x.MinorCourseID));
- }
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- public void MinorSpecialtyCourseImport(Dictionary<string, string> cellheader, out int OkCount, out List<MinorSpecialtyCourseView> errdataList, out int ErrCount, string sourcePhysicalPath)
- {
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- List<MinorSpecialtyCourseView> errList = new List<MinorSpecialtyCourseView>();
- #region 1.1解析文件,存放到一个List集合里
- cellheader.Remove("ErrorMessage");//去除异常列、导入操作不需要
- // 1.1解析文件,存放到一个List集合里
- List<MinorSpecialtyCourseView> enlist =
- NpoiExcelHelper.ExcelToEntityList<MinorSpecialtyCourseView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- cellheader.Add("ErrorMessage", "错误信息");//还原字典项
- #endregion
- #region 读取数据库数据
- //专业字典
- var StandardList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Standard.ToString()).ToList();
- //课程
- var CoursematerialList = CoursematerialDAL.Value.CoursematerialRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- //教研室
- var DepartmentList = DepartmentRepository.Value.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- //授课年级字典
- var SchoolyearNumList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_SchoolyearNum.ToString()).ToList();
- //学期字典
- var SchoolcodeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Semester.ToString()).ToList();
- //课程类型字典
- var CourseTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseType.ToString()).ToList();
- //课程属性字典
- var CourseCategoryList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseCategory.ToString()).ToList();
- //课程性质字典
- var CourseQualityList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseQuality.ToString()).ToList();
- //课程结构字典
- var CourseStructureList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseStructure.ToString()).ToList();
- //实践类型字典
- var PracticeTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.EM_PracticeType.ToString()).ToList();
- //考试方式字典
- var ExaminationModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ExaminationMode.ToString()).ToList();
- //通用是或否字典
- var YesOrNoStatusList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_YesOrNoStatus.ToString()).ToList();
- //精品课程字典
- var CourseFineList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseFine.ToString()).ToList();
- //授课语言字典
- var TeachinglanguageList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Teachinglanguage.ToString()).ToList();
- //授课方式字典
- var TeachingModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_TeachingMode.ToString()).ToList();
- //授课地点字典
- var TeachingPlaceList = IdNameExt.GetDictionaryItem(DictionaryItem.EM_TeachingPlace.ToString()).ToList();
- //成绩类型字典
- var ResultTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ResultType.ToString()).ToList();
- //辅修课程List
- var MinorCourseList = minorSpecialtyCourseDAL.MinorCourseRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- #endregion
- #region 1.2 检验数据合格性
- if (enlist.Count() <= 0)
- {
- throw new Exception("请填写Excel模板信息数据。");
- }
- #region 验证
- //Regex reg = new Regex(@"^[0-9]*$");
- Regex reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$");
- for (int i = 0; i < enlist.Count; i++)
- {
- MinorSpecialtyCourseView en = enlist[i];
- string errorMsgStr = "第" + (i + 2) + "行数据检测异常:";
- bool isHaveNoInputValue = false; // 是否含有未输入项
- #region 专业代码
- if (string.IsNullOrEmpty(en.SpecialtyCodeStr))
- {
- errorMsgStr += "专业代码不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- #endregion
- #region 专业名称
- if (string.IsNullOrEmpty(en.StandardNameStr))
- {
- errorMsgStr += "专业名称不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.StandardNameStr) && !string.IsNullOrEmpty(en.SpecialtyCodeStr))
- {
- var Standard = StandardList.Where(x => x.Name == en.StandardNameStr.Trim() && x.Code == en.SpecialtyCodeStr.Trim()).FirstOrDefault();
- if (Standard == null)
- {
- errorMsgStr += "专业代码与专业名称不符;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- }
- #endregion
-
- #region 课程名称
- if (string.IsNullOrEmpty(en.CourseCode))
- {
- errorMsgStr += "课程代码不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.CourseCode))
- {
- if (CoursematerialList.Where(x => x.CourseCode == en.CourseCode.Trim()).FirstOrDefault() == null)
- {
- errorMsgStr += "该课程代码不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- }
- #endregion
- #region 教研室
- if (string.IsNullOrEmpty(en.DepartmentName))
- {
- errorMsgStr += "教研室不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.DepartmentName))
- {
- if (DepartmentList.Where(x => x.Name == en.DepartmentName.Trim()).FirstOrDefault() == null)
- {
- errorMsgStr += "教研室不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.DepartmentID = DepartmentList.Where(x => x.Name == en.DepartmentName.Trim()).FirstOrDefault().DepartmentID;
- }
- }
- #endregion
- #region 授课年级
- if (string.IsNullOrEmpty(en.SchoolyearNumNameStr))
- {
- errorMsgStr += "授课年级不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- if (SchoolyearNumList.Where(x => x.Name.Trim() == en.SchoolyearNumNameStr.Trim()).FirstOrDefault() == null)
- {
- errorMsgStr += "授课年级不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- }
- #endregion
- #region 学期
- if (string.IsNullOrEmpty(en.SchoolcodeStr))
- {
- errorMsgStr += "学期不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.SchoolcodeStr))
- {
- if (SchoolcodeList.Where(x => x.Name == en.SchoolcodeStr).FirstOrDefault() == null)
- {
- errorMsgStr += "学期不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.SchoolcodeID = SchoolcodeList.Where(x => x.Name == en.SchoolcodeStr).FirstOrDefault().Value;
- }
- }
- #endregion
- #region 课程类型
- if (string.IsNullOrEmpty(en.CourseTypeStr))
- {
- errorMsgStr += "课程类型不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.CourseTypeStr))
- {
- if (CourseTypeList.Where(x => x.Name == en.CourseTypeStr).FirstOrDefault() == null)
- {
- errorMsgStr += "课程类型不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.CourseTypeID = CourseTypeList.Where(x => x.Name == en.CourseTypeStr).FirstOrDefault().Value;
- }
- }
- #endregion
- #region 课程属性
- if (string.IsNullOrEmpty(en.CourseCategoryNameStr))
- {
- errorMsgStr += "课程属性不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.CourseCategoryNameStr))
- {
- if (CourseCategoryList.Where(x => x.Name == en.CourseCategoryNameStr).FirstOrDefault() == null)
- {
- errorMsgStr += "课程属性不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.CourseCategoryID = CourseCategoryList.Where(x => x.Name == en.CourseCategoryNameStr).FirstOrDefault().Value;
- }
- }
- #endregion
- #region 课程性质
- if (string.IsNullOrEmpty(en.CourseQualityNameStr))
- {
- errorMsgStr += "课程性质不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.CourseQualityNameStr))
- {
- if (CourseQualityList.Where(x => x.Name == en.CourseQualityNameStr).FirstOrDefault() == null)
- {
- errorMsgStr += "课程性质不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.CourseQualityID = CourseQualityList.Where(x => x.Name == en.CourseQualityNameStr).FirstOrDefault().Value;
- }
- }
- #endregion
- #region 课程结构
- if (!string.IsNullOrEmpty(en.CourseStructureNameStr))
- {
- if (CourseStructureList.Where(x => x.Name == en.CourseStructureNameStr).FirstOrDefault() == null)
- {
- errorMsgStr += "课程结构不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.CourseStructureID = CourseStructureList.Where(x => x.Name == en.CourseStructureNameStr).FirstOrDefault().Value;
- }
- }
- #endregion
- #region 学分
- if (string.IsNullOrEmpty(en.CreditStr))
- {
- errorMsgStr += "学分不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.CreditStr))
- {
- if (!reg.IsMatch(en.CreditStr))
- {
- errorMsgStr += "学分格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.Credit = Convert.ToDecimal(en.CreditStr);
- }
- }
- #endregion
- #region 理论学时
- if (string.IsNullOrEmpty(en.TheoryCourseStr))
- {
- errorMsgStr += "理论学时不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.TheoryCourseStr))
- {
- if (!reg.IsMatch(en.TheoryCourseStr))
- {
- errorMsgStr += "理论学时格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.TheoryCourse = Convert.ToInt32(en.TheoryCourseStr);
- }
- }
- #endregion
- #region 实践学时
- if (string.IsNullOrEmpty(en.PracticehoursStr))
- {
- errorMsgStr += "实践学时不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.PracticehoursStr))
- {
- if (!reg.IsMatch(en.PracticehoursStr))
- {
- errorMsgStr += "实践学时格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.Practicehours = Convert.ToInt32(en.PracticehoursStr);
- }
- }
- #endregion
- #region 实验学时
- if (string.IsNullOrEmpty(en.TrialhoursStr))
- {
- errorMsgStr += "实验学时不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.TrialhoursStr))
- {
- if (!reg.IsMatch(en.TrialhoursStr))
- {
- errorMsgStr += "实验学时格式不正确;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.Trialhours = Convert.ToInt32(en.TrialhoursStr);
- }
- }
- #endregion
- #region 实践方式
- if (!string.IsNullOrEmpty(en.PracticeTypeNameStr))
- {
- if (PracticeTypeList.Where(x => x.Name == en.PracticeTypeNameStr).FirstOrDefault() == null)
- {
- errorMsgStr += "实践方式不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.PracticeTypeID = PracticeTypeList.Where(x => x.Name == en.PracticeTypeNameStr).FirstOrDefault().Value;
- }
- }
- #endregion
- #region 考试方式
- if (string.IsNullOrEmpty(en.ExaminationModeNameStr))
- {
- errorMsgStr += "考试方式不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.ExaminationModeNameStr))
- {
- if (ExaminationModeList.Where(x => x.Name == en.ExaminationModeNameStr).FirstOrDefault() == null)
- {
- errorMsgStr += "考试方式不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.ExaminationModeID = ExaminationModeList.Where(x => x.Name == en.ExaminationModeNameStr).FirstOrDefault().Value;
- }
- }
- #endregion
- #region 成绩类型
- if (string.IsNullOrEmpty(en.ResultTypeNameStr))
- {
- errorMsgStr += "成绩类型不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.ResultTypeNameStr))
- {
- if (ResultTypeList.Where(x => x.Name == en.ResultTypeNameStr).FirstOrDefault() == null)
- {
- errorMsgStr += "成绩类型不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.ResultTypeID = ResultTypeList.Where(x => x.Name == en.ResultTypeNameStr).FirstOrDefault().Value;
- }
- }
- #endregion
- #region 是否专业核心
- if (!string.IsNullOrEmpty(en.IsSpecialtycoreName))
- {
- //var t = typeof(MinorSpecialtyCourseView);
- //var pName = t.GetProperty(en.IsSpecialtycoreName);
- ////4.0或以上版本
- //var displayName = pName.GetCustomAttributes<DisplayNameAttribute>();
- if (YesOrNoStatusList.Where(x => x.Name == en.IsSpecialtycoreName).FirstOrDefault() == null)
- {
- errorMsgStr += "是否专业核心不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.IsSpecialtycore = en.IsSpecialtycoreName == "是" ? true : false;
- }
- }
- #endregion
- #region 是否校企开发
- if (!string.IsNullOrEmpty(en.IsCooperationName))
- {
- if (YesOrNoStatusList.Where(x => x.Name == en.IsCooperationName).FirstOrDefault() == null)
- {
- errorMsgStr += "是否校企开发不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.IsCooperation = en.IsCooperationName == "是" ? true : false;
- }
- }
- #endregion
- #region 是否课证融通
- if (!string.IsNullOrEmpty(en.IsRequiredName))
- {
- if (YesOrNoStatusList.Where(x => x.Name == en.IsRequiredName).FirstOrDefault() == null)
- {
- errorMsgStr += "是否课证融通不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.IsRequired = en.IsRequiredName == "是" ? true : false;
- }
- }
- #endregion
- #region 是否学位主干
- if (!string.IsNullOrEmpty(en.IsMainCourseName))
- {
- if (YesOrNoStatusList.Where(x => x.Name == en.IsMainCourseName).FirstOrDefault() == null)
- {
- errorMsgStr += "是否学位主干不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.IsMainCourse = en.IsMainCourseName == "是" ? true : false;
- }
- }
- #endregion
- #region 是否选修
- if (!string.IsNullOrEmpty(en.IsElectiveName))
- {
- if (YesOrNoStatusList.Where(x => x.Name == en.IsElectiveName).FirstOrDefault() == null)
- {
- errorMsgStr += "是否选修不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.IsElective = en.IsElectiveName == "是" ? true : false;
- }
- }
- #endregion
- #region 是否网络
- if (!string.IsNullOrEmpty(en.IsNetworkCourseName))
- {
- if (YesOrNoStatusList.Where(x => x.Name == en.IsNetworkCourseName).FirstOrDefault() == null)
- {
- errorMsgStr += "是否网络不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.IsNetworkCourse = en.IsNetworkCourseName == "是" ? true : false;
- }
- }
- #endregion
- #region 精品课程
- if (!string.IsNullOrEmpty(en.CourseFineNameStr))
- {
- if (CourseFineList.Where(x => x.Name == en.CourseFineNameStr).FirstOrDefault() == null)
- {
- errorMsgStr += "精品课程不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.CourseFineID = CourseFineList.Where(x => x.Name == en.CourseFineNameStr).FirstOrDefault().Value;
- }
- }
- #endregion
- #region 授课语言
- if (!string.IsNullOrEmpty(en.TeachinglanguageNameStr))
- {
- if (TeachinglanguageList.Where(x => x.Name == en.TeachinglanguageNameStr).FirstOrDefault() == null)
- {
- errorMsgStr += "授课语言不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- en.TeachinglanguageID = TeachinglanguageList.Where(x => x.Name == en.TeachinglanguageNameStr).FirstOrDefault().Value;
- }
- }
- #endregion
- #region 授课方式
- if (string.IsNullOrEmpty(en.TeachingModeStr))
- {
- errorMsgStr += "授课方式不能为空;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.TeachingModeStr))
- {
- bool IsExists = true;//是否存在!
- string[] StrArry = null;
- if (en.TeachingModeStr.Contains(","))
- {
- StrArry = en.TeachingModeStr.Split(',');
- }
- if (en.TeachingModeStr.Contains(","))
- {
- StrArry = en.TeachingModeStr.Split(',');
- }
- if (en.TeachingModeStr.Contains(",") && en.TeachingModeStr.Contains(","))
- {
- StrArry = new string[1];
- StrArry[0] = en.TeachingModeStr.ToString();
- }
- if (StrArry != null)
- {
- foreach (var Str in StrArry)
- {
- if (TeachingModeList.Where(x => x.Name == Str).FirstOrDefault() == null && !string.IsNullOrEmpty(Str))
- {
- IsExists = false;
- }
- }
- }
- else
- {
- if (TeachingModeList.Where(x => x.Name == en.TeachingModeStr).FirstOrDefault() == null && !string.IsNullOrEmpty(en.TeachingModeStr))
- {
- IsExists = false;
- }
- }
- if (!IsExists)
- {
- errorMsgStr += "授课方式不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- List<int> TeachingModesList = new List<int>();
- if (StrArry != null)
- {
- foreach (var Str in StrArry)
- {
- if (!string.IsNullOrEmpty(Str))
- {
- int? TeachingModeID = TeachingModeList.Where(x => x.Name == Str).FirstOrDefault().Value;
- TeachingModesList.Add((int)TeachingModeID);
- }
- }
- }
- else
- {
- if (!string.IsNullOrEmpty(en.TeachingModeStr))
- {
- int? TeachingModeID = TeachingModeList.Where(x => x.Name == en.TeachingModeStr).FirstOrDefault().Value;
- TeachingModesList.Add((int)TeachingModeID);
- }
- }
- en.TeachingModeID = TeachingModesList.Distinct().ToList();
- }
- }
- #endregion
- #region 授课地点
- if (!string.IsNullOrEmpty(en.TeachingPlaceStr))
- {
- string[] StrArry = null;
- if (en.TeachingPlaceStr.Contains(","))
- {
- StrArry = en.TeachingPlaceStr.Split(',');
- }
- if (en.TeachingPlaceStr.Contains(","))
- {
- StrArry = en.TeachingPlaceStr.Split(',');
- }
- if (en.TeachingPlaceStr.Contains(",") && en.TeachingPlaceStr.Contains(","))
- {
- StrArry = new string[1];
- StrArry[0] = en.TeachingPlaceStr.ToString();
- }
- bool IsExists = true;//是否存在!
- if (StrArry != null)
- {
- foreach (var Str in StrArry)
- {
- if (TeachingPlaceList.Where(x => x.Name == Str).FirstOrDefault() == null && !string.IsNullOrEmpty(Str))
- {
- IsExists = false;
- }
- }
- }
- else
- {
- if (TeachingPlaceList.Where(x => x.Name == en.TeachingPlaceStr).FirstOrDefault() == null && !string.IsNullOrEmpty(en.TeachingPlaceStr))
- {
- IsExists = false;
- }
- }
- if (!IsExists)
- {
- errorMsgStr += "授课地点不存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- }
- else
- {
- List<int> TeachingsPlaceList = new List<int>();
- if (StrArry != null)
- {
- foreach (var Str in StrArry)
- {
- if (!string.IsNullOrEmpty(Str))
- {
- int? TeachingPlaceID = TeachingPlaceList.Where(x => x.Name == Str).FirstOrDefault().Value;
- TeachingsPlaceList.Add((int)TeachingPlaceID);
- }
- }
- }
- else
- {
- if (!string.IsNullOrEmpty(en.TeachingPlaceStr))
- {
- int? TeachingPlaceID = TeachingPlaceList.Where(x => x.Name == en.TeachingPlaceStr).FirstOrDefault().Value;
- TeachingsPlaceList.Add((int)TeachingPlaceID);
- }
- }
- en.TeachingPlaceID = TeachingsPlaceList.Distinct().ToList();
- }
- }
- #endregion
- //唯一值 专业信息+课程+开课学期
- #region 唯一值
- if (!isHaveNoInputValue)
- {
- int? standardID = StandardList.Where(x => x.Name == en.StandardNameStr.Trim() && x.Code == en.SpecialtyCodeStr.Trim()).FirstOrDefault().Value;
- //学期
- int? schoolcodeID = SchoolcodeList.Where(x => x.Name == en.SchoolcodeStr).FirstOrDefault().Value;
- //开课年级
- int? schoolyearNum = SchoolyearNumList.Where(x => x.Name == en.SchoolyearNumNameStr).FirstOrDefault().Value;
- //以开课年级+学期 得出对应的 开课学期
- EM_Coursematerial CoursematerialEntity = CoursematerialList.Where(x => x.CourseCode == en.CourseCode.Trim()).FirstOrDefault();
- if (CoursematerialEntity == null)
- {
- isHaveNoInputValue = true;
- }
- else
- {
- if (MinorCourseList.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
- && x.StandardID == standardID && x.CoursematerialID == CoursematerialEntity.CoursematerialID
- && x.SchoolyearNumID == schoolyearNum && x.SchoolcodeID == schoolcodeID).Count() > 0)
- {
- errorMsgStr += "该标准专业课程已经存在;";
- en.ErrorMessage = errorMsgStr;
- isHaveNoInputValue = true;
- // throw new Exception("该标准专业课程已经存在,请重新输入!");
- }
- else
- {
- en.StandardID = standardID;
- en.CoursematerialID = CoursematerialEntity.CoursematerialID;
- en.SchoolcodeID = schoolcodeID;
- en.SchoolyearNumID = schoolyearNum;
- }
- }
- }
- if (isHaveNoInputValue) // 若必填项有值未填
- {
- en.IsExcelVaildateOK = false;
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- }
- }
- #endregion
- #endregion
- #region 插入数据
- List<EM_MinorCourse> MinorCourseLists = new List<EM_MinorCourse>();
- List<EM_MinorCourseTeachingSetting> MinorCourseTeachingSettingList = new List<EM_MinorCourseTeachingSetting>();
- List<EM_MinorCourseTeachingPlace> MinorCourseTeachingPlaceList = new List<EM_MinorCourseTeachingPlace>();
- List<EM_MinorCourseTeachingModeType> MinorCourseTeachingModeTypeList = new List<EM_MinorCourseTeachingModeType>();
- for (int i = 0; i < enlist.Count; i++)
- {
- MinorSpecialtyCourseView enA = enlist[i];
- if (enA.IsExcelVaildateOK == false) // 上面验证不通过,不进行此步验证
- {
- continue;
- }
- EM_MinorCourse MinorCourse = null;
- EM_MinorCourseTeachingSetting MinorCourseTeachingSetting = null;
- if (enA != null)
- {
- MinorCourse = new EM_MinorCourse();
- MinorCourse.MinorCourseID = Guid.NewGuid();
- MinorCourse.StandardID = enA.StandardID;
- MinorCourse.DepartmentID = enA.DepartmentID;
- MinorCourse.CoursematerialID = enA.CoursematerialID;
- MinorCourse.CourseStructureID = enA.CourseStructureID;
- MinorCourse.CourseCategoryID = enA.CourseCategoryID;
- MinorCourse.CourseTypeID = enA.CourseTypeID;
- MinorCourse.CourseQualityID = enA.CourseQualityID;
- MinorCourse.PracticeTypeID = enA.PracticeTypeID;
- MinorCourse.ExaminationModeID = enA.ExaminationModeID;
- MinorCourse.TeachinglanguageID = enA.TeachinglanguageID;
- MinorCourse.SchoolyearNumID = enA.SchoolyearNumID;
- MinorCourse.SchoolcodeID = enA.SchoolcodeID;
- MinorCourse.CourseFineID = enA.CourseFineID;
- MinorCourse.IsSpecialtycore = enA.IsSpecialtycore;
- MinorCourse.IsCooperation = enA.IsCooperation;
- MinorCourse.IsRequired = enA.IsRequired;
- MinorCourse.IsElective = enA.IsElective;
- MinorCourse.IsNetworkCourse = enA.IsNetworkCourse;
- MinorCourse.IsMainCourse = enA.IsMainCourse;
- MinorCourse.IsEnable = true;//默认启用
- MinorCourse.ResultTypeID = enA.ResultTypeID;
- MinorCourse.Remarks = enA.Remarks;
- SetNewStatus(MinorCourse);
- MinorCourseLists.Add(MinorCourse);
- MinorCourseTeachingSetting = new EM_MinorCourseTeachingSetting();
- MinorCourseTeachingSetting.MinorCourseID = MinorCourse.MinorCourseID;
- MinorCourseTeachingSetting.Credit = enA.Credit;
- MinorCourseTeachingSetting.TheoryCourse = enA.TheoryCourse;
- MinorCourseTeachingSetting.Practicehours = enA.Practicehours;
- MinorCourseTeachingSetting.Trialhours = enA.Trialhours;
- MinorCourseTeachingSetting.WeeklyNum = enA.WeeklyNum;
- MinorCourseTeachingSetting.TheoryWeeklyNum = enA.TheoryWeeklyNum;
- MinorCourseTeachingSetting.PracticeWeeklyNum = enA.PracticeWeeklyNum;
- MinorCourseTeachingSetting.TrialWeeklyNum = enA.TrialWeeklyNum;
- MinorCourseTeachingSetting.StartWeeklyNum = enA.StartWeeklyNum;
- MinorCourseTeachingSetting.EndWeeklyNum = enA.EndWeeklyNum;
- MinorCourseTeachingSetting.WeeklyHours = enA.WeeklyHours;
- MinorCourseTeachingSettingList.Add(MinorCourseTeachingSetting);
- if (enA.TeachingModeID != null)
- {
- foreach (var item in enA.TeachingModeID)
- {
- EM_MinorCourseTeachingModeType teachingModeType = new EM_MinorCourseTeachingModeType();
- teachingModeType.MinorCourseTeachingModeTypeID = Guid.NewGuid();
- teachingModeType.MinorCourseID = MinorCourse.MinorCourseID;
- teachingModeType.TeachingModeID = item;
- SetNewStatus(teachingModeType);
- MinorCourseTeachingModeTypeList.Add(teachingModeType);
- }
- }
- if (enA.TeachingPlaceID != null)
- {
- foreach (var item in enA.TeachingPlaceID)
- {
- EM_MinorCourseTeachingPlace teachingPlace = new EM_MinorCourseTeachingPlace();
- teachingPlace.MinorCourseTeachingPlaceID = Guid.NewGuid();
- teachingPlace.MinorCourseID = MinorCourse.MinorCourseID;
- teachingPlace.TeachingPlace = item;
- SetNewStatus(teachingPlace);
- MinorCourseTeachingPlaceList.Add(teachingPlace);
- }
- }
- }
- }
- #endregion
- #endregion
- #region 1.3 返回各项数据值
- UnitOfWork.BulkInsert(MinorCourseLists);//统一写入
- UnitOfWork.BulkInsert(MinorCourseTeachingSettingList);//统一写入
- UnitOfWork.BulkInsert(MinorCourseTeachingPlaceList);//统一写入
- UnitOfWork.BulkInsert(MinorCourseTeachingModeTypeList);//统一写入
- OkCount = enlist.Distinct().Count() - errList.Distinct().Count();//共条数减去失败条数
- errdataList = errList.Distinct().ToList();
- ErrCount = errList.Distinct().Count();
- #endregion
- }
- }
- }
|