12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.ComponentModel;
- using System.Text.RegularExpressions;
- using System.Linq.Expressions;
- using System.Transactions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Utility;
- using EMIS.Utility;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.CacheManage;
- using EMIS.ViewModel.CultureplanManage;
- using EMIS.DataLogic.CultureplanManage.PlanManagement;
- namespace EMIS.CommonLogic.CultureplanManage.PlanManagement
- {
- public class SpecialtyCourseServices : BaseServices, ISpecialtyCourseServices
- {
- public SpecialtyCourseDAL SpecialtyCourseDAL { get; set; }
- /// <summary>
- /// 查询专业课程信息SpecialtyCourseView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="courseTypeID"></param>
- /// <param name="starttermID"></param>
- /// <param name="teachingModeID"></param>
- /// <param name="handleModeID"></param>
- /// <param name="isEnable"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<SpecialtyCourseView> GetSpecialtyCourseViewGrid(ConfiguretView configuretView, Guid? collegeID, Guid? departmentID,
- int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID, int? courseTypeID,
- int? starttermID, int? teachingModeID, int? handleModeID, int? isEnable, int pageIndex, int pageSize)
- {
- //专业课程
- Expression<Func<EM_SpecialtyCourse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (departmentID.HasValue)
- {
- //开课教研室ID
- exp = exp.And(x => x.DepartmentID == departmentID);
- }
- if (coursematerialID.HasValue)
- {
- //课程信息ID
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- }
- if (courseTypeID.HasValue)
- {
- //课程类型
- exp = exp.And(x => x.CourseTypeID == courseTypeID);
- }
- if (starttermID.HasValue)
- {
- //开课学期
- exp = exp.And(x => x.StarttermID == starttermID);
- }
- if (handleModeID.HasValue)
- {
- //处理方式
- exp = exp.And(x => x.HandleModeID == handleModeID);
- }
- if (isEnable.HasValue)
- {
- //是否启用
- if (isEnable == 1)
- {
- exp = exp.And(x => x.IsEnable == true);
- }
- if (isEnable == 0)
- {
- exp = exp.And(x => x.IsEnable != true);
- }
- }
- var query = SpecialtyCourseDAL.GetSpecialtyCourseViewQueryable(exp);
- if (collegeID.HasValue)
- {
- //开课院系ID
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (standardID.HasValue)
- {
- //专业ID(Value)
- query = query.Where(x => x.StandardID == standardID);
- }
- 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 (teachingModeID.HasValue)
- {
- //授课方式
- query = query.Where(x => x.TeachingModeIDList.Contains(teachingModeID));
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.EducationID)
- .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
- .ThenBy(x => x.StarttermID).ThenBy(x => x.CourseTypeID)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ToGridResultSet<SpecialtyCourseView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询专业课程信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="courseTypeID"></param>
- /// <param name="starttermID"></param>
- /// <param name="teachingModeID"></param>
- /// <param name="handleModeID"></param>
- /// <param name="isEnable"></param>
- /// <returns></returns>
- public IList<SpecialtyCourseView> GetSpecialtyCourseViewList(ConfiguretView configuretView, Guid? collegeID, Guid? departmentID,
- int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID, int? courseTypeID,
- int? starttermID, int? teachingModeID, int? handleModeID, int? isEnable)
- {
- //专业课程
- Expression<Func<EM_SpecialtyCourse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (departmentID.HasValue)
- {
- //开课教研室ID
- exp = exp.And(x => x.DepartmentID == departmentID);
- }
- if (coursematerialID.HasValue)
- {
- //课程信息ID
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- }
- if (courseTypeID.HasValue)
- {
- //课程类型
- exp = exp.And(x => x.CourseTypeID == courseTypeID);
- }
- if (starttermID.HasValue)
- {
- //开课学期
- exp = exp.And(x => x.StarttermID == starttermID);
- }
- if (handleModeID.HasValue)
- {
- //处理方式
- exp = exp.And(x => x.HandleModeID == handleModeID);
- }
- if (isEnable.HasValue)
- {
- //是否启用
- if (isEnable == 1)
- {
- exp = exp.And(x => x.IsEnable == true);
- }
- if (isEnable == 0)
- {
- exp = exp.And(x => x.IsEnable != true);
- }
- }
- var query = SpecialtyCourseDAL.GetSpecialtyCourseViewQueryable(exp);
- if (collegeID.HasValue)
- {
- //开课院系ID
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (standardID.HasValue)
- {
- //专业ID(Value)
- query = query.Where(x => x.StandardID == standardID);
- }
- 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 (teachingModeID.HasValue)
- {
- //授课方式
- query = query.Where(x => x.TeachingModeIDList.Contains(teachingModeID));
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.EducationID)
- .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
- .ThenBy(x => x.StarttermID).ThenBy(x => x.CourseTypeID)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ToList();
- }
- /// <summary>
- /// 查询对应的专业课程信息SpecialtyCourseView
- /// </summary>
- /// <param name="specialtyCourseID"></param>
- /// <returns></returns>
- public SpecialtyCourseView GetSpecialtyCourseView(Guid? specialtyCourseID)
- {
- try
- {
- var specialtyCourseView = SpecialtyCourseDAL.GetSpecialtyCourseViewQueryable(x => x.SpecialtyCourseID == specialtyCourseID)
- .SingleOrDefault();
- return specialtyCourseView;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:专业信息ID、开课学期、课程信息ID)
- /// </summary>
- /// <param name="specialtyCourseView"></param>
- public virtual void SpecialtyCourseEdit(SpecialtyCourseView specialtyCourseView)
- {
- try
- {
- //查询数据库进行验证
- var specialtyCourseVerify = SpecialtyCourseDAL.SpecialtyCourseRepository
- .GetList(x => x.SpecialtyCourseID != specialtyCourseView.SpecialtyCourseID
- && x.SpecialtyID == specialtyCourseView.SpecialtyID
- && x.StarttermID == specialtyCourseView.StarttermID
- && x.CoursematerialID == specialtyCourseView.CoursematerialID).SingleOrDefault();
- if (specialtyCourseVerify == null)
- {
- //查询对应的专业信息
- var specialty = SpecialtyCourseDAL.SpecialtyRepository
- .GetList(x => x.SpecialtyID == specialtyCourseView.SpecialtyID).SingleOrDefault();
- if (specialty == null)
- {
- throw new Exception("专业信息不存在,请检查。");
- }
- //对学制和开课学期进行判断
- var maxStartterm = Convert.ToInt32(Math.Ceiling(specialty.LearnSystem.Value * 2 - 1)) + 1;
- if (specialtyCourseView.StarttermID > maxStartterm)
- {
- throw new Exception("开课学期超出学制范围,请检查。");
- }
- List<EM_SpecialtyCourse> newSpecialtyCourseInList = new List<EM_SpecialtyCourse>();
- List<EM_SpecialtyCourse> newSpecialtyCourseUpList = new List<EM_SpecialtyCourse>();
- List<EM_SpecialtyCourseTeachingSetting> newTeachingSettingInList = new List<EM_SpecialtyCourseTeachingSetting>();
- List<EM_SpecialtyCourseTeachingSetting> newTeachingSettingUpList = new List<EM_SpecialtyCourseTeachingSetting>();
- List<EM_TeachingModeType> newTeachingModeTypeInList = new List<EM_TeachingModeType>();
- List<EMIS.Entities.EM_TeachingPlace> newTeachingPlaceInList = new List<EMIS.Entities.EM_TeachingPlace>();
- List<Guid?> specialtyCourseTMDelList = new List<Guid?>();
- List<Guid?> specialtyCourseTPDelList = new List<Guid?>();
- //数据有误验证
- if (specialtyCourseView.SpecialtyCourseID != Guid.Empty)
- {
- var specialtyCourse = SpecialtyCourseDAL.SpecialtyCourseRepository
- .GetList(x => x.SpecialtyCourseID == specialtyCourseView.SpecialtyCourseID,
- (x => x.EM_SpecialtyCourseTeachingSetting)).SingleOrDefault();
- if (specialtyCourse == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- specialtyCourse.SpecialtyID = specialtyCourseView.SpecialtyID;
- specialtyCourse.StarttermID = specialtyCourseView.StarttermID;
- specialtyCourse.CoursematerialID = specialtyCourseView.CoursematerialID;
- specialtyCourse.CourseStructureID = specialtyCourseView.CourseStructureID;
- specialtyCourse.CourseCategoryID = specialtyCourseView.CourseCategoryID;
- specialtyCourse.CourseTypeID = specialtyCourseView.CourseTypeID;
- specialtyCourse.CourseQualityID = specialtyCourseView.CourseQualityID;
- specialtyCourse.DepartmentID = specialtyCourseView.DepartmentID;
- specialtyCourse.IsSpecialtycore = specialtyCourseView.IsSpecialtycore;
- specialtyCourse.IsCooperation = specialtyCourseView.IsCooperation;
- specialtyCourse.IsRequired = specialtyCourseView.IsRequired;
- specialtyCourse.IsElective = specialtyCourseView.IsElective;
- specialtyCourse.IsNetworkCourse = specialtyCourseView.IsNetworkCourse;
- specialtyCourse.IsMainCourse = specialtyCourseView.IsMainCourse;
- specialtyCourse.IsNeedMaterial = specialtyCourseView.IsNeedMaterial;
- specialtyCourse.CourseFineID = specialtyCourseView.CourseFineID;
- specialtyCourse.PracticeTypeID = specialtyCourseView.PracticeTypeID;
- specialtyCourse.TeachinglanguageID = specialtyCourseView.TeachinglanguageID;
- specialtyCourse.ExaminationModeID = specialtyCourseView.ExaminationModeID;
- specialtyCourse.ResultTypeID = specialtyCourseView.ResultTypeID;
- specialtyCourse.HandleModeID = specialtyCourseView.HandleModeID;
- specialtyCourse.IsEnable = specialtyCourseView.IsEnable;
- specialtyCourse.Remark = specialtyCourseView.Remark;
- SetModifyStatus(specialtyCourse);
- newSpecialtyCourseUpList.Add(specialtyCourse);
- if (specialtyCourse.EM_SpecialtyCourseTeachingSetting == null)
- {
- var newTeachingSetting = new EM_SpecialtyCourseTeachingSetting();
- newTeachingSetting.SpecialtyCourseID = specialtyCourse.SpecialtyCourseID;
- newTeachingSetting.Credit = specialtyCourseView.Credit;
- newTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse;
- newTeachingSetting.Practicehours = specialtyCourseView.Practicehours;
- newTeachingSetting.Trialhours = specialtyCourseView.Trialhours;
- newTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum;
- newTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum;
- newTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum;
- newTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours;
- newTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum;
- newTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum;
- newTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum;
- newTeachingSettingInList.Add(newTeachingSetting);
- }
- else
- {
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.Credit = specialtyCourseView.Credit;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.Practicehours = specialtyCourseView.Practicehours;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.Trialhours = specialtyCourseView.Trialhours;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum;
- specialtyCourse.EM_SpecialtyCourseTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum;
- newTeachingSettingUpList.Add(specialtyCourse.EM_SpecialtyCourseTeachingSetting);
- }
- if (specialtyCourseView.TeachingModeIDList != null && specialtyCourseView.TeachingModeIDList.Count() > 0)
- {
- specialtyCourseTMDelList.Add(specialtyCourse.SpecialtyCourseID);
- foreach (var teachingModeID in specialtyCourseView.TeachingModeIDList)
- {
- var newTeachingMode = new EM_TeachingModeType();
- newTeachingMode.TeachingModeTypeID = Guid.NewGuid();
- newTeachingMode.SpecialtyCourseID = specialtyCourse.SpecialtyCourseID;
- newTeachingMode.TeachingModeID = teachingModeID;
- SetNewStatus(newTeachingMode);
- newTeachingModeTypeInList.Add(newTeachingMode);
- }
- }
- else
- {
- specialtyCourseTMDelList.Add(specialtyCourse.SpecialtyCourseID);
- }
- if (specialtyCourseView.TeachingPlaceIDList != null && specialtyCourseView.TeachingPlaceIDList.Count() > 0)
- {
- specialtyCourseTPDelList.Add(specialtyCourse.SpecialtyCourseID);
- foreach (var teachingPlaceID in specialtyCourseView.TeachingPlaceIDList)
- {
- var newTeachingPlace = new EMIS.Entities.EM_TeachingPlace();
- newTeachingPlace.TeachingPlaceID = Guid.NewGuid();
- newTeachingPlace.SpecialtyCourseID = specialtyCourse.SpecialtyCourseID;
- newTeachingPlace.TeachingPlace = teachingPlaceID;
- SetNewStatus(newTeachingPlace);
- newTeachingPlaceInList.Add(newTeachingPlace);
- }
- }
- else
- {
- specialtyCourseTPDelList.Add(specialtyCourse.SpecialtyCourseID);
- }
- }
- }
- else
- {
- //表示新增
- var newSpecialtyCourse = new EM_SpecialtyCourse();
- newSpecialtyCourse.SpecialtyCourseID = Guid.NewGuid();
- newSpecialtyCourse.SpecialtyID = specialtyCourseView.SpecialtyID;
- newSpecialtyCourse.StarttermID = specialtyCourseView.StarttermID;
- newSpecialtyCourse.CoursematerialID = specialtyCourseView.CoursematerialID;
- newSpecialtyCourse.CourseStructureID = specialtyCourseView.CourseStructureID;
- newSpecialtyCourse.CourseCategoryID = specialtyCourseView.CourseCategoryID;
- newSpecialtyCourse.CourseTypeID = specialtyCourseView.CourseTypeID;
- newSpecialtyCourse.CourseQualityID = specialtyCourseView.CourseQualityID;
- newSpecialtyCourse.DepartmentID = specialtyCourseView.DepartmentID;
- newSpecialtyCourse.IsSpecialtycore = specialtyCourseView.IsSpecialtycore;
- newSpecialtyCourse.IsCooperation = specialtyCourseView.IsCooperation;
- newSpecialtyCourse.IsRequired = specialtyCourseView.IsRequired;
- newSpecialtyCourse.IsElective = specialtyCourseView.IsElective;
- newSpecialtyCourse.IsNetworkCourse = specialtyCourseView.IsNetworkCourse;
- newSpecialtyCourse.IsMainCourse = specialtyCourseView.IsMainCourse;
- newSpecialtyCourse.IsNeedMaterial = specialtyCourseView.IsNeedMaterial;
- newSpecialtyCourse.CourseFineID = specialtyCourseView.CourseFineID;
- newSpecialtyCourse.PracticeTypeID = specialtyCourseView.PracticeTypeID;
- newSpecialtyCourse.TeachinglanguageID = specialtyCourseView.TeachinglanguageID;
- newSpecialtyCourse.ExaminationModeID = specialtyCourseView.ExaminationModeID;
- newSpecialtyCourse.ResultTypeID = specialtyCourseView.ResultTypeID;
- newSpecialtyCourse.HandleModeID = specialtyCourseView.HandleModeID;
- newSpecialtyCourse.IsEnable = specialtyCourseView.IsEnable;
- newSpecialtyCourse.Remark = specialtyCourseView.Remark;
- SetNewStatus(newSpecialtyCourse);
- newSpecialtyCourseInList.Add(newSpecialtyCourse);
- var newTeachingSetting = new EM_SpecialtyCourseTeachingSetting();
- newTeachingSetting.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
- newTeachingSetting.Credit = specialtyCourseView.Credit;
- newTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse;
- newTeachingSetting.Practicehours = specialtyCourseView.Practicehours;
- newTeachingSetting.Trialhours = specialtyCourseView.Trialhours;
- newTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum;
- newTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum;
- newTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum;
- newTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours;
- newTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum;
- newTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum;
- newTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum;
- newTeachingSettingInList.Add(newTeachingSetting);
- if (specialtyCourseView.TeachingModeIDList != null && specialtyCourseView.TeachingModeIDList.Count() > 0)
- {
- foreach (var teachingModeID in specialtyCourseView.TeachingModeIDList)
- {
- var newTeachingMode = new EM_TeachingModeType();
- newTeachingMode.TeachingModeTypeID = Guid.NewGuid();
- newTeachingMode.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
- newTeachingMode.TeachingModeID = teachingModeID;
- SetNewStatus(newTeachingMode);
- newTeachingModeTypeInList.Add(newTeachingMode);
- }
- }
- if (specialtyCourseView.TeachingPlaceIDList != null && specialtyCourseView.TeachingPlaceIDList.Count() > 0)
- {
- foreach (var teachingPlaceID in specialtyCourseView.TeachingPlaceIDList)
- {
- var newTeachingPlace = new EMIS.Entities.EM_TeachingPlace();
- newTeachingPlace.TeachingPlaceID = Guid.NewGuid();
- newTeachingPlace.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
- newTeachingPlace.TeachingPlace = teachingPlaceID;
- SetNewStatus(newTeachingPlace);
- newTeachingPlaceInList.Add(newTeachingPlace);
- }
- }
- }
- //事务提交
- //UnitOfWork.Commit();
- using (TransactionScope ts = new TransactionScope())
- {
- //删除
- UnitOfWork.Delete<EMIS.Entities.EM_TeachingPlace>(x => specialtyCourseTPDelList.Contains(x.SpecialtyCourseID));
- UnitOfWork.Delete<EM_TeachingModeType>(x => specialtyCourseTMDelList.Contains(x.SpecialtyCourseID));
- //批量插入
- UnitOfWork.BulkInsert(newSpecialtyCourseInList);
- UnitOfWork.BulkInsert(newTeachingSettingInList);
- UnitOfWork.BulkInsert(newTeachingModeTypeInList);
- UnitOfWork.BulkInsert(newTeachingPlaceInList);
- //批量统一提交更新
- if (newSpecialtyCourseUpList != null && newSpecialtyCourseUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newSpecialtyCourseUpList);
- }
- //批量统一提交更新
- if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newTeachingSettingUpList);
- }
- ts.Complete();
- }
- }
- else
- {
- throw new Exception("已存在相同的专业课程信息(专业信息、开课学期、课程信息唯一),请核查。");
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="specialtyCourseIDs"></param>
- /// <returns></returns>
- public bool SpecialtyCourseDelete(List<Guid?> specialtyCourseIDs)
- {
- try
- {
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.Delete<EMIS.Entities.EM_TeachingPlace>(x => specialtyCourseIDs.Contains(x.SpecialtyCourseID));
- UnitOfWork.Delete<EM_TeachingModeType>(x => specialtyCourseIDs.Contains(x.SpecialtyCourseID));
- UnitOfWork.Delete<EM_SpecialtyCourseTeachingSetting>(x => specialtyCourseIDs.Contains(x.SpecialtyCourseID));
- UnitOfWork.Delete<EM_SpecialtyCourse>(x => specialtyCourseIDs.Contains(x.SpecialtyCourseID));
- ts.Complete();
- return true;
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 查询专业课程对应的授课方式List
- /// </summary>
- /// <param name="specialtyCourseID"></param>
- /// <returns></returns>
- public List<string> GetTeachingModeTypeList(Guid? specialtyCourseID)
- {
- //专业课程
- Expression<Func<EM_SpecialtyCourse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.SpecialtyCourseID == specialtyCourseID);
- var query = SpecialtyCourseDAL.GetTeachingModeTypeQueryble(exp);
- return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList();
- }
- /// <summary>
- /// 查询专业课程对应的授课地点List
- /// </summary>
- /// <param name="specialtyCourseID"></param>
- /// <returns></returns>
- public List<string> GetTeachingPlaceList(Guid? specialtyCourseID)
- {
- //专业课程
- Expression<Func<EM_SpecialtyCourse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.SpecialtyCourseID == specialtyCourseID);
- var query = SpecialtyCourseDAL.GetTeachingPlaceQueryble(exp);
- return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList();
- }
- /// <summary>
- /// 专业课程信息Excel导入
- /// </summary>
- /// <param name="cellheader"></param>
- /// <param name="inCount"></param>
- /// <param name="upCount"></param>
- /// <param name="errdataList"></param>
- /// <param name="errCount"></param>
- /// <param name="sourcePhysicalPath"></param>
- public void SpecialtyCourseImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<SpecialtyCourseView> errdataList, out int? errCount, string sourcePhysicalPath)
- {
- try
- {
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- List<SpecialtyCourseView> errList = new List<SpecialtyCourseView>();
- // 1.1解析文件,存放到一个List集合里
- cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage)
- List<SpecialtyCourseView> enlist = NpoiExcelHelper.ExcelToEntityList<SpecialtyCourseView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- cellheader.Add("ErrorMessage", "未导入原因");
- //对List集合进行有效性校验
- if (enlist.Count() <= 0)
- {
- throw new Exception("Excel文件数据为空,请检查。");
- }
- Regex reg = null; //正则表达式
- //DateTime result; //用于返回判断日期字段格式
- bool isListPass = true; //List判断标识
- inCount = 0; //导入个数
- upCount = 0; //更新个数
- errCount = 0; //失败个数
- string errorMsgStr = ""; //错误信息
- List<EM_SpecialtyCourse> newSpecialtyCourseInList = new List<EM_SpecialtyCourse>();
- List<EM_SpecialtyCourse> newSpecialtyCourseUpList = new List<EM_SpecialtyCourse>();
- List<EM_SpecialtyCourseTeachingSetting> newTeachingSettingInList = new List<EM_SpecialtyCourseTeachingSetting>();
- List<EM_SpecialtyCourseTeachingSetting> newTeachingSettingUpList = new List<EM_SpecialtyCourseTeachingSetting>();
- List<EM_TeachingModeType> newTeachingModeTypeInList = new List<EM_TeachingModeType>();
- List<EMIS.Entities.EM_TeachingPlace> newTeachingPlaceInList = new List<EMIS.Entities.EM_TeachingPlace>();
- List<Guid?> specialtyCourseTMDelList = new List<Guid?>();
- List<Guid?> specialtyCourseTPDelList = new List<Guid?>();
- //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
- //专业代码、专业名称、专业ID(Value)
- var standardList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Standard).ToList();
- //培养层次(所修学历)
- var educationList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Education).ToList();
- //学习形式
- var learningFormList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Learningform).ToList();
- //专业信息
- var specialtyList = SpecialtyCourseDAL.SpecialtyRepository.GetList(x => true).ToList();
- //开课学期
- var starttermList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Startterm).ToList();
- //课程信息
- var courseList = SpecialtyCourseDAL.CoursematerialRepository.GetList(x => true).ToList();
- //课程代码
- var courseCodeList = enlist.Where(x => !string.IsNullOrWhiteSpace(x.CourseCode)).Select(x => x.CourseCode.Trim()).ToList();
- //对比后的newCourseList
- var newCourseList = courseList.Where(x => courseCodeList.Contains(x.CourseCode)).ToList();
- //对比后的coursematerialIDList
- var coursematerialIDList = newCourseList.Select(x => (Guid?)x.CoursematerialID).ToList();
- //课程结构
- var courseStructureList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseStructure).ToList();
- //课程属性
- var courseCategoryList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseCategory).ToList();
- //课程类型
- var courseTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseType).ToList();
- //课程性质
- var courseQualityList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseQuality).ToList();
- //教研室信息
- var departmentList = SpecialtyCourseDAL.DepartmentRepository.GetList(x => true).ToList();
- //开课教研室
- var departmentNameList = enlist.Where(x => !string.IsNullOrWhiteSpace(x.DepartmentName)).Select(x => x.DepartmentName.Trim()).ToList();
- //对比后的newDepartmentList
- var newDepartmentList = departmentList.Where(x => departmentNameList.Contains(x.Name)).ToList();
- //通用是否
- var generalPurposeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_GeneralPurpose).ToList();
- //精品课程
- var courseFineList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseFine).ToList();
- //实践类型
- var practiceTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.EM_PracticeType).ToList();
- //授课语言
- var teachinglanguageList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Teachinglanguage).ToList();
- //考试方式
- var examinationModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ExaminationMode).ToList();
- //成绩类型
- var resultTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ResultType).ToList();
- //处理方式
- var handleModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_HandleMode).ToList();
- //授课方式
- var teachingModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_TeachingMode).ToList();
- //授课地点
- var teachingPlaceList = IdNameExt.GetDictionaryItem(DictionaryItem.EM_TeachingPlace).ToList();
- //专业课程
- var specialtyCourseList = SpecialtyCourseDAL.SpecialtyCourseRepository
- .GetList(x => true, (x => x.EM_SpecialtyCourseTeachingSetting)).ToList();
- //对比后的newSpecialtyCourseList(暂时只对比课程信息ID)
- var newSpecialtyCourseList = specialtyCourseList.Where(x => coursematerialIDList.Contains(x.CoursematerialID)).ToList();
- //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
- for (int i = 0; i < enlist.Count; i++)
- {
- SpecialtyCourseView en = enlist[i]; //Excel表数据视图
- EM_SpecialtyCourse newSpecialtyCourse = new EM_SpecialtyCourse();
- EM_SpecialtyCourseTeachingSetting newTeachingSetting = new EM_SpecialtyCourseTeachingSetting();
- List<int> newModeTypeList = new List<int>();
- List<int> newPlaceList = new List<int>();
- //专业代码
- if (string.IsNullOrWhiteSpace(en.StandardCodeStr))
- {
- errCount++;
- errorMsgStr = "专业代码不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var standard = standardList.Where(x => x.Code == en.StandardCodeStr.Trim()).FirstOrDefault();
- if (standard == null)
- {
- errCount++;
- errorMsgStr = "专业代码不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //专业代码
- }
- }
- //专业名称
- if (string.IsNullOrWhiteSpace(en.StandardNameStr))
- {
- errCount++;
- errorMsgStr = "专业名称不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var standard = standardList.Where(x => x.Name == en.StandardNameStr.Trim()).FirstOrDefault();
- if (standard == null)
- {
- errCount++;
- errorMsgStr = "专业名称不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //专业名称
- }
- }
- //专业代码与专业名称查询专业ID(Value)
- if (string.IsNullOrWhiteSpace(en.StandardCodeStr) || string.IsNullOrWhiteSpace(en.StandardNameStr))
- {
- errCount++;
- errorMsgStr = "专业代码或专业名称不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var standard = standardList.Where(x => x.Code == en.StandardCodeStr.Trim() && x.Name == en.StandardNameStr.Trim()).SingleOrDefault();
- if (standard == null)
- {
- errCount++;
- errorMsgStr = "专业代码与专业名称对应的元素值不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //专业ID(Value)
- en.StandardID = standard.Value;
- }
- }
- //培养层次
- if (string.IsNullOrWhiteSpace(en.EducationStr))
- {
- errCount++;
- errorMsgStr = RSL.Get("EducationID") + "不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var education = educationList.Where(x => x.Name == en.EducationStr.Trim()).SingleOrDefault();
- if (education == null)
- {
- errCount++;
- errorMsgStr = RSL.Get("EducationID") + "不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //培养层次
- en.EducationID = education.Value;
- }
- }
- //学习形式
- if (string.IsNullOrWhiteSpace(en.LearningformStr))
- {
- errCount++;
- errorMsgStr = "学习形式不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var learningForm = learningFormList.Where(x => x.Name == en.LearningformStr.Trim()).SingleOrDefault();
- if (learningForm == null)
- {
- errCount++;
- errorMsgStr = "学习形式不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //学习形式
- en.LearningformID = learningForm.Value;
- }
- }
- //学制
- if (string.IsNullOrWhiteSpace(en.LearnSystemStr))
- {
- errCount++;
- errorMsgStr = "学制不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //学制字段正则表达式(数字)
- if (!reg.IsMatch(en.LearnSystemStr.Trim()))
- {
- errCount++;
- errorMsgStr = "学制格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //学制
- en.LearnSystem = Convert.ToDecimal(en.LearnSystemStr.Trim());
- }
- }
- //查询对应的专业信息ID
- if (en.StandardID.HasValue && en.EducationID.HasValue && en.LearningformID.HasValue && en.LearnSystem.HasValue)
- {
- //查询对应的专业信息
- var specialty = specialtyList.Where(x => x.StandardID == en.StandardID
- && x.EducationID == en.EducationID
- && x.LearningformID == en.LearningformID
- && x.LearnSystem == en.LearnSystem).SingleOrDefault();
- if (specialty == null)
- {
- errCount++;
- errorMsgStr = "对应的专业信息不存在(以专业代码、专业名称、"
- + RSL.Get("EducationID") + "、学习形式、学制查询),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //判断对应的专业信息状态(启用、禁用状态)
- if (specialty.RecordStatus > (int)SYS_STATUS.UNUSABLE)
- {
- newSpecialtyCourse.SpecialtyID = specialty.SpecialtyID;
- }
- else
- {
- newSpecialtyCourse.SpecialtyID = specialty.SpecialtyID;
- errCount++;
- errorMsgStr = "对应的专业信息为禁用状态,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "数据有误,请检查(专业ID(Value)、"
- + RSL.Get("EducationID") + "、学习形式或学制不能为空)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- //开课学期
- if (string.IsNullOrWhiteSpace(en.StarttermStr))
- {
- errCount++;
- errorMsgStr = "开课学期不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var startterm = starttermList.Where(x => x.Name == en.StarttermStr.Trim()).SingleOrDefault();
- if (startterm == null)
- {
- errCount++;
- errorMsgStr = "开课学期不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //对学制和开课学期进行判断
- var maxStartterm = Convert.ToInt32(Math.Ceiling(en.LearnSystem.Value * 2 - 1)) + 1;
- if (startterm.Value > maxStartterm)
- {
- errCount++;
- errorMsgStr = "开课学期超出学制范围,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //开课学期
- newSpecialtyCourse.StarttermID = startterm.Value;
- }
- }
- }
- //课程代码
- if (string.IsNullOrWhiteSpace(en.CourseCode))
- {
- errCount++;
- errorMsgStr = "课程代码不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
- if (!reg.IsMatch(en.CourseCode.Trim()))
- {
- errCount++;
- errorMsgStr = "课程代码格式不正确,请检查(数字或英文字母)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var course = newCourseList.Where(x => x.CourseCode == en.CourseCode.Trim()).SingleOrDefault();
- if (course == null)
- {
- errCount++;
- errorMsgStr = "课程代码不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //判断课程代码与课程名称(以课程代码为准)
- if (string.IsNullOrWhiteSpace(en.CourseName))
- {
- //暂不考虑
- }
- else
- {
- //课程代码与课程名称不对应
- if (course.CourseName.Trim() != en.CourseName.Trim())
- {
- errCount++;
- errorMsgStr = "课程代码与课程名称不对应(以课程代码为准),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- //判断对应的课程信息状态(启用、禁用状态)
- if (course.IsEnable == true)
- {
- //课程信息ID
- newSpecialtyCourse.CoursematerialID = course.CoursematerialID;
- }
- else
- {
- newSpecialtyCourse.CoursematerialID = course.CoursematerialID;
- errCount++;
- errorMsgStr = "对应的课程信息为禁用状态,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- }
- }
- //课程名称
- if (string.IsNullOrWhiteSpace(en.CourseName))
- {
- //暂不考虑
- }
- else
- {
- //暂不考虑
- }
- //课程结构
- if (string.IsNullOrWhiteSpace(en.CourseStructureStr))
- {
- newSpecialtyCourse.CourseStructureID = (int)CF_CourseStructure.ClassroomTeaching;
- }
- else
- {
- var courseStructure = courseStructureList.Where(x => x.Name == en.CourseStructureStr.Trim()).SingleOrDefault();
- if (courseStructure == null)
- {
- errCount++;
- errorMsgStr = "课程结构不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //课程结构
- newSpecialtyCourse.CourseStructureID = courseStructure.Value;
- }
- }
- //课程属性
- if (string.IsNullOrWhiteSpace(en.CourseCategoryStr))
- {
- newSpecialtyCourse.CourseCategoryID = (int)CF_CourseCategory.Publiccourse;
- }
- else
- {
- var courseCategory = courseCategoryList.Where(x => x.Name == en.CourseCategoryStr.Trim()).SingleOrDefault();
- if (courseCategory == null)
- {
- errCount++;
- errorMsgStr = "课程属性不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //课程属性
- newSpecialtyCourse.CourseCategoryID = courseCategory.Value;
- }
- }
- //课程类型
- if (string.IsNullOrWhiteSpace(en.CourseTypeStr))
- {
- errCount++;
- errorMsgStr = "课程类型不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var courseType = courseTypeList.Where(x => x.Name == en.CourseTypeStr.Trim()).SingleOrDefault();
- if (courseType == null)
- {
- errCount++;
- errorMsgStr = "课程类型不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //课程类型
- newSpecialtyCourse.CourseTypeID = courseType.Value;
- }
- }
- //课程性质
- if (string.IsNullOrWhiteSpace(en.CourseQualityStr))
- {
- newSpecialtyCourse.CourseQualityID = (int)CF_CourseQuality.Required;
- }
- else
- {
- var courseQuality = courseQualityList.Where(x => x.Name == en.CourseQualityStr.Trim()).SingleOrDefault();
- if (courseQuality == null)
- {
- errCount++;
- errorMsgStr = "课程性质不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //课程性质
- newSpecialtyCourse.CourseQualityID = courseQuality.Value;
- }
- }
- //课程学分
- if (string.IsNullOrWhiteSpace(en.CreditStr))
- {
- errCount++;
- errorMsgStr = "课程学分不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //课程学分字段正则表达式(数字)
- if (!reg.IsMatch(en.CreditStr.Trim()))
- {
- errCount++;
- errorMsgStr = "课程学分格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //课程学分
- newTeachingSetting.Credit = Convert.ToDecimal(en.CreditStr.Trim());
- }
- }
- //理论学时
- if (string.IsNullOrWhiteSpace(en.TheoryCourseStr))
- {
- errCount++;
- errorMsgStr = "理论学时不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
- if (!reg.IsMatch(en.TheoryCourseStr.Trim()))
- {
- errCount++;
- errorMsgStr = "理论学时格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //理论学时
- newTeachingSetting.TheoryCourse = Convert.ToInt32(en.TheoryCourseStr.Trim());
- }
- }
- //实践学时
- if (string.IsNullOrWhiteSpace(en.PracticehoursStr))
- {
- //默认为0
- newTeachingSetting.Practicehours = 0;
- }
- else
- {
- reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
- if (!reg.IsMatch(en.PracticehoursStr.Trim()))
- {
- errCount++;
- errorMsgStr = "实践学时格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //实践学时
- newTeachingSetting.Practicehours = Convert.ToInt32(en.PracticehoursStr.Trim());
- }
- }
- //实验学时
- if (string.IsNullOrWhiteSpace(en.TrialhoursStr))
- {
- //默认为0
- newTeachingSetting.Trialhours = 0;
- }
- else
- {
- reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
- if (!reg.IsMatch(en.TrialhoursStr.Trim()))
- {
- errCount++;
- errorMsgStr = "实验学时格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //实验学时
- newTeachingSetting.Trialhours = Convert.ToInt32(en.TrialhoursStr.Trim());
- }
- }
- //开课教研室
- if (string.IsNullOrWhiteSpace(en.DepartmentName))
- {
- errCount++;
- errorMsgStr = "开课教研室不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var department = newDepartmentList.Where(x => x.Name == en.DepartmentName.Trim()).SingleOrDefault();
- if (department == null)
- {
- errCount++;
- errorMsgStr = "开课教研室不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //开课教研室ID
- newSpecialtyCourse.DepartmentID = department.DepartmentID;
- }
- }
- //是否专业核心
- if (string.IsNullOrWhiteSpace(en.IsSpecialtycoreStr))
- {
- //是否专业核心(默认为否)
- newSpecialtyCourse.IsSpecialtycore = false;
- }
- else
- {
- var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsSpecialtycoreStr.Trim()).SingleOrDefault();
- if (generalPurpose == null)
- {
- errCount++;
- errorMsgStr = "是否专业核心不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //是否专业核心
- newSpecialtyCourse.IsSpecialtycore = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
- }
- }
- //是否合作开发
- if (string.IsNullOrWhiteSpace(en.IsCooperationStr))
- {
- //是否合作开发(默认为否)
- newSpecialtyCourse.IsCooperation = false;
- }
- else
- {
- var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsCooperationStr.Trim()).SingleOrDefault();
- if (generalPurpose == null)
- {
- errCount++;
- errorMsgStr = "是否合作开发不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //是否合作开发
- newSpecialtyCourse.IsCooperation = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
- }
- }
- //是否必修课
- if (string.IsNullOrWhiteSpace(en.IsRequiredStr))
- {
- //是否必修课(默认为否)
- newSpecialtyCourse.IsRequired = false;
- }
- else
- {
- var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsRequiredStr.Trim()).SingleOrDefault();
- if (generalPurpose == null)
- {
- errCount++;
- errorMsgStr = RSL.Get("IsRequired") + "不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //是否必修课
- newSpecialtyCourse.IsRequired = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
- }
- }
- //是否网上选修
- if (string.IsNullOrWhiteSpace(en.IsElectiveStr))
- {
- //是否网上选修(默认为否)
- newSpecialtyCourse.IsElective = false;
- }
- else
- {
- var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsElectiveStr.Trim()).SingleOrDefault();
- if (generalPurpose == null)
- {
- errCount++;
- errorMsgStr = "是否网上选修不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //是否网上选修
- newSpecialtyCourse.IsElective = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
- }
- }
- //是否网络课程
- if (string.IsNullOrWhiteSpace(en.IsNetworkCourseStr))
- {
- //是否网络课程(默认为否)
- newSpecialtyCourse.IsNetworkCourse = false;
- }
- else
- {
- var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsNetworkCourseStr.Trim()).SingleOrDefault();
- if (generalPurpose == null)
- {
- errCount++;
- errorMsgStr = "是否网络课程不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //是否网络课程
- newSpecialtyCourse.IsNetworkCourse = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
- }
- }
- //是否学位课程
- if (string.IsNullOrWhiteSpace(en.IsMainCourseStr))
- {
- //是否学位课程(默认为否)
- newSpecialtyCourse.IsMainCourse = false;
- }
- else
- {
- var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsMainCourseStr.Trim()).SingleOrDefault();
- if (generalPurpose == null)
- {
- errCount++;
- errorMsgStr = "是否学位课程不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //是否学位课程
- newSpecialtyCourse.IsMainCourse = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
- }
- }
- //是否需要教材
- if (string.IsNullOrWhiteSpace(en.IsNeedMaterialStr))
- {
- //是否需要教材(默认为是)
- newSpecialtyCourse.IsNeedMaterial = true;
- }
- else
- {
- var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsNeedMaterialStr.Trim()).SingleOrDefault();
- if (generalPurpose == null)
- {
- errCount++;
- errorMsgStr = "是否需要教材不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //是否需要教材
- newSpecialtyCourse.IsNeedMaterial = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
- }
- }
- //精品课程
- if (string.IsNullOrWhiteSpace(en.CourseFineStr))
- {
- newSpecialtyCourse.CourseFineID = (int)CF_CourseFine.No;
- }
- else
- {
- var courseFine = courseFineList.Where(x => x.Name == en.CourseFineStr.Trim()).SingleOrDefault();
- if (courseFine == null)
- {
- errCount++;
- errorMsgStr = "精品课程不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //精品课程
- newSpecialtyCourse.CourseFineID = courseFine.Value;
- }
- }
- //实践类型
- if (string.IsNullOrWhiteSpace(en.PracticeTypeStr))
- {
- //不考虑
- }
- else
- {
- var practiceType = practiceTypeList.Where(x => x.Name == en.PracticeTypeStr.Trim()).SingleOrDefault();
- if (practiceType == null)
- {
- errCount++;
- errorMsgStr = "实践类型不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //实践类型
- newSpecialtyCourse.PracticeTypeID = practiceType.Value;
- }
- }
- //授课语言
- if (string.IsNullOrWhiteSpace(en.TeachinglanguageStr))
- {
- newSpecialtyCourse.TeachinglanguageID = (int)CF_Teachinglanguage.Chinese;
- }
- else
- {
- var teachinglanguage = teachinglanguageList.Where(x => x.Name == en.TeachinglanguageStr.Trim()).SingleOrDefault();
- if (teachinglanguage == null)
- {
- errCount++;
- errorMsgStr = "授课语言不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //授课语言
- newSpecialtyCourse.TeachinglanguageID = teachinglanguage.Value;
- }
- }
- //考试方式
- if (string.IsNullOrWhiteSpace(en.ExaminationModeStr))
- {
- newSpecialtyCourse.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam;
- }
- else
- {
- var examinationMode = examinationModeList.Where(x => x.Name == en.ExaminationModeStr.Trim()).SingleOrDefault();
- if (examinationMode == null)
- {
- errCount++;
- errorMsgStr = "考试方式不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //考试方式
- newSpecialtyCourse.ExaminationModeID = examinationMode.Value;
- }
- }
- //成绩类型
- if (string.IsNullOrWhiteSpace(en.ResultTypeStr))
- {
- //默认为百分制
- newSpecialtyCourse.ResultTypeID = (int)CF_ResultType.Percentage;
- }
- else
- {
- var resultType = resultTypeList.Where(x => x.Name == en.ResultTypeStr.Trim()).SingleOrDefault();
- if (resultType == null)
- {
- errCount++;
- errorMsgStr = "成绩类型不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //成绩类型
- newSpecialtyCourse.ResultTypeID = resultType.Value;
- }
- }
- //处理方式
- if (string.IsNullOrWhiteSpace(en.HandleModeStr))
- {
- //默认为必修课
- newSpecialtyCourse.HandleModeID = (int)CF_HandleMode.RequiredCourse;
- }
- else
- {
- var handleMode = handleModeList.Where(x => x.Name == en.HandleModeStr.Trim()).SingleOrDefault();
- if (handleMode == null)
- {
- errCount++;
- errorMsgStr = "处理方式不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //处理方式
- newSpecialtyCourse.HandleModeID = handleMode.Value;
- }
- }
- //授课方式
- if (string.IsNullOrEmpty(en.TeachingModeIDListStr))
- {
- newModeTypeList.Add((int)CF_TeachingMode.Theory);
- }
- else
- {
- //授课方式可为多个(可用顿号隔开)
- List<string> list = en.TeachingModeIDListStr.Split('、').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => x.Trim()).Distinct().ToList();
- foreach (var item in list)
- {
- var teachingMode = teachingModeList.Where(x => x.Name == item.Trim()).SingleOrDefault();
- if (teachingMode == null)
- {
- errCount++;
- errorMsgStr = "授课方式(" + item.Trim() + ")不存在,请检查(存在多个授课方式时,可用顿号隔开)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- isListPass = false;
- break;
- }
- }
- if (isListPass)
- {
- newModeTypeList = teachingModeList.Where(x => list.Contains(x.Name))
- .Select(x => x.Value.Value).ToList();
- }
- else
- {
- isListPass = true;
- continue;
- }
- }
- //授课地点
- if (string.IsNullOrEmpty(en.TeachingPlaceIDListStr))
- {
- newPlaceList.Add((int)EMIS.ViewModel.EM_TeachingPlace.Multimedia);
- }
- else
- {
- //授课地点可为多个(可用顿号隔开)
- List<string> list = en.TeachingPlaceIDListStr.Split('、').Where(x => !string.IsNullOrEmpty(x))
- .Select(x => x.Trim()).Distinct().ToList();
- foreach (var item in list)
- {
- var teachingPlace = teachingPlaceList.Where(x => x.Name == item.Trim()).SingleOrDefault();
- if (teachingPlace == null)
- {
- errCount++;
- errorMsgStr = "授课地点(" + item.Trim() + ")不存在,请检查(存在多个授课地点时,可用顿号隔开)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- isListPass = false;
- break;
- }
- }
- if (isListPass)
- {
- newPlaceList = teachingPlaceList.Where(x => list.Contains(x.Name))
- .Select(x => x.Value.Value).ToList();
- }
- else
- {
- isListPass = true;
- continue;
- }
- }
- //是否启用(默认为是)
- newSpecialtyCourse.IsEnable = true;
- //备注
- if (string.IsNullOrWhiteSpace(en.Remark))
- {
- //不考虑
- }
- else
- {
- newSpecialtyCourse.Remark = en.Remark;
- }
- ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
- //for (int j = i + 1; j < enlist.Count; j++)
- //{
- // SpecialtyCourseView enA = enlist[j];
- // //根据Excel表中的业务主键进行去重(专业信息ID、开课学期、课程信息ID唯一)
- // if (en.No == enA.No && en.Name == enA.Name)
- // {
- // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
- // }
- //}
- //数据表重复性验证(专业信息ID、开课学期、课程信息ID唯一)
- var specialtyCourseVerify = newSpecialtyCourseList.Where(x => x.SpecialtyID == newSpecialtyCourse.SpecialtyID
- && x.StarttermID == newSpecialtyCourse.StarttermID
- && x.CoursematerialID == newSpecialtyCourse.CoursematerialID).SingleOrDefault();
- if (specialtyCourseVerify == null)
- {
- //新增
- if (!newSpecialtyCourseInList.Any(x => x.SpecialtyID == newSpecialtyCourse.SpecialtyID
- && x.StarttermID == newSpecialtyCourse.StarttermID
- && x.CoursematerialID == newSpecialtyCourse.CoursematerialID))
- {
- newSpecialtyCourse.SpecialtyCourseID = Guid.NewGuid();
- SetNewStatus(newSpecialtyCourse);
- newSpecialtyCourseInList.Add(newSpecialtyCourse);
- newTeachingSetting.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
- newTeachingSetting.TheoryWeeklyNum = 0;
- newTeachingSetting.PracticeWeeklyNum = 0;
- newTeachingSetting.TrialWeeklyNum = 0;
- newTeachingSetting.WeeklyHours = 0;
- newTeachingSetting.WeeklyNum = 0;
- newTeachingSetting.StartWeeklyNum = 1;
- newTeachingSetting.EndWeeklyNum = 18;
- newTeachingSettingInList.Add(newTeachingSetting);
- if (newModeTypeList != null && newModeTypeList.Count() > 0)
- {
- foreach (var newModeTypeID in newModeTypeList)
- {
- var newTeachingModeType = new EM_TeachingModeType();
- newTeachingModeType.TeachingModeTypeID = Guid.NewGuid();
- newTeachingModeType.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
- newTeachingModeType.TeachingModeID = newModeTypeID;
- this.SetNewStatus(newTeachingModeType);
- newTeachingModeTypeInList.Add(newTeachingModeType);
- }
- }
- if (newPlaceList != null && newPlaceList.Count() > 0)
- {
- foreach (var newPlaceID in newPlaceList)
- {
- var newTeachingPlace = new EMIS.Entities.EM_TeachingPlace();
- newTeachingPlace.TeachingPlaceID = Guid.NewGuid();
- newTeachingPlace.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
- newTeachingPlace.TeachingPlace = newPlaceID;
- this.SetNewStatus(newTeachingPlace);
- newTeachingPlaceInList.Add(newTeachingPlace);
- }
- }
- inCount++;
- }
- else
- {
- //Excel表重复性验证
- //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中,目前暂不考虑)
- inCount++;
- }
- }
- else
- {
- //更新(Excel有重复时,以最后一条记录的更新为准)
- specialtyCourseVerify.CourseStructureID = newSpecialtyCourse.CourseStructureID;
- specialtyCourseVerify.CourseCategoryID = newSpecialtyCourse.CourseCategoryID;
- specialtyCourseVerify.CourseTypeID = newSpecialtyCourse.CourseTypeID;
- specialtyCourseVerify.CourseQualityID = newSpecialtyCourse.CourseQualityID;
- specialtyCourseVerify.DepartmentID = newSpecialtyCourse.DepartmentID;
- specialtyCourseVerify.IsSpecialtycore = newSpecialtyCourse.IsSpecialtycore;
- specialtyCourseVerify.IsCooperation = newSpecialtyCourse.IsCooperation;
- specialtyCourseVerify.IsRequired = newSpecialtyCourse.IsRequired;
- specialtyCourseVerify.IsElective = newSpecialtyCourse.IsElective;
- specialtyCourseVerify.IsNetworkCourse = newSpecialtyCourse.IsNetworkCourse;
- specialtyCourseVerify.IsMainCourse = newSpecialtyCourse.IsMainCourse;
- specialtyCourseVerify.IsNeedMaterial = newSpecialtyCourse.IsNeedMaterial;
- specialtyCourseVerify.CourseFineID = newSpecialtyCourse.CourseFineID;
- specialtyCourseVerify.PracticeTypeID = newSpecialtyCourse.PracticeTypeID;
- specialtyCourseVerify.TeachinglanguageID = newSpecialtyCourse.TeachinglanguageID;
- specialtyCourseVerify.ExaminationModeID = newSpecialtyCourse.ExaminationModeID;
- specialtyCourseVerify.ResultTypeID = newSpecialtyCourse.ResultTypeID;
- specialtyCourseVerify.HandleModeID = newSpecialtyCourse.HandleModeID;
- //specialtyCourseVerify.IsEnable = newSpecialtyCourse.IsEnable;
- specialtyCourseVerify.Remark = newSpecialtyCourse.Remark;
- SetModifyStatus(specialtyCourseVerify);
- newSpecialtyCourseUpList.Add(specialtyCourseVerify);
- if (specialtyCourseVerify.EM_SpecialtyCourseTeachingSetting == null)
- {
- if (newTeachingSettingInList.Any(x => x.SpecialtyCourseID == specialtyCourseVerify.SpecialtyCourseID))
- {
- newTeachingSettingInList.RemoveAll(x => x.SpecialtyCourseID == specialtyCourseVerify.SpecialtyCourseID);
- }
- newTeachingSetting.SpecialtyCourseID = specialtyCourseVerify.SpecialtyCourseID;
- newTeachingSetting.TheoryWeeklyNum = 0;
- newTeachingSetting.PracticeWeeklyNum = 0;
- newTeachingSetting.TrialWeeklyNum = 0;
- newTeachingSetting.WeeklyHours = 0;
- newTeachingSetting.WeeklyNum = 0;
- newTeachingSetting.StartWeeklyNum = 1;
- newTeachingSetting.EndWeeklyNum = 16;
- newTeachingSettingInList.Add(newTeachingSetting);
- }
- else
- {
- specialtyCourseVerify.EM_SpecialtyCourseTeachingSetting.Credit = newTeachingSetting.Credit;
- specialtyCourseVerify.EM_SpecialtyCourseTeachingSetting.TheoryCourse = newTeachingSetting.TheoryCourse;
- specialtyCourseVerify.EM_SpecialtyCourseTeachingSetting.Practicehours = newTeachingSetting.Practicehours;
- specialtyCourseVerify.EM_SpecialtyCourseTeachingSetting.Trialhours = newTeachingSetting.Trialhours;
- newTeachingSettingUpList.Add(specialtyCourseVerify.EM_SpecialtyCourseTeachingSetting);
- }
- if (newModeTypeList != null && newModeTypeList.Count() > 0)
- {
- if (newTeachingModeTypeInList.Any(x => x.SpecialtyCourseID == specialtyCourseVerify.SpecialtyCourseID))
- {
- newTeachingModeTypeInList.RemoveAll(x => x.SpecialtyCourseID == specialtyCourseVerify.SpecialtyCourseID);
- }
- specialtyCourseTMDelList.Add(specialtyCourseVerify.SpecialtyCourseID);
- foreach (var newModeTypeID in newModeTypeList)
- {
- var newTeachingModeType = new EM_TeachingModeType();
- newTeachingModeType.TeachingModeTypeID = Guid.NewGuid();
- newTeachingModeType.SpecialtyCourseID = specialtyCourseVerify.SpecialtyCourseID;
- newTeachingModeType.TeachingModeID = newModeTypeID;
- this.SetNewStatus(newTeachingModeType);
- newTeachingModeTypeInList.Add(newTeachingModeType);
- }
- }
- else
- {
- specialtyCourseTMDelList.Add(specialtyCourseVerify.SpecialtyCourseID);
- }
- if (newPlaceList != null && newPlaceList.Count() > 0)
- {
- if (newTeachingPlaceInList.Any(x => x.SpecialtyCourseID == specialtyCourseVerify.SpecialtyCourseID))
- {
- newTeachingPlaceInList.RemoveAll(x => x.SpecialtyCourseID == specialtyCourseVerify.SpecialtyCourseID);
- }
- specialtyCourseTPDelList.Add(specialtyCourseVerify.SpecialtyCourseID);
- foreach (var newPlace in newPlaceList)
- {
- var newTeachingPlace = new EMIS.Entities.EM_TeachingPlace();
- newTeachingPlace.TeachingPlaceID = Guid.NewGuid();
- newTeachingPlace.SpecialtyCourseID = specialtyCourseVerify.SpecialtyCourseID;
- newTeachingPlace.TeachingPlace = newPlace;
- this.SetNewStatus(newTeachingPlace);
- newTeachingPlaceInList.Add(newTeachingPlace);
- }
- }
- else
- {
- specialtyCourseTPDelList.Add(specialtyCourseVerify.SpecialtyCourseID);
- }
- upCount++;
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- //删除
- UnitOfWork.Delete<EMIS.Entities.EM_TeachingPlace>(x => specialtyCourseTPDelList.Contains(x.SpecialtyCourseID));
- UnitOfWork.Delete<EM_TeachingModeType>(x => specialtyCourseTMDelList.Contains(x.SpecialtyCourseID));
- //批量插入
- UnitOfWork.BulkInsert(newSpecialtyCourseInList);
- UnitOfWork.BulkInsert(newTeachingSettingInList);
- UnitOfWork.BulkInsert(newTeachingModeTypeInList);
- UnitOfWork.BulkInsert(newTeachingPlaceInList);
- //批量统一提交更新
- if (newSpecialtyCourseUpList != null && newSpecialtyCourseUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newSpecialtyCourseUpList);
- }
- //批量统一提交更新
- if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newTeachingSettingUpList);
- }
- ts.Complete();
- }
- errdataList = errList.Distinct().ToList(); //错误列表List
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|