AdultSpecialtyPlanServices.cs 231 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Linq.Expressions;
  7. using System.Transactions;
  8. using Bowin.Common.Utility;
  9. using Bowin.Common.Linq;
  10. using Bowin.Common.Linq.Entity;
  11. using EMIS.Utility;
  12. using EMIS.Entities;
  13. using EMIS.ViewModel;
  14. using EMIS.ViewModel.CacheManage;
  15. using EMIS.ViewModel.CultureplanManage;
  16. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  17. using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
  18. using EMIS.ViewModel.Students;
  19. using EMIS.DataLogic.CultureplanManage.PlanManagement;
  20. using EMIS.DataLogic.EducationManage;
  21. using EMIS.CommonLogic.StudentManage.StudentStatistics;
  22. namespace EMIS.CommonLogic.CultureplanManage.PlanManagement
  23. {
  24. public class AdultSpecialtyPlanServices : BaseServices, IAdultSpecialtyPlanServices
  25. {
  26. public SpecialtyPlanDAL SpecialtyPlanDAL { get; set; }
  27. public ExecutablePlanDAL ExecutablePlanDAL { get; set; }
  28. public Lazy<IInSchoolSettingServices> InSchoolSettingServices { get; set; }
  29. /// <summary>
  30. /// 查询对应的专业计划信息SpecialtyPlanView
  31. /// 注:成教版本(入学学年学期、专业信息)
  32. /// </summary>
  33. /// <param name="configuretView"></param>
  34. /// <param name="schoolyearID"></param>
  35. /// <param name="departmentID"></param>
  36. /// <param name="yearID"></param>
  37. /// <param name="standardID"></param>
  38. /// <param name="educationID"></param>
  39. /// <param name="learningformID"></param>
  40. /// <param name="learnSystem"></param>
  41. /// <param name="coursematerialID"></param>
  42. /// <param name="courseTypeID"></param>
  43. /// <param name="isMainCourse"></param>
  44. /// <param name="teachingModeID"></param>
  45. /// <param name="handleModeID"></param>
  46. /// <param name="pageIndex"></param>
  47. /// <param name="pageSize"></param>
  48. /// <returns></returns>
  49. public IGridResultSet<SpecialtyPlanView> GetAdultSpecialtyPlanViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? departmentID,
  50. int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID,
  51. int? courseTypeID, int? isMainCourse, int? teachingModeID, int? handleModeID, int pageIndex, int pageSize)
  52. {
  53. //专业计划
  54. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  55. if (schoolyearID.HasValue)
  56. {
  57. expSpecialtyPlan = expSpecialtyPlan.And(x => x.SchoolyearID == schoolyearID);
  58. }
  59. if (departmentID.HasValue)
  60. {
  61. expSpecialtyPlan = expSpecialtyPlan.And(x => x.DepartmentID == departmentID);
  62. }
  63. if (coursematerialID.HasValue)
  64. {
  65. expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID);
  66. }
  67. if (courseTypeID.HasValue)
  68. {
  69. expSpecialtyPlan = expSpecialtyPlan.And(x => x.CourseTypeID == courseTypeID);
  70. }
  71. if (isMainCourse.HasValue)
  72. {
  73. //是否学位课程
  74. if (isMainCourse == (int)CF_GeneralPurpose.IsYes)
  75. {
  76. expSpecialtyPlan = expSpecialtyPlan.And(x => x.IsMainCourse == true);
  77. }
  78. if (isMainCourse == (int)CF_GeneralPurpose.IsNo)
  79. {
  80. expSpecialtyPlan = expSpecialtyPlan.And(x => x.IsMainCourse != true);
  81. }
  82. }
  83. if (handleModeID.HasValue)
  84. {
  85. expSpecialtyPlan = expSpecialtyPlan.And(x => x.HandleModeID == handleModeID);
  86. }
  87. //学生信息
  88. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  89. var query = SpecialtyPlanDAL.GetAdultSpecialtyPlanViewQueryable(expSpecialtyPlan, expStudent);
  90. if (yearID.HasValue)
  91. {
  92. query = query.Where(x => x.GradeID == yearID);
  93. }
  94. if (standardID.HasValue)
  95. {
  96. query = query.Where(x => x.StandardID == standardID);
  97. }
  98. if (educationID.HasValue)
  99. {
  100. query = query.Where(x => x.EducationID == educationID);
  101. }
  102. if (learningformID.HasValue)
  103. {
  104. query = query.Where(x => x.LearningformID == learningformID);
  105. }
  106. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  107. {
  108. var LearnSystems = Convert.ToDecimal(learnSystem);
  109. query = query.Where(x => x.LearnSystem == LearnSystems);
  110. }
  111. if (teachingModeID.HasValue)
  112. {
  113. //授课方式
  114. query = query.Where(x => x.TeachingModeIDList.Contains(teachingModeID));
  115. }
  116. //查询条件
  117. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  118. {
  119. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  120. }
  121. return this.GetQueryByDataRangeByCollege(query)
  122. .OrderBy(x => x.GradeID).ThenBy(x => x.StandardID)
  123. .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID)
  124. .ThenBy(x => x.LearnSystem).ThenBy(x => x.Value)
  125. .ThenBy(x => x.CourseTypeID).ThenBy(x => x.CourseCode.Length)
  126. .ThenBy(x => x.CourseCode)
  127. .ToGridResultSet<SpecialtyPlanView>(pageIndex, pageSize);
  128. }
  129. /// <summary>
  130. /// 查询对应的专业计划信息List
  131. /// 注:成教版本(入学学年学期、专业信息)
  132. /// </summary>
  133. /// <param name="configuretView"></param>
  134. /// <param name="schoolyearID"></param>
  135. /// <param name="departmentID"></param>
  136. /// <param name="yearID"></param>
  137. /// <param name="standardID"></param>
  138. /// <param name="educationID"></param>
  139. /// <param name="learningformID"></param>
  140. /// <param name="learnSystem"></param>
  141. /// <param name="coursematerialID"></param>
  142. /// <param name="courseTypeID"></param>
  143. /// <param name="isMainCourse"></param>
  144. /// <param name="teachingModeID"></param>
  145. /// <param name="handleModeID"></param>
  146. /// <returns></returns>
  147. public IList<SpecialtyPlanView> GetAdultSpecialtyPlanViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? departmentID,
  148. int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID,
  149. int? courseTypeID, int? isMainCourse, int? teachingModeID, int? handleModeID)
  150. {
  151. //专业计划
  152. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  153. if (schoolyearID.HasValue)
  154. {
  155. expSpecialtyPlan = expSpecialtyPlan.And(x => x.SchoolyearID == schoolyearID);
  156. }
  157. if (departmentID.HasValue)
  158. {
  159. expSpecialtyPlan = expSpecialtyPlan.And(x => x.DepartmentID == departmentID);
  160. }
  161. if (coursematerialID.HasValue)
  162. {
  163. expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID);
  164. }
  165. if (courseTypeID.HasValue)
  166. {
  167. expSpecialtyPlan = expSpecialtyPlan.And(x => x.CourseTypeID == courseTypeID);
  168. }
  169. if (isMainCourse.HasValue)
  170. {
  171. //是否学位课程
  172. if (isMainCourse == (int)CF_GeneralPurpose.IsYes)
  173. {
  174. expSpecialtyPlan = expSpecialtyPlan.And(x => x.IsMainCourse == true);
  175. }
  176. if (isMainCourse == (int)CF_GeneralPurpose.IsNo)
  177. {
  178. expSpecialtyPlan = expSpecialtyPlan.And(x => x.IsMainCourse != true);
  179. }
  180. }
  181. if (handleModeID.HasValue)
  182. {
  183. expSpecialtyPlan = expSpecialtyPlan.And(x => x.HandleModeID == handleModeID);
  184. }
  185. //学生信息
  186. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  187. var query = SpecialtyPlanDAL.GetAdultSpecialtyPlanViewQueryable(expSpecialtyPlan, expStudent);
  188. if (yearID.HasValue)
  189. {
  190. query = query.Where(x => x.GradeID == yearID);
  191. }
  192. if (standardID.HasValue)
  193. {
  194. query = query.Where(x => x.StandardID == standardID);
  195. }
  196. if (educationID.HasValue)
  197. {
  198. query = query.Where(x => x.EducationID == educationID);
  199. }
  200. if (learningformID.HasValue)
  201. {
  202. query = query.Where(x => x.LearningformID == learningformID);
  203. }
  204. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  205. {
  206. var LearnSystems = Convert.ToDecimal(learnSystem);
  207. query = query.Where(x => x.LearnSystem == LearnSystems);
  208. }
  209. if (teachingModeID.HasValue)
  210. {
  211. //授课方式
  212. query = query.Where(x => x.TeachingModeIDList.Contains(teachingModeID));
  213. }
  214. //查询条件
  215. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  216. {
  217. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  218. }
  219. return this.GetQueryByDataRangeByCollege(query)
  220. .OrderBy(x => x.GradeID).ThenBy(x => x.StandardID)
  221. .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID)
  222. .ThenBy(x => x.LearnSystem).ThenBy(x => x.Value)
  223. .ThenBy(x => x.CourseTypeID).ThenBy(x => x.CourseCode.Length)
  224. .ThenBy(x => x.CourseCode).ToList();
  225. }
  226. /// <summary>
  227. /// 查询对应的专业计划信息SpecialtyPlanView(根据专业计划ID)
  228. /// </summary>
  229. /// <param name="specialtyPlanID"></param>
  230. /// <returns></returns>
  231. public SpecialtyPlanView GetAdultSpecialtyPlanView(Guid? specialtyPlanID)
  232. {
  233. try
  234. {
  235. var specialtyPlanView = SpecialtyPlanDAL.GetAdultSpecialtyPlanViewQueryable(x => x.SpecialtyPlanID == specialtyPlanID).SingleOrDefault();
  236. return specialtyPlanView;
  237. }
  238. catch (Exception ex)
  239. {
  240. throw new Exception(ex.Message);
  241. }
  242. }
  243. /// <summary>
  244. /// 编辑(新增、修改,业务主键:学年学期ID、入学学年学期ID、专业信息ID、课程信息ID)
  245. /// 注:刷新相关的执行计划信息
  246. /// </summary>
  247. /// <param name="specialtyPlanView"></param>
  248. public void AdultSpecialtyPlanEdit(SpecialtyPlanView specialtyPlanView)
  249. {
  250. try
  251. {
  252. //查询对应的专业信息
  253. var specialty = SpecialtyPlanDAL.SpecialtyRepository
  254. .GetList(x => x.SpecialtyID == specialtyPlanView.SpecialtyID).SingleOrDefault();
  255. if (specialty == null)
  256. {
  257. throw new Exception("专业信息不存在,请检查。");
  258. }
  259. //查询学年学期信息schoolyearList
  260. var schoolyearList = SpecialtyPlanDAL.SchoolyearRepository
  261. .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  262. //查询对应的入学学年学期信息
  263. var startSchoolyear = schoolyearList.Where(x => x.Years == specialtyPlanView.GradeID
  264. && x.SchoolcodeID == specialtyPlanView.StartSchoolcodeID).SingleOrDefault();
  265. if (startSchoolyear == null)
  266. {
  267. throw new Exception("入学学期、年级对应的入学学年学期信息不存在,请检查。");
  268. }
  269. //查询对应的毕业学年学期信息(根据入学学期、年级和专业信息对应的学制计算)
  270. var graduateSchoolyearValue = (specialtyPlanView.GradeID.Value * 2) - 1
  271. + (specialtyPlanView.StartSchoolcodeID.Value - 1);
  272. graduateSchoolyearValue += Convert.ToInt32(Math.Ceiling(specialty.LearnSystem.Value * 2 - 1));
  273. var graduatingSemester = schoolyearList.Where(x => x.Value == graduateSchoolyearValue).SingleOrDefault();
  274. if (graduatingSemester == null)
  275. {
  276. throw new Exception("入学学期、年级和专业信息对应的毕业学年学期信息不存在,请检查。");
  277. }
  278. //查询对应的学年学期信息
  279. var schoolyear = schoolyearList.Where(x => x.SchoolyearID == specialtyPlanView.SchoolyearID).SingleOrDefault();
  280. if (schoolyear == null)
  281. {
  282. throw new Exception("学年学期信息不存在,请检查。");
  283. }
  284. if (schoolyear.Value < startSchoolyear.Value)
  285. {
  286. throw new Exception("学年学期小于入学学年学期,请检查。");
  287. }
  288. if (schoolyear.Value > graduatingSemester.Value)
  289. {
  290. throw new Exception("学年学期大于毕业学年学期,请检查。");
  291. }
  292. //查询数据库进行验证
  293. var specialtyPlanVerify = SpecialtyPlanDAL.SpecialtyPlanRepository
  294. .GetList(x => x.SpecialtyPlanID != specialtyPlanView.SpecialtyPlanID
  295. && x.SchoolyearID == specialtyPlanView.SchoolyearID
  296. && x.StartSchoolyearID == startSchoolyear.SchoolyearID
  297. && x.SpecialtyID == specialty.SpecialtyID
  298. && x.CoursematerialID == specialtyPlanView.CoursematerialID).SingleOrDefault();
  299. if (specialtyPlanVerify == null)
  300. {
  301. //学年学期
  302. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  303. expSchoolyear = expSchoolyear.And(x => x.Years == specialtyPlanView.GradeID);
  304. expSchoolyear = expSchoolyear.And(x => x.SchoolcodeID == specialtyPlanView.StartSchoolcodeID);
  305. //专业信息
  306. Expression<Func<CF_Specialty, bool>> expSpecialty = (x => x.RecordStatus >= (int)SYS_STATUS.UNUSABLE);
  307. expSpecialty = expSpecialty.And(x => x.SpecialtyID == specialtyPlanView.SpecialtyID);
  308. //查询对应的年级专业信息grademajorViewList
  309. var grademajorViewList = SpecialtyPlanDAL.GetAdultGrademajorViewQueryable(expSchoolyear, expSpecialty).ToList();
  310. List<EM_SpecialtyPlan> newSpecialtyPlanInList = new List<EM_SpecialtyPlan>();
  311. List<EM_SpecialtyPlan> newSpecialtyPlanUpList = new List<EM_SpecialtyPlan>();
  312. List<EM_SpecialtyPlanTeachingSetting> newSPTeachingSettingInList = new List<EM_SpecialtyPlanTeachingSetting>();
  313. List<EM_SpecialtyPlanTeachingSetting> newSPTeachingSettingUpList = new List<EM_SpecialtyPlanTeachingSetting>();
  314. List<EM_SpecialtyPlanTeachingModeType> newSPTeachingModeTypeInList = new List<EM_SpecialtyPlanTeachingModeType>();
  315. List<EM_SpecialtyPlanTeachingPlace> newSPTeachingPlaceInList = new List<EM_SpecialtyPlanTeachingPlace>();
  316. List<Guid?> specialtyPlanTMDelList = new List<Guid?>();
  317. List<Guid?> specialtyPlanTPDelList = new List<Guid?>();
  318. List<EM_ExecutablePlan> newExecutablePlanUpList = new List<EM_ExecutablePlan>();
  319. List<EM_ExecutablePlanProfile> newProfileInList = new List<EM_ExecutablePlanProfile>();
  320. List<EM_ExecutablePlanProfile> newProfileUpList = new List<EM_ExecutablePlanProfile>();
  321. List<EM_ExecutablePlanTeachingSetting> newEPTeachingSettingInList = new List<EM_ExecutablePlanTeachingSetting>();
  322. List<EM_ExecutablePlanTeachingSetting> newEPTeachingSettingUpList = new List<EM_ExecutablePlanTeachingSetting>();
  323. List<EM_ExecutablePlanTeachingModeType> newEPTeachingModeTypeInList = new List<EM_ExecutablePlanTeachingModeType>();
  324. List<EM_ExecutablePlanTeachingPlace> newEPTeachingPlaceInList = new List<EM_ExecutablePlanTeachingPlace>();
  325. List<Guid?> executablePlanTMDelList = new List<Guid?>();
  326. List<Guid?> executablePlanTPDelList = new List<Guid?>();
  327. List<Guid> executablePlanIDList = new List<Guid>();
  328. //数据有误验证
  329. if (specialtyPlanView.SpecialtyPlanID != Guid.Empty)
  330. {
  331. var specialtyPlan = SpecialtyPlanDAL.SpecialtyPlanRepository
  332. .GetList(x => x.SpecialtyPlanID == specialtyPlanView.SpecialtyPlanID,
  333. (x => x.EM_SpecialtyPlanTeachingSetting)).SingleOrDefault();
  334. if (specialtyPlan == null)
  335. {
  336. throw new Exception("数据有误,请核查。");
  337. }
  338. else
  339. {
  340. //表示修改
  341. specialtyPlan.SchoolyearID = specialtyPlanView.SchoolyearID;
  342. specialtyPlan.StartSchoolyearID = startSchoolyear.SchoolyearID;
  343. specialtyPlan.SpecialtyID = specialty.SpecialtyID;
  344. specialtyPlan.CoursematerialID = specialtyPlanView.CoursematerialID;
  345. specialtyPlan.CourseStructureID = specialtyPlanView.CourseStructureID;
  346. specialtyPlan.CourseCategoryID = specialtyPlanView.CourseCategoryID;
  347. specialtyPlan.CourseTypeID = specialtyPlanView.CourseTypeID;
  348. specialtyPlan.CourseQualityID = specialtyPlanView.CourseQualityID;
  349. specialtyPlan.DepartmentID = specialtyPlanView.DepartmentID;
  350. specialtyPlan.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  351. specialtyPlan.IsCooperation = specialtyPlanView.IsCooperation;
  352. specialtyPlan.IsRequired = specialtyPlanView.IsRequired;
  353. specialtyPlan.IsElective = specialtyPlanView.IsElective;
  354. specialtyPlan.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  355. specialtyPlan.IsMainCourse = specialtyPlanView.IsMainCourse;
  356. specialtyPlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial;
  357. specialtyPlan.CourseFineID = specialtyPlanView.CourseFineID;
  358. specialtyPlan.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  359. specialtyPlan.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  360. specialtyPlan.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  361. specialtyPlan.ResultTypeID = specialtyPlanView.ResultTypeID;
  362. specialtyPlan.HandleModeID = specialtyPlanView.HandleModeID;
  363. specialtyPlan.Remark = specialtyPlanView.Remark;
  364. SetModifyStatus(specialtyPlan);
  365. newSpecialtyPlanUpList.Add(specialtyPlan);
  366. if (specialtyPlan.EM_SpecialtyPlanTeachingSetting == null)
  367. {
  368. var newSPTeachingSetting = new EM_SpecialtyPlanTeachingSetting();
  369. newSPTeachingSetting.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
  370. newSPTeachingSetting.Credit = specialtyPlanView.Credit;
  371. newSPTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  372. newSPTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  373. newSPTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  374. newSPTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  375. newSPTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  376. newSPTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  377. newSPTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  378. newSPTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  379. newSPTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  380. newSPTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  381. newSPTeachingSettingInList.Add(newSPTeachingSetting);
  382. }
  383. else
  384. {
  385. specialtyPlan.EM_SpecialtyPlanTeachingSetting.Credit = specialtyPlanView.Credit;
  386. specialtyPlan.EM_SpecialtyPlanTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  387. specialtyPlan.EM_SpecialtyPlanTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  388. specialtyPlan.EM_SpecialtyPlanTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  389. specialtyPlan.EM_SpecialtyPlanTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  390. specialtyPlan.EM_SpecialtyPlanTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  391. specialtyPlan.EM_SpecialtyPlanTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  392. specialtyPlan.EM_SpecialtyPlanTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  393. specialtyPlan.EM_SpecialtyPlanTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  394. specialtyPlan.EM_SpecialtyPlanTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  395. specialtyPlan.EM_SpecialtyPlanTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  396. newSPTeachingSettingUpList.Add(specialtyPlan.EM_SpecialtyPlanTeachingSetting);
  397. }
  398. if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0)
  399. {
  400. specialtyPlanTMDelList.Add(specialtyPlan.SpecialtyPlanID);
  401. foreach (var teachingModeID in specialtyPlanView.TeachingModeIDList)
  402. {
  403. var newSPTeachingMode = new EM_SpecialtyPlanTeachingModeType();
  404. newSPTeachingMode.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid();
  405. newSPTeachingMode.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
  406. newSPTeachingMode.TeachingModeID = teachingModeID;
  407. SetNewStatus(newSPTeachingMode);
  408. newSPTeachingModeTypeInList.Add(newSPTeachingMode);
  409. }
  410. }
  411. else
  412. {
  413. specialtyPlanTMDelList.Add(specialtyPlan.SpecialtyPlanID);
  414. }
  415. if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0)
  416. {
  417. specialtyPlanTPDelList.Add(specialtyPlan.SpecialtyPlanID);
  418. foreach (var teachingPlaceID in specialtyPlanView.TeachingPlaceIDList)
  419. {
  420. var newSPTeachingPlace = new EM_SpecialtyPlanTeachingPlace();
  421. newSPTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid();
  422. newSPTeachingPlace.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
  423. newSPTeachingPlace.TeachingPlace = teachingPlaceID;
  424. SetNewStatus(newSPTeachingPlace);
  425. newSPTeachingPlaceInList.Add(newSPTeachingPlace);
  426. }
  427. }
  428. else
  429. {
  430. specialtyPlanTPDelList.Add(specialtyPlan.SpecialtyPlanID);
  431. }
  432. //对应的执行计划信息更新(根据业务主键:学年学期ID、年级专业ID、课程信息ID)
  433. //注:由于相关业务主键冗余且同时存在主外键关联,目前不允许修改相关业务主键
  434. foreach (var grademajorView in grademajorViewList)
  435. {
  436. //判断年级专业对应的学生人数
  437. if (grademajorView.StudentCount <= 0)
  438. {
  439. //表示年级专业对应的学生人数小于等于0(暂不做考虑)
  440. }
  441. else
  442. {
  443. //查询对应的执行计划信息(业务主键:学年学期ID、年级专业ID、课程信息ID)
  444. var executablePlan = SpecialtyPlanDAL.ExecutablePlanRepository.GetList(x => x.SchoolyearID == specialtyPlanView.SchoolyearID
  445. && x.GrademajorID == grademajorView.GrademajorID
  446. && x.CoursematerialID == specialtyPlanView.CoursematerialID,
  447. (x => x.EM_ExecutablePlanProfile), (x => x.EM_ExecutablePlanTeachingSetting)).SingleOrDefault();
  448. if (executablePlan == null)
  449. {
  450. //表示不存在对应的执行计划信息(暂不新增)
  451. }
  452. else
  453. {
  454. //表示存在对应的执行计划信息(修改)
  455. executablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse;
  456. //暂不考虑
  457. //executablePlan.DefaultClassName = specialtyPlanView.CourseName + "-" + grademajorView.Name;
  458. executablePlan.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID;
  459. executablePlan.SchoolyearID = specialtyPlanView.SchoolyearID;
  460. executablePlan.GrademajorID = grademajorView.GrademajorID;
  461. executablePlan.CoursematerialID = specialtyPlanView.CoursematerialID;
  462. executablePlan.CourseStructureID = specialtyPlanView.CourseStructureID;
  463. executablePlan.CourseCategoryID = specialtyPlanView.CourseCategoryID;
  464. executablePlan.CourseTypeID = specialtyPlanView.CourseTypeID;
  465. executablePlan.CourseQualityID = specialtyPlanView.CourseQualityID;
  466. executablePlan.DepartmentID = specialtyPlanView.DepartmentID;
  467. executablePlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial;
  468. executablePlan.ResultTypeID = specialtyPlanView.ResultTypeID;
  469. executablePlan.HandleModeID = specialtyPlanView.HandleModeID;
  470. SetModifyStatus(executablePlan);
  471. newExecutablePlanUpList.Add(executablePlan);
  472. if (executablePlan.EM_ExecutablePlanProfile == null)
  473. {
  474. var newProfile = new EM_ExecutablePlanProfile();
  475. newProfile.ExecutablePlanID = executablePlan.ExecutablePlanID;
  476. newProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  477. newProfile.IsCooperation = specialtyPlanView.IsCooperation;
  478. newProfile.IsRequired = specialtyPlanView.IsRequired;
  479. newProfile.IsElective = specialtyPlanView.IsElective;
  480. newProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  481. newProfile.IsMainCourse = specialtyPlanView.IsMainCourse;
  482. newProfile.CourseFineID = specialtyPlanView.CourseFineID;
  483. newProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  484. newProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  485. newProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  486. SetNewStatus(newProfile);
  487. newProfileInList.Add(newProfile);
  488. }
  489. else
  490. {
  491. executablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  492. executablePlan.EM_ExecutablePlanProfile.IsCooperation = specialtyPlanView.IsCooperation;
  493. executablePlan.EM_ExecutablePlanProfile.IsRequired = specialtyPlanView.IsRequired;
  494. executablePlan.EM_ExecutablePlanProfile.IsElective = specialtyPlanView.IsElective;
  495. executablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  496. executablePlan.EM_ExecutablePlanProfile.IsMainCourse = specialtyPlanView.IsMainCourse;
  497. executablePlan.EM_ExecutablePlanProfile.CourseFineID = specialtyPlanView.CourseFineID;
  498. executablePlan.EM_ExecutablePlanProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  499. executablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  500. executablePlan.EM_ExecutablePlanProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  501. SetModifyStatus(executablePlan.EM_ExecutablePlanProfile);
  502. newProfileUpList.Add(executablePlan.EM_ExecutablePlanProfile);
  503. }
  504. if (executablePlan.EM_ExecutablePlanTeachingSetting == null)
  505. {
  506. var newEPTeachingSetting = new EM_ExecutablePlanTeachingSetting();
  507. newEPTeachingSetting.ExecutablePlanID = executablePlan.ExecutablePlanID;
  508. newEPTeachingSetting.Credit = specialtyPlanView.Credit;
  509. newEPTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  510. newEPTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  511. newEPTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  512. newEPTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  513. newEPTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  514. newEPTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  515. newEPTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  516. newEPTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  517. newEPTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  518. newEPTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  519. newEPTeachingSettingInList.Add(newEPTeachingSetting);
  520. }
  521. else
  522. {
  523. //可更新的相关信息
  524. executablePlan.EM_ExecutablePlanTeachingSetting.Credit = specialtyPlanView.Credit;
  525. executablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  526. executablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  527. executablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  528. if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  529. {
  530. executablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  531. executablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  532. executablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  533. executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  534. executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  535. executablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  536. executablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  537. }
  538. newEPTeachingSettingUpList.Add(executablePlan.EM_ExecutablePlanTeachingSetting);
  539. }
  540. if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  541. {
  542. //可更新的相关信息
  543. if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0)
  544. {
  545. executablePlanTMDelList.Add(executablePlan.ExecutablePlanID);
  546. foreach (var newModeType in specialtyPlanView.TeachingModeIDList.ToList())
  547. {
  548. var newEPTeachingModeType = new EM_ExecutablePlanTeachingModeType();
  549. newEPTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid();
  550. newEPTeachingModeType.ExecutablePlanID = executablePlan.ExecutablePlanID;
  551. newEPTeachingModeType.TeachingModeID = newModeType;
  552. this.SetNewStatus(newEPTeachingModeType);
  553. newEPTeachingModeTypeInList.Add(newEPTeachingModeType);
  554. }
  555. }
  556. else
  557. {
  558. executablePlanTMDelList.Add(executablePlan.ExecutablePlanID);
  559. }
  560. }
  561. if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0)
  562. {
  563. executablePlanTPDelList.Add(executablePlan.ExecutablePlanID);
  564. foreach (var newPlace in specialtyPlanView.TeachingPlaceIDList.ToList())
  565. {
  566. var newEPTeachingPlace = new EM_ExecutablePlanTeachingPlace();
  567. newEPTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid();
  568. newEPTeachingPlace.ExecutablePlanID = executablePlan.ExecutablePlanID;
  569. newEPTeachingPlace.TeachingPlace = newPlace;
  570. this.SetNewStatus(newEPTeachingPlace);
  571. newEPTeachingPlaceInList.Add(newEPTeachingPlace);
  572. }
  573. }
  574. else
  575. {
  576. executablePlanTPDelList.Add(executablePlan.ExecutablePlanID);
  577. }
  578. executablePlanIDList.Add(executablePlan.ExecutablePlanID);
  579. }
  580. }
  581. }
  582. //存在对应的主外键关联
  583. if (specialtyPlan.EM_ExecutablePlan.Count() > 0)
  584. {
  585. //根据专业计划主键ID查询对应的执行计划信息List
  586. var newExecutablePlanList = SpecialtyPlanDAL.ExecutablePlanRepository
  587. .GetList(x => x.SpecialtyPlanID == specialtyPlan.SpecialtyPlanID,
  588. (x => x.EM_ExecutablePlanProfile), (x => x.EM_ExecutablePlanTeachingSetting)).ToList();
  589. foreach (var newExecutablePlan in newExecutablePlanList)
  590. {
  591. if (!executablePlanIDList.Contains(newExecutablePlan.ExecutablePlanID))
  592. {
  593. //查询对应的执行计划信息View
  594. var newExecutablePlanView = ExecutablePlanDAL.GetExecutablePlanViewQueryable(x => x.ExecutablePlanID == newExecutablePlan.ExecutablePlanID).SingleOrDefault();
  595. //查询对应的专业计划信息(业务主键:学年学期ID、入学学年学期ID、专业信息ID、课程信息ID)
  596. var newSpecialtyPlanView = SpecialtyPlanDAL.GetAdultSpecialtyPlanViewQueryable(x => x.SpecialtyPlanID != specialtyPlan.SpecialtyPlanID
  597. && x.SchoolyearID == newExecutablePlanView.SchoolyearID
  598. && x.StartSchoolyearID == newExecutablePlanView.StartSchoolyearID
  599. && x.SpecialtyID == newExecutablePlanView.SpecialtyID
  600. && x.CoursematerialID == newExecutablePlanView.CoursematerialID).SingleOrDefault();
  601. if (newSpecialtyPlanView == null)
  602. {
  603. newExecutablePlan.SpecialtyPlanID = null;
  604. SetModifyStatus(newExecutablePlan);
  605. newExecutablePlanUpList.Add(newExecutablePlan);
  606. }
  607. else
  608. {
  609. //来源专业计划默认为必修课
  610. newExecutablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse;
  611. newExecutablePlan.DefaultClassName = newExecutablePlanView.CourseName + "-" + newExecutablePlanView.GrademajorName;
  612. newExecutablePlan.SpecialtyPlanID = newSpecialtyPlanView.SpecialtyPlanID;
  613. newExecutablePlan.SchoolyearID = newSpecialtyPlanView.SchoolyearID;
  614. newExecutablePlan.GrademajorID = newExecutablePlanView.GrademajorID;
  615. newExecutablePlan.CoursematerialID = newSpecialtyPlanView.CoursematerialID;
  616. newExecutablePlan.CourseStructureID = newSpecialtyPlanView.CourseStructureID;
  617. newExecutablePlan.CourseCategoryID = newSpecialtyPlanView.CourseCategoryID;
  618. newExecutablePlan.CourseTypeID = newSpecialtyPlanView.CourseTypeID;
  619. newExecutablePlan.CourseQualityID = newSpecialtyPlanView.CourseQualityID;
  620. newExecutablePlan.DepartmentID = newSpecialtyPlanView.DepartmentID;
  621. newExecutablePlan.IsNeedMaterial = newSpecialtyPlanView.IsNeedMaterial;
  622. newExecutablePlan.ResultTypeID = newSpecialtyPlanView.ResultTypeID;
  623. newExecutablePlan.HandleModeID = newSpecialtyPlanView.HandleModeID;
  624. SetModifyStatus(newExecutablePlan);
  625. newExecutablePlanUpList.Add(newExecutablePlan);
  626. if (newExecutablePlan.EM_ExecutablePlanProfile == null)
  627. {
  628. var newProfile = new EM_ExecutablePlanProfile();
  629. newProfile.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  630. newProfile.IsSpecialtycore = newSpecialtyPlanView.IsSpecialtycore;
  631. newProfile.IsCooperation = newSpecialtyPlanView.IsCooperation;
  632. newProfile.IsRequired = newSpecialtyPlanView.IsRequired;
  633. newProfile.IsElective = newSpecialtyPlanView.IsElective;
  634. newProfile.IsNetworkCourse = newSpecialtyPlanView.IsNetworkCourse;
  635. newProfile.IsMainCourse = newSpecialtyPlanView.IsMainCourse;
  636. newProfile.CourseFineID = newSpecialtyPlanView.CourseFineID;
  637. newProfile.PracticeTypeID = newSpecialtyPlanView.PracticeTypeID;
  638. newProfile.TeachinglanguageID = newSpecialtyPlanView.TeachinglanguageID;
  639. newProfile.ExaminationModeID = newSpecialtyPlanView.ExaminationModeID;
  640. SetNewStatus(newProfile);
  641. newProfileInList.Add(newProfile);
  642. }
  643. else
  644. {
  645. newExecutablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = newSpecialtyPlanView.IsSpecialtycore;
  646. newExecutablePlan.EM_ExecutablePlanProfile.IsCooperation = newSpecialtyPlanView.IsCooperation;
  647. newExecutablePlan.EM_ExecutablePlanProfile.IsRequired = newSpecialtyPlanView.IsRequired;
  648. newExecutablePlan.EM_ExecutablePlanProfile.IsElective = newSpecialtyPlanView.IsElective;
  649. newExecutablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = newSpecialtyPlanView.IsNetworkCourse;
  650. newExecutablePlan.EM_ExecutablePlanProfile.IsMainCourse = newSpecialtyPlanView.IsMainCourse;
  651. newExecutablePlan.EM_ExecutablePlanProfile.CourseFineID = newSpecialtyPlanView.CourseFineID;
  652. newExecutablePlan.EM_ExecutablePlanProfile.PracticeTypeID = newSpecialtyPlanView.PracticeTypeID;
  653. newExecutablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = newSpecialtyPlanView.TeachinglanguageID;
  654. newExecutablePlan.EM_ExecutablePlanProfile.ExaminationModeID = newSpecialtyPlanView.ExaminationModeID;
  655. SetModifyStatus(newExecutablePlan.EM_ExecutablePlanProfile);
  656. newProfileUpList.Add(newExecutablePlan.EM_ExecutablePlanProfile);
  657. }
  658. if (newExecutablePlan.EM_ExecutablePlanTeachingSetting == null)
  659. {
  660. var newEPTeachingSetting = new EM_ExecutablePlanTeachingSetting();
  661. newEPTeachingSetting.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  662. newEPTeachingSetting.Credit = newSpecialtyPlanView.Credit;
  663. newEPTeachingSetting.TheoryCourse = newSpecialtyPlanView.TheoryCourse;
  664. newEPTeachingSetting.Practicehours = newSpecialtyPlanView.Practicehours;
  665. newEPTeachingSetting.Trialhours = newSpecialtyPlanView.Trialhours;
  666. newEPTeachingSetting.TheoryWeeklyNum = newSpecialtyPlanView.TheoryWeeklyNum;
  667. newEPTeachingSetting.PracticeWeeklyNum = newSpecialtyPlanView.PracticeWeeklyNum;
  668. newEPTeachingSetting.TrialWeeklyNum = newSpecialtyPlanView.TrialWeeklyNum;
  669. newEPTeachingSetting.WeeklyHours = newSpecialtyPlanView.WeeklyHours;
  670. newEPTeachingSetting.WeeklyNum = newSpecialtyPlanView.WeeklyNum;
  671. newEPTeachingSetting.StartWeeklyNum = newSpecialtyPlanView.StartWeeklyNum;
  672. newEPTeachingSetting.EndWeeklyNum = newSpecialtyPlanView.EndWeeklyNum;
  673. newEPTeachingSettingInList.Add(newEPTeachingSetting);
  674. }
  675. else
  676. {
  677. //可更新的相关信息
  678. newExecutablePlan.EM_ExecutablePlanTeachingSetting.Credit = newSpecialtyPlanView.Credit;
  679. newExecutablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = newSpecialtyPlanView.TheoryCourse;
  680. newExecutablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = newSpecialtyPlanView.Practicehours;
  681. newExecutablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = newSpecialtyPlanView.Trialhours;
  682. if (newExecutablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  683. {
  684. newExecutablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = newSpecialtyPlanView.TheoryWeeklyNum;
  685. newExecutablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = newSpecialtyPlanView.PracticeWeeklyNum;
  686. newExecutablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = newSpecialtyPlanView.TrialWeeklyNum;
  687. newExecutablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = newSpecialtyPlanView.WeeklyHours;
  688. newExecutablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = newSpecialtyPlanView.WeeklyNum;
  689. newExecutablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = newSpecialtyPlanView.StartWeeklyNum;
  690. newExecutablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = newSpecialtyPlanView.EndWeeklyNum;
  691. }
  692. newEPTeachingSettingUpList.Add(newExecutablePlan.EM_ExecutablePlanTeachingSetting);
  693. }
  694. if (newExecutablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  695. {
  696. //可更新的相关信息
  697. if (newSpecialtyPlanView.TeachingModeIDList != null && newSpecialtyPlanView.TeachingModeIDList.Count() > 0)
  698. {
  699. executablePlanTMDelList.Add(newExecutablePlan.ExecutablePlanID);
  700. foreach (var newModeType in newSpecialtyPlanView.TeachingModeIDList.ToList())
  701. {
  702. var newEPTeachingModeType = new EM_ExecutablePlanTeachingModeType();
  703. newEPTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid();
  704. newEPTeachingModeType.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  705. newEPTeachingModeType.TeachingModeID = newModeType;
  706. this.SetNewStatus(newEPTeachingModeType);
  707. newEPTeachingModeTypeInList.Add(newEPTeachingModeType);
  708. }
  709. }
  710. else
  711. {
  712. executablePlanTMDelList.Add(newExecutablePlan.ExecutablePlanID);
  713. }
  714. }
  715. if (newSpecialtyPlanView.TeachingPlaceIDList != null && newSpecialtyPlanView.TeachingPlaceIDList.Count() > 0)
  716. {
  717. executablePlanTPDelList.Add(newExecutablePlan.ExecutablePlanID);
  718. foreach (var newPlace in newSpecialtyPlanView.TeachingPlaceIDList.ToList())
  719. {
  720. var newEPTeachingPlace = new EM_ExecutablePlanTeachingPlace();
  721. newEPTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid();
  722. newEPTeachingPlace.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  723. newEPTeachingPlace.TeachingPlace = newPlace;
  724. this.SetNewStatus(newEPTeachingPlace);
  725. newEPTeachingPlaceInList.Add(newEPTeachingPlace);
  726. }
  727. }
  728. else
  729. {
  730. executablePlanTPDelList.Add(newExecutablePlan.ExecutablePlanID);
  731. }
  732. }
  733. executablePlanIDList.Add(newExecutablePlan.ExecutablePlanID);
  734. }
  735. }
  736. }
  737. }
  738. }
  739. else
  740. {
  741. //表示新增
  742. var newSpecialtyPlan = new EM_SpecialtyPlan();
  743. newSpecialtyPlan.SpecialtyPlanID = Guid.NewGuid();
  744. newSpecialtyPlan.PlanApplicationID = null;
  745. newSpecialtyPlan.SchoolyearID = specialtyPlanView.SchoolyearID;
  746. newSpecialtyPlan.StartSchoolyearID = startSchoolyear.SchoolyearID;
  747. newSpecialtyPlan.SpecialtyID = specialty.SpecialtyID;
  748. newSpecialtyPlan.CoursematerialID = specialtyPlanView.CoursematerialID;
  749. newSpecialtyPlan.CourseStructureID = specialtyPlanView.CourseStructureID;
  750. newSpecialtyPlan.CourseCategoryID = specialtyPlanView.CourseCategoryID;
  751. newSpecialtyPlan.CourseTypeID = specialtyPlanView.CourseTypeID;
  752. newSpecialtyPlan.CourseQualityID = specialtyPlanView.CourseQualityID;
  753. newSpecialtyPlan.DepartmentID = specialtyPlanView.DepartmentID;
  754. newSpecialtyPlan.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  755. newSpecialtyPlan.IsCooperation = specialtyPlanView.IsCooperation;
  756. newSpecialtyPlan.IsRequired = specialtyPlanView.IsRequired;
  757. newSpecialtyPlan.IsElective = specialtyPlanView.IsElective;
  758. newSpecialtyPlan.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  759. newSpecialtyPlan.IsMainCourse = specialtyPlanView.IsMainCourse;
  760. newSpecialtyPlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial;
  761. newSpecialtyPlan.CourseFineID = specialtyPlanView.CourseFineID;
  762. newSpecialtyPlan.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  763. newSpecialtyPlan.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  764. newSpecialtyPlan.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  765. newSpecialtyPlan.ResultTypeID = specialtyPlanView.ResultTypeID;
  766. newSpecialtyPlan.HandleModeID = specialtyPlanView.HandleModeID;
  767. newSpecialtyPlan.Remark = specialtyPlanView.Remark;
  768. SetNewStatus(newSpecialtyPlan);
  769. newSpecialtyPlanInList.Add(newSpecialtyPlan);
  770. var newSPTeachingSetting = new EM_SpecialtyPlanTeachingSetting();
  771. newSPTeachingSetting.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  772. newSPTeachingSetting.Credit = specialtyPlanView.Credit;
  773. newSPTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  774. newSPTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  775. newSPTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  776. newSPTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  777. newSPTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  778. newSPTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  779. newSPTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  780. newSPTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  781. newSPTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  782. newSPTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  783. newSPTeachingSettingInList.Add(newSPTeachingSetting);
  784. if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0)
  785. {
  786. foreach (var teachingModeID in specialtyPlanView.TeachingModeIDList)
  787. {
  788. var newSPTeachingMode = new EM_SpecialtyPlanTeachingModeType();
  789. newSPTeachingMode.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid();
  790. newSPTeachingMode.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  791. newSPTeachingMode.TeachingModeID = teachingModeID;
  792. SetNewStatus(newSPTeachingMode);
  793. newSPTeachingModeTypeInList.Add(newSPTeachingMode);
  794. }
  795. }
  796. if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0)
  797. {
  798. foreach (var teachingPlaceID in specialtyPlanView.TeachingPlaceIDList)
  799. {
  800. var newSPTeachingPlace = new EM_SpecialtyPlanTeachingPlace();
  801. newSPTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid();
  802. newSPTeachingPlace.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  803. newSPTeachingPlace.TeachingPlace = teachingPlaceID;
  804. SetNewStatus(newSPTeachingPlace);
  805. newSPTeachingPlaceInList.Add(newSPTeachingPlace);
  806. }
  807. }
  808. //对应的执行计划信息更新(根据业务主键:学年学期ID、年级专业ID、课程信息ID)
  809. //注:由于相关业务主键冗余且同时存在主外键关联,目前不允许修改相关业务主键
  810. foreach (var grademajorView in grademajorViewList)
  811. {
  812. //查询对应的执行计划信息(业务主键:学年学期ID、年级专业ID、课程信息ID)
  813. var executablePlan = SpecialtyPlanDAL.ExecutablePlanRepository.GetList(x => x.SchoolyearID == specialtyPlanView.SchoolyearID
  814. && x.GrademajorID == grademajorView.GrademajorID
  815. && x.CoursematerialID == specialtyPlanView.CoursematerialID,
  816. (x => x.EM_ExecutablePlanProfile), (x => x.EM_ExecutablePlanTeachingSetting)).SingleOrDefault();
  817. if (executablePlan == null)
  818. {
  819. //表示不存在对应的执行计划信息(暂不新增)
  820. }
  821. else
  822. {
  823. //表示存在对应的执行计划信息(修改)
  824. executablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse;
  825. //暂不考虑
  826. //executablePlan.DefaultClassName = specialtyPlanView.CourseName + "-" + grademajorView.Name;
  827. executablePlan.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  828. executablePlan.SchoolyearID = specialtyPlanView.SchoolyearID;
  829. executablePlan.GrademajorID = grademajorView.GrademajorID;
  830. executablePlan.CoursematerialID = specialtyPlanView.CoursematerialID;
  831. executablePlan.CourseStructureID = specialtyPlanView.CourseStructureID;
  832. executablePlan.CourseCategoryID = specialtyPlanView.CourseCategoryID;
  833. executablePlan.CourseTypeID = specialtyPlanView.CourseTypeID;
  834. executablePlan.CourseQualityID = specialtyPlanView.CourseQualityID;
  835. executablePlan.DepartmentID = specialtyPlanView.DepartmentID;
  836. executablePlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial;
  837. executablePlan.ResultTypeID = specialtyPlanView.ResultTypeID;
  838. executablePlan.HandleModeID = specialtyPlanView.HandleModeID;
  839. SetModifyStatus(executablePlan);
  840. newExecutablePlanUpList.Add(executablePlan);
  841. if (executablePlan.EM_ExecutablePlanProfile == null)
  842. {
  843. var newProfile = new EM_ExecutablePlanProfile();
  844. newProfile.ExecutablePlanID = executablePlan.ExecutablePlanID;
  845. newProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  846. newProfile.IsCooperation = specialtyPlanView.IsCooperation;
  847. newProfile.IsRequired = specialtyPlanView.IsRequired;
  848. newProfile.IsElective = specialtyPlanView.IsElective;
  849. newProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  850. newProfile.IsMainCourse = specialtyPlanView.IsMainCourse;
  851. newProfile.CourseFineID = specialtyPlanView.CourseFineID;
  852. newProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  853. newProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  854. newProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  855. SetNewStatus(newProfile);
  856. newProfileInList.Add(newProfile);
  857. }
  858. else
  859. {
  860. executablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  861. executablePlan.EM_ExecutablePlanProfile.IsCooperation = specialtyPlanView.IsCooperation;
  862. executablePlan.EM_ExecutablePlanProfile.IsRequired = specialtyPlanView.IsRequired;
  863. executablePlan.EM_ExecutablePlanProfile.IsElective = specialtyPlanView.IsElective;
  864. executablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  865. executablePlan.EM_ExecutablePlanProfile.IsMainCourse = specialtyPlanView.IsMainCourse;
  866. executablePlan.EM_ExecutablePlanProfile.CourseFineID = specialtyPlanView.CourseFineID;
  867. executablePlan.EM_ExecutablePlanProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  868. executablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  869. executablePlan.EM_ExecutablePlanProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  870. SetModifyStatus(executablePlan.EM_ExecutablePlanProfile);
  871. newProfileUpList.Add(executablePlan.EM_ExecutablePlanProfile);
  872. }
  873. if (executablePlan.EM_ExecutablePlanTeachingSetting == null)
  874. {
  875. var newEPTeachingSetting = new EM_ExecutablePlanTeachingSetting();
  876. newEPTeachingSetting.ExecutablePlanID = executablePlan.ExecutablePlanID;
  877. newEPTeachingSetting.Credit = specialtyPlanView.Credit;
  878. newEPTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  879. newEPTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  880. newEPTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  881. newEPTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  882. newEPTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  883. newEPTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  884. newEPTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  885. newEPTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  886. newEPTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  887. newEPTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  888. newEPTeachingSettingInList.Add(newEPTeachingSetting);
  889. }
  890. else
  891. {
  892. //可更新的相关信息
  893. executablePlan.EM_ExecutablePlanTeachingSetting.Credit = specialtyPlanView.Credit;
  894. executablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  895. executablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  896. executablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  897. if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  898. {
  899. executablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  900. executablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  901. executablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  902. executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  903. executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  904. executablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  905. executablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  906. }
  907. newEPTeachingSettingUpList.Add(executablePlan.EM_ExecutablePlanTeachingSetting);
  908. }
  909. if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  910. {
  911. //可更新的相关信息
  912. if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0)
  913. {
  914. executablePlanTMDelList.Add(executablePlan.ExecutablePlanID);
  915. foreach (var newModeType in specialtyPlanView.TeachingModeIDList.ToList())
  916. {
  917. var newEPTeachingModeType = new EM_ExecutablePlanTeachingModeType();
  918. newEPTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid();
  919. newEPTeachingModeType.ExecutablePlanID = executablePlan.ExecutablePlanID;
  920. newEPTeachingModeType.TeachingModeID = newModeType;
  921. this.SetNewStatus(newEPTeachingModeType);
  922. newEPTeachingModeTypeInList.Add(newEPTeachingModeType);
  923. }
  924. }
  925. else
  926. {
  927. executablePlanTMDelList.Add(executablePlan.ExecutablePlanID);
  928. }
  929. }
  930. if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0)
  931. {
  932. executablePlanTPDelList.Add(executablePlan.ExecutablePlanID);
  933. foreach (var newPlace in specialtyPlanView.TeachingPlaceIDList.ToList())
  934. {
  935. var newEPTeachingPlace = new EM_ExecutablePlanTeachingPlace();
  936. newEPTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid();
  937. newEPTeachingPlace.ExecutablePlanID = executablePlan.ExecutablePlanID;
  938. newEPTeachingPlace.TeachingPlace = newPlace;
  939. this.SetNewStatus(newEPTeachingPlace);
  940. newEPTeachingPlaceInList.Add(newEPTeachingPlace);
  941. }
  942. }
  943. else
  944. {
  945. executablePlanTPDelList.Add(executablePlan.ExecutablePlanID);
  946. }
  947. executablePlanIDList.Add(executablePlan.ExecutablePlanID);
  948. }
  949. }
  950. }
  951. //事务提交
  952. //UnitOfWork.Commit();
  953. using (TransactionScope ts = new TransactionScope())
  954. {
  955. //删除
  956. UnitOfWork.Delete<EM_SpecialtyPlanTeachingPlace>(x => specialtyPlanTPDelList.Contains(x.SpecialtyPlanID));
  957. UnitOfWork.Delete<EM_SpecialtyPlanTeachingModeType>(x => specialtyPlanTMDelList.Contains(x.SpecialtyPlanID));
  958. //批量插入
  959. UnitOfWork.BulkInsert(newSpecialtyPlanInList);
  960. UnitOfWork.BulkInsert(newSPTeachingSettingInList);
  961. UnitOfWork.BulkInsert(newSPTeachingModeTypeInList);
  962. UnitOfWork.BulkInsert(newSPTeachingPlaceInList);
  963. //批量统一提交更新
  964. if (newSpecialtyPlanUpList != null && newSpecialtyPlanUpList.Count() > 0)
  965. {
  966. UnitOfWork.BatchUpdate(newSpecialtyPlanUpList);
  967. }
  968. //批量统一提交更新
  969. if (newSPTeachingSettingUpList != null && newSPTeachingSettingUpList.Count() > 0)
  970. {
  971. UnitOfWork.BatchUpdate(newSPTeachingSettingUpList);
  972. }
  973. //删除
  974. UnitOfWork.Delete<EM_ExecutablePlanTeachingPlace>(x => executablePlanTPDelList.Contains(x.ExecutablePlanID));
  975. UnitOfWork.Delete<EM_ExecutablePlanTeachingModeType>(x => executablePlanTMDelList.Contains(x.ExecutablePlanID));
  976. //批量插入
  977. UnitOfWork.BulkInsert(newProfileInList);
  978. UnitOfWork.BulkInsert(newEPTeachingSettingInList);
  979. UnitOfWork.BulkInsert(newEPTeachingModeTypeInList);
  980. UnitOfWork.BulkInsert(newEPTeachingPlaceInList);
  981. //批量统一提交更新
  982. if (newExecutablePlanUpList != null && newExecutablePlanUpList.Count() > 0)
  983. {
  984. UnitOfWork.BatchUpdate(newExecutablePlanUpList);
  985. }
  986. //批量统一提交更新
  987. if (newProfileUpList != null && newProfileUpList.Count() > 0)
  988. {
  989. UnitOfWork.BatchUpdate(newProfileUpList);
  990. }
  991. //批量统一提交更新
  992. if (newEPTeachingSettingUpList != null && newEPTeachingSettingUpList.Count() > 0)
  993. {
  994. UnitOfWork.BatchUpdate(newEPTeachingSettingUpList);
  995. }
  996. ts.Complete();
  997. }
  998. }
  999. else
  1000. {
  1001. throw new Exception("已存在相同的专业计划信息(学年学期、入学学期、年级、专业信息、课程信息唯一),请核查。");
  1002. }
  1003. }
  1004. catch (Exception ex)
  1005. {
  1006. throw new Exception(ex.Message);
  1007. }
  1008. }
  1009. /// <summary>
  1010. /// 专业课程模版批量新增
  1011. /// </summary>
  1012. /// <param name="specialtyCourseViewList"></param>
  1013. /// <param name="specialtyPlanView"></param>
  1014. /// <returns></returns>
  1015. public string AdultSpecialtyPlanBatchAdd(List<SpecialtyCourseView> specialtyCourseViewList, SpecialtyPlanView specialtyPlanView)
  1016. {
  1017. try
  1018. {
  1019. //查询对应的专业信息
  1020. var specialty = SpecialtyPlanDAL.SpecialtyRepository
  1021. .GetList(x => x.SpecialtyID == specialtyPlanView.SpecialtyID).SingleOrDefault();
  1022. if (specialty == null)
  1023. {
  1024. throw new Exception("选择新增的专业信息不存在,请检查。");
  1025. }
  1026. //查询学年学期信息schoolyearList
  1027. var schoolyearList = SpecialtyPlanDAL.SchoolyearRepository
  1028. .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  1029. //查询对应的入学学年学期信息
  1030. var startSchoolyear = schoolyearList.Where(x => x.Years == specialtyPlanView.GradeID
  1031. && x.SchoolcodeID == specialtyPlanView.StartSchoolcodeID).SingleOrDefault();
  1032. if (startSchoolyear == null)
  1033. {
  1034. throw new Exception("选择新增的入学学期、年级对应的入学学年学期不存在,请检查。");
  1035. }
  1036. //查询对应的毕业学年学期信息(根据入学学期、年级和专业信息对应的学制计算)
  1037. var graduateSchoolyearValue = (specialtyPlanView.GradeID.Value * 2) - 1
  1038. + (specialtyPlanView.StartSchoolcodeID.Value - 1);
  1039. graduateSchoolyearValue += Convert.ToInt32(Math.Ceiling(specialty.LearnSystem.Value * 2 - 1));
  1040. var graduatingSemester = schoolyearList.Where(x => x.Value == graduateSchoolyearValue).SingleOrDefault();
  1041. if (graduatingSemester == null)
  1042. {
  1043. throw new Exception("选择新增的入学学期、年级和专业信息对应的毕业学年学期信息不存在,请检查。");
  1044. }
  1045. //查询专业计划信息specialtyPlanList
  1046. var specialtyPlanList = SpecialtyPlanDAL.SpecialtyPlanRepository.GetList(x => x.SpecialtyID == specialty.SpecialtyID
  1047. && x.StartSchoolyearID == startSchoolyear.SchoolyearID, (x => x.EM_SpecialtyPlanTeachingSetting)).ToList();
  1048. int success = 0; //成功
  1049. int fail = 0; //失败
  1050. string tipMessage = null; //提示消息
  1051. List<EM_SpecialtyPlan> newSpecialtyPlanInList = new List<EM_SpecialtyPlan>();
  1052. List<EM_SpecialtyPlanTeachingSetting> newTeachingSettingInList = new List<EM_SpecialtyPlanTeachingSetting>();
  1053. List<EM_SpecialtyPlanTeachingModeType> newTeachingModeTypeInList = new List<EM_SpecialtyPlanTeachingModeType>();
  1054. List<EM_SpecialtyPlanTeachingPlace> newTeachingPlaceInList = new List<EM_SpecialtyPlanTeachingPlace>();
  1055. foreach (var specialtyCourseView in specialtyCourseViewList)
  1056. {
  1057. //判断对应的学年学期信息
  1058. var value = startSchoolyear.Value + specialtyCourseView.StarttermID - 1;
  1059. if (value < startSchoolyear.Value)
  1060. {
  1061. //表示学年学期小于入学学年学期
  1062. fail++;
  1063. }
  1064. else
  1065. {
  1066. if (value > graduatingSemester.Value)
  1067. {
  1068. //表示学年学期大于毕业学年学期
  1069. fail++;
  1070. }
  1071. else
  1072. {
  1073. var schoolyear = schoolyearList.Where(x => x.Value == value).SingleOrDefault();
  1074. if (schoolyear == null)
  1075. {
  1076. //表示对应的学年学期信息不存在
  1077. fail++;
  1078. }
  1079. else
  1080. {
  1081. //查询对应的专业计划信息(根据业务主键:学年学期ID、入学学年学期ID、专业信息ID、课程信息ID)
  1082. var specialtyPlan = specialtyPlanList.Where(x => x.SchoolyearID == schoolyear.SchoolyearID
  1083. && x.StartSchoolyearID == startSchoolyear.SchoolyearID
  1084. && x.SpecialtyID == specialty.SpecialtyID
  1085. && x.CoursematerialID == specialtyCourseView.CoursematerialID).SingleOrDefault();
  1086. if (specialtyPlan == null)
  1087. {
  1088. //表示新增
  1089. var newSpecialtyPlan = new EM_SpecialtyPlan();
  1090. newSpecialtyPlan.SpecialtyPlanID = Guid.NewGuid();
  1091. newSpecialtyPlan.PlanApplicationID = null;
  1092. newSpecialtyPlan.SchoolyearID = schoolyear.SchoolyearID;
  1093. newSpecialtyPlan.StartSchoolyearID = startSchoolyear.SchoolyearID;
  1094. newSpecialtyPlan.SpecialtyID = specialty.SpecialtyID;
  1095. newSpecialtyPlan.CoursematerialID = specialtyCourseView.CoursematerialID;
  1096. newSpecialtyPlan.CourseStructureID = specialtyCourseView.CourseStructureID;
  1097. newSpecialtyPlan.CourseCategoryID = specialtyCourseView.CourseCategoryID;
  1098. newSpecialtyPlan.CourseTypeID = specialtyCourseView.CourseTypeID;
  1099. newSpecialtyPlan.CourseQualityID = specialtyCourseView.CourseQualityID;
  1100. newSpecialtyPlan.DepartmentID = specialtyCourseView.DepartmentID;
  1101. newSpecialtyPlan.IsSpecialtycore = specialtyCourseView.IsSpecialtycore;
  1102. newSpecialtyPlan.IsCooperation = specialtyCourseView.IsCooperation;
  1103. newSpecialtyPlan.IsRequired = specialtyCourseView.IsRequired;
  1104. newSpecialtyPlan.IsElective = specialtyCourseView.IsElective;
  1105. newSpecialtyPlan.IsNetworkCourse = specialtyCourseView.IsNetworkCourse;
  1106. newSpecialtyPlan.IsMainCourse = specialtyCourseView.IsMainCourse;
  1107. newSpecialtyPlan.IsNeedMaterial = specialtyCourseView.IsNeedMaterial;
  1108. newSpecialtyPlan.CourseFineID = specialtyCourseView.CourseFineID;
  1109. newSpecialtyPlan.PracticeTypeID = specialtyCourseView.PracticeTypeID;
  1110. newSpecialtyPlan.TeachinglanguageID = specialtyCourseView.TeachinglanguageID;
  1111. newSpecialtyPlan.ExaminationModeID = specialtyCourseView.ExaminationModeID;
  1112. newSpecialtyPlan.ResultTypeID = specialtyCourseView.ResultTypeID;
  1113. newSpecialtyPlan.HandleModeID = specialtyCourseView.HandleModeID;
  1114. newSpecialtyPlan.Remark = specialtyPlanView.Remark;
  1115. SetNewStatus(newSpecialtyPlan);
  1116. newSpecialtyPlanInList.Add(newSpecialtyPlan);
  1117. var newTeachingSetting = new EM_SpecialtyPlanTeachingSetting();
  1118. newTeachingSetting.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  1119. newTeachingSetting.Credit = specialtyCourseView.Credit;
  1120. newTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse;
  1121. newTeachingSetting.Practicehours = specialtyCourseView.Practicehours;
  1122. newTeachingSetting.Trialhours = specialtyCourseView.Trialhours;
  1123. newTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum;
  1124. newTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum;
  1125. newTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum;
  1126. newTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours;
  1127. newTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum;
  1128. newTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum;
  1129. newTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum;
  1130. newTeachingSettingInList.Add(newTeachingSetting);
  1131. if (specialtyCourseView.TeachingModeIDList != null && specialtyCourseView.TeachingModeIDList.Count() > 0)
  1132. {
  1133. foreach (var teachingModeID in specialtyCourseView.TeachingModeIDList)
  1134. {
  1135. var newTeachingMode = new EM_SpecialtyPlanTeachingModeType();
  1136. newTeachingMode.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid();
  1137. newTeachingMode.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  1138. newTeachingMode.TeachingModeID = teachingModeID;
  1139. SetNewStatus(newTeachingMode);
  1140. newTeachingModeTypeInList.Add(newTeachingMode);
  1141. }
  1142. }
  1143. if (specialtyCourseView.TeachingPlaceIDList != null && specialtyCourseView.TeachingPlaceIDList.Count() > 0)
  1144. {
  1145. foreach (var teachingPlaceID in specialtyCourseView.TeachingPlaceIDList)
  1146. {
  1147. var newTeachingPlace = new EM_SpecialtyPlanTeachingPlace();
  1148. newTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid();
  1149. newTeachingPlace.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  1150. newTeachingPlace.TeachingPlace = teachingPlaceID;
  1151. SetNewStatus(newTeachingPlace);
  1152. newTeachingPlaceInList.Add(newTeachingPlace);
  1153. }
  1154. }
  1155. success++;
  1156. }
  1157. else
  1158. {
  1159. //表示已存在相同的计划申请信息
  1160. fail++;
  1161. }
  1162. }
  1163. }
  1164. }
  1165. }
  1166. //事务提交
  1167. using (TransactionScope ts = new TransactionScope())
  1168. {
  1169. //批量插入
  1170. UnitOfWork.BulkInsert(newSpecialtyPlanInList);
  1171. UnitOfWork.BulkInsert(newTeachingSettingInList);
  1172. UnitOfWork.BulkInsert(newTeachingModeTypeInList);
  1173. UnitOfWork.BulkInsert(newTeachingPlaceInList);
  1174. ts.Complete();
  1175. }
  1176. if (success > 0 && fail <= 0)
  1177. {
  1178. tipMessage = success + "条";
  1179. }
  1180. else
  1181. {
  1182. tipMessage = success + "条,失败" + fail + "条,原因:学年学期小于入学学年学期、学年学期大于毕业学年学期、对应的学年学期不存在或已存在相同的专业计划信息,请检查";
  1183. }
  1184. return tipMessage;
  1185. }
  1186. catch (Exception ex)
  1187. {
  1188. throw new Exception(ex.Message);
  1189. }
  1190. }
  1191. /// <summary>
  1192. /// 查询对应的未新增专业课程信息SpecialtyCourseView
  1193. /// </summary>
  1194. /// <param name="configuretView"></param>
  1195. /// <param name="departmentID"></param>
  1196. /// <param name="educationID"></param>
  1197. /// <param name="learningformID"></param>
  1198. /// <param name="learnSystem"></param>
  1199. /// <param name="coursematerialID"></param>
  1200. /// <param name="starttermID"></param>
  1201. /// <param name="handleModeID"></param>
  1202. /// <param name="startSchoolcodeID"></param>
  1203. /// <param name="yearID"></param>
  1204. /// <param name="specialtyID"></param>
  1205. /// <param name="pageIndex"></param>
  1206. /// <param name="pageSize"></param>
  1207. /// <returns></returns>
  1208. public IGridResultSet<SpecialtyCourseView> GetAdultSpecialtyCourseViewNoAddGrid(ConfiguretView configuretView, Guid? departmentID,
  1209. int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID, int? starttermID, int? handleModeID,
  1210. int? startSchoolcodeID, int? yearID, Guid? specialtyID, int pageIndex, int pageSize)
  1211. {
  1212. //专业课程
  1213. Expression<Func<EM_SpecialtyCourse, bool>> expSpecialtyCourse = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1214. expSpecialtyCourse = expSpecialtyCourse.And(x => x.IsEnable == true);
  1215. expSpecialtyCourse = expSpecialtyCourse.And(x => x.SpecialtyID == specialtyID);
  1216. if (departmentID.HasValue)
  1217. {
  1218. expSpecialtyCourse = expSpecialtyCourse.And(x => x.DepartmentID == departmentID);
  1219. }
  1220. if (coursematerialID.HasValue)
  1221. {
  1222. expSpecialtyCourse = expSpecialtyCourse.And(x => x.CoursematerialID == coursematerialID);
  1223. }
  1224. if (starttermID.HasValue)
  1225. {
  1226. expSpecialtyCourse = expSpecialtyCourse.And(x => x.StarttermID == starttermID);
  1227. }
  1228. if (handleModeID.HasValue)
  1229. {
  1230. expSpecialtyCourse = expSpecialtyCourse.And(x => x.HandleModeID == handleModeID);
  1231. }
  1232. //学年学期
  1233. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1234. expSchoolyear = expSchoolyear.And(x => x.SchoolcodeID == startSchoolcodeID);
  1235. expSchoolyear = expSchoolyear.And(x => x.Years == yearID);
  1236. //专业信息
  1237. Expression<Func<CF_Specialty, bool>> expSpecialty = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1238. expSpecialty = expSpecialty.And(x => x.SpecialtyID == specialtyID);
  1239. if (educationID.HasValue)
  1240. {
  1241. expSpecialty = expSpecialty.And(x => x.EducationID == educationID);
  1242. }
  1243. if (learningformID.HasValue)
  1244. {
  1245. expSpecialty = expSpecialty.And(x => x.LearningformID == learningformID);
  1246. }
  1247. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  1248. {
  1249. var LearnSystems = Convert.ToDecimal(learnSystem);
  1250. expSpecialty = expSpecialty.And(x => x.LearnSystem == LearnSystems);
  1251. }
  1252. //专业计划
  1253. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1254. if (coursematerialID.HasValue)
  1255. {
  1256. expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID);
  1257. }
  1258. if (specialtyID.HasValue)
  1259. {
  1260. expSpecialtyPlan = expSpecialtyPlan.And(x => x.SpecialtyID == specialtyID);
  1261. }
  1262. var query = SpecialtyPlanDAL.GetAdultSpecialtyCourseViewNoAddQueryable(expSpecialtyCourse, expSchoolyear, expSpecialty, expSpecialtyPlan);
  1263. //查询条件
  1264. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1265. {
  1266. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1267. }
  1268. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.EducationID)
  1269. .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
  1270. .ThenBy(x => x.StarttermID).ThenBy(x => x.CourseTypeID)
  1271. .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
  1272. .ToGridResultSet<SpecialtyCourseView>(pageIndex, pageSize);
  1273. }
  1274. /// <summary>
  1275. /// 查询对应的未新增专业课程信息List
  1276. /// </summary>
  1277. /// <param name="configuretView"></param>
  1278. /// <param name="departmentID"></param>
  1279. /// <param name="educationID"></param>
  1280. /// <param name="learningformID"></param>
  1281. /// <param name="learnSystem"></param>
  1282. /// <param name="coursematerialID"></param>
  1283. /// <param name="starttermID"></param>
  1284. /// <param name="handleModeID"></param>
  1285. /// <param name="startSchoolcodeID"></param>
  1286. /// <param name="yearID"></param>
  1287. /// <param name="specialtyID"></param>
  1288. /// <returns></returns>
  1289. public IList<SpecialtyCourseView> GetAdultSpecialtyCourseViewNoAddList(ConfiguretView configuretView, Guid? departmentID,
  1290. int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID, int? starttermID, int? handleModeID,
  1291. int? startSchoolcodeID, int? yearID, Guid? specialtyID)
  1292. {
  1293. //专业课程
  1294. Expression<Func<EM_SpecialtyCourse, bool>> expSpecialtyCourse = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1295. expSpecialtyCourse = expSpecialtyCourse.And(x => x.IsEnable == true);
  1296. expSpecialtyCourse = expSpecialtyCourse.And(x => x.SpecialtyID == specialtyID);
  1297. if (departmentID.HasValue)
  1298. {
  1299. expSpecialtyCourse = expSpecialtyCourse.And(x => x.DepartmentID == departmentID);
  1300. }
  1301. if (coursematerialID.HasValue)
  1302. {
  1303. expSpecialtyCourse = expSpecialtyCourse.And(x => x.CoursematerialID == coursematerialID);
  1304. }
  1305. if (starttermID.HasValue)
  1306. {
  1307. expSpecialtyCourse = expSpecialtyCourse.And(x => x.StarttermID == starttermID);
  1308. }
  1309. if (handleModeID.HasValue)
  1310. {
  1311. expSpecialtyCourse = expSpecialtyCourse.And(x => x.HandleModeID == handleModeID);
  1312. }
  1313. //学年学期
  1314. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1315. expSchoolyear = expSchoolyear.And(x => x.SchoolcodeID == startSchoolcodeID);
  1316. expSchoolyear = expSchoolyear.And(x => x.Years == yearID);
  1317. //专业信息
  1318. Expression<Func<CF_Specialty, bool>> expSpecialty = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1319. expSpecialty = expSpecialty.And(x => x.SpecialtyID == specialtyID);
  1320. if (educationID.HasValue)
  1321. {
  1322. expSpecialty = expSpecialty.And(x => x.EducationID == educationID);
  1323. }
  1324. if (learningformID.HasValue)
  1325. {
  1326. expSpecialty = expSpecialty.And(x => x.LearningformID == learningformID);
  1327. }
  1328. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  1329. {
  1330. var LearnSystems = Convert.ToDecimal(learnSystem);
  1331. expSpecialty = expSpecialty.And(x => x.LearnSystem == LearnSystems);
  1332. }
  1333. //专业计划
  1334. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1335. if (coursematerialID.HasValue)
  1336. {
  1337. expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID);
  1338. }
  1339. if (specialtyID.HasValue)
  1340. {
  1341. expSpecialtyPlan = expSpecialtyPlan.And(x => x.SpecialtyID == specialtyID);
  1342. }
  1343. var query = SpecialtyPlanDAL.GetAdultSpecialtyCourseViewNoAddQueryable(expSpecialtyCourse, expSchoolyear, expSpecialty, expSpecialtyPlan);
  1344. //查询条件
  1345. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1346. {
  1347. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1348. }
  1349. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.EducationID)
  1350. .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
  1351. .ThenBy(x => x.StarttermID).ThenBy(x => x.CourseTypeID)
  1352. .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
  1353. .ToList();
  1354. }
  1355. /// <summary>
  1356. /// 删除
  1357. /// </summary>
  1358. /// <param name="specialtyPlanIDs"></param>
  1359. /// <returns></returns>
  1360. public bool AdultSpecialtyPlanDelete(List<Guid?> specialtyPlanIDs)
  1361. {
  1362. try
  1363. {
  1364. using (TransactionScope ts = new TransactionScope())
  1365. {
  1366. UnitOfWork.Delete<EM_SpecialtyPlanTeachingPlace>(x => specialtyPlanIDs.Contains(x.SpecialtyPlanID));
  1367. UnitOfWork.Delete<EM_SpecialtyPlanTeachingModeType>(x => specialtyPlanIDs.Contains(x.SpecialtyPlanID));
  1368. UnitOfWork.Delete<EM_SpecialtyPlanTeachingSetting>(x => specialtyPlanIDs.Contains(x.SpecialtyPlanID));
  1369. UnitOfWork.Delete<EM_SpecialtyPlan>(x => specialtyPlanIDs.Contains(x.SpecialtyPlanID));
  1370. ts.Complete();
  1371. return true;
  1372. }
  1373. }
  1374. catch (Exception)
  1375. {
  1376. throw;
  1377. }
  1378. }
  1379. /// <summary>
  1380. /// 专业计划执行
  1381. /// 注:成教版本(入学学年学期、专业信息)
  1382. /// 注:年级专业对应的学生人数小于等于0时,不可执行
  1383. /// </summary>
  1384. /// <param name="specialtyPlanIDList"></param>
  1385. /// <returns></returns>
  1386. public string AdultSpecialtyPlanExecute(List<Guid?> specialtyPlanIDList)
  1387. {
  1388. try
  1389. {
  1390. //查询对应的专业计划信息specialtyPlanViewList
  1391. var specialtyPlanViewList = SpecialtyPlanDAL.GetAdultSpecialtyPlanViewQueryable(x => specialtyPlanIDList.Contains(x.SpecialtyPlanID)).ToList();
  1392. //查询对应的入学学年学期IDList
  1393. var startSchoolyearIDList = specialtyPlanViewList.Select(x => x.StartSchoolyearID).Distinct().ToList();
  1394. //查询对应的专业信息IDList
  1395. var specialtyIDList = specialtyPlanViewList.Select(x => x.SpecialtyID).Distinct().ToList();
  1396. //学年学期
  1397. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1398. expSchoolyear = expSchoolyear.And(x => startSchoolyearIDList.Contains(x.SchoolyearID));
  1399. //专业信息
  1400. Expression<Func<CF_Specialty, bool>> expSpecialty = (x => x.RecordStatus >= (int)SYS_STATUS.UNUSABLE);
  1401. expSpecialty = expSpecialty.And(x => specialtyIDList.Contains(x.SpecialtyID));
  1402. //查询对应的年级专业信息grademajorViewList
  1403. var grademajorViewList = SpecialtyPlanDAL.GetAdultGrademajorViewQueryable(expSchoolyear, expSpecialty).ToList();
  1404. //查询对应的年级专业IDList
  1405. var grademajorIDList = grademajorViewList.Select(x => x.GrademajorID).Distinct().ToList();
  1406. //查询对比后的执行计划信息List(暂时只对比年级专业ID)
  1407. var executablePlanList = SpecialtyPlanDAL.ExecutablePlanRepository
  1408. .GetList(x => grademajorIDList.Contains(x.GrademajorID.Value), (x => x.EM_ExecutablePlanProfile),
  1409. (x => x.EM_ExecutablePlanTeachingSetting)).ToList();
  1410. int insert = 0; //成功
  1411. int update = 0; //更新
  1412. int fail = 0; //失败
  1413. string tipMessage = null; //提示消息
  1414. List<EM_ExecutablePlan> newExecutablePlanInList = new List<EM_ExecutablePlan>();
  1415. List<EM_ExecutablePlan> newExecutablePlanUpList = new List<EM_ExecutablePlan>();
  1416. List<EM_ExecutablePlanProfile> newProfileInList = new List<EM_ExecutablePlanProfile>();
  1417. List<EM_ExecutablePlanProfile> newProfileUpList = new List<EM_ExecutablePlanProfile>();
  1418. List<EM_ExecutablePlanTeachingSetting> newTeachingSettingInList = new List<EM_ExecutablePlanTeachingSetting>();
  1419. List<EM_ExecutablePlanTeachingSetting> newTeachingSettingUpList = new List<EM_ExecutablePlanTeachingSetting>();
  1420. List<EM_ExecutablePlanTeachingModeType> newTeachingModeTypeInList = new List<EM_ExecutablePlanTeachingModeType>();
  1421. List<EM_ExecutablePlanTeachingPlace> newTeachingPlaceInList = new List<EM_ExecutablePlanTeachingPlace>();
  1422. List<Guid?> executablePlanTMDelList = new List<Guid?>();
  1423. List<Guid?> executablePlanTPDelList = new List<Guid?>();
  1424. List<Guid> executablePlanIDList = new List<Guid>();
  1425. foreach (var specialtyPlanView in specialtyPlanViewList)
  1426. {
  1427. if (specialtyPlanView.Value < specialtyPlanView.StartValue)
  1428. {
  1429. //表示学年学期小于入学学年学期
  1430. fail++;
  1431. }
  1432. else
  1433. {
  1434. if (specialtyPlanView.Value > specialtyPlanView.GraduatingSemesterValue)
  1435. {
  1436. //表示学年学期大于毕业学年学期
  1437. fail++;
  1438. }
  1439. else
  1440. {
  1441. //查询对应的年级专业信息List
  1442. var newGrademajorViewList = grademajorViewList.Where(x => x.StartSchoolyearID == specialtyPlanView.StartSchoolyearID
  1443. && x.SpecialtyID == specialtyPlanView.SpecialtyID).ToList();
  1444. //根据业务主键查询对应的执行计划信息(业务主键:学年学期ID、年级专业ID、课程信息ID)
  1445. //注:由于相关业务主键冗余且同时存在主外键关联,目前不允许修改相关业务主键
  1446. foreach (var newGrademajorView in newGrademajorViewList)
  1447. {
  1448. //判断年级专业对应的学生人数
  1449. if (newGrademajorView.StudentCount <= 0)
  1450. {
  1451. //表示年级专业对应的学生人数小于等于0
  1452. fail++;
  1453. }
  1454. else
  1455. {
  1456. var executablePlan = executablePlanList.Where(x => x.SchoolyearID == specialtyPlanView.SchoolyearID
  1457. && x.GrademajorID == newGrademajorView.GrademajorID
  1458. && x.CoursematerialID == specialtyPlanView.CoursematerialID).SingleOrDefault();
  1459. if (executablePlan == null)
  1460. {
  1461. //表示不存在对应的执行计划信息(新增)
  1462. var newExecutablePlan = new EM_ExecutablePlan();
  1463. newExecutablePlan.ExecutablePlanID = Guid.NewGuid();
  1464. //来源专业计划默认为必修课
  1465. newExecutablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse;
  1466. newExecutablePlan.DefaultClassName = specialtyPlanView.CourseName + "-" + newGrademajorView.Name;
  1467. newExecutablePlan.SpecialtyPlanID = specialtyPlanView.SpecialtyPlanID;
  1468. newExecutablePlan.SchoolyearID = specialtyPlanView.SchoolyearID;
  1469. newExecutablePlan.GrademajorID = newGrademajorView.GrademajorID;
  1470. newExecutablePlan.CoursematerialID = specialtyPlanView.CoursematerialID;
  1471. newExecutablePlan.CourseStructureID = specialtyPlanView.CourseStructureID;
  1472. newExecutablePlan.CourseCategoryID = specialtyPlanView.CourseCategoryID;
  1473. newExecutablePlan.CourseTypeID = specialtyPlanView.CourseTypeID;
  1474. newExecutablePlan.CourseQualityID = specialtyPlanView.CourseQualityID;
  1475. newExecutablePlan.DepartmentID = specialtyPlanView.DepartmentID;
  1476. newExecutablePlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial;
  1477. newExecutablePlan.ResultTypeID = specialtyPlanView.ResultTypeID;
  1478. newExecutablePlan.HandleModeID = specialtyPlanView.HandleModeID;
  1479. newExecutablePlan.Remark = specialtyPlanView.Remark;
  1480. SetNewStatus(newExecutablePlan, (int)EM_ExecuteStatus.NotSubmited);
  1481. newExecutablePlanInList.Add(newExecutablePlan);
  1482. var newProfile = new EM_ExecutablePlanProfile();
  1483. newProfile.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  1484. newProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  1485. newProfile.IsCooperation = specialtyPlanView.IsCooperation;
  1486. newProfile.IsRequired = specialtyPlanView.IsRequired;
  1487. newProfile.IsElective = specialtyPlanView.IsElective;
  1488. newProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  1489. newProfile.IsMainCourse = specialtyPlanView.IsMainCourse;
  1490. newProfile.CourseFineID = specialtyPlanView.CourseFineID;
  1491. newProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  1492. newProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  1493. newProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  1494. SetNewStatus(newProfile);
  1495. newProfileInList.Add(newProfile);
  1496. var newTeachingSetting = new EM_ExecutablePlanTeachingSetting();
  1497. newTeachingSetting.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  1498. newTeachingSetting.Credit = specialtyPlanView.Credit;
  1499. newTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  1500. newTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  1501. newTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  1502. newTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  1503. newTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  1504. newTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  1505. newTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  1506. newTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  1507. newTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  1508. newTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  1509. newTeachingSettingInList.Add(newTeachingSetting);
  1510. if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0)
  1511. {
  1512. foreach (var newModeType in specialtyPlanView.TeachingModeIDList.ToList())
  1513. {
  1514. var newTeachingModeType = new EM_ExecutablePlanTeachingModeType();
  1515. newTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid();
  1516. newTeachingModeType.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  1517. newTeachingModeType.TeachingModeID = newModeType;
  1518. this.SetNewStatus(newTeachingModeType);
  1519. newTeachingModeTypeInList.Add(newTeachingModeType);
  1520. }
  1521. }
  1522. if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0)
  1523. {
  1524. foreach (var newPlace in specialtyPlanView.TeachingPlaceIDList.ToList())
  1525. {
  1526. var newTeachingPlace = new EM_ExecutablePlanTeachingPlace();
  1527. newTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid();
  1528. newTeachingPlace.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  1529. newTeachingPlace.TeachingPlace = newPlace;
  1530. this.SetNewStatus(newTeachingPlace);
  1531. newTeachingPlaceInList.Add(newTeachingPlace);
  1532. }
  1533. }
  1534. insert++;
  1535. }
  1536. else
  1537. {
  1538. if (!executablePlanIDList.Contains(executablePlan.ExecutablePlanID))
  1539. {
  1540. //表示存在对应的执行计划信息(修改)
  1541. executablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse;
  1542. executablePlan.DefaultClassName = specialtyPlanView.CourseName + "-" + newGrademajorView.Name;
  1543. executablePlan.SpecialtyPlanID = specialtyPlanView.SpecialtyPlanID;
  1544. executablePlan.SchoolyearID = specialtyPlanView.SchoolyearID;
  1545. executablePlan.GrademajorID = newGrademajorView.GrademajorID;
  1546. executablePlan.CoursematerialID = specialtyPlanView.CoursematerialID;
  1547. executablePlan.CourseStructureID = specialtyPlanView.CourseStructureID;
  1548. executablePlan.CourseCategoryID = specialtyPlanView.CourseCategoryID;
  1549. executablePlan.CourseTypeID = specialtyPlanView.CourseTypeID;
  1550. executablePlan.CourseQualityID = specialtyPlanView.CourseQualityID;
  1551. executablePlan.DepartmentID = specialtyPlanView.DepartmentID;
  1552. executablePlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial;
  1553. executablePlan.ResultTypeID = specialtyPlanView.ResultTypeID;
  1554. executablePlan.HandleModeID = specialtyPlanView.HandleModeID;
  1555. SetModifyStatus(executablePlan);
  1556. newExecutablePlanUpList.Add(executablePlan);
  1557. if (executablePlan.EM_ExecutablePlanProfile == null)
  1558. {
  1559. var newProfile = new EM_ExecutablePlanProfile();
  1560. newProfile.ExecutablePlanID = executablePlan.ExecutablePlanID;
  1561. newProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  1562. newProfile.IsCooperation = specialtyPlanView.IsCooperation;
  1563. newProfile.IsRequired = specialtyPlanView.IsRequired;
  1564. newProfile.IsElective = specialtyPlanView.IsElective;
  1565. newProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  1566. newProfile.IsMainCourse = specialtyPlanView.IsMainCourse;
  1567. newProfile.CourseFineID = specialtyPlanView.CourseFineID;
  1568. newProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  1569. newProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  1570. newProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  1571. SetNewStatus(newProfile);
  1572. newProfileInList.Add(newProfile);
  1573. }
  1574. else
  1575. {
  1576. executablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore;
  1577. executablePlan.EM_ExecutablePlanProfile.IsCooperation = specialtyPlanView.IsCooperation;
  1578. executablePlan.EM_ExecutablePlanProfile.IsRequired = specialtyPlanView.IsRequired;
  1579. executablePlan.EM_ExecutablePlanProfile.IsElective = specialtyPlanView.IsElective;
  1580. executablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse;
  1581. executablePlan.EM_ExecutablePlanProfile.IsMainCourse = specialtyPlanView.IsMainCourse;
  1582. executablePlan.EM_ExecutablePlanProfile.CourseFineID = specialtyPlanView.CourseFineID;
  1583. executablePlan.EM_ExecutablePlanProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID;
  1584. executablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID;
  1585. executablePlan.EM_ExecutablePlanProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID;
  1586. SetModifyStatus(executablePlan.EM_ExecutablePlanProfile);
  1587. newProfileUpList.Add(executablePlan.EM_ExecutablePlanProfile);
  1588. }
  1589. if (executablePlan.EM_ExecutablePlanTeachingSetting == null)
  1590. {
  1591. var newTeachingSetting = new EM_ExecutablePlanTeachingSetting();
  1592. newTeachingSetting.ExecutablePlanID = executablePlan.ExecutablePlanID;
  1593. newTeachingSetting.Credit = specialtyPlanView.Credit;
  1594. newTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  1595. newTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  1596. newTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  1597. newTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  1598. newTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  1599. newTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  1600. newTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  1601. newTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  1602. newTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  1603. newTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  1604. newTeachingSettingInList.Add(newTeachingSetting);
  1605. }
  1606. else
  1607. {
  1608. //可更新的相关信息
  1609. executablePlan.EM_ExecutablePlanTeachingSetting.Credit = specialtyPlanView.Credit;
  1610. executablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse;
  1611. executablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = specialtyPlanView.Practicehours;
  1612. executablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = specialtyPlanView.Trialhours;
  1613. if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  1614. {
  1615. executablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum;
  1616. executablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum;
  1617. executablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum;
  1618. executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours;
  1619. executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum;
  1620. executablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum;
  1621. executablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum;
  1622. }
  1623. newTeachingSettingUpList.Add(executablePlan.EM_ExecutablePlanTeachingSetting);
  1624. }
  1625. if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  1626. {
  1627. //可更新的相关信息
  1628. if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0)
  1629. {
  1630. executablePlanTMDelList.Add(executablePlan.ExecutablePlanID);
  1631. foreach (var newModeType in specialtyPlanView.TeachingModeIDList.ToList())
  1632. {
  1633. var newTeachingModeType = new EM_ExecutablePlanTeachingModeType();
  1634. newTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid();
  1635. newTeachingModeType.ExecutablePlanID = executablePlan.ExecutablePlanID;
  1636. newTeachingModeType.TeachingModeID = newModeType;
  1637. this.SetNewStatus(newTeachingModeType);
  1638. newTeachingModeTypeInList.Add(newTeachingModeType);
  1639. }
  1640. }
  1641. else
  1642. {
  1643. executablePlanTMDelList.Add(executablePlan.ExecutablePlanID);
  1644. }
  1645. }
  1646. if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0)
  1647. {
  1648. executablePlanTPDelList.Add(executablePlan.ExecutablePlanID);
  1649. foreach (var newPlace in specialtyPlanView.TeachingPlaceIDList.ToList())
  1650. {
  1651. var newTeachingPlace = new EM_ExecutablePlanTeachingPlace();
  1652. newTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid();
  1653. newTeachingPlace.ExecutablePlanID = executablePlan.ExecutablePlanID;
  1654. newTeachingPlace.TeachingPlace = newPlace;
  1655. this.SetNewStatus(newTeachingPlace);
  1656. newTeachingPlaceInList.Add(newTeachingPlace);
  1657. }
  1658. }
  1659. else
  1660. {
  1661. executablePlanTPDelList.Add(executablePlan.ExecutablePlanID);
  1662. }
  1663. executablePlanIDList.Add(executablePlan.ExecutablePlanID);
  1664. }
  1665. update++;
  1666. }
  1667. }
  1668. }
  1669. //表示存在对应的主外键关联
  1670. if (specialtyPlanView.PlanStatus == (int)EM_PlanStatus.Execute)
  1671. {
  1672. //根据专业计划主键ID查询对应的执行计划信息List
  1673. var newExecutablePlanList = SpecialtyPlanDAL.ExecutablePlanRepository
  1674. .GetList(x => x.SpecialtyPlanID == specialtyPlanView.SpecialtyPlanID,
  1675. (x => x.EM_ExecutablePlanProfile), (x => x.EM_ExecutablePlanTeachingSetting)).ToList();
  1676. foreach (var newExecutablePlan in newExecutablePlanList)
  1677. {
  1678. if (!executablePlanIDList.Contains(newExecutablePlan.ExecutablePlanID))
  1679. {
  1680. //查询对应的执行计划信息View
  1681. var newExecutablePlanView = ExecutablePlanDAL.GetExecutablePlanViewQueryable(x => x.ExecutablePlanID == newExecutablePlan.ExecutablePlanID).SingleOrDefault();
  1682. //查询对应的专业计划信息(业务主键:学年学期ID、入学学年学期ID、专业信息ID、课程信息ID)
  1683. var newSpecialtyPlanView = SpecialtyPlanDAL.GetAdultSpecialtyPlanViewQueryable(x => x.SpecialtyPlanID != specialtyPlanView.SpecialtyPlanID
  1684. && x.SchoolyearID == newExecutablePlanView.SchoolyearID
  1685. && x.StartSchoolyearID == newExecutablePlanView.StartSchoolyearID
  1686. && x.SpecialtyID == newExecutablePlanView.SpecialtyID
  1687. && x.CoursematerialID == newExecutablePlanView.CoursematerialID).SingleOrDefault();
  1688. if (newSpecialtyPlanView == null)
  1689. {
  1690. newExecutablePlan.SpecialtyPlanID = null;
  1691. SetModifyStatus(newExecutablePlan);
  1692. newExecutablePlanUpList.Add(newExecutablePlan);
  1693. }
  1694. else
  1695. {
  1696. //来源专业计划默认为必修课
  1697. newExecutablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse;
  1698. newExecutablePlan.DefaultClassName = newExecutablePlanView.CourseName + "-" + newExecutablePlanView.GrademajorName;
  1699. newExecutablePlan.SpecialtyPlanID = newSpecialtyPlanView.SpecialtyPlanID;
  1700. newExecutablePlan.SchoolyearID = newSpecialtyPlanView.SchoolyearID;
  1701. newExecutablePlan.GrademajorID = newExecutablePlanView.GrademajorID;
  1702. newExecutablePlan.CoursematerialID = newSpecialtyPlanView.CoursematerialID;
  1703. newExecutablePlan.CourseStructureID = newSpecialtyPlanView.CourseStructureID;
  1704. newExecutablePlan.CourseCategoryID = newSpecialtyPlanView.CourseCategoryID;
  1705. newExecutablePlan.CourseTypeID = newSpecialtyPlanView.CourseTypeID;
  1706. newExecutablePlan.CourseQualityID = newSpecialtyPlanView.CourseQualityID;
  1707. newExecutablePlan.DepartmentID = newSpecialtyPlanView.DepartmentID;
  1708. newExecutablePlan.IsNeedMaterial = newSpecialtyPlanView.IsNeedMaterial;
  1709. newExecutablePlan.ResultTypeID = newSpecialtyPlanView.ResultTypeID;
  1710. newExecutablePlan.HandleModeID = newSpecialtyPlanView.HandleModeID;
  1711. SetModifyStatus(newExecutablePlan);
  1712. newExecutablePlanUpList.Add(newExecutablePlan);
  1713. if (newExecutablePlan.EM_ExecutablePlanProfile == null)
  1714. {
  1715. var newProfile = new EM_ExecutablePlanProfile();
  1716. newProfile.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  1717. newProfile.IsSpecialtycore = newSpecialtyPlanView.IsSpecialtycore;
  1718. newProfile.IsCooperation = newSpecialtyPlanView.IsCooperation;
  1719. newProfile.IsRequired = newSpecialtyPlanView.IsRequired;
  1720. newProfile.IsElective = newSpecialtyPlanView.IsElective;
  1721. newProfile.IsNetworkCourse = newSpecialtyPlanView.IsNetworkCourse;
  1722. newProfile.IsMainCourse = newSpecialtyPlanView.IsMainCourse;
  1723. newProfile.CourseFineID = newSpecialtyPlanView.CourseFineID;
  1724. newProfile.PracticeTypeID = newSpecialtyPlanView.PracticeTypeID;
  1725. newProfile.TeachinglanguageID = newSpecialtyPlanView.TeachinglanguageID;
  1726. newProfile.ExaminationModeID = newSpecialtyPlanView.ExaminationModeID;
  1727. SetNewStatus(newProfile);
  1728. newProfileInList.Add(newProfile);
  1729. }
  1730. else
  1731. {
  1732. newExecutablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = newSpecialtyPlanView.IsSpecialtycore;
  1733. newExecutablePlan.EM_ExecutablePlanProfile.IsCooperation = newSpecialtyPlanView.IsCooperation;
  1734. newExecutablePlan.EM_ExecutablePlanProfile.IsRequired = newSpecialtyPlanView.IsRequired;
  1735. newExecutablePlan.EM_ExecutablePlanProfile.IsElective = newSpecialtyPlanView.IsElective;
  1736. newExecutablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = newSpecialtyPlanView.IsNetworkCourse;
  1737. newExecutablePlan.EM_ExecutablePlanProfile.IsMainCourse = newSpecialtyPlanView.IsMainCourse;
  1738. newExecutablePlan.EM_ExecutablePlanProfile.CourseFineID = newSpecialtyPlanView.CourseFineID;
  1739. newExecutablePlan.EM_ExecutablePlanProfile.PracticeTypeID = newSpecialtyPlanView.PracticeTypeID;
  1740. newExecutablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = newSpecialtyPlanView.TeachinglanguageID;
  1741. newExecutablePlan.EM_ExecutablePlanProfile.ExaminationModeID = newSpecialtyPlanView.ExaminationModeID;
  1742. SetModifyStatus(newExecutablePlan.EM_ExecutablePlanProfile);
  1743. newProfileUpList.Add(newExecutablePlan.EM_ExecutablePlanProfile);
  1744. }
  1745. if (newExecutablePlan.EM_ExecutablePlanTeachingSetting == null)
  1746. {
  1747. var newTeachingSetting = new EM_ExecutablePlanTeachingSetting();
  1748. newTeachingSetting.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  1749. newTeachingSetting.Credit = newSpecialtyPlanView.Credit;
  1750. newTeachingSetting.TheoryCourse = newSpecialtyPlanView.TheoryCourse;
  1751. newTeachingSetting.Practicehours = newSpecialtyPlanView.Practicehours;
  1752. newTeachingSetting.Trialhours = newSpecialtyPlanView.Trialhours;
  1753. newTeachingSetting.TheoryWeeklyNum = newSpecialtyPlanView.TheoryWeeklyNum;
  1754. newTeachingSetting.PracticeWeeklyNum = newSpecialtyPlanView.PracticeWeeklyNum;
  1755. newTeachingSetting.TrialWeeklyNum = newSpecialtyPlanView.TrialWeeklyNum;
  1756. newTeachingSetting.WeeklyHours = newSpecialtyPlanView.WeeklyHours;
  1757. newTeachingSetting.WeeklyNum = newSpecialtyPlanView.WeeklyNum;
  1758. newTeachingSetting.StartWeeklyNum = newSpecialtyPlanView.StartWeeklyNum;
  1759. newTeachingSetting.EndWeeklyNum = newSpecialtyPlanView.EndWeeklyNum;
  1760. newTeachingSettingInList.Add(newTeachingSetting);
  1761. }
  1762. else
  1763. {
  1764. //可更新的相关信息
  1765. newExecutablePlan.EM_ExecutablePlanTeachingSetting.Credit = newSpecialtyPlanView.Credit;
  1766. newExecutablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = newSpecialtyPlanView.TheoryCourse;
  1767. newExecutablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = newSpecialtyPlanView.Practicehours;
  1768. newExecutablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = newSpecialtyPlanView.Trialhours;
  1769. if (newExecutablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  1770. {
  1771. newExecutablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = newSpecialtyPlanView.TheoryWeeklyNum;
  1772. newExecutablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = newSpecialtyPlanView.PracticeWeeklyNum;
  1773. newExecutablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = newSpecialtyPlanView.TrialWeeklyNum;
  1774. newExecutablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = newSpecialtyPlanView.WeeklyHours;
  1775. newExecutablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = newSpecialtyPlanView.WeeklyNum;
  1776. newExecutablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = newSpecialtyPlanView.StartWeeklyNum;
  1777. newExecutablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = newSpecialtyPlanView.EndWeeklyNum;
  1778. }
  1779. newTeachingSettingUpList.Add(newExecutablePlan.EM_ExecutablePlanTeachingSetting);
  1780. }
  1781. if (newExecutablePlan.RecordStatus == (int)EM_ExecuteStatus.NotSubmited)
  1782. {
  1783. //可更新的相关信息
  1784. if (newSpecialtyPlanView.TeachingModeIDList != null && newSpecialtyPlanView.TeachingModeIDList.Count() > 0)
  1785. {
  1786. executablePlanTMDelList.Add(newExecutablePlan.ExecutablePlanID);
  1787. foreach (var newModeType in newSpecialtyPlanView.TeachingModeIDList.ToList())
  1788. {
  1789. var newTeachingModeType = new EM_ExecutablePlanTeachingModeType();
  1790. newTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid();
  1791. newTeachingModeType.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  1792. newTeachingModeType.TeachingModeID = newModeType;
  1793. this.SetNewStatus(newTeachingModeType);
  1794. newTeachingModeTypeInList.Add(newTeachingModeType);
  1795. }
  1796. }
  1797. else
  1798. {
  1799. executablePlanTMDelList.Add(newExecutablePlan.ExecutablePlanID);
  1800. }
  1801. }
  1802. if (newSpecialtyPlanView.TeachingPlaceIDList != null && newSpecialtyPlanView.TeachingPlaceIDList.Count() > 0)
  1803. {
  1804. executablePlanTPDelList.Add(newExecutablePlan.ExecutablePlanID);
  1805. foreach (var newPlace in newSpecialtyPlanView.TeachingPlaceIDList.ToList())
  1806. {
  1807. var newTeachingPlace = new EM_ExecutablePlanTeachingPlace();
  1808. newTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid();
  1809. newTeachingPlace.ExecutablePlanID = newExecutablePlan.ExecutablePlanID;
  1810. newTeachingPlace.TeachingPlace = newPlace;
  1811. this.SetNewStatus(newTeachingPlace);
  1812. newTeachingPlaceInList.Add(newTeachingPlace);
  1813. }
  1814. }
  1815. else
  1816. {
  1817. executablePlanTPDelList.Add(newExecutablePlan.ExecutablePlanID);
  1818. }
  1819. }
  1820. executablePlanIDList.Add(newExecutablePlan.ExecutablePlanID);
  1821. }
  1822. }
  1823. }
  1824. }
  1825. }
  1826. }
  1827. using (TransactionScope ts = new TransactionScope())
  1828. {
  1829. //删除
  1830. UnitOfWork.Delete<EM_ExecutablePlanTeachingPlace>(x => executablePlanTPDelList.Contains(x.ExecutablePlanID));
  1831. UnitOfWork.Delete<EM_ExecutablePlanTeachingModeType>(x => executablePlanTMDelList.Contains(x.ExecutablePlanID));
  1832. //批量插入
  1833. UnitOfWork.BulkInsert(newExecutablePlanInList);
  1834. UnitOfWork.BulkInsert(newProfileInList);
  1835. UnitOfWork.BulkInsert(newTeachingSettingInList);
  1836. UnitOfWork.BulkInsert(newTeachingModeTypeInList);
  1837. UnitOfWork.BulkInsert(newTeachingPlaceInList);
  1838. //批量统一提交更新
  1839. if (newExecutablePlanUpList != null && newExecutablePlanUpList.Count() > 0)
  1840. {
  1841. UnitOfWork.BatchUpdate(newExecutablePlanUpList);
  1842. }
  1843. //批量统一提交更新
  1844. if (newProfileUpList != null && newProfileUpList.Count() > 0)
  1845. {
  1846. UnitOfWork.BatchUpdate(newProfileUpList);
  1847. }
  1848. //批量统一提交更新
  1849. if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0)
  1850. {
  1851. UnitOfWork.BatchUpdate(newTeachingSettingUpList);
  1852. }
  1853. ts.Complete();
  1854. }
  1855. if (fail > 0)
  1856. {
  1857. tipMessage = insert + "条,刷新成功" + update + "条,失败" + fail + "条,原因:年级专业对应的学生人数为0、学年学期小于入学学年学期或学年学期大于毕业学年学期,请检查";
  1858. }
  1859. else if (insert > 0 && update <= 0)
  1860. {
  1861. tipMessage = insert + "条";
  1862. }
  1863. else
  1864. {
  1865. tipMessage = insert + "条,刷新成功" + update + "条";
  1866. }
  1867. return tipMessage;
  1868. }
  1869. catch (Exception)
  1870. {
  1871. throw;
  1872. }
  1873. }
  1874. /// <summary>
  1875. /// 查询专业计划对应的授课方式List
  1876. /// </summary>
  1877. /// <param name="specialtyPlanID"></param>
  1878. /// <returns></returns>
  1879. public List<string> GetTeachingModeTypeList(Guid? specialtyPlanID)
  1880. {
  1881. //专业计划
  1882. Expression<Func<EM_SpecialtyPlan, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1883. exp = exp.And(x => x.SpecialtyPlanID == specialtyPlanID);
  1884. var query = SpecialtyPlanDAL.GetTeachingModeTypeQueryble(exp);
  1885. return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList();
  1886. }
  1887. /// <summary>
  1888. /// 查询专业计划对应的授课地点List
  1889. /// </summary>
  1890. /// <param name="specialtyPlanID"></param>
  1891. /// <returns></returns>
  1892. public List<string> GetTeachingPlaceList(Guid? specialtyPlanID)
  1893. {
  1894. //专业计划
  1895. Expression<Func<EM_SpecialtyPlan, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1896. exp = exp.And(x => x.SpecialtyPlanID == specialtyPlanID);
  1897. var query = SpecialtyPlanDAL.GetTeachingPlaceQueryble(exp);
  1898. return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList();
  1899. }
  1900. /// <summary>
  1901. /// 查询对应的计划范围信息GrademajorView(根据专业计划信息,统计各年级专业对应的班级数、学生人数)
  1902. /// 注:成教版本(入学学年学期、专业信息)
  1903. /// </summary>
  1904. /// <param name="configuretView"></param>
  1905. /// <param name="specialtyPlanID"></param>
  1906. /// <param name="collegeID"></param>
  1907. /// <param name="grademajorID"></param>
  1908. /// <param name="inSchoolStatus"></param>
  1909. /// <param name="pageIndex"></param>
  1910. /// <param name="pageSize"></param>
  1911. /// <returns></returns>
  1912. public IGridResultSet<GrademajorView> GetAdultPlanRangeViewGrid(ConfiguretView configuretView, Guid? specialtyPlanID,
  1913. Guid? collegeID, Guid? grademajorID, int? inSchoolStatus, int pageIndex, int pageSize)
  1914. {
  1915. //专业计划
  1916. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1917. expSpecialtyPlan = expSpecialtyPlan.And(x => x.SpecialtyPlanID == specialtyPlanID);
  1918. //学生信息
  1919. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1920. if (inSchoolStatus != null && inSchoolStatus > -1)
  1921. {
  1922. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  1923. if (inSchoolStatus == 1)
  1924. {
  1925. //表示在校
  1926. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  1927. }
  1928. if (inSchoolStatus == 0)
  1929. {
  1930. //不在校
  1931. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  1932. }
  1933. }
  1934. var query = SpecialtyPlanDAL.GetAdultPlanRangeViewQueryable(expSpecialtyPlan, expStudent);
  1935. if (collegeID.HasValue)
  1936. {
  1937. query = query.Where(x => x.CollegeID == collegeID);
  1938. }
  1939. if (grademajorID.HasValue)
  1940. {
  1941. query = query.Where(x => x.GrademajorID == grademajorID);
  1942. }
  1943. //查询条件
  1944. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1945. {
  1946. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1947. }
  1948. return query.OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  1949. .ThenBy(x => x.StandardID).ThenBy(x => x.Code.Length).ThenBy(x => x.Code)
  1950. .ToGridResultSet<GrademajorView>(pageIndex, pageSize);
  1951. }
  1952. /// <summary>
  1953. /// 查询对应的计划范围信息List(根据专业计划信息,统计各年级专业对应的班级数、学生人数)
  1954. /// 注:成教版本(入学学年学期、专业信息)
  1955. /// </summary>
  1956. /// <param name="configuretView"></param>
  1957. /// <param name="specialtyPlanID"></param>
  1958. /// <param name="collegeID"></param>
  1959. /// <param name="grademajorID"></param>
  1960. /// <param name="inSchoolStatus"></param>
  1961. /// <returns></returns>
  1962. public IList<GrademajorView> GetAdultPlanRangeViewList(ConfiguretView configuretView, Guid? specialtyPlanID,
  1963. Guid? collegeID, Guid? grademajorID, int? inSchoolStatus)
  1964. {
  1965. //专业计划
  1966. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1967. expSpecialtyPlan = expSpecialtyPlan.And(x => x.SpecialtyPlanID == specialtyPlanID);
  1968. //学生信息
  1969. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1970. if (inSchoolStatus != null && inSchoolStatus > -1)
  1971. {
  1972. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  1973. if (inSchoolStatus == 1)
  1974. {
  1975. //表示在校
  1976. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  1977. }
  1978. if (inSchoolStatus == 0)
  1979. {
  1980. //不在校
  1981. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  1982. }
  1983. }
  1984. var query = SpecialtyPlanDAL.GetAdultPlanRangeViewQueryable(expSpecialtyPlan, expStudent);
  1985. if (collegeID.HasValue)
  1986. {
  1987. query = query.Where(x => x.CollegeID == collegeID);
  1988. }
  1989. if (grademajorID.HasValue)
  1990. {
  1991. query = query.Where(x => x.GrademajorID == grademajorID);
  1992. }
  1993. //查询条件
  1994. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1995. {
  1996. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1997. }
  1998. return query.OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  1999. .ThenBy(x => x.StandardID).ThenBy(x => x.Code.Length).ThenBy(x => x.Code)
  2000. .ToList();
  2001. }
  2002. /// <summary>
  2003. /// 查询专业计划对应的学生信息BaseStudentView
  2004. /// 注:成教版本(入学学年学期、专业信息)
  2005. /// </summary>
  2006. /// <param name="configuretView"></param>
  2007. /// <param name="specialtyPlanID"></param>
  2008. /// <param name="collegeID"></param>
  2009. /// <param name="classmajorID"></param>
  2010. /// <param name="inSchoolStatus"></param>
  2011. /// <param name="pageIndex"></param>
  2012. /// <param name="pageSize"></param>
  2013. /// <returns></returns>
  2014. public IGridResultSet<BaseStudentView> GetAdultBaseStudentViewGrid(ConfiguretView configuretView, Guid? specialtyPlanID,
  2015. Guid? collegeID, Guid? classmajorID, int? inSchoolStatus, int pageIndex, int pageSize)
  2016. {
  2017. //专业计划
  2018. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  2019. expSpecialtyPlan = expSpecialtyPlan.And(x => x.SpecialtyPlanID == specialtyPlanID);
  2020. //学生信息
  2021. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  2022. if (inSchoolStatus != null && inSchoolStatus > -1)
  2023. {
  2024. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  2025. if (inSchoolStatus == 1)
  2026. {
  2027. //表示在校
  2028. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  2029. }
  2030. if (inSchoolStatus == 0)
  2031. {
  2032. //不在校
  2033. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  2034. }
  2035. }
  2036. var query = SpecialtyPlanDAL.GetAdultBaseStudentViewQueryable(expSpecialtyPlan, expStudent);
  2037. if (collegeID.HasValue)
  2038. {
  2039. query = query.Where(x => x.CollegeID == collegeID);
  2040. }
  2041. if (classmajorID.HasValue)
  2042. {
  2043. query = query.Where(x => x.ClassmajorID == classmajorID);
  2044. }
  2045. //查询条件
  2046. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  2047. {
  2048. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  2049. }
  2050. return query.OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  2051. .ThenBy(x => x.ClassmajorCode.Length)
  2052. .ThenBy(x => x.ClassmajorCode).ThenBy(x => x.LoginID)
  2053. .ToGridResultSet<BaseStudentView>(pageIndex, pageSize);
  2054. }
  2055. /// <summary>
  2056. /// 查询专业计划对应的学生信息List
  2057. /// 注:成教版本(入学学年学期、专业信息)
  2058. /// </summary>
  2059. /// <param name="configuretView"></param>
  2060. /// <param name="specialtyPlanID"></param>
  2061. /// <param name="collegeID"></param>
  2062. /// <param name="classmajorID"></param>
  2063. /// <param name="inSchoolStatus"></param>
  2064. /// <returns></returns>
  2065. public IList<BaseStudentView> GetAdultBaseStudentViewList(ConfiguretView configuretView, Guid? specialtyPlanID,
  2066. Guid? collegeID, Guid? classmajorID, int? inSchoolStatus)
  2067. {
  2068. //专业计划
  2069. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  2070. expSpecialtyPlan = expSpecialtyPlan.And(x => x.SpecialtyPlanID == specialtyPlanID);
  2071. //学生信息
  2072. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  2073. if (inSchoolStatus != null && inSchoolStatus > -1)
  2074. {
  2075. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  2076. if (inSchoolStatus == 1)
  2077. {
  2078. //表示在校
  2079. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  2080. }
  2081. if (inSchoolStatus == 0)
  2082. {
  2083. //不在校
  2084. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  2085. }
  2086. }
  2087. var query = SpecialtyPlanDAL.GetAdultBaseStudentViewQueryable(expSpecialtyPlan, expStudent);
  2088. if (collegeID.HasValue)
  2089. {
  2090. query = query.Where(x => x.CollegeID == collegeID);
  2091. }
  2092. if (classmajorID.HasValue)
  2093. {
  2094. query = query.Where(x => x.ClassmajorID == classmajorID);
  2095. }
  2096. //查询条件
  2097. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  2098. {
  2099. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  2100. }
  2101. return query.OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  2102. .ThenBy(x => x.ClassmajorCode.Length)
  2103. .ThenBy(x => x.ClassmajorCode).ThenBy(x => x.LoginID)
  2104. .ToList();
  2105. }
  2106. /// <summary>
  2107. /// 新增(数据库表,用于报表)
  2108. /// </summary>
  2109. /// <param name="tempTableName"></param>
  2110. /// <param name="ids"></param>
  2111. public void CreateIDTempTable(string tempTableName, List<Guid?> ids)
  2112. {
  2113. try
  2114. {
  2115. UnitOfWork.CreateIDTempTable(tempTableName, ids);
  2116. }
  2117. catch (Exception)
  2118. {
  2119. throw;
  2120. }
  2121. }
  2122. /// <summary>
  2123. /// 删除(数据库表,用于报表)
  2124. /// </summary>
  2125. /// <param name="tempTableName"></param>
  2126. /// <returns></returns>
  2127. public bool DeleteTempTable(string tempTableName)
  2128. {
  2129. try
  2130. {
  2131. UnitOfWork.DeleteTempTable(tempTableName);
  2132. return true;
  2133. }
  2134. catch (Exception)
  2135. {
  2136. throw;
  2137. }
  2138. }
  2139. /// <summary>
  2140. /// 专业计划信息Excel导入
  2141. /// </summary>
  2142. /// <param name="cellheader"></param>
  2143. /// <param name="inCount"></param>
  2144. /// <param name="upCount"></param>
  2145. /// <param name="errdataList"></param>
  2146. /// <param name="errCount"></param>
  2147. /// <param name="sourcePhysicalPath"></param>
  2148. public void AdultSpecialtyPlanImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount,
  2149. out List<SpecialtyPlanView> errdataList, out int? errCount, string sourcePhysicalPath)
  2150. {
  2151. try
  2152. {
  2153. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  2154. List<SpecialtyPlanView> errList = new List<SpecialtyPlanView>();
  2155. // 1.1解析文件,存放到一个List集合里
  2156. cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage)
  2157. List<SpecialtyPlanView> enlist = NpoiExcelHelper.ExcelToEntityList<SpecialtyPlanView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
  2158. cellheader.Add("ErrorMessage", "未导入原因");
  2159. //对List集合进行有效性校验
  2160. if (enlist.Count() <= 0)
  2161. {
  2162. throw new Exception("Excel文件数据为空,请检查。");
  2163. }
  2164. Regex reg = null; //正则表达式
  2165. //DateTime result; //用于返回判断日期字段格式
  2166. bool isListPass = true; //List判断标识
  2167. inCount = 0; //导入个数
  2168. upCount = 0; //更新个数
  2169. errCount = 0; //失败个数
  2170. string errorMsgStr = ""; //错误信息
  2171. List<EM_SpecialtyPlan> newSpecialtyPlanInList = new List<EM_SpecialtyPlan>();
  2172. List<EM_SpecialtyPlan> newSpecialtyPlanUpList = new List<EM_SpecialtyPlan>();
  2173. List<EM_SpecialtyPlanTeachingSetting> newTeachingSettingInList = new List<EM_SpecialtyPlanTeachingSetting>();
  2174. List<EM_SpecialtyPlanTeachingSetting> newTeachingSettingUpList = new List<EM_SpecialtyPlanTeachingSetting>();
  2175. List<EM_SpecialtyPlanTeachingModeType> newTeachingModeTypeInList = new List<EM_SpecialtyPlanTeachingModeType>();
  2176. List<EM_SpecialtyPlanTeachingPlace> newTeachingPlaceInList = new List<EM_SpecialtyPlanTeachingPlace>();
  2177. List<Guid?> specialtyPlanTMDelList = new List<Guid?>();
  2178. List<Guid?> specialtyPlanTPDelList = new List<Guid?>();
  2179. //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
  2180. //年级
  2181. var gradeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Grade).ToList();
  2182. //开课学年
  2183. var schoolyearNumList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_SchoolyearNum).ToList();
  2184. //学期
  2185. var schoolcodeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Semester).ToList();
  2186. //专业代码、专业名称、专业ID(Value)
  2187. var standardList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Standard).ToList();
  2188. //培养层次(所修学历)
  2189. var educationList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Education).ToList();
  2190. //学习形式
  2191. var learningFormList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Learningform).ToList();
  2192. //专业信息
  2193. var specialtyList = SpecialtyPlanDAL.SpecialtyRepository.GetList(x => true).ToList();
  2194. //学年学期
  2195. var schoolyearList = SpecialtyPlanDAL.SchoolyearRepository.GetList(x => true).ToList();
  2196. //课程信息
  2197. var courseList = SpecialtyPlanDAL.CoursematerialRepository.GetList(x => true).ToList();
  2198. //课程代码
  2199. var courseCodeList = enlist.Where(x => !string.IsNullOrEmpty(x.CourseCode)).Select(x => x.CourseCode.Trim()).ToList();
  2200. //对比后的newCourseList
  2201. var newCourseList = courseList.Where(x => courseCodeList.Contains(x.CourseCode)).ToList();
  2202. //对比后的coursematerialIDList
  2203. var coursematerialIDList = newCourseList.Select(x => (Guid?)x.CoursematerialID).ToList();
  2204. //课程结构
  2205. var courseStructureList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseStructure).ToList();
  2206. //课程属性
  2207. var courseCategoryList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseCategory).ToList();
  2208. //课程类型
  2209. var courseTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseType).ToList();
  2210. //课程性质
  2211. var courseQualityList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseQuality).ToList();
  2212. //教研室信息
  2213. var departmentList = SpecialtyPlanDAL.DepartmentRepository.GetList(x => true).ToList();
  2214. //开课教研室
  2215. var departmentNameList = enlist.Where(x => !string.IsNullOrEmpty(x.DepartmentName)).Select(x => x.DepartmentName.Trim()).ToList();
  2216. //对比后的newDepartmentList
  2217. var newDepartmentList = departmentList.Where(x => departmentNameList.Contains(x.Name)).ToList();
  2218. //是否启用
  2219. var generalPurposeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_GeneralPurpose).ToList();
  2220. //精品课程
  2221. var courseFineList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseFine).ToList();
  2222. //实践类型
  2223. var practiceTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.EM_PracticeType).ToList();
  2224. //授课语言
  2225. var teachinglanguageList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Teachinglanguage).ToList();
  2226. //考试方式
  2227. var examinationModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ExaminationMode).ToList();
  2228. //成绩类型
  2229. var resultTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ResultType).ToList();
  2230. //处理方式
  2231. var handleModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_HandleMode).ToList();
  2232. //授课方式
  2233. var teachingModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_TeachingMode).ToList();
  2234. //授课地点
  2235. var teachingPlaceList = IdNameExt.GetDictionaryItem(DictionaryItem.EM_TeachingPlace).ToList();
  2236. //专业计划
  2237. var specialtyPlanList = SpecialtyPlanDAL.SpecialtyPlanRepository
  2238. .GetList(x => true, (x => x.EM_SpecialtyPlanTeachingSetting)).ToList();
  2239. //对比后的newSpecialtyPlanList(暂时只对比课程信息ID)
  2240. var newSpecialtyPlanList = specialtyPlanList.Where(x => coursematerialIDList.Contains(x.CoursematerialID)).ToList();
  2241. //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
  2242. for (int i = 0; i < enlist.Count; i++)
  2243. {
  2244. SpecialtyPlanView en = enlist[i]; //Excel表数据视图
  2245. EM_SpecialtyPlan newSpecialtyPlan = new EM_SpecialtyPlan();
  2246. EM_SpecialtyPlanTeachingSetting newTeachingSetting = new EM_SpecialtyPlanTeachingSetting();
  2247. List<int> newModeTypeList = new List<int>();
  2248. List<int> newPlaceList = new List<int>();
  2249. //年级
  2250. if (string.IsNullOrWhiteSpace(en.GradeStr))
  2251. {
  2252. errCount++;
  2253. errorMsgStr = "年级不能为空";
  2254. en.ErrorMessage = errorMsgStr;
  2255. errList.Add(en);
  2256. errorMsg.AppendLine(errorMsgStr);
  2257. continue;
  2258. }
  2259. else
  2260. {
  2261. var grade = gradeList.Where(x => x.Name == en.GradeStr.Trim()).SingleOrDefault();
  2262. if (grade == null)
  2263. {
  2264. errCount++;
  2265. errorMsgStr = "年级不存在,请检查";
  2266. en.ErrorMessage = errorMsgStr;
  2267. errList.Add(en);
  2268. errorMsg.AppendLine(errorMsgStr);
  2269. continue;
  2270. }
  2271. else
  2272. {
  2273. //年级
  2274. en.GradeID = grade.Value;
  2275. }
  2276. }
  2277. //入学学期
  2278. if (string.IsNullOrWhiteSpace(en.StartSchoolcodeStr))
  2279. {
  2280. errCount++;
  2281. errorMsgStr = "入学学期不能为空";
  2282. en.ErrorMessage = errorMsgStr;
  2283. errList.Add(en);
  2284. errorMsg.AppendLine(errorMsgStr);
  2285. continue;
  2286. }
  2287. else
  2288. {
  2289. var startSchoolcode = schoolcodeList.Where(x => x.Name == en.StartSchoolcodeStr.Trim()).SingleOrDefault();
  2290. if (startSchoolcode == null)
  2291. {
  2292. errCount++;
  2293. errorMsgStr = "入学学期不存在,请检查";
  2294. en.ErrorMessage = errorMsgStr;
  2295. errList.Add(en);
  2296. errorMsg.AppendLine(errorMsgStr);
  2297. continue;
  2298. }
  2299. else
  2300. {
  2301. //入学学期
  2302. en.StartSchoolcodeID = startSchoolcode.Value;
  2303. }
  2304. }
  2305. //查询对应的入学学年学期ID
  2306. if (en.GradeID.HasValue && en.StartSchoolcodeID.HasValue)
  2307. {
  2308. //查询对应的学年学期信息
  2309. var startSchoolyear = schoolyearList.Where(x => x.Years == en.GradeID && x.SchoolcodeID == en.StartSchoolcodeID).SingleOrDefault();
  2310. if (startSchoolyear == null)
  2311. {
  2312. errCount++;
  2313. errorMsgStr = "无法计算出对应的入学学年学期信息(以年级、入学学期计算),请检查";
  2314. en.ErrorMessage = errorMsgStr;
  2315. errList.Add(en);
  2316. errorMsg.AppendLine(errorMsgStr);
  2317. continue;
  2318. }
  2319. else
  2320. {
  2321. //入学学年学期ID
  2322. newSpecialtyPlan.StartSchoolyearID = startSchoolyear.SchoolyearID;
  2323. //入学学年学期对应的Value值
  2324. en.StartValue = startSchoolyear.Value;
  2325. }
  2326. }
  2327. else
  2328. {
  2329. errCount++;
  2330. errorMsgStr = "数据有误,请检查(年级或入学学期不能为空)";
  2331. en.ErrorMessage = errorMsgStr;
  2332. errList.Add(en);
  2333. errorMsg.AppendLine(errorMsgStr);
  2334. continue;
  2335. }
  2336. //专业代码
  2337. if (string.IsNullOrWhiteSpace(en.StandardCodeStr))
  2338. {
  2339. errCount++;
  2340. errorMsgStr = "专业代码不能为空";
  2341. en.ErrorMessage = errorMsgStr;
  2342. errList.Add(en);
  2343. errorMsg.AppendLine(errorMsgStr);
  2344. continue;
  2345. }
  2346. else
  2347. {
  2348. var standard = standardList.Where(x => x.Code == en.StandardCodeStr.Trim()).FirstOrDefault();
  2349. if (standard == null)
  2350. {
  2351. errCount++;
  2352. errorMsgStr = "专业代码不存在,请检查";
  2353. en.ErrorMessage = errorMsgStr;
  2354. errList.Add(en);
  2355. errorMsg.AppendLine(errorMsgStr);
  2356. continue;
  2357. }
  2358. else
  2359. {
  2360. //专业代码
  2361. }
  2362. }
  2363. //专业名称
  2364. if (string.IsNullOrWhiteSpace(en.StandardNameStr))
  2365. {
  2366. errCount++;
  2367. errorMsgStr = "专业名称不能为空";
  2368. en.ErrorMessage = errorMsgStr;
  2369. errList.Add(en);
  2370. errorMsg.AppendLine(errorMsgStr);
  2371. continue;
  2372. }
  2373. else
  2374. {
  2375. var standard = standardList.Where(x => x.Name == en.StandardNameStr.Trim()).FirstOrDefault();
  2376. if (standard == null)
  2377. {
  2378. errCount++;
  2379. errorMsgStr = "专业名称不存在,请检查";
  2380. en.ErrorMessage = errorMsgStr;
  2381. errList.Add(en);
  2382. errorMsg.AppendLine(errorMsgStr);
  2383. continue;
  2384. }
  2385. else
  2386. {
  2387. //专业名称
  2388. }
  2389. }
  2390. //专业代码与专业名称查询专业ID(Value)
  2391. if (string.IsNullOrWhiteSpace(en.StandardCodeStr) || string.IsNullOrWhiteSpace(en.StandardNameStr))
  2392. {
  2393. errCount++;
  2394. errorMsgStr = "专业代码或专业名称不能为空";
  2395. en.ErrorMessage = errorMsgStr;
  2396. errList.Add(en);
  2397. errorMsg.AppendLine(errorMsgStr);
  2398. continue;
  2399. }
  2400. else
  2401. {
  2402. var standard = standardList.Where(x => x.Code == en.StandardCodeStr.Trim() && x.Name == en.StandardNameStr.Trim()).SingleOrDefault();
  2403. if (standard == null)
  2404. {
  2405. errCount++;
  2406. errorMsgStr = "专业代码与专业名称对应的元素值不存在,请检查";
  2407. en.ErrorMessage = errorMsgStr;
  2408. errList.Add(en);
  2409. errorMsg.AppendLine(errorMsgStr);
  2410. continue;
  2411. }
  2412. else
  2413. {
  2414. //专业ID(Value)
  2415. en.StandardID = standard.Value;
  2416. }
  2417. }
  2418. //培养层次
  2419. if (string.IsNullOrWhiteSpace(en.EducationStr))
  2420. {
  2421. errCount++;
  2422. errorMsgStr = RSL.Get("EducationID") + "不能为空";
  2423. en.ErrorMessage = errorMsgStr;
  2424. errList.Add(en);
  2425. errorMsg.AppendLine(errorMsgStr);
  2426. continue;
  2427. }
  2428. else
  2429. {
  2430. var education = educationList.Where(x => x.Name == en.EducationStr.Trim()).SingleOrDefault();
  2431. if (education == null)
  2432. {
  2433. errCount++;
  2434. errorMsgStr = RSL.Get("EducationID") + "不存在,请检查";
  2435. en.ErrorMessage = errorMsgStr;
  2436. errList.Add(en);
  2437. errorMsg.AppendLine(errorMsgStr);
  2438. continue;
  2439. }
  2440. else
  2441. {
  2442. //培养层次
  2443. en.EducationID = education.Value;
  2444. }
  2445. }
  2446. //学习形式
  2447. if (string.IsNullOrWhiteSpace(en.LearningformStr))
  2448. {
  2449. errCount++;
  2450. errorMsgStr = "学习形式不能为空";
  2451. en.ErrorMessage = errorMsgStr;
  2452. errList.Add(en);
  2453. errorMsg.AppendLine(errorMsgStr);
  2454. continue;
  2455. }
  2456. else
  2457. {
  2458. var learningForm = learningFormList.Where(x => x.Name == en.LearningformStr.Trim()).SingleOrDefault();
  2459. if (learningForm == null)
  2460. {
  2461. errCount++;
  2462. errorMsgStr = "学习形式不存在,请检查";
  2463. en.ErrorMessage = errorMsgStr;
  2464. errList.Add(en);
  2465. errorMsg.AppendLine(errorMsgStr);
  2466. continue;
  2467. }
  2468. else
  2469. {
  2470. //学习形式
  2471. en.LearningformID = learningForm.Value;
  2472. }
  2473. }
  2474. //学制
  2475. if (string.IsNullOrWhiteSpace(en.LearnSystemStr))
  2476. {
  2477. errCount++;
  2478. errorMsgStr = "学制不能为空";
  2479. en.ErrorMessage = errorMsgStr;
  2480. errList.Add(en);
  2481. errorMsg.AppendLine(errorMsgStr);
  2482. continue;
  2483. }
  2484. else
  2485. {
  2486. reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //学制字段正则表达式()
  2487. if (!reg.IsMatch(en.LearnSystemStr.Trim()))
  2488. {
  2489. errCount++;
  2490. errorMsgStr = "学制格式不正确,请检查";
  2491. en.ErrorMessage = errorMsgStr;
  2492. errList.Add(en);
  2493. errorMsg.AppendLine(errorMsgStr);
  2494. continue;
  2495. }
  2496. else
  2497. {
  2498. //学制
  2499. en.LearnSystem = Convert.ToDecimal(en.LearnSystemStr.Trim());
  2500. }
  2501. }
  2502. //查询对应的专业信息ID
  2503. if (en.StandardID.HasValue && en.EducationID.HasValue && en.LearningformID.HasValue && en.LearnSystem.HasValue)
  2504. {
  2505. //查询对应的专业信息
  2506. var specialty = specialtyList.Where(x => x.StandardID == en.StandardID
  2507. && x.EducationID == en.EducationID
  2508. && x.LearningformID == en.LearningformID
  2509. && x.LearnSystem == en.LearnSystem).SingleOrDefault();
  2510. if (specialty == null)
  2511. {
  2512. errCount++;
  2513. errorMsgStr = "对应的专业信息不存在(以专业代码、专业名称、"
  2514. + RSL.Get("EducationID") + "、学习形式、学制查询),请检查";
  2515. en.ErrorMessage = errorMsgStr;
  2516. errList.Add(en);
  2517. errorMsg.AppendLine(errorMsgStr);
  2518. continue;
  2519. }
  2520. else
  2521. {
  2522. //判断对应的专业信息状态(启用、禁用状态)
  2523. if (specialty.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  2524. {
  2525. newSpecialtyPlan.SpecialtyID = specialty.SpecialtyID;
  2526. }
  2527. else
  2528. {
  2529. newSpecialtyPlan.SpecialtyID = specialty.SpecialtyID;
  2530. errCount++;
  2531. errorMsgStr = "对应的专业信息为禁用状态,请检查";
  2532. en.ErrorMessage = errorMsgStr;
  2533. errList.Add(en);
  2534. errorMsg.AppendLine(errorMsgStr);
  2535. continue;
  2536. }
  2537. }
  2538. }
  2539. else
  2540. {
  2541. errCount++;
  2542. errorMsgStr = "数据有误,请检查(专业ID(Value)、"
  2543. + RSL.Get("EducationID") + "、学习形式或学制不能为空)";
  2544. en.ErrorMessage = errorMsgStr;
  2545. errList.Add(en);
  2546. errorMsg.AppendLine(errorMsgStr);
  2547. continue;
  2548. }
  2549. //开课学年
  2550. if (string.IsNullOrWhiteSpace(en.SchoolyearNumStr))
  2551. {
  2552. errCount++;
  2553. errorMsgStr = "开课学年不能为空";
  2554. en.ErrorMessage = errorMsgStr;
  2555. errList.Add(en);
  2556. errorMsg.AppendLine(errorMsgStr);
  2557. continue;
  2558. }
  2559. else
  2560. {
  2561. var schoolyearNum = schoolyearNumList.Where(x => x.Name == en.SchoolyearNumStr.Trim()).SingleOrDefault();
  2562. if (schoolyearNum == null)
  2563. {
  2564. errCount++;
  2565. errorMsgStr = "开课学年不存在,请检查";
  2566. en.ErrorMessage = errorMsgStr;
  2567. errList.Add(en);
  2568. errorMsg.AppendLine(errorMsgStr);
  2569. continue;
  2570. }
  2571. else
  2572. {
  2573. //开课学年
  2574. en.SchoolyearNumID = schoolyearNum.Value;
  2575. }
  2576. }
  2577. //学期
  2578. if (string.IsNullOrWhiteSpace(en.SchoolcodeStr))
  2579. {
  2580. errCount++;
  2581. errorMsgStr = "学期不能为空";
  2582. en.ErrorMessage = errorMsgStr;
  2583. errList.Add(en);
  2584. errorMsg.AppendLine(errorMsgStr);
  2585. continue;
  2586. }
  2587. else
  2588. {
  2589. var schoolcode = schoolcodeList.Where(x => x.Name == en.SchoolcodeStr.Trim()).SingleOrDefault();
  2590. if (schoolcode == null)
  2591. {
  2592. errCount++;
  2593. errorMsgStr = "学期不存在,请检查";
  2594. en.ErrorMessage = errorMsgStr;
  2595. errList.Add(en);
  2596. errorMsg.AppendLine(errorMsgStr);
  2597. continue;
  2598. }
  2599. else
  2600. {
  2601. //学期
  2602. en.SchoolcodeID = schoolcode.Value;
  2603. }
  2604. }
  2605. //查询对应的学年学期ID且匹配对应的学年学期(学年学期不为空时)
  2606. if (en.GradeID.HasValue && en.StartSchoolcodeID.HasValue && en.SchoolyearNumID.HasValue && en.SchoolcodeID.HasValue && en.LearnSystem.HasValue)
  2607. {
  2608. //查询对应的毕业学年学期信息
  2609. var graduateSchoolyearValue = (en.GradeID.Value * 2) - 1 + (en.StartSchoolcodeID.Value - 1);
  2610. graduateSchoolyearValue += Convert.ToInt32(Math.Ceiling(en.LearnSystem.Value * 2 - 1));
  2611. var graduatingSemester = schoolyearList.Where(x => x.Value == graduateSchoolyearValue).SingleOrDefault();
  2612. if (graduatingSemester == null)
  2613. {
  2614. errCount++;
  2615. errorMsgStr = "年级、入学学期和学制对应的毕业学年学期信息不存在,请检查";
  2616. en.ErrorMessage = errorMsgStr;
  2617. errList.Add(en);
  2618. errorMsg.AppendLine(errorMsgStr);
  2619. continue;
  2620. }
  2621. else
  2622. {
  2623. //查询对应的学年学期信息
  2624. var yearID = Convert.ToInt32(en.GradeID + en.SchoolyearNumID - 1);
  2625. var schoolyear = schoolyearList.Where(x => x.Years == yearID && x.SchoolcodeID == en.SchoolcodeID).SingleOrDefault();
  2626. if (schoolyear == null)
  2627. {
  2628. errCount++;
  2629. errorMsgStr = "无法计算出对应的学年学期信息(以开课学年、学期、年级计算),请检查";
  2630. en.ErrorMessage = errorMsgStr;
  2631. errList.Add(en);
  2632. errorMsg.AppendLine(errorMsgStr);
  2633. continue;
  2634. }
  2635. else
  2636. {
  2637. //判断学年学期(以计算出的学年学期为准)
  2638. if (string.IsNullOrWhiteSpace(en.SchoolyearCode))
  2639. {
  2640. //暂不考虑
  2641. }
  2642. else
  2643. {
  2644. //学年学期与计算出的学年学期不对应
  2645. if (schoolyear.Code.Trim() != en.SchoolyearCode.Trim())
  2646. {
  2647. errCount++;
  2648. errorMsgStr = "学年学期与计算出的学年学期不对应(以计算出的学年学期为准),请检查";
  2649. en.ErrorMessage = errorMsgStr;
  2650. errList.Add(en);
  2651. errorMsg.AppendLine(errorMsgStr);
  2652. continue;
  2653. }
  2654. }
  2655. //学年学期小于入学学年学期
  2656. if (schoolyear.Value < en.StartValue)
  2657. {
  2658. errCount++;
  2659. errorMsgStr = "学年学期小于对应的入学学年学期(以计算出的学年学期为准),请检查";
  2660. en.ErrorMessage = errorMsgStr;
  2661. errList.Add(en);
  2662. errorMsg.AppendLine(errorMsgStr);
  2663. continue;
  2664. }
  2665. //学年学期大于毕业学年学期
  2666. if (schoolyear.Value > graduatingSemester.Value)
  2667. {
  2668. errCount++;
  2669. errorMsgStr = "学年学期大于对应的毕业学年学期(以计算出的学年学期为准),请检查";
  2670. en.ErrorMessage = errorMsgStr;
  2671. errList.Add(en);
  2672. errorMsg.AppendLine(errorMsgStr);
  2673. continue;
  2674. }
  2675. //学年学期ID
  2676. newSpecialtyPlan.SchoolyearID = schoolyear.SchoolyearID;
  2677. }
  2678. }
  2679. }
  2680. else
  2681. {
  2682. errCount++;
  2683. errorMsgStr = "数据有误,请检查(年级、入学学期、学制、开课学年或学期不能为空)";
  2684. en.ErrorMessage = errorMsgStr;
  2685. errList.Add(en);
  2686. errorMsg.AppendLine(errorMsgStr);
  2687. continue;
  2688. }
  2689. //学年学期
  2690. if (string.IsNullOrWhiteSpace(en.SchoolyearCode))
  2691. {
  2692. //暂不考虑
  2693. }
  2694. else
  2695. {
  2696. //暂不考虑
  2697. }
  2698. //课程代码
  2699. if (string.IsNullOrWhiteSpace(en.CourseCode))
  2700. {
  2701. errCount++;
  2702. errorMsgStr = "课程代码不能为空";
  2703. en.ErrorMessage = errorMsgStr;
  2704. errList.Add(en);
  2705. errorMsg.AppendLine(errorMsgStr);
  2706. continue;
  2707. }
  2708. else
  2709. {
  2710. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  2711. if (!reg.IsMatch(en.CourseCode.Trim()))
  2712. {
  2713. errCount++;
  2714. errorMsgStr = "课程代码格式不正确,请检查(数字或英文字母)";
  2715. en.ErrorMessage = errorMsgStr;
  2716. errList.Add(en);
  2717. errorMsg.AppendLine(errorMsgStr);
  2718. continue;
  2719. }
  2720. else
  2721. {
  2722. var course = newCourseList.Where(x => x.CourseCode == en.CourseCode.Trim()).SingleOrDefault();
  2723. if (course == null)
  2724. {
  2725. errCount++;
  2726. errorMsgStr = "课程代码不存在,请检查";
  2727. en.ErrorMessage = errorMsgStr;
  2728. errList.Add(en);
  2729. errorMsg.AppendLine(errorMsgStr);
  2730. continue;
  2731. }
  2732. else
  2733. {
  2734. //判断课程代码与课程名称(以课程代码为准)
  2735. if (string.IsNullOrWhiteSpace(en.CourseName))
  2736. {
  2737. //暂不考虑
  2738. }
  2739. else
  2740. {
  2741. //课程代码与课程名称不对应
  2742. if (course.CourseName.Trim() != en.CourseName.Trim())
  2743. {
  2744. errCount++;
  2745. errorMsgStr = "课程代码与课程名称不对应(以课程代码为准),请检查";
  2746. en.ErrorMessage = errorMsgStr;
  2747. errList.Add(en);
  2748. errorMsg.AppendLine(errorMsgStr);
  2749. continue;
  2750. }
  2751. }
  2752. //判断对应的课程信息状态(启用、禁用状态)
  2753. if (course.IsEnable == true)
  2754. {
  2755. //课程信息ID
  2756. newSpecialtyPlan.CoursematerialID = course.CoursematerialID;
  2757. }
  2758. else
  2759. {
  2760. newSpecialtyPlan.CoursematerialID = course.CoursematerialID;
  2761. errCount++;
  2762. errorMsgStr = "对应的课程信息为禁用状态,请检查";
  2763. en.ErrorMessage = errorMsgStr;
  2764. errList.Add(en);
  2765. errorMsg.AppendLine(errorMsgStr);
  2766. continue;
  2767. }
  2768. }
  2769. }
  2770. }
  2771. //课程名称
  2772. if (string.IsNullOrWhiteSpace(en.CourseName))
  2773. {
  2774. //暂不考虑
  2775. }
  2776. else
  2777. {
  2778. //暂不考虑
  2779. }
  2780. //课程结构
  2781. if (string.IsNullOrWhiteSpace(en.CourseStructureStr))
  2782. {
  2783. newSpecialtyPlan.CourseStructureID = (int)CF_CourseStructure.ClassroomTeaching;
  2784. }
  2785. else
  2786. {
  2787. var courseStructure = courseStructureList.Where(x => x.Name == en.CourseStructureStr.Trim()).SingleOrDefault();
  2788. if (courseStructure == null)
  2789. {
  2790. errCount++;
  2791. errorMsgStr = "课程结构不存在,请检查";
  2792. en.ErrorMessage = errorMsgStr;
  2793. errList.Add(en);
  2794. errorMsg.AppendLine(errorMsgStr);
  2795. continue;
  2796. }
  2797. else
  2798. {
  2799. //课程结构
  2800. newSpecialtyPlan.CourseStructureID = courseStructure.Value;
  2801. }
  2802. }
  2803. //课程属性
  2804. if (string.IsNullOrWhiteSpace(en.CourseCategoryStr))
  2805. {
  2806. newSpecialtyPlan.CourseCategoryID = (int)CF_CourseCategory.Publiccourse;
  2807. }
  2808. else
  2809. {
  2810. var courseCategory = courseCategoryList.Where(x => x.Name == en.CourseCategoryStr.Trim()).SingleOrDefault();
  2811. if (courseCategory == null)
  2812. {
  2813. errCount++;
  2814. errorMsgStr = "课程属性不存在,请检查";
  2815. en.ErrorMessage = errorMsgStr;
  2816. errList.Add(en);
  2817. errorMsg.AppendLine(errorMsgStr);
  2818. continue;
  2819. }
  2820. else
  2821. {
  2822. //课程属性
  2823. newSpecialtyPlan.CourseCategoryID = courseCategory.Value;
  2824. }
  2825. }
  2826. //课程类型
  2827. if (string.IsNullOrWhiteSpace(en.CourseTypeStr))
  2828. {
  2829. errCount++;
  2830. errorMsgStr = "课程类型不能为空";
  2831. en.ErrorMessage = errorMsgStr;
  2832. errList.Add(en);
  2833. errorMsg.AppendLine(errorMsgStr);
  2834. continue;
  2835. }
  2836. else
  2837. {
  2838. var courseType = courseTypeList.Where(x => x.Name == en.CourseTypeStr.Trim()).SingleOrDefault();
  2839. if (courseType == null)
  2840. {
  2841. errCount++;
  2842. errorMsgStr = "课程类型不存在,请检查";
  2843. en.ErrorMessage = errorMsgStr;
  2844. errList.Add(en);
  2845. errorMsg.AppendLine(errorMsgStr);
  2846. continue;
  2847. }
  2848. else
  2849. {
  2850. //课程类型
  2851. newSpecialtyPlan.CourseTypeID = courseType.Value;
  2852. }
  2853. }
  2854. //课程性质
  2855. if (string.IsNullOrWhiteSpace(en.CourseQualityStr))
  2856. {
  2857. newSpecialtyPlan.CourseQualityID = (int)CF_CourseQuality.Required;
  2858. }
  2859. else
  2860. {
  2861. var courseQuality = courseQualityList.Where(x => x.Name == en.CourseQualityStr.Trim()).SingleOrDefault();
  2862. if (courseQuality == null)
  2863. {
  2864. errCount++;
  2865. errorMsgStr = "课程性质不存在,请检查";
  2866. en.ErrorMessage = errorMsgStr;
  2867. errList.Add(en);
  2868. errorMsg.AppendLine(errorMsgStr);
  2869. continue;
  2870. }
  2871. else
  2872. {
  2873. //课程性质
  2874. newSpecialtyPlan.CourseQualityID = courseQuality.Value;
  2875. }
  2876. }
  2877. //课程学分
  2878. if (string.IsNullOrWhiteSpace(en.CreditStr))
  2879. {
  2880. errCount++;
  2881. errorMsgStr = "课程学分不能为空";
  2882. en.ErrorMessage = errorMsgStr;
  2883. errList.Add(en);
  2884. errorMsg.AppendLine(errorMsgStr);
  2885. continue;
  2886. }
  2887. else
  2888. {
  2889. reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //课程学分字段正则表达式()
  2890. if (!reg.IsMatch(en.CreditStr.Trim()))
  2891. {
  2892. errCount++;
  2893. errorMsgStr = "课程学分格式不正确,请检查";
  2894. en.ErrorMessage = errorMsgStr;
  2895. errList.Add(en);
  2896. errorMsg.AppendLine(errorMsgStr);
  2897. continue;
  2898. }
  2899. else
  2900. {
  2901. //课程学分
  2902. newTeachingSetting.Credit = Convert.ToDecimal(en.CreditStr.Trim());
  2903. }
  2904. }
  2905. //理论学时
  2906. if (string.IsNullOrWhiteSpace(en.TheoryCourseStr))
  2907. {
  2908. errCount++;
  2909. errorMsgStr = "理论学时不能为空";
  2910. en.ErrorMessage = errorMsgStr;
  2911. errList.Add(en);
  2912. errorMsg.AppendLine(errorMsgStr);
  2913. continue;
  2914. }
  2915. else
  2916. {
  2917. reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
  2918. if (!reg.IsMatch(en.TheoryCourseStr.Trim()))
  2919. {
  2920. errCount++;
  2921. errorMsgStr = "理论学时格式不正确,请检查";
  2922. en.ErrorMessage = errorMsgStr;
  2923. errList.Add(en);
  2924. errorMsg.AppendLine(errorMsgStr);
  2925. continue;
  2926. }
  2927. else
  2928. {
  2929. //理论学时
  2930. newTeachingSetting.TheoryCourse = Convert.ToInt32(en.TheoryCourseStr.Trim());
  2931. }
  2932. }
  2933. //实践学时
  2934. if (string.IsNullOrWhiteSpace(en.PracticehoursStr))
  2935. {
  2936. errCount++;
  2937. errorMsgStr = "实践学时不能为空";
  2938. en.ErrorMessage = errorMsgStr;
  2939. errList.Add(en);
  2940. errorMsg.AppendLine(errorMsgStr);
  2941. continue;
  2942. }
  2943. else
  2944. {
  2945. reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
  2946. if (!reg.IsMatch(en.PracticehoursStr.Trim()))
  2947. {
  2948. errCount++;
  2949. errorMsgStr = "实践学时格式不正确,请检查";
  2950. en.ErrorMessage = errorMsgStr;
  2951. errList.Add(en);
  2952. errorMsg.AppendLine(errorMsgStr);
  2953. continue;
  2954. }
  2955. else
  2956. {
  2957. //实践学时
  2958. newTeachingSetting.Practicehours = Convert.ToInt32(en.PracticehoursStr.Trim());
  2959. }
  2960. }
  2961. //实验学时
  2962. if (string.IsNullOrWhiteSpace(en.TrialhoursStr))
  2963. {
  2964. newTeachingSetting.Trialhours = 0;
  2965. }
  2966. else
  2967. {
  2968. reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
  2969. if (!reg.IsMatch(en.TrialhoursStr.Trim()))
  2970. {
  2971. errCount++;
  2972. errorMsgStr = "实验学时格式不正确,请检查";
  2973. en.ErrorMessage = errorMsgStr;
  2974. errList.Add(en);
  2975. errorMsg.AppendLine(errorMsgStr);
  2976. continue;
  2977. }
  2978. else
  2979. {
  2980. //实验学时
  2981. newTeachingSetting.Trialhours = Convert.ToInt32(en.TrialhoursStr.Trim());
  2982. }
  2983. }
  2984. //理论周次
  2985. if (string.IsNullOrWhiteSpace(en.TheoryWeeklyNumStr))
  2986. {
  2987. newTeachingSetting.TheoryWeeklyNum = 0;
  2988. }
  2989. else
  2990. {
  2991. reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
  2992. if (!reg.IsMatch(en.TheoryWeeklyNumStr.Trim()))
  2993. {
  2994. errCount++;
  2995. errorMsgStr = "理论周次格式不正确,请检查";
  2996. en.ErrorMessage = errorMsgStr;
  2997. errList.Add(en);
  2998. errorMsg.AppendLine(errorMsgStr);
  2999. continue;
  3000. }
  3001. else
  3002. {
  3003. //理论周次
  3004. newTeachingSetting.TheoryWeeklyNum = Convert.ToInt32(en.TheoryWeeklyNumStr.Trim());
  3005. }
  3006. }
  3007. //实践周次
  3008. if (string.IsNullOrWhiteSpace(en.PracticeWeeklyNumStr))
  3009. {
  3010. newTeachingSetting.PracticeWeeklyNum = 0;
  3011. }
  3012. else
  3013. {
  3014. reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
  3015. if (!reg.IsMatch(en.PracticeWeeklyNumStr.Trim()))
  3016. {
  3017. errCount++;
  3018. errorMsgStr = "实践周次格式不正确,请检查";
  3019. en.ErrorMessage = errorMsgStr;
  3020. errList.Add(en);
  3021. errorMsg.AppendLine(errorMsgStr);
  3022. continue;
  3023. }
  3024. else
  3025. {
  3026. //实践周次
  3027. newTeachingSetting.PracticeWeeklyNum = Convert.ToInt32(en.PracticeWeeklyNumStr.Trim());
  3028. }
  3029. }
  3030. //实验周次
  3031. if (string.IsNullOrWhiteSpace(en.TrialWeeklyNumStr))
  3032. {
  3033. newTeachingSetting.TrialWeeklyNum = 0;
  3034. }
  3035. else
  3036. {
  3037. reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
  3038. if (!reg.IsMatch(en.TrialWeeklyNumStr.Trim()))
  3039. {
  3040. errCount++;
  3041. errorMsgStr = "实验周次格式不正确,请检查";
  3042. en.ErrorMessage = errorMsgStr;
  3043. errList.Add(en);
  3044. errorMsg.AppendLine(errorMsgStr);
  3045. continue;
  3046. }
  3047. else
  3048. {
  3049. //实践周次
  3050. newTeachingSetting.TrialWeeklyNum = Convert.ToInt32(en.TrialWeeklyNumStr.Trim());
  3051. }
  3052. }
  3053. //开课教研室
  3054. if (string.IsNullOrWhiteSpace(en.DepartmentName))
  3055. {
  3056. errCount++;
  3057. errorMsgStr = "开课教研室不能为空";
  3058. en.ErrorMessage = errorMsgStr;
  3059. errList.Add(en);
  3060. errorMsg.AppendLine(errorMsgStr);
  3061. continue;
  3062. }
  3063. else
  3064. {
  3065. var department = newDepartmentList.Where(x => x.Name == en.DepartmentName.Trim()).SingleOrDefault();
  3066. if (department == null)
  3067. {
  3068. errCount++;
  3069. errorMsgStr = "开课教研室不存在,请检查";
  3070. en.ErrorMessage = errorMsgStr;
  3071. errList.Add(en);
  3072. errorMsg.AppendLine(errorMsgStr);
  3073. continue;
  3074. }
  3075. else
  3076. {
  3077. //教研室信息ID
  3078. newSpecialtyPlan.DepartmentID = department.DepartmentID;
  3079. }
  3080. }
  3081. //是否专业核心
  3082. if (string.IsNullOrWhiteSpace(en.IsSpecialtycoreStr))
  3083. {
  3084. //是否专业核心(默认为否)
  3085. newSpecialtyPlan.IsSpecialtycore = false;
  3086. }
  3087. else
  3088. {
  3089. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsSpecialtycoreStr.Trim()).SingleOrDefault();
  3090. if (generalPurpose == null)
  3091. {
  3092. errCount++;
  3093. errorMsgStr = "是否专业核心不存在,请检查";
  3094. en.ErrorMessage = errorMsgStr;
  3095. errList.Add(en);
  3096. errorMsg.AppendLine(errorMsgStr);
  3097. continue;
  3098. }
  3099. else
  3100. {
  3101. //是否专业核心
  3102. newSpecialtyPlan.IsSpecialtycore = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  3103. }
  3104. }
  3105. //是否合作开发
  3106. if (string.IsNullOrWhiteSpace(en.IsCooperationStr))
  3107. {
  3108. //是否合作开发(默认为否)
  3109. newSpecialtyPlan.IsCooperation = false;
  3110. }
  3111. else
  3112. {
  3113. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsCooperationStr.Trim()).SingleOrDefault();
  3114. if (generalPurpose == null)
  3115. {
  3116. errCount++;
  3117. errorMsgStr = "是否合作开发不存在,请检查";
  3118. en.ErrorMessage = errorMsgStr;
  3119. errList.Add(en);
  3120. errorMsg.AppendLine(errorMsgStr);
  3121. continue;
  3122. }
  3123. else
  3124. {
  3125. //是否合作开发
  3126. newSpecialtyPlan.IsCooperation = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  3127. }
  3128. }
  3129. //是否必修课
  3130. if (string.IsNullOrWhiteSpace(en.IsRequiredStr))
  3131. {
  3132. //是否必修课(默认为否)
  3133. newSpecialtyPlan.IsRequired = false;
  3134. }
  3135. else
  3136. {
  3137. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsRequiredStr.Trim()).SingleOrDefault();
  3138. if (generalPurpose == null)
  3139. {
  3140. errCount++;
  3141. errorMsgStr = RSL.Get("IsRequired") + "不存在,请检查";
  3142. en.ErrorMessage = errorMsgStr;
  3143. errList.Add(en);
  3144. errorMsg.AppendLine(errorMsgStr);
  3145. continue;
  3146. }
  3147. else
  3148. {
  3149. //是否必修课
  3150. newSpecialtyPlan.IsRequired = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  3151. }
  3152. }
  3153. //是否网上选修
  3154. if (string.IsNullOrWhiteSpace(en.IsElectiveStr))
  3155. {
  3156. //是否网上选修(默认为否)
  3157. newSpecialtyPlan.IsElective = false;
  3158. }
  3159. else
  3160. {
  3161. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsElectiveStr.Trim()).SingleOrDefault();
  3162. if (generalPurpose == null)
  3163. {
  3164. errCount++;
  3165. errorMsgStr = "是否网上选修不存在,请检查";
  3166. en.ErrorMessage = errorMsgStr;
  3167. errList.Add(en);
  3168. errorMsg.AppendLine(errorMsgStr);
  3169. continue;
  3170. }
  3171. else
  3172. {
  3173. //是否网上选修
  3174. newSpecialtyPlan.IsElective = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  3175. }
  3176. }
  3177. //是否网络课程
  3178. if (string.IsNullOrWhiteSpace(en.IsNetworkCourseStr))
  3179. {
  3180. //是否网络课程(默认为否)
  3181. newSpecialtyPlan.IsNetworkCourse = false;
  3182. }
  3183. else
  3184. {
  3185. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsNetworkCourseStr.Trim()).SingleOrDefault();
  3186. if (generalPurpose == null)
  3187. {
  3188. errCount++;
  3189. errorMsgStr = "是否网络课程不存在,请检查";
  3190. en.ErrorMessage = errorMsgStr;
  3191. errList.Add(en);
  3192. errorMsg.AppendLine(errorMsgStr);
  3193. continue;
  3194. }
  3195. else
  3196. {
  3197. //是否网络课程
  3198. newSpecialtyPlan.IsNetworkCourse = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  3199. }
  3200. }
  3201. //是否学位课程
  3202. if (string.IsNullOrWhiteSpace(en.IsMainCourseStr))
  3203. {
  3204. //是否学位课程(默认为否)
  3205. newSpecialtyPlan.IsMainCourse = false;
  3206. }
  3207. else
  3208. {
  3209. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsMainCourseStr.Trim()).SingleOrDefault();
  3210. if (generalPurpose == null)
  3211. {
  3212. errCount++;
  3213. errorMsgStr = "是否学位课程不存在,请检查";
  3214. en.ErrorMessage = errorMsgStr;
  3215. errList.Add(en);
  3216. errorMsg.AppendLine(errorMsgStr);
  3217. continue;
  3218. }
  3219. else
  3220. {
  3221. //是否学位课程
  3222. newSpecialtyPlan.IsMainCourse = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  3223. }
  3224. }
  3225. //是否需要教材
  3226. if (string.IsNullOrWhiteSpace(en.IsNeedMaterialStr))
  3227. {
  3228. //是否需要教材(默认为否)
  3229. newSpecialtyPlan.IsNeedMaterial = false;
  3230. }
  3231. else
  3232. {
  3233. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsNeedMaterialStr.Trim()).SingleOrDefault();
  3234. if (generalPurpose == null)
  3235. {
  3236. errCount++;
  3237. errorMsgStr = "是否需要教材不存在,请检查";
  3238. en.ErrorMessage = errorMsgStr;
  3239. errList.Add(en);
  3240. errorMsg.AppendLine(errorMsgStr);
  3241. continue;
  3242. }
  3243. else
  3244. {
  3245. //是否需要教材
  3246. newSpecialtyPlan.IsNeedMaterial = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  3247. }
  3248. }
  3249. //精品课程
  3250. if (string.IsNullOrWhiteSpace(en.CourseFineStr))
  3251. {
  3252. newSpecialtyPlan.CourseFineID = (int)CF_CourseFine.No;
  3253. }
  3254. else
  3255. {
  3256. var courseFine = courseFineList.Where(x => x.Name == en.CourseFineStr.Trim()).SingleOrDefault();
  3257. if (courseFine == null)
  3258. {
  3259. errCount++;
  3260. errorMsgStr = "精品课程不存在,请检查";
  3261. en.ErrorMessage = errorMsgStr;
  3262. errList.Add(en);
  3263. errorMsg.AppendLine(errorMsgStr);
  3264. continue;
  3265. }
  3266. else
  3267. {
  3268. //精品课程
  3269. newSpecialtyPlan.CourseFineID = courseFine.Value;
  3270. }
  3271. }
  3272. //实践类型
  3273. if (string.IsNullOrWhiteSpace(en.PracticeTypeStr))
  3274. {
  3275. //不考虑
  3276. }
  3277. else
  3278. {
  3279. var practiceType = practiceTypeList.Where(x => x.Name == en.PracticeTypeStr.Trim()).SingleOrDefault();
  3280. if (practiceType == null)
  3281. {
  3282. errCount++;
  3283. errorMsgStr = "实践类型不存在,请检查";
  3284. en.ErrorMessage = errorMsgStr;
  3285. errList.Add(en);
  3286. errorMsg.AppendLine(errorMsgStr);
  3287. continue;
  3288. }
  3289. else
  3290. {
  3291. //实践类型
  3292. newSpecialtyPlan.PracticeTypeID = practiceType.Value;
  3293. }
  3294. }
  3295. //授课语言
  3296. if (string.IsNullOrWhiteSpace(en.TeachinglanguageStr))
  3297. {
  3298. newSpecialtyPlan.TeachinglanguageID = (int)CF_Teachinglanguage.Chinese;
  3299. }
  3300. else
  3301. {
  3302. var teachinglanguage = teachinglanguageList.Where(x => x.Name == en.TeachinglanguageStr.Trim()).SingleOrDefault();
  3303. if (teachinglanguage == null)
  3304. {
  3305. errCount++;
  3306. errorMsgStr = "授课语言不存在,请检查";
  3307. en.ErrorMessage = errorMsgStr;
  3308. errList.Add(en);
  3309. errorMsg.AppendLine(errorMsgStr);
  3310. continue;
  3311. }
  3312. else
  3313. {
  3314. //授课语言
  3315. newSpecialtyPlan.TeachinglanguageID = teachinglanguage.Value;
  3316. }
  3317. }
  3318. //考试方式
  3319. if (string.IsNullOrWhiteSpace(en.ExaminationModeStr))
  3320. {
  3321. newSpecialtyPlan.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam;
  3322. }
  3323. else
  3324. {
  3325. var examinationMode = examinationModeList.Where(x => x.Name == en.ExaminationModeStr.Trim()).SingleOrDefault();
  3326. if (examinationMode == null)
  3327. {
  3328. errCount++;
  3329. errorMsgStr = "考试方式不存在,请检查";
  3330. en.ErrorMessage = errorMsgStr;
  3331. errList.Add(en);
  3332. errorMsg.AppendLine(errorMsgStr);
  3333. continue;
  3334. }
  3335. else
  3336. {
  3337. //考试方式
  3338. newSpecialtyPlan.ExaminationModeID = examinationMode.Value;
  3339. }
  3340. }
  3341. //成绩类型
  3342. if (string.IsNullOrWhiteSpace(en.ResultTypeStr))
  3343. {
  3344. newSpecialtyPlan.ResultTypeID = (int)CF_ResultType.Percentage;
  3345. }
  3346. else
  3347. {
  3348. var resultType = resultTypeList.Where(x => x.Name == en.ResultTypeStr.Trim()).SingleOrDefault();
  3349. if (resultType == null)
  3350. {
  3351. errCount++;
  3352. errorMsgStr = "成绩类型不存在,请检查";
  3353. en.ErrorMessage = errorMsgStr;
  3354. errList.Add(en);
  3355. errorMsg.AppendLine(errorMsgStr);
  3356. continue;
  3357. }
  3358. else
  3359. {
  3360. //成绩类型
  3361. newSpecialtyPlan.ResultTypeID = resultType.Value;
  3362. }
  3363. }
  3364. //处理方式
  3365. if (string.IsNullOrWhiteSpace(en.HandleModeStr))
  3366. {
  3367. newSpecialtyPlan.HandleModeID = (int)CF_HandleMode.RequiredCourse;
  3368. }
  3369. else
  3370. {
  3371. var handleMode = handleModeList.Where(x => x.Name == en.HandleModeStr.Trim()).SingleOrDefault();
  3372. if (handleMode == null)
  3373. {
  3374. errCount++;
  3375. errorMsgStr = "处理方式不存在,请检查";
  3376. en.ErrorMessage = errorMsgStr;
  3377. errList.Add(en);
  3378. errorMsg.AppendLine(errorMsgStr);
  3379. continue;
  3380. }
  3381. else
  3382. {
  3383. //处理方式
  3384. newSpecialtyPlan.HandleModeID = handleMode.Value;
  3385. }
  3386. }
  3387. //授课方式
  3388. if (string.IsNullOrWhiteSpace(en.TeachingModeIDListStr))
  3389. {
  3390. newModeTypeList.Add((int)CF_TeachingMode.Theory);
  3391. }
  3392. else
  3393. {
  3394. //授课方式可为多个(可用顿号隔开)
  3395. List<string> list = en.TeachingModeIDListStr.Split('、').Where(x => !string.IsNullOrEmpty(x))
  3396. .Select(x => x.Trim()).Distinct().ToList();
  3397. foreach (var item in list)
  3398. {
  3399. var teachingMode = teachingModeList.Where(x => x.Name == item.Trim()).SingleOrDefault();
  3400. if (teachingMode == null)
  3401. {
  3402. errCount++;
  3403. errorMsgStr = "授课方式(" + item.Trim() + ")不存在,请检查(存在多个授课方式时,可用顿号隔开)";
  3404. en.ErrorMessage = errorMsgStr;
  3405. errList.Add(en);
  3406. errorMsg.AppendLine(errorMsgStr);
  3407. isListPass = false;
  3408. break;
  3409. }
  3410. }
  3411. if (isListPass)
  3412. {
  3413. newModeTypeList = teachingModeList.Where(x => list.Contains(x.Name))
  3414. .Select(x => x.Value.Value).ToList();
  3415. }
  3416. else
  3417. {
  3418. isListPass = true;
  3419. continue;
  3420. }
  3421. }
  3422. //授课地点
  3423. if (string.IsNullOrWhiteSpace(en.TeachingPlaceIDListStr))
  3424. {
  3425. newPlaceList.Add((int)EMIS.ViewModel.EM_TeachingPlace.Multimedia);
  3426. }
  3427. else
  3428. {
  3429. //授课地点可为多个(可用顿号隔开)
  3430. List<string> list = en.TeachingPlaceIDListStr.Split('、').Where(x => !string.IsNullOrEmpty(x))
  3431. .Select(x => x.Trim()).Distinct().ToList();
  3432. foreach (var item in list)
  3433. {
  3434. var teachingPlace = teachingPlaceList.Where(x => x.Name == item.Trim()).SingleOrDefault();
  3435. if (teachingPlace == null)
  3436. {
  3437. errCount++;
  3438. errorMsgStr = "授课地点(" + item.Trim() + ")不存在,请检查(存在多个授课地点时,可用顿号隔开)";
  3439. en.ErrorMessage = errorMsgStr;
  3440. errList.Add(en);
  3441. errorMsg.AppendLine(errorMsgStr);
  3442. isListPass = false;
  3443. break;
  3444. }
  3445. }
  3446. if (isListPass)
  3447. {
  3448. newPlaceList = teachingPlaceList.Where(x => list.Contains(x.Name))
  3449. .Select(x => x.Value.Value).ToList();
  3450. }
  3451. else
  3452. {
  3453. isListPass = true;
  3454. continue;
  3455. }
  3456. }
  3457. //备注
  3458. if (string.IsNullOrWhiteSpace(en.Remark))
  3459. {
  3460. //不考虑
  3461. }
  3462. else
  3463. {
  3464. newSpecialtyPlan.Remark = en.Remark;
  3465. }
  3466. ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
  3467. //for (int j = i + 1; j < enlist.Count; j++)
  3468. //{
  3469. // SpecialtyPlanView enA = enlist[j];
  3470. // //根据Excel表中的业务主键进行去重(学年学期ID、入学学年学期ID、专业信息ID、课程信息ID唯一)
  3471. // if (en.No == enA.No && en.Name == enA.Name)
  3472. // {
  3473. // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
  3474. // }
  3475. //}
  3476. //数据表重复性验证(学年学期ID、入学学年学期ID、专业信息ID、课程信息ID唯一)
  3477. var specialtyPlanVerification = newSpecialtyPlanList.Where(x => x.SchoolyearID == newSpecialtyPlan.SchoolyearID
  3478. && x.StartSchoolyearID == newSpecialtyPlan.StartSchoolyearID
  3479. && x.SpecialtyID == newSpecialtyPlan.SpecialtyID
  3480. && x.CoursematerialID == newSpecialtyPlan.CoursematerialID).SingleOrDefault();
  3481. if (specialtyPlanVerification == null)
  3482. {
  3483. //新增
  3484. if (!newSpecialtyPlanInList.Any(x => x.SchoolyearID == newSpecialtyPlan.SchoolyearID
  3485. && x.StartSchoolyearID == newSpecialtyPlan.StartSchoolyearID
  3486. && x.SpecialtyID == newSpecialtyPlan.SpecialtyID
  3487. && x.CoursematerialID == newSpecialtyPlan.CoursematerialID))
  3488. {
  3489. newSpecialtyPlan.SpecialtyPlanID = Guid.NewGuid();
  3490. SetNewStatus(newSpecialtyPlan);
  3491. newSpecialtyPlanInList.Add(newSpecialtyPlan);
  3492. newTeachingSetting.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  3493. //newTeachingSetting.TheoryWeeklyNum = 0;
  3494. //newTeachingSetting.PracticeWeeklyNum = 0;
  3495. //newTeachingSetting.TrialWeeklyNum = 0;
  3496. newTeachingSetting.WeeklyHours = 0;
  3497. newTeachingSetting.WeeklyNum = 0;
  3498. newTeachingSetting.StartWeeklyNum = 1;
  3499. newTeachingSetting.EndWeeklyNum = 16;
  3500. newTeachingSettingInList.Add(newTeachingSetting);
  3501. if (newModeTypeList != null && newModeTypeList.Count() > 0)
  3502. {
  3503. foreach (var newModeType in newModeTypeList)
  3504. {
  3505. var newTeachingModeType = new EM_SpecialtyPlanTeachingModeType();
  3506. newTeachingModeType.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid();
  3507. newTeachingModeType.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  3508. newTeachingModeType.TeachingModeID = newModeType;
  3509. this.SetNewStatus(newTeachingModeType);
  3510. newTeachingModeTypeInList.Add(newTeachingModeType);
  3511. }
  3512. }
  3513. if (newPlaceList != null && newPlaceList.Count() > 0)
  3514. {
  3515. foreach (var newPlace in newPlaceList)
  3516. {
  3517. var newTeachingPlace = new EM_SpecialtyPlanTeachingPlace();
  3518. newTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid();
  3519. newTeachingPlace.SpecialtyPlanID = newSpecialtyPlan.SpecialtyPlanID;
  3520. newTeachingPlace.TeachingPlace = newPlace;
  3521. this.SetNewStatus(newTeachingPlace);
  3522. newTeachingPlaceInList.Add(newTeachingPlace);
  3523. }
  3524. }
  3525. inCount++;
  3526. }
  3527. else
  3528. {
  3529. //Excel表重复性验证
  3530. //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中,目前暂不考虑)
  3531. inCount++;
  3532. }
  3533. }
  3534. else
  3535. {
  3536. //更新(Excel有重复时,以最后一条记录的更新为准)
  3537. specialtyPlanVerification.CourseStructureID = newSpecialtyPlan.CourseStructureID;
  3538. specialtyPlanVerification.CourseCategoryID = newSpecialtyPlan.CourseCategoryID;
  3539. specialtyPlanVerification.CourseTypeID = newSpecialtyPlan.CourseTypeID;
  3540. specialtyPlanVerification.CourseQualityID = newSpecialtyPlan.CourseQualityID;
  3541. specialtyPlanVerification.DepartmentID = newSpecialtyPlan.DepartmentID;
  3542. specialtyPlanVerification.IsSpecialtycore = newSpecialtyPlan.IsSpecialtycore;
  3543. specialtyPlanVerification.IsCooperation = newSpecialtyPlan.IsCooperation;
  3544. specialtyPlanVerification.IsRequired = newSpecialtyPlan.IsRequired;
  3545. specialtyPlanVerification.IsElective = newSpecialtyPlan.IsElective;
  3546. specialtyPlanVerification.IsNetworkCourse = newSpecialtyPlan.IsNetworkCourse;
  3547. specialtyPlanVerification.IsMainCourse = newSpecialtyPlan.IsMainCourse;
  3548. specialtyPlanVerification.IsNeedMaterial = newSpecialtyPlan.IsNeedMaterial;
  3549. specialtyPlanVerification.CourseFineID = newSpecialtyPlan.CourseFineID;
  3550. specialtyPlanVerification.PracticeTypeID = newSpecialtyPlan.PracticeTypeID;
  3551. specialtyPlanVerification.TeachinglanguageID = newSpecialtyPlan.TeachinglanguageID;
  3552. specialtyPlanVerification.ExaminationModeID = newSpecialtyPlan.ExaminationModeID;
  3553. specialtyPlanVerification.ResultTypeID = newSpecialtyPlan.ResultTypeID;
  3554. specialtyPlanVerification.HandleModeID = newSpecialtyPlan.HandleModeID;
  3555. SetModifyStatus(specialtyPlanVerification);
  3556. newSpecialtyPlanUpList.Add(specialtyPlanVerification);
  3557. if (specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting == null)
  3558. {
  3559. if (newTeachingSettingInList.Any(x => x.SpecialtyPlanID == specialtyPlanVerification.SpecialtyPlanID))
  3560. {
  3561. newTeachingSettingInList.RemoveAll(x => x.SpecialtyPlanID == specialtyPlanVerification.SpecialtyPlanID);
  3562. }
  3563. newTeachingSetting.SpecialtyPlanID = specialtyPlanVerification.SpecialtyPlanID;
  3564. //newTeachingSetting.TheoryWeeklyNum = 0;
  3565. //newTeachingSetting.PracticeWeeklyNum = 0;
  3566. //newTeachingSetting.TrialWeeklyNum = 0;
  3567. newTeachingSetting.WeeklyHours = 0;
  3568. newTeachingSetting.WeeklyNum = 0;
  3569. newTeachingSetting.StartWeeklyNum = 1;
  3570. newTeachingSetting.EndWeeklyNum = 16;
  3571. newTeachingSettingInList.Add(newTeachingSetting);
  3572. }
  3573. else
  3574. {
  3575. specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting.Credit = newTeachingSetting.Credit;
  3576. specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting.TheoryCourse = newTeachingSetting.TheoryCourse;
  3577. specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting.Practicehours = newTeachingSetting.Practicehours;
  3578. specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting.Trialhours = newTeachingSetting.Trialhours;
  3579. specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting.TheoryWeeklyNum = newTeachingSetting.TheoryWeeklyNum;
  3580. specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting.PracticeWeeklyNum = newTeachingSetting.PracticeWeeklyNum;
  3581. specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting.TrialWeeklyNum = newTeachingSetting.TrialWeeklyNum;
  3582. newTeachingSettingUpList.Add(specialtyPlanVerification.EM_SpecialtyPlanTeachingSetting);
  3583. }
  3584. if (newModeTypeList != null && newModeTypeList.Count() > 0)
  3585. {
  3586. if (newTeachingModeTypeInList.Any(x => x.SpecialtyPlanID == specialtyPlanVerification.SpecialtyPlanID))
  3587. {
  3588. newTeachingModeTypeInList.RemoveAll(x => x.SpecialtyPlanID == specialtyPlanVerification.SpecialtyPlanID);
  3589. }
  3590. specialtyPlanTMDelList.Add(specialtyPlanVerification.SpecialtyPlanID);
  3591. foreach (var newModeType in newModeTypeList)
  3592. {
  3593. var newTeachingModeType = new EM_SpecialtyPlanTeachingModeType();
  3594. newTeachingModeType.SpecialtyPlanTeachingModeTypeID = Guid.NewGuid();
  3595. newTeachingModeType.SpecialtyPlanID = specialtyPlanVerification.SpecialtyPlanID;
  3596. newTeachingModeType.TeachingModeID = newModeType;
  3597. this.SetNewStatus(newTeachingModeType);
  3598. newTeachingModeTypeInList.Add(newTeachingModeType);
  3599. }
  3600. }
  3601. else
  3602. {
  3603. specialtyPlanTMDelList.Add(specialtyPlanVerification.SpecialtyPlanID);
  3604. }
  3605. if (newPlaceList != null && newPlaceList.Count() > 0)
  3606. {
  3607. if (newTeachingPlaceInList.Any(x => x.SpecialtyPlanID == specialtyPlanVerification.SpecialtyPlanID))
  3608. {
  3609. newTeachingPlaceInList.RemoveAll(x => x.SpecialtyPlanID == specialtyPlanVerification.SpecialtyPlanID);
  3610. }
  3611. specialtyPlanTPDelList.Add(specialtyPlanVerification.SpecialtyPlanID);
  3612. foreach (var newPlace in newPlaceList)
  3613. {
  3614. var newTeachingPlace = new EM_SpecialtyPlanTeachingPlace();
  3615. newTeachingPlace.SpecialtyPlanTeachingPlaceID = Guid.NewGuid();
  3616. newTeachingPlace.SpecialtyPlanID = specialtyPlanVerification.SpecialtyPlanID;
  3617. newTeachingPlace.TeachingPlace = newPlace;
  3618. this.SetNewStatus(newTeachingPlace);
  3619. newTeachingPlaceInList.Add(newTeachingPlace);
  3620. }
  3621. }
  3622. else
  3623. {
  3624. specialtyPlanTPDelList.Add(specialtyPlanVerification.SpecialtyPlanID);
  3625. }
  3626. upCount++;
  3627. }
  3628. }
  3629. using (TransactionScope ts = new TransactionScope())
  3630. {
  3631. //删除
  3632. UnitOfWork.Delete<EM_SpecialtyPlanTeachingPlace>(x => specialtyPlanTPDelList.Contains(x.SpecialtyPlanID));
  3633. UnitOfWork.Delete<EM_SpecialtyPlanTeachingModeType>(x => specialtyPlanTMDelList.Contains(x.SpecialtyPlanID));
  3634. //批量插入
  3635. UnitOfWork.BulkInsert(newSpecialtyPlanInList);
  3636. UnitOfWork.BulkInsert(newTeachingSettingInList);
  3637. UnitOfWork.BulkInsert(newTeachingModeTypeInList);
  3638. UnitOfWork.BulkInsert(newTeachingPlaceInList);
  3639. //批量统一提交更新
  3640. if (newSpecialtyPlanUpList != null && newSpecialtyPlanUpList.Count() > 0)
  3641. {
  3642. UnitOfWork.BatchUpdate(newSpecialtyPlanUpList);
  3643. }
  3644. //批量统一提交更新
  3645. if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0)
  3646. {
  3647. UnitOfWork.BatchUpdate(newTeachingSettingUpList);
  3648. }
  3649. ts.Complete();
  3650. }
  3651. errdataList = errList.Distinct().ToList(); //错误列表List
  3652. }
  3653. catch (Exception)
  3654. {
  3655. throw;
  3656. }
  3657. }
  3658. }
  3659. }