SpecialtyCourseServices.cs 95 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.ComponentModel;
  6. using System.Text.RegularExpressions;
  7. using System.Linq.Expressions;
  8. using System.Transactions;
  9. using Bowin.Common.Linq;
  10. using Bowin.Common.Linq.Entity;
  11. using Bowin.Common.Utility;
  12. using EMIS.Utility;
  13. using EMIS.Entities;
  14. using EMIS.ViewModel;
  15. using EMIS.ViewModel.CacheManage;
  16. using EMIS.ViewModel.CultureplanManage;
  17. using EMIS.DataLogic.CultureplanManage.PlanManagement;
  18. namespace EMIS.CommonLogic.CultureplanManage.PlanManagement
  19. {
  20. public class SpecialtyCourseServices : BaseServices, ISpecialtyCourseServices
  21. {
  22. public SpecialtyCourseDAL SpecialtyCourseDAL { get; set; }
  23. /// <summary>
  24. /// 查询专业课程信息SpecialtyCourseView
  25. /// </summary>
  26. /// <param name="configuretView"></param>
  27. /// <param name="collegeID"></param>
  28. /// <param name="departmentID"></param>
  29. /// <param name="standardID"></param>
  30. /// <param name="educationID"></param>
  31. /// <param name="learningformID"></param>
  32. /// <param name="learnSystem"></param>
  33. /// <param name="coursematerialID"></param>
  34. /// <param name="courseTypeID"></param>
  35. /// <param name="starttermID"></param>
  36. /// <param name="teachingModeID"></param>
  37. /// <param name="handleModeID"></param>
  38. /// <param name="isEnable"></param>
  39. /// <param name="pageIndex"></param>
  40. /// <param name="pageSize"></param>
  41. /// <returns></returns>
  42. public IGridResultSet<SpecialtyCourseView> GetSpecialtyCourseViewGrid(ConfiguretView configuretView, Guid? collegeID, Guid? departmentID,
  43. int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID, int? courseTypeID,
  44. int? starttermID, int? teachingModeID, int? handleModeID, int? isEnable, int pageIndex, int pageSize)
  45. {
  46. //专业课程
  47. Expression<Func<EM_SpecialtyCourse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  48. if (departmentID.HasValue)
  49. {
  50. //开课教研室ID
  51. exp = exp.And(x => x.DepartmentID == departmentID);
  52. }
  53. if (coursematerialID.HasValue)
  54. {
  55. //课程信息ID
  56. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  57. }
  58. if (courseTypeID.HasValue)
  59. {
  60. //课程类型
  61. exp = exp.And(x => x.CourseTypeID == courseTypeID);
  62. }
  63. if (starttermID.HasValue)
  64. {
  65. //开课学期
  66. exp = exp.And(x => x.StarttermID == starttermID);
  67. }
  68. if (handleModeID.HasValue)
  69. {
  70. //处理方式
  71. exp = exp.And(x => x.HandleModeID == handleModeID);
  72. }
  73. if (isEnable.HasValue)
  74. {
  75. //是否启用
  76. if (isEnable == 1)
  77. {
  78. exp = exp.And(x => x.IsEnable == true);
  79. }
  80. if (isEnable == 0)
  81. {
  82. exp = exp.And(x => x.IsEnable != true);
  83. }
  84. }
  85. var query = SpecialtyCourseDAL.GetSpecialtyCourseViewQueryable(exp);
  86. if (collegeID.HasValue)
  87. {
  88. //开课院系ID
  89. query = query.Where(x => x.CollegeID == collegeID);
  90. }
  91. if (standardID.HasValue)
  92. {
  93. //专业ID(Value)
  94. query = query.Where(x => x.StandardID == standardID);
  95. }
  96. if (educationID.HasValue)
  97. {
  98. //培养方式
  99. query = query.Where(x => x.EducationID == educationID);
  100. }
  101. if (learningformID.HasValue)
  102. {
  103. //学习形式
  104. query = query.Where(x => x.LearningformID == learningformID);
  105. }
  106. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  107. {
  108. //学制
  109. var LearnSystems = Convert.ToDecimal(learnSystem);
  110. query = query.Where(x => x.LearnSystem == LearnSystems);
  111. }
  112. if (teachingModeID.HasValue)
  113. {
  114. //授课方式
  115. query = query.Where(x => x.TeachingModeIDList.Contains(teachingModeID));
  116. }
  117. //查询条件
  118. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  119. {
  120. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  121. }
  122. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.EducationID)
  123. .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
  124. .ThenBy(x => x.StarttermID).ThenBy(x => x.CourseTypeID)
  125. .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
  126. .ToGridResultSet<SpecialtyCourseView>(pageIndex, pageSize);
  127. }
  128. /// <summary>
  129. /// 查询专业课程信息List
  130. /// </summary>
  131. /// <param name="configuretView"></param>
  132. /// <param name="collegeID"></param>
  133. /// <param name="departmentID"></param>
  134. /// <param name="standardID"></param>
  135. /// <param name="educationID"></param>
  136. /// <param name="learningformID"></param>
  137. /// <param name="learnSystem"></param>
  138. /// <param name="coursematerialID"></param>
  139. /// <param name="courseTypeID"></param>
  140. /// <param name="starttermID"></param>
  141. /// <param name="teachingModeID"></param>
  142. /// <param name="handleModeID"></param>
  143. /// <param name="isEnable"></param>
  144. /// <returns></returns>
  145. public IList<SpecialtyCourseView> GetSpecialtyCourseViewList(ConfiguretView configuretView, Guid? collegeID, Guid? departmentID,
  146. int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? coursematerialID, int? courseTypeID,
  147. int? starttermID, int? teachingModeID, int? handleModeID, int? isEnable)
  148. {
  149. //专业课程
  150. Expression<Func<EM_SpecialtyCourse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  151. if (departmentID.HasValue)
  152. {
  153. //开课教研室ID
  154. exp = exp.And(x => x.DepartmentID == departmentID);
  155. }
  156. if (coursematerialID.HasValue)
  157. {
  158. //课程信息ID
  159. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  160. }
  161. if (courseTypeID.HasValue)
  162. {
  163. //课程类型
  164. exp = exp.And(x => x.CourseTypeID == courseTypeID);
  165. }
  166. if (starttermID.HasValue)
  167. {
  168. //开课学期
  169. exp = exp.And(x => x.StarttermID == starttermID);
  170. }
  171. if (handleModeID.HasValue)
  172. {
  173. //处理方式
  174. exp = exp.And(x => x.HandleModeID == handleModeID);
  175. }
  176. if (isEnable.HasValue)
  177. {
  178. //是否启用
  179. if (isEnable == 1)
  180. {
  181. exp = exp.And(x => x.IsEnable == true);
  182. }
  183. if (isEnable == 0)
  184. {
  185. exp = exp.And(x => x.IsEnable != true);
  186. }
  187. }
  188. var query = SpecialtyCourseDAL.GetSpecialtyCourseViewQueryable(exp);
  189. if (collegeID.HasValue)
  190. {
  191. //开课院系ID
  192. query = query.Where(x => x.CollegeID == collegeID);
  193. }
  194. if (standardID.HasValue)
  195. {
  196. //专业ID(Value)
  197. query = query.Where(x => x.StandardID == standardID);
  198. }
  199. if (educationID.HasValue)
  200. {
  201. //培养方式
  202. query = query.Where(x => x.EducationID == educationID);
  203. }
  204. if (learningformID.HasValue)
  205. {
  206. //学习形式
  207. query = query.Where(x => x.LearningformID == learningformID);
  208. }
  209. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  210. {
  211. //学制
  212. var LearnSystems = Convert.ToDecimal(learnSystem);
  213. query = query.Where(x => x.LearnSystem == LearnSystems);
  214. }
  215. if (teachingModeID.HasValue)
  216. {
  217. //授课方式
  218. query = query.Where(x => x.TeachingModeIDList.Contains(teachingModeID));
  219. }
  220. //查询条件
  221. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  222. {
  223. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  224. }
  225. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.EducationID)
  226. .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
  227. .ThenBy(x => x.StarttermID).ThenBy(x => x.CourseTypeID)
  228. .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
  229. .ToList();
  230. }
  231. /// <summary>
  232. /// 查询对应的专业课程信息SpecialtyCourseView
  233. /// </summary>
  234. /// <param name="specialtyCourseID"></param>
  235. /// <returns></returns>
  236. public SpecialtyCourseView GetSpecialtyCourseView(Guid? specialtyCourseID)
  237. {
  238. try
  239. {
  240. var specialtyCourseView = SpecialtyCourseDAL.GetSpecialtyCourseViewQueryable(x => x.SpecialtyCourseID == specialtyCourseID)
  241. .SingleOrDefault();
  242. return specialtyCourseView;
  243. }
  244. catch (Exception ex)
  245. {
  246. throw new Exception(ex.Message);
  247. }
  248. }
  249. /// <summary>
  250. /// 编辑(新增、修改,业务主键:专业信息ID、开课学期、课程信息ID)
  251. /// </summary>
  252. /// <param name="specialtyCourseView"></param>
  253. public virtual void SpecialtyCourseEdit(SpecialtyCourseView specialtyCourseView)
  254. {
  255. try
  256. {
  257. //查询数据库进行验证
  258. var specialtyCourseVerify = SpecialtyCourseDAL.SpecialtyCourseRepository
  259. .GetList(x => x.SpecialtyCourseID != specialtyCourseView.SpecialtyCourseID
  260. && x.SpecialtyID == specialtyCourseView.SpecialtyID
  261. && x.StarttermID == specialtyCourseView.StarttermID
  262. && x.CoursematerialID == specialtyCourseView.CoursematerialID).SingleOrDefault();
  263. if (specialtyCourseVerify == null)
  264. {
  265. //查询对应的专业信息
  266. var specialty = SpecialtyCourseDAL.SpecialtyRepository
  267. .GetList(x => x.SpecialtyID == specialtyCourseView.SpecialtyID).SingleOrDefault();
  268. if (specialty == null)
  269. {
  270. throw new Exception("专业信息不存在,请检查。");
  271. }
  272. //对学制和开课学期进行判断
  273. var maxStartterm = Convert.ToInt32(Math.Ceiling(specialty.LearnSystem.Value * 2 - 1)) + 1;
  274. if (specialtyCourseView.StarttermID > maxStartterm)
  275. {
  276. throw new Exception("开课学期超出学制范围,请检查。");
  277. }
  278. List<EM_SpecialtyCourse> newSpecialtyCourseInList = new List<EM_SpecialtyCourse>();
  279. List<EM_SpecialtyCourse> newSpecialtyCourseUpList = new List<EM_SpecialtyCourse>();
  280. List<EM_SpecialtyCourseTeachingSetting> newTeachingSettingInList = new List<EM_SpecialtyCourseTeachingSetting>();
  281. List<EM_SpecialtyCourseTeachingSetting> newTeachingSettingUpList = new List<EM_SpecialtyCourseTeachingSetting>();
  282. List<EM_TeachingModeType> newTeachingModeTypeInList = new List<EM_TeachingModeType>();
  283. List<EMIS.Entities.EM_TeachingPlace> newTeachingPlaceInList = new List<EMIS.Entities.EM_TeachingPlace>();
  284. List<Guid?> specialtyCourseTMDelList = new List<Guid?>();
  285. List<Guid?> specialtyCourseTPDelList = new List<Guid?>();
  286. //数据有误验证
  287. if (specialtyCourseView.SpecialtyCourseID != Guid.Empty)
  288. {
  289. var specialtyCourse = SpecialtyCourseDAL.SpecialtyCourseRepository
  290. .GetList(x => x.SpecialtyCourseID == specialtyCourseView.SpecialtyCourseID,
  291. (x => x.EM_SpecialtyCourseTeachingSetting)).SingleOrDefault();
  292. if (specialtyCourse == null)
  293. {
  294. throw new Exception("数据有误,请核查。");
  295. }
  296. else
  297. {
  298. //表示修改
  299. specialtyCourse.SpecialtyID = specialtyCourseView.SpecialtyID;
  300. specialtyCourse.StarttermID = specialtyCourseView.StarttermID;
  301. specialtyCourse.CoursematerialID = specialtyCourseView.CoursematerialID;
  302. specialtyCourse.CourseStructureID = specialtyCourseView.CourseStructureID;
  303. specialtyCourse.CourseCategoryID = specialtyCourseView.CourseCategoryID;
  304. specialtyCourse.CourseTypeID = specialtyCourseView.CourseTypeID;
  305. specialtyCourse.CourseQualityID = specialtyCourseView.CourseQualityID;
  306. specialtyCourse.DepartmentID = specialtyCourseView.DepartmentID;
  307. specialtyCourse.IsSpecialtycore = specialtyCourseView.IsSpecialtycore;
  308. specialtyCourse.IsCooperation = specialtyCourseView.IsCooperation;
  309. specialtyCourse.IsRequired = specialtyCourseView.IsRequired;
  310. specialtyCourse.IsElective = specialtyCourseView.IsElective;
  311. specialtyCourse.IsNetworkCourse = specialtyCourseView.IsNetworkCourse;
  312. specialtyCourse.IsMainCourse = specialtyCourseView.IsMainCourse;
  313. specialtyCourse.IsNeedMaterial = specialtyCourseView.IsNeedMaterial;
  314. specialtyCourse.CourseFineID = specialtyCourseView.CourseFineID;
  315. specialtyCourse.PracticeTypeID = specialtyCourseView.PracticeTypeID;
  316. specialtyCourse.TeachinglanguageID = specialtyCourseView.TeachinglanguageID;
  317. specialtyCourse.ExaminationModeID = specialtyCourseView.ExaminationModeID;
  318. specialtyCourse.ResultTypeID = specialtyCourseView.ResultTypeID;
  319. specialtyCourse.HandleModeID = specialtyCourseView.HandleModeID;
  320. specialtyCourse.IsEnable = specialtyCourseView.IsEnable;
  321. specialtyCourse.Remark = specialtyCourseView.Remark;
  322. SetModifyStatus(specialtyCourse);
  323. newSpecialtyCourseUpList.Add(specialtyCourse);
  324. if (specialtyCourse.EM_SpecialtyCourseTeachingSetting == null)
  325. {
  326. var newTeachingSetting = new EM_SpecialtyCourseTeachingSetting();
  327. newTeachingSetting.SpecialtyCourseID = specialtyCourse.SpecialtyCourseID;
  328. newTeachingSetting.Credit = specialtyCourseView.Credit;
  329. newTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse;
  330. newTeachingSetting.Practicehours = specialtyCourseView.Practicehours;
  331. newTeachingSetting.Trialhours = specialtyCourseView.Trialhours;
  332. newTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum;
  333. newTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum;
  334. newTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum;
  335. newTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours;
  336. newTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum;
  337. newTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum;
  338. newTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum;
  339. newTeachingSettingInList.Add(newTeachingSetting);
  340. }
  341. else
  342. {
  343. specialtyCourse.EM_SpecialtyCourseTeachingSetting.Credit = specialtyCourseView.Credit;
  344. specialtyCourse.EM_SpecialtyCourseTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse;
  345. specialtyCourse.EM_SpecialtyCourseTeachingSetting.Practicehours = specialtyCourseView.Practicehours;
  346. specialtyCourse.EM_SpecialtyCourseTeachingSetting.Trialhours = specialtyCourseView.Trialhours;
  347. specialtyCourse.EM_SpecialtyCourseTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum;
  348. specialtyCourse.EM_SpecialtyCourseTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum;
  349. specialtyCourse.EM_SpecialtyCourseTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum;
  350. specialtyCourse.EM_SpecialtyCourseTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours;
  351. specialtyCourse.EM_SpecialtyCourseTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum;
  352. specialtyCourse.EM_SpecialtyCourseTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum;
  353. specialtyCourse.EM_SpecialtyCourseTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum;
  354. newTeachingSettingUpList.Add(specialtyCourse.EM_SpecialtyCourseTeachingSetting);
  355. }
  356. if (specialtyCourseView.TeachingModeIDList != null && specialtyCourseView.TeachingModeIDList.Count() > 0)
  357. {
  358. specialtyCourseTMDelList.Add(specialtyCourse.SpecialtyCourseID);
  359. foreach (var teachingModeID in specialtyCourseView.TeachingModeIDList)
  360. {
  361. var newTeachingMode = new EM_TeachingModeType();
  362. newTeachingMode.TeachingModeTypeID = Guid.NewGuid();
  363. newTeachingMode.SpecialtyCourseID = specialtyCourse.SpecialtyCourseID;
  364. newTeachingMode.TeachingModeID = teachingModeID;
  365. SetNewStatus(newTeachingMode);
  366. newTeachingModeTypeInList.Add(newTeachingMode);
  367. }
  368. }
  369. else
  370. {
  371. specialtyCourseTMDelList.Add(specialtyCourse.SpecialtyCourseID);
  372. }
  373. if (specialtyCourseView.TeachingPlaceIDList != null && specialtyCourseView.TeachingPlaceIDList.Count() > 0)
  374. {
  375. specialtyCourseTPDelList.Add(specialtyCourse.SpecialtyCourseID);
  376. foreach (var teachingPlaceID in specialtyCourseView.TeachingPlaceIDList)
  377. {
  378. var newTeachingPlace = new EMIS.Entities.EM_TeachingPlace();
  379. newTeachingPlace.TeachingPlaceID = Guid.NewGuid();
  380. newTeachingPlace.SpecialtyCourseID = specialtyCourse.SpecialtyCourseID;
  381. newTeachingPlace.TeachingPlace = teachingPlaceID;
  382. SetNewStatus(newTeachingPlace);
  383. newTeachingPlaceInList.Add(newTeachingPlace);
  384. }
  385. }
  386. else
  387. {
  388. specialtyCourseTPDelList.Add(specialtyCourse.SpecialtyCourseID);
  389. }
  390. }
  391. }
  392. else
  393. {
  394. //表示新增
  395. var newSpecialtyCourse = new EM_SpecialtyCourse();
  396. newSpecialtyCourse.SpecialtyCourseID = Guid.NewGuid();
  397. newSpecialtyCourse.SpecialtyID = specialtyCourseView.SpecialtyID;
  398. newSpecialtyCourse.StarttermID = specialtyCourseView.StarttermID;
  399. newSpecialtyCourse.CoursematerialID = specialtyCourseView.CoursematerialID;
  400. newSpecialtyCourse.CourseStructureID = specialtyCourseView.CourseStructureID;
  401. newSpecialtyCourse.CourseCategoryID = specialtyCourseView.CourseCategoryID;
  402. newSpecialtyCourse.CourseTypeID = specialtyCourseView.CourseTypeID;
  403. newSpecialtyCourse.CourseQualityID = specialtyCourseView.CourseQualityID;
  404. newSpecialtyCourse.DepartmentID = specialtyCourseView.DepartmentID;
  405. newSpecialtyCourse.IsSpecialtycore = specialtyCourseView.IsSpecialtycore;
  406. newSpecialtyCourse.IsCooperation = specialtyCourseView.IsCooperation;
  407. newSpecialtyCourse.IsRequired = specialtyCourseView.IsRequired;
  408. newSpecialtyCourse.IsElective = specialtyCourseView.IsElective;
  409. newSpecialtyCourse.IsNetworkCourse = specialtyCourseView.IsNetworkCourse;
  410. newSpecialtyCourse.IsMainCourse = specialtyCourseView.IsMainCourse;
  411. newSpecialtyCourse.IsNeedMaterial = specialtyCourseView.IsNeedMaterial;
  412. newSpecialtyCourse.CourseFineID = specialtyCourseView.CourseFineID;
  413. newSpecialtyCourse.PracticeTypeID = specialtyCourseView.PracticeTypeID;
  414. newSpecialtyCourse.TeachinglanguageID = specialtyCourseView.TeachinglanguageID;
  415. newSpecialtyCourse.ExaminationModeID = specialtyCourseView.ExaminationModeID;
  416. newSpecialtyCourse.ResultTypeID = specialtyCourseView.ResultTypeID;
  417. newSpecialtyCourse.HandleModeID = specialtyCourseView.HandleModeID;
  418. newSpecialtyCourse.IsEnable = specialtyCourseView.IsEnable;
  419. newSpecialtyCourse.Remark = specialtyCourseView.Remark;
  420. SetNewStatus(newSpecialtyCourse);
  421. newSpecialtyCourseInList.Add(newSpecialtyCourse);
  422. var newTeachingSetting = new EM_SpecialtyCourseTeachingSetting();
  423. newTeachingSetting.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
  424. newTeachingSetting.Credit = specialtyCourseView.Credit;
  425. newTeachingSetting.TheoryCourse = specialtyCourseView.TheoryCourse;
  426. newTeachingSetting.Practicehours = specialtyCourseView.Practicehours;
  427. newTeachingSetting.Trialhours = specialtyCourseView.Trialhours;
  428. newTeachingSetting.TheoryWeeklyNum = specialtyCourseView.TheoryWeeklyNum;
  429. newTeachingSetting.PracticeWeeklyNum = specialtyCourseView.PracticeWeeklyNum;
  430. newTeachingSetting.TrialWeeklyNum = specialtyCourseView.TrialWeeklyNum;
  431. newTeachingSetting.WeeklyHours = specialtyCourseView.WeeklyHours;
  432. newTeachingSetting.WeeklyNum = specialtyCourseView.WeeklyNum;
  433. newTeachingSetting.StartWeeklyNum = specialtyCourseView.StartWeeklyNum;
  434. newTeachingSetting.EndWeeklyNum = specialtyCourseView.EndWeeklyNum;
  435. newTeachingSettingInList.Add(newTeachingSetting);
  436. if (specialtyCourseView.TeachingModeIDList != null && specialtyCourseView.TeachingModeIDList.Count() > 0)
  437. {
  438. foreach (var teachingModeID in specialtyCourseView.TeachingModeIDList)
  439. {
  440. var newTeachingMode = new EM_TeachingModeType();
  441. newTeachingMode.TeachingModeTypeID = Guid.NewGuid();
  442. newTeachingMode.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
  443. newTeachingMode.TeachingModeID = teachingModeID;
  444. SetNewStatus(newTeachingMode);
  445. newTeachingModeTypeInList.Add(newTeachingMode);
  446. }
  447. }
  448. if (specialtyCourseView.TeachingPlaceIDList != null && specialtyCourseView.TeachingPlaceIDList.Count() > 0)
  449. {
  450. foreach (var teachingPlaceID in specialtyCourseView.TeachingPlaceIDList)
  451. {
  452. var newTeachingPlace = new EMIS.Entities.EM_TeachingPlace();
  453. newTeachingPlace.TeachingPlaceID = Guid.NewGuid();
  454. newTeachingPlace.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
  455. newTeachingPlace.TeachingPlace = teachingPlaceID;
  456. SetNewStatus(newTeachingPlace);
  457. newTeachingPlaceInList.Add(newTeachingPlace);
  458. }
  459. }
  460. }
  461. //事务提交
  462. //UnitOfWork.Commit();
  463. using (TransactionScope ts = new TransactionScope())
  464. {
  465. //删除
  466. UnitOfWork.Delete<EMIS.Entities.EM_TeachingPlace>(x => specialtyCourseTPDelList.Contains(x.SpecialtyCourseID));
  467. UnitOfWork.Delete<EM_TeachingModeType>(x => specialtyCourseTMDelList.Contains(x.SpecialtyCourseID));
  468. //批量插入
  469. UnitOfWork.BulkInsert(newSpecialtyCourseInList);
  470. UnitOfWork.BulkInsert(newTeachingSettingInList);
  471. UnitOfWork.BulkInsert(newTeachingModeTypeInList);
  472. UnitOfWork.BulkInsert(newTeachingPlaceInList);
  473. //批量统一提交更新
  474. if (newSpecialtyCourseUpList != null && newSpecialtyCourseUpList.Count() > 0)
  475. {
  476. UnitOfWork.BatchUpdate(newSpecialtyCourseUpList);
  477. }
  478. //批量统一提交更新
  479. if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0)
  480. {
  481. UnitOfWork.BatchUpdate(newTeachingSettingUpList);
  482. }
  483. ts.Complete();
  484. }
  485. }
  486. else
  487. {
  488. throw new Exception("已存在相同的专业课程信息(专业信息、开课学期、课程信息唯一),请核查。");
  489. }
  490. }
  491. catch (Exception ex)
  492. {
  493. throw new Exception(ex.Message);
  494. }
  495. }
  496. /// <summary>
  497. /// 删除
  498. /// </summary>
  499. /// <param name="specialtyCourseIDs"></param>
  500. /// <returns></returns>
  501. public bool SpecialtyCourseDelete(List<Guid?> specialtyCourseIDs)
  502. {
  503. try
  504. {
  505. using (TransactionScope ts = new TransactionScope())
  506. {
  507. UnitOfWork.Delete<EMIS.Entities.EM_TeachingPlace>(x => specialtyCourseIDs.Contains(x.SpecialtyCourseID));
  508. UnitOfWork.Delete<EM_TeachingModeType>(x => specialtyCourseIDs.Contains(x.SpecialtyCourseID));
  509. UnitOfWork.Delete<EM_SpecialtyCourseTeachingSetting>(x => specialtyCourseIDs.Contains(x.SpecialtyCourseID));
  510. UnitOfWork.Delete<EM_SpecialtyCourse>(x => specialtyCourseIDs.Contains(x.SpecialtyCourseID));
  511. ts.Complete();
  512. return true;
  513. }
  514. }
  515. catch (Exception)
  516. {
  517. throw;
  518. }
  519. }
  520. /// <summary>
  521. /// 查询专业课程对应的授课方式List
  522. /// </summary>
  523. /// <param name="specialtyCourseID"></param>
  524. /// <returns></returns>
  525. public List<string> GetTeachingModeTypeList(Guid? specialtyCourseID)
  526. {
  527. //专业课程
  528. Expression<Func<EM_SpecialtyCourse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  529. exp = exp.And(x => x.SpecialtyCourseID == specialtyCourseID);
  530. var query = SpecialtyCourseDAL.GetTeachingModeTypeQueryble(exp);
  531. return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList();
  532. }
  533. /// <summary>
  534. /// 查询专业课程对应的授课地点List
  535. /// </summary>
  536. /// <param name="specialtyCourseID"></param>
  537. /// <returns></returns>
  538. public List<string> GetTeachingPlaceList(Guid? specialtyCourseID)
  539. {
  540. //专业课程
  541. Expression<Func<EM_SpecialtyCourse, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  542. exp = exp.And(x => x.SpecialtyCourseID == specialtyCourseID);
  543. var query = SpecialtyCourseDAL.GetTeachingPlaceQueryble(exp);
  544. return query.OrderBy(x => x.Value).Select(x => x.ToString()).ToList();
  545. }
  546. /// <summary>
  547. /// 专业课程信息Excel导入
  548. /// </summary>
  549. /// <param name="cellheader"></param>
  550. /// <param name="inCount"></param>
  551. /// <param name="upCount"></param>
  552. /// <param name="errdataList"></param>
  553. /// <param name="errCount"></param>
  554. /// <param name="sourcePhysicalPath"></param>
  555. public void SpecialtyCourseImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<SpecialtyCourseView> errdataList, out int? errCount, string sourcePhysicalPath)
  556. {
  557. try
  558. {
  559. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  560. List<SpecialtyCourseView> errList = new List<SpecialtyCourseView>();
  561. // 1.1解析文件,存放到一个List集合里
  562. cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage)
  563. List<SpecialtyCourseView> enlist = NpoiExcelHelper.ExcelToEntityList<SpecialtyCourseView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
  564. cellheader.Add("ErrorMessage", "未导入原因");
  565. //对List集合进行有效性校验
  566. if (enlist.Count() <= 0)
  567. {
  568. throw new Exception("Excel文件数据为空,请检查。");
  569. }
  570. Regex reg = null; //正则表达式
  571. //DateTime result; //用于返回判断日期字段格式
  572. bool isListPass = true; //List判断标识
  573. inCount = 0; //导入个数
  574. upCount = 0; //更新个数
  575. errCount = 0; //失败个数
  576. string errorMsgStr = ""; //错误信息
  577. List<EM_SpecialtyCourse> newSpecialtyCourseInList = new List<EM_SpecialtyCourse>();
  578. List<EM_SpecialtyCourse> newSpecialtyCourseUpList = new List<EM_SpecialtyCourse>();
  579. List<EM_SpecialtyCourseTeachingSetting> newTeachingSettingInList = new List<EM_SpecialtyCourseTeachingSetting>();
  580. List<EM_SpecialtyCourseTeachingSetting> newTeachingSettingUpList = new List<EM_SpecialtyCourseTeachingSetting>();
  581. List<EM_TeachingModeType> newTeachingModeTypeInList = new List<EM_TeachingModeType>();
  582. List<EMIS.Entities.EM_TeachingPlace> newTeachingPlaceInList = new List<EMIS.Entities.EM_TeachingPlace>();
  583. List<Guid?> specialtyCourseTMDelList = new List<Guid?>();
  584. List<Guid?> specialtyCourseTPDelList = new List<Guid?>();
  585. //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
  586. //专业代码、专业名称、专业ID(Value)
  587. var standardList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Standard).ToList();
  588. //培养层次(所修学历)
  589. var educationList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Education).ToList();
  590. //学习形式
  591. var learningFormList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Learningform).ToList();
  592. //专业信息
  593. var specialtyList = SpecialtyCourseDAL.SpecialtyRepository.GetList(x => true).ToList();
  594. //开课学期
  595. var starttermList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Startterm).ToList();
  596. //课程信息
  597. var courseList = SpecialtyCourseDAL.CoursematerialRepository.GetList(x => true).ToList();
  598. //课程代码
  599. var courseCodeList = enlist.Where(x => !string.IsNullOrWhiteSpace(x.CourseCode)).Select(x => x.CourseCode.Trim()).ToList();
  600. //对比后的newCourseList
  601. var newCourseList = courseList.Where(x => courseCodeList.Contains(x.CourseCode)).ToList();
  602. //对比后的coursematerialIDList
  603. var coursematerialIDList = newCourseList.Select(x => (Guid?)x.CoursematerialID).ToList();
  604. //课程结构
  605. var courseStructureList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseStructure).ToList();
  606. //课程属性
  607. var courseCategoryList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseCategory).ToList();
  608. //课程类型
  609. var courseTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseType).ToList();
  610. //课程性质
  611. var courseQualityList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseQuality).ToList();
  612. //教研室信息
  613. var departmentList = SpecialtyCourseDAL.DepartmentRepository.GetList(x => true).ToList();
  614. //开课教研室
  615. var departmentNameList = enlist.Where(x => !string.IsNullOrWhiteSpace(x.DepartmentName)).Select(x => x.DepartmentName.Trim()).ToList();
  616. //对比后的newDepartmentList
  617. var newDepartmentList = departmentList.Where(x => departmentNameList.Contains(x.Name)).ToList();
  618. //通用是否
  619. var generalPurposeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_GeneralPurpose).ToList();
  620. //精品课程
  621. var courseFineList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseFine).ToList();
  622. //实践类型
  623. var practiceTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.EM_PracticeType).ToList();
  624. //授课语言
  625. var teachinglanguageList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Teachinglanguage).ToList();
  626. //考试方式
  627. var examinationModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ExaminationMode).ToList();
  628. //成绩类型
  629. var resultTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ResultType).ToList();
  630. //处理方式
  631. var handleModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_HandleMode).ToList();
  632. //授课方式
  633. var teachingModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_TeachingMode).ToList();
  634. //授课地点
  635. var teachingPlaceList = IdNameExt.GetDictionaryItem(DictionaryItem.EM_TeachingPlace).ToList();
  636. //专业课程
  637. var specialtyCourseList = SpecialtyCourseDAL.SpecialtyCourseRepository
  638. .GetList(x => true, (x => x.EM_SpecialtyCourseTeachingSetting)).ToList();
  639. //对比后的newSpecialtyCourseList(暂时只对比课程信息ID)
  640. var newSpecialtyCourseList = specialtyCourseList.Where(x => coursematerialIDList.Contains(x.CoursematerialID)).ToList();
  641. //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
  642. for (int i = 0; i < enlist.Count; i++)
  643. {
  644. SpecialtyCourseView en = enlist[i]; //Excel表数据视图
  645. EM_SpecialtyCourse newSpecialtyCourse = new EM_SpecialtyCourse();
  646. EM_SpecialtyCourseTeachingSetting newTeachingSetting = new EM_SpecialtyCourseTeachingSetting();
  647. List<int> newModeTypeList = new List<int>();
  648. List<int> newPlaceList = new List<int>();
  649. //专业代码
  650. if (string.IsNullOrWhiteSpace(en.StandardCodeStr))
  651. {
  652. errCount++;
  653. errorMsgStr = "专业代码不能为空";
  654. en.ErrorMessage = errorMsgStr;
  655. errList.Add(en);
  656. errorMsg.AppendLine(errorMsgStr);
  657. continue;
  658. }
  659. else
  660. {
  661. var standard = standardList.Where(x => x.Code == en.StandardCodeStr.Trim()).FirstOrDefault();
  662. if (standard == null)
  663. {
  664. errCount++;
  665. errorMsgStr = "专业代码不存在,请检查";
  666. en.ErrorMessage = errorMsgStr;
  667. errList.Add(en);
  668. errorMsg.AppendLine(errorMsgStr);
  669. continue;
  670. }
  671. else
  672. {
  673. //专业代码
  674. }
  675. }
  676. //专业名称
  677. if (string.IsNullOrWhiteSpace(en.StandardNameStr))
  678. {
  679. errCount++;
  680. errorMsgStr = "专业名称不能为空";
  681. en.ErrorMessage = errorMsgStr;
  682. errList.Add(en);
  683. errorMsg.AppendLine(errorMsgStr);
  684. continue;
  685. }
  686. else
  687. {
  688. var standard = standardList.Where(x => x.Name == en.StandardNameStr.Trim()).FirstOrDefault();
  689. if (standard == null)
  690. {
  691. errCount++;
  692. errorMsgStr = "专业名称不存在,请检查";
  693. en.ErrorMessage = errorMsgStr;
  694. errList.Add(en);
  695. errorMsg.AppendLine(errorMsgStr);
  696. continue;
  697. }
  698. else
  699. {
  700. //专业名称
  701. }
  702. }
  703. //专业代码与专业名称查询专业ID(Value)
  704. if (string.IsNullOrWhiteSpace(en.StandardCodeStr) || string.IsNullOrWhiteSpace(en.StandardNameStr))
  705. {
  706. errCount++;
  707. errorMsgStr = "专业代码或专业名称不能为空";
  708. en.ErrorMessage = errorMsgStr;
  709. errList.Add(en);
  710. errorMsg.AppendLine(errorMsgStr);
  711. continue;
  712. }
  713. else
  714. {
  715. var standard = standardList.Where(x => x.Code == en.StandardCodeStr.Trim() && x.Name == en.StandardNameStr.Trim()).SingleOrDefault();
  716. if (standard == null)
  717. {
  718. errCount++;
  719. errorMsgStr = "专业代码与专业名称对应的元素值不存在,请检查";
  720. en.ErrorMessage = errorMsgStr;
  721. errList.Add(en);
  722. errorMsg.AppendLine(errorMsgStr);
  723. continue;
  724. }
  725. else
  726. {
  727. //专业ID(Value)
  728. en.StandardID = standard.Value;
  729. }
  730. }
  731. //培养层次
  732. if (string.IsNullOrWhiteSpace(en.EducationStr))
  733. {
  734. errCount++;
  735. errorMsgStr = RSL.Get("EducationID") + "不能为空";
  736. en.ErrorMessage = errorMsgStr;
  737. errList.Add(en);
  738. errorMsg.AppendLine(errorMsgStr);
  739. continue;
  740. }
  741. else
  742. {
  743. var education = educationList.Where(x => x.Name == en.EducationStr.Trim()).SingleOrDefault();
  744. if (education == null)
  745. {
  746. errCount++;
  747. errorMsgStr = RSL.Get("EducationID") + "不存在,请检查";
  748. en.ErrorMessage = errorMsgStr;
  749. errList.Add(en);
  750. errorMsg.AppendLine(errorMsgStr);
  751. continue;
  752. }
  753. else
  754. {
  755. //培养层次
  756. en.EducationID = education.Value;
  757. }
  758. }
  759. //学习形式
  760. if (string.IsNullOrWhiteSpace(en.LearningformStr))
  761. {
  762. errCount++;
  763. errorMsgStr = "学习形式不能为空";
  764. en.ErrorMessage = errorMsgStr;
  765. errList.Add(en);
  766. errorMsg.AppendLine(errorMsgStr);
  767. continue;
  768. }
  769. else
  770. {
  771. var learningForm = learningFormList.Where(x => x.Name == en.LearningformStr.Trim()).SingleOrDefault();
  772. if (learningForm == null)
  773. {
  774. errCount++;
  775. errorMsgStr = "学习形式不存在,请检查";
  776. en.ErrorMessage = errorMsgStr;
  777. errList.Add(en);
  778. errorMsg.AppendLine(errorMsgStr);
  779. continue;
  780. }
  781. else
  782. {
  783. //学习形式
  784. en.LearningformID = learningForm.Value;
  785. }
  786. }
  787. //学制
  788. if (string.IsNullOrWhiteSpace(en.LearnSystemStr))
  789. {
  790. errCount++;
  791. errorMsgStr = "学制不能为空";
  792. en.ErrorMessage = errorMsgStr;
  793. errList.Add(en);
  794. errorMsg.AppendLine(errorMsgStr);
  795. continue;
  796. }
  797. else
  798. {
  799. reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //学制字段正则表达式(数字)
  800. if (!reg.IsMatch(en.LearnSystemStr.Trim()))
  801. {
  802. errCount++;
  803. errorMsgStr = "学制格式不正确,请检查";
  804. en.ErrorMessage = errorMsgStr;
  805. errList.Add(en);
  806. errorMsg.AppendLine(errorMsgStr);
  807. continue;
  808. }
  809. else
  810. {
  811. //学制
  812. en.LearnSystem = Convert.ToDecimal(en.LearnSystemStr.Trim());
  813. }
  814. }
  815. //查询对应的专业信息ID
  816. if (en.StandardID.HasValue && en.EducationID.HasValue && en.LearningformID.HasValue && en.LearnSystem.HasValue)
  817. {
  818. //查询对应的专业信息
  819. var specialty = specialtyList.Where(x => x.StandardID == en.StandardID
  820. && x.EducationID == en.EducationID
  821. && x.LearningformID == en.LearningformID
  822. && x.LearnSystem == en.LearnSystem).SingleOrDefault();
  823. if (specialty == null)
  824. {
  825. errCount++;
  826. errorMsgStr = "对应的专业信息不存在(以专业代码、专业名称、"
  827. + RSL.Get("EducationID") + "、学习形式、学制查询),请检查";
  828. en.ErrorMessage = errorMsgStr;
  829. errList.Add(en);
  830. errorMsg.AppendLine(errorMsgStr);
  831. continue;
  832. }
  833. else
  834. {
  835. //判断对应的专业信息状态(启用、禁用状态)
  836. if (specialty.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  837. {
  838. newSpecialtyCourse.SpecialtyID = specialty.SpecialtyID;
  839. }
  840. else
  841. {
  842. newSpecialtyCourse.SpecialtyID = specialty.SpecialtyID;
  843. errCount++;
  844. errorMsgStr = "对应的专业信息为禁用状态,请检查";
  845. en.ErrorMessage = errorMsgStr;
  846. errList.Add(en);
  847. errorMsg.AppendLine(errorMsgStr);
  848. continue;
  849. }
  850. }
  851. }
  852. else
  853. {
  854. errCount++;
  855. errorMsgStr = "数据有误,请检查(专业ID(Value)、"
  856. + RSL.Get("EducationID") + "、学习形式或学制不能为空)";
  857. en.ErrorMessage = errorMsgStr;
  858. errList.Add(en);
  859. errorMsg.AppendLine(errorMsgStr);
  860. continue;
  861. }
  862. //开课学期
  863. if (string.IsNullOrWhiteSpace(en.StarttermStr))
  864. {
  865. errCount++;
  866. errorMsgStr = "开课学期不能为空";
  867. en.ErrorMessage = errorMsgStr;
  868. errList.Add(en);
  869. errorMsg.AppendLine(errorMsgStr);
  870. continue;
  871. }
  872. else
  873. {
  874. var startterm = starttermList.Where(x => x.Name == en.StarttermStr.Trim()).SingleOrDefault();
  875. if (startterm == null)
  876. {
  877. errCount++;
  878. errorMsgStr = "开课学期不存在,请检查";
  879. en.ErrorMessage = errorMsgStr;
  880. errList.Add(en);
  881. errorMsg.AppendLine(errorMsgStr);
  882. continue;
  883. }
  884. else
  885. {
  886. //对学制和开课学期进行判断
  887. var maxStartterm = Convert.ToInt32(Math.Ceiling(en.LearnSystem.Value * 2 - 1)) + 1;
  888. if (startterm.Value > maxStartterm)
  889. {
  890. errCount++;
  891. errorMsgStr = "开课学期超出学制范围,请检查";
  892. en.ErrorMessage = errorMsgStr;
  893. errList.Add(en);
  894. errorMsg.AppendLine(errorMsgStr);
  895. continue;
  896. }
  897. else
  898. {
  899. //开课学期
  900. newSpecialtyCourse.StarttermID = startterm.Value;
  901. }
  902. }
  903. }
  904. //课程代码
  905. if (string.IsNullOrWhiteSpace(en.CourseCode))
  906. {
  907. errCount++;
  908. errorMsgStr = "课程代码不能为空";
  909. en.ErrorMessage = errorMsgStr;
  910. errList.Add(en);
  911. errorMsg.AppendLine(errorMsgStr);
  912. continue;
  913. }
  914. else
  915. {
  916. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  917. if (!reg.IsMatch(en.CourseCode.Trim()))
  918. {
  919. errCount++;
  920. errorMsgStr = "课程代码格式不正确,请检查(数字或英文字母)";
  921. en.ErrorMessage = errorMsgStr;
  922. errList.Add(en);
  923. errorMsg.AppendLine(errorMsgStr);
  924. continue;
  925. }
  926. else
  927. {
  928. var course = newCourseList.Where(x => x.CourseCode == en.CourseCode.Trim()).SingleOrDefault();
  929. if (course == null)
  930. {
  931. errCount++;
  932. errorMsgStr = "课程代码不存在,请检查";
  933. en.ErrorMessage = errorMsgStr;
  934. errList.Add(en);
  935. errorMsg.AppendLine(errorMsgStr);
  936. continue;
  937. }
  938. else
  939. {
  940. //判断课程代码与课程名称(以课程代码为准)
  941. if (string.IsNullOrWhiteSpace(en.CourseName))
  942. {
  943. //暂不考虑
  944. }
  945. else
  946. {
  947. //课程代码与课程名称不对应
  948. if (course.CourseName.Trim() != en.CourseName.Trim())
  949. {
  950. errCount++;
  951. errorMsgStr = "课程代码与课程名称不对应(以课程代码为准),请检查";
  952. en.ErrorMessage = errorMsgStr;
  953. errList.Add(en);
  954. errorMsg.AppendLine(errorMsgStr);
  955. continue;
  956. }
  957. }
  958. //判断对应的课程信息状态(启用、禁用状态)
  959. if (course.IsEnable == true)
  960. {
  961. //课程信息ID
  962. newSpecialtyCourse.CoursematerialID = course.CoursematerialID;
  963. }
  964. else
  965. {
  966. newSpecialtyCourse.CoursematerialID = course.CoursematerialID;
  967. errCount++;
  968. errorMsgStr = "对应的课程信息为禁用状态,请检查";
  969. en.ErrorMessage = errorMsgStr;
  970. errList.Add(en);
  971. errorMsg.AppendLine(errorMsgStr);
  972. continue;
  973. }
  974. }
  975. }
  976. }
  977. //课程名称
  978. if (string.IsNullOrWhiteSpace(en.CourseName))
  979. {
  980. //暂不考虑
  981. }
  982. else
  983. {
  984. //暂不考虑
  985. }
  986. //课程结构
  987. if (string.IsNullOrWhiteSpace(en.CourseStructureStr))
  988. {
  989. newSpecialtyCourse.CourseStructureID = (int)CF_CourseStructure.ClassroomTeaching;
  990. }
  991. else
  992. {
  993. var courseStructure = courseStructureList.Where(x => x.Name == en.CourseStructureStr.Trim()).SingleOrDefault();
  994. if (courseStructure == null)
  995. {
  996. errCount++;
  997. errorMsgStr = "课程结构不存在,请检查";
  998. en.ErrorMessage = errorMsgStr;
  999. errList.Add(en);
  1000. errorMsg.AppendLine(errorMsgStr);
  1001. continue;
  1002. }
  1003. else
  1004. {
  1005. //课程结构
  1006. newSpecialtyCourse.CourseStructureID = courseStructure.Value;
  1007. }
  1008. }
  1009. //课程属性
  1010. if (string.IsNullOrWhiteSpace(en.CourseCategoryStr))
  1011. {
  1012. newSpecialtyCourse.CourseCategoryID = (int)CF_CourseCategory.Publiccourse;
  1013. }
  1014. else
  1015. {
  1016. var courseCategory = courseCategoryList.Where(x => x.Name == en.CourseCategoryStr.Trim()).SingleOrDefault();
  1017. if (courseCategory == null)
  1018. {
  1019. errCount++;
  1020. errorMsgStr = "课程属性不存在,请检查";
  1021. en.ErrorMessage = errorMsgStr;
  1022. errList.Add(en);
  1023. errorMsg.AppendLine(errorMsgStr);
  1024. continue;
  1025. }
  1026. else
  1027. {
  1028. //课程属性
  1029. newSpecialtyCourse.CourseCategoryID = courseCategory.Value;
  1030. }
  1031. }
  1032. //课程类型
  1033. if (string.IsNullOrWhiteSpace(en.CourseTypeStr))
  1034. {
  1035. errCount++;
  1036. errorMsgStr = "课程类型不能为空";
  1037. en.ErrorMessage = errorMsgStr;
  1038. errList.Add(en);
  1039. errorMsg.AppendLine(errorMsgStr);
  1040. continue;
  1041. }
  1042. else
  1043. {
  1044. var courseType = courseTypeList.Where(x => x.Name == en.CourseTypeStr.Trim()).SingleOrDefault();
  1045. if (courseType == null)
  1046. {
  1047. errCount++;
  1048. errorMsgStr = "课程类型不存在,请检查";
  1049. en.ErrorMessage = errorMsgStr;
  1050. errList.Add(en);
  1051. errorMsg.AppendLine(errorMsgStr);
  1052. continue;
  1053. }
  1054. else
  1055. {
  1056. //课程类型
  1057. newSpecialtyCourse.CourseTypeID = courseType.Value;
  1058. }
  1059. }
  1060. //课程性质
  1061. if (string.IsNullOrWhiteSpace(en.CourseQualityStr))
  1062. {
  1063. newSpecialtyCourse.CourseQualityID = (int)CF_CourseQuality.Required;
  1064. }
  1065. else
  1066. {
  1067. var courseQuality = courseQualityList.Where(x => x.Name == en.CourseQualityStr.Trim()).SingleOrDefault();
  1068. if (courseQuality == null)
  1069. {
  1070. errCount++;
  1071. errorMsgStr = "课程性质不存在,请检查";
  1072. en.ErrorMessage = errorMsgStr;
  1073. errList.Add(en);
  1074. errorMsg.AppendLine(errorMsgStr);
  1075. continue;
  1076. }
  1077. else
  1078. {
  1079. //课程性质
  1080. newSpecialtyCourse.CourseQualityID = courseQuality.Value;
  1081. }
  1082. }
  1083. //课程学分
  1084. if (string.IsNullOrWhiteSpace(en.CreditStr))
  1085. {
  1086. errCount++;
  1087. errorMsgStr = "课程学分不能为空";
  1088. en.ErrorMessage = errorMsgStr;
  1089. errList.Add(en);
  1090. errorMsg.AppendLine(errorMsgStr);
  1091. continue;
  1092. }
  1093. else
  1094. {
  1095. reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //课程学分字段正则表达式(数字)
  1096. if (!reg.IsMatch(en.CreditStr.Trim()))
  1097. {
  1098. errCount++;
  1099. errorMsgStr = "课程学分格式不正确,请检查";
  1100. en.ErrorMessage = errorMsgStr;
  1101. errList.Add(en);
  1102. errorMsg.AppendLine(errorMsgStr);
  1103. continue;
  1104. }
  1105. else
  1106. {
  1107. //课程学分
  1108. newTeachingSetting.Credit = Convert.ToDecimal(en.CreditStr.Trim());
  1109. }
  1110. }
  1111. //理论学时
  1112. if (string.IsNullOrWhiteSpace(en.TheoryCourseStr))
  1113. {
  1114. errCount++;
  1115. errorMsgStr = "理论学时不能为空";
  1116. en.ErrorMessage = errorMsgStr;
  1117. errList.Add(en);
  1118. errorMsg.AppendLine(errorMsgStr);
  1119. continue;
  1120. }
  1121. else
  1122. {
  1123. reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
  1124. if (!reg.IsMatch(en.TheoryCourseStr.Trim()))
  1125. {
  1126. errCount++;
  1127. errorMsgStr = "理论学时格式不正确,请检查";
  1128. en.ErrorMessage = errorMsgStr;
  1129. errList.Add(en);
  1130. errorMsg.AppendLine(errorMsgStr);
  1131. continue;
  1132. }
  1133. else
  1134. {
  1135. //理论学时
  1136. newTeachingSetting.TheoryCourse = Convert.ToInt32(en.TheoryCourseStr.Trim());
  1137. }
  1138. }
  1139. //实践学时
  1140. if (string.IsNullOrWhiteSpace(en.PracticehoursStr))
  1141. {
  1142. //默认为0
  1143. newTeachingSetting.Practicehours = 0;
  1144. }
  1145. else
  1146. {
  1147. reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
  1148. if (!reg.IsMatch(en.PracticehoursStr.Trim()))
  1149. {
  1150. errCount++;
  1151. errorMsgStr = "实践学时格式不正确,请检查";
  1152. en.ErrorMessage = errorMsgStr;
  1153. errList.Add(en);
  1154. errorMsg.AppendLine(errorMsgStr);
  1155. continue;
  1156. }
  1157. else
  1158. {
  1159. //实践学时
  1160. newTeachingSetting.Practicehours = Convert.ToInt32(en.PracticehoursStr.Trim());
  1161. }
  1162. }
  1163. //实验学时
  1164. if (string.IsNullOrWhiteSpace(en.TrialhoursStr))
  1165. {
  1166. //默认为0
  1167. newTeachingSetting.Trialhours = 0;
  1168. }
  1169. else
  1170. {
  1171. reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
  1172. if (!reg.IsMatch(en.TrialhoursStr.Trim()))
  1173. {
  1174. errCount++;
  1175. errorMsgStr = "实验学时格式不正确,请检查";
  1176. en.ErrorMessage = errorMsgStr;
  1177. errList.Add(en);
  1178. errorMsg.AppendLine(errorMsgStr);
  1179. continue;
  1180. }
  1181. else
  1182. {
  1183. //实验学时
  1184. newTeachingSetting.Trialhours = Convert.ToInt32(en.TrialhoursStr.Trim());
  1185. }
  1186. }
  1187. //开课教研室
  1188. if (string.IsNullOrWhiteSpace(en.DepartmentName))
  1189. {
  1190. errCount++;
  1191. errorMsgStr = "开课教研室不能为空";
  1192. en.ErrorMessage = errorMsgStr;
  1193. errList.Add(en);
  1194. errorMsg.AppendLine(errorMsgStr);
  1195. continue;
  1196. }
  1197. else
  1198. {
  1199. var department = newDepartmentList.Where(x => x.Name == en.DepartmentName.Trim()).SingleOrDefault();
  1200. if (department == null)
  1201. {
  1202. errCount++;
  1203. errorMsgStr = "开课教研室不存在,请检查";
  1204. en.ErrorMessage = errorMsgStr;
  1205. errList.Add(en);
  1206. errorMsg.AppendLine(errorMsgStr);
  1207. continue;
  1208. }
  1209. else
  1210. {
  1211. //开课教研室ID
  1212. newSpecialtyCourse.DepartmentID = department.DepartmentID;
  1213. }
  1214. }
  1215. //是否专业核心
  1216. if (string.IsNullOrWhiteSpace(en.IsSpecialtycoreStr))
  1217. {
  1218. //是否专业核心(默认为否)
  1219. newSpecialtyCourse.IsSpecialtycore = false;
  1220. }
  1221. else
  1222. {
  1223. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsSpecialtycoreStr.Trim()).SingleOrDefault();
  1224. if (generalPurpose == null)
  1225. {
  1226. errCount++;
  1227. errorMsgStr = "是否专业核心不存在,请检查";
  1228. en.ErrorMessage = errorMsgStr;
  1229. errList.Add(en);
  1230. errorMsg.AppendLine(errorMsgStr);
  1231. continue;
  1232. }
  1233. else
  1234. {
  1235. //是否专业核心
  1236. newSpecialtyCourse.IsSpecialtycore = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  1237. }
  1238. }
  1239. //是否合作开发
  1240. if (string.IsNullOrWhiteSpace(en.IsCooperationStr))
  1241. {
  1242. //是否合作开发(默认为否)
  1243. newSpecialtyCourse.IsCooperation = false;
  1244. }
  1245. else
  1246. {
  1247. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsCooperationStr.Trim()).SingleOrDefault();
  1248. if (generalPurpose == null)
  1249. {
  1250. errCount++;
  1251. errorMsgStr = "是否合作开发不存在,请检查";
  1252. en.ErrorMessage = errorMsgStr;
  1253. errList.Add(en);
  1254. errorMsg.AppendLine(errorMsgStr);
  1255. continue;
  1256. }
  1257. else
  1258. {
  1259. //是否合作开发
  1260. newSpecialtyCourse.IsCooperation = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  1261. }
  1262. }
  1263. //是否必修课
  1264. if (string.IsNullOrWhiteSpace(en.IsRequiredStr))
  1265. {
  1266. //是否必修课(默认为否)
  1267. newSpecialtyCourse.IsRequired = false;
  1268. }
  1269. else
  1270. {
  1271. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsRequiredStr.Trim()).SingleOrDefault();
  1272. if (generalPurpose == null)
  1273. {
  1274. errCount++;
  1275. errorMsgStr = RSL.Get("IsRequired") + "不存在,请检查";
  1276. en.ErrorMessage = errorMsgStr;
  1277. errList.Add(en);
  1278. errorMsg.AppendLine(errorMsgStr);
  1279. continue;
  1280. }
  1281. else
  1282. {
  1283. //是否必修课
  1284. newSpecialtyCourse.IsRequired = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  1285. }
  1286. }
  1287. //是否网上选修
  1288. if (string.IsNullOrWhiteSpace(en.IsElectiveStr))
  1289. {
  1290. //是否网上选修(默认为否)
  1291. newSpecialtyCourse.IsElective = false;
  1292. }
  1293. else
  1294. {
  1295. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsElectiveStr.Trim()).SingleOrDefault();
  1296. if (generalPurpose == null)
  1297. {
  1298. errCount++;
  1299. errorMsgStr = "是否网上选修不存在,请检查";
  1300. en.ErrorMessage = errorMsgStr;
  1301. errList.Add(en);
  1302. errorMsg.AppendLine(errorMsgStr);
  1303. continue;
  1304. }
  1305. else
  1306. {
  1307. //是否网上选修
  1308. newSpecialtyCourse.IsElective = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  1309. }
  1310. }
  1311. //是否网络课程
  1312. if (string.IsNullOrWhiteSpace(en.IsNetworkCourseStr))
  1313. {
  1314. //是否网络课程(默认为否)
  1315. newSpecialtyCourse.IsNetworkCourse = false;
  1316. }
  1317. else
  1318. {
  1319. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsNetworkCourseStr.Trim()).SingleOrDefault();
  1320. if (generalPurpose == null)
  1321. {
  1322. errCount++;
  1323. errorMsgStr = "是否网络课程不存在,请检查";
  1324. en.ErrorMessage = errorMsgStr;
  1325. errList.Add(en);
  1326. errorMsg.AppendLine(errorMsgStr);
  1327. continue;
  1328. }
  1329. else
  1330. {
  1331. //是否网络课程
  1332. newSpecialtyCourse.IsNetworkCourse = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  1333. }
  1334. }
  1335. //是否学位课程
  1336. if (string.IsNullOrWhiteSpace(en.IsMainCourseStr))
  1337. {
  1338. //是否学位课程(默认为否)
  1339. newSpecialtyCourse.IsMainCourse = false;
  1340. }
  1341. else
  1342. {
  1343. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsMainCourseStr.Trim()).SingleOrDefault();
  1344. if (generalPurpose == null)
  1345. {
  1346. errCount++;
  1347. errorMsgStr = "是否学位课程不存在,请检查";
  1348. en.ErrorMessage = errorMsgStr;
  1349. errList.Add(en);
  1350. errorMsg.AppendLine(errorMsgStr);
  1351. continue;
  1352. }
  1353. else
  1354. {
  1355. //是否学位课程
  1356. newSpecialtyCourse.IsMainCourse = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  1357. }
  1358. }
  1359. //是否需要教材
  1360. if (string.IsNullOrWhiteSpace(en.IsNeedMaterialStr))
  1361. {
  1362. //是否需要教材(默认为是)
  1363. newSpecialtyCourse.IsNeedMaterial = true;
  1364. }
  1365. else
  1366. {
  1367. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsNeedMaterialStr.Trim()).SingleOrDefault();
  1368. if (generalPurpose == null)
  1369. {
  1370. errCount++;
  1371. errorMsgStr = "是否需要教材不存在,请检查";
  1372. en.ErrorMessage = errorMsgStr;
  1373. errList.Add(en);
  1374. errorMsg.AppendLine(errorMsgStr);
  1375. continue;
  1376. }
  1377. else
  1378. {
  1379. //是否需要教材
  1380. newSpecialtyCourse.IsNeedMaterial = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  1381. }
  1382. }
  1383. //精品课程
  1384. if (string.IsNullOrWhiteSpace(en.CourseFineStr))
  1385. {
  1386. newSpecialtyCourse.CourseFineID = (int)CF_CourseFine.No;
  1387. }
  1388. else
  1389. {
  1390. var courseFine = courseFineList.Where(x => x.Name == en.CourseFineStr.Trim()).SingleOrDefault();
  1391. if (courseFine == null)
  1392. {
  1393. errCount++;
  1394. errorMsgStr = "精品课程不存在,请检查";
  1395. en.ErrorMessage = errorMsgStr;
  1396. errList.Add(en);
  1397. errorMsg.AppendLine(errorMsgStr);
  1398. continue;
  1399. }
  1400. else
  1401. {
  1402. //精品课程
  1403. newSpecialtyCourse.CourseFineID = courseFine.Value;
  1404. }
  1405. }
  1406. //实践类型
  1407. if (string.IsNullOrWhiteSpace(en.PracticeTypeStr))
  1408. {
  1409. //不考虑
  1410. }
  1411. else
  1412. {
  1413. var practiceType = practiceTypeList.Where(x => x.Name == en.PracticeTypeStr.Trim()).SingleOrDefault();
  1414. if (practiceType == null)
  1415. {
  1416. errCount++;
  1417. errorMsgStr = "实践类型不存在,请检查";
  1418. en.ErrorMessage = errorMsgStr;
  1419. errList.Add(en);
  1420. errorMsg.AppendLine(errorMsgStr);
  1421. continue;
  1422. }
  1423. else
  1424. {
  1425. //实践类型
  1426. newSpecialtyCourse.PracticeTypeID = practiceType.Value;
  1427. }
  1428. }
  1429. //授课语言
  1430. if (string.IsNullOrWhiteSpace(en.TeachinglanguageStr))
  1431. {
  1432. newSpecialtyCourse.TeachinglanguageID = (int)CF_Teachinglanguage.Chinese;
  1433. }
  1434. else
  1435. {
  1436. var teachinglanguage = teachinglanguageList.Where(x => x.Name == en.TeachinglanguageStr.Trim()).SingleOrDefault();
  1437. if (teachinglanguage == null)
  1438. {
  1439. errCount++;
  1440. errorMsgStr = "授课语言不存在,请检查";
  1441. en.ErrorMessage = errorMsgStr;
  1442. errList.Add(en);
  1443. errorMsg.AppendLine(errorMsgStr);
  1444. continue;
  1445. }
  1446. else
  1447. {
  1448. //授课语言
  1449. newSpecialtyCourse.TeachinglanguageID = teachinglanguage.Value;
  1450. }
  1451. }
  1452. //考试方式
  1453. if (string.IsNullOrWhiteSpace(en.ExaminationModeStr))
  1454. {
  1455. newSpecialtyCourse.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam;
  1456. }
  1457. else
  1458. {
  1459. var examinationMode = examinationModeList.Where(x => x.Name == en.ExaminationModeStr.Trim()).SingleOrDefault();
  1460. if (examinationMode == null)
  1461. {
  1462. errCount++;
  1463. errorMsgStr = "考试方式不存在,请检查";
  1464. en.ErrorMessage = errorMsgStr;
  1465. errList.Add(en);
  1466. errorMsg.AppendLine(errorMsgStr);
  1467. continue;
  1468. }
  1469. else
  1470. {
  1471. //考试方式
  1472. newSpecialtyCourse.ExaminationModeID = examinationMode.Value;
  1473. }
  1474. }
  1475. //成绩类型
  1476. if (string.IsNullOrWhiteSpace(en.ResultTypeStr))
  1477. {
  1478. //默认为百分制
  1479. newSpecialtyCourse.ResultTypeID = (int)CF_ResultType.Percentage;
  1480. }
  1481. else
  1482. {
  1483. var resultType = resultTypeList.Where(x => x.Name == en.ResultTypeStr.Trim()).SingleOrDefault();
  1484. if (resultType == null)
  1485. {
  1486. errCount++;
  1487. errorMsgStr = "成绩类型不存在,请检查";
  1488. en.ErrorMessage = errorMsgStr;
  1489. errList.Add(en);
  1490. errorMsg.AppendLine(errorMsgStr);
  1491. continue;
  1492. }
  1493. else
  1494. {
  1495. //成绩类型
  1496. newSpecialtyCourse.ResultTypeID = resultType.Value;
  1497. }
  1498. }
  1499. //处理方式
  1500. if (string.IsNullOrWhiteSpace(en.HandleModeStr))
  1501. {
  1502. //默认为必修课
  1503. newSpecialtyCourse.HandleModeID = (int)CF_HandleMode.RequiredCourse;
  1504. }
  1505. else
  1506. {
  1507. var handleMode = handleModeList.Where(x => x.Name == en.HandleModeStr.Trim()).SingleOrDefault();
  1508. if (handleMode == null)
  1509. {
  1510. errCount++;
  1511. errorMsgStr = "处理方式不存在,请检查";
  1512. en.ErrorMessage = errorMsgStr;
  1513. errList.Add(en);
  1514. errorMsg.AppendLine(errorMsgStr);
  1515. continue;
  1516. }
  1517. else
  1518. {
  1519. //处理方式
  1520. newSpecialtyCourse.HandleModeID = handleMode.Value;
  1521. }
  1522. }
  1523. //授课方式
  1524. if (string.IsNullOrEmpty(en.TeachingModeIDListStr))
  1525. {
  1526. newModeTypeList.Add((int)CF_TeachingMode.Theory);
  1527. }
  1528. else
  1529. {
  1530. //授课方式可为多个(可用顿号隔开)
  1531. List<string> list = en.TeachingModeIDListStr.Split('、').Where(x => !string.IsNullOrEmpty(x))
  1532. .Select(x => x.Trim()).Distinct().ToList();
  1533. foreach (var item in list)
  1534. {
  1535. var teachingMode = teachingModeList.Where(x => x.Name == item.Trim()).SingleOrDefault();
  1536. if (teachingMode == null)
  1537. {
  1538. errCount++;
  1539. errorMsgStr = "授课方式(" + item.Trim() + ")不存在,请检查(存在多个授课方式时,可用顿号隔开)";
  1540. en.ErrorMessage = errorMsgStr;
  1541. errList.Add(en);
  1542. errorMsg.AppendLine(errorMsgStr);
  1543. isListPass = false;
  1544. break;
  1545. }
  1546. }
  1547. if (isListPass)
  1548. {
  1549. newModeTypeList = teachingModeList.Where(x => list.Contains(x.Name))
  1550. .Select(x => x.Value.Value).ToList();
  1551. }
  1552. else
  1553. {
  1554. isListPass = true;
  1555. continue;
  1556. }
  1557. }
  1558. //授课地点
  1559. if (string.IsNullOrEmpty(en.TeachingPlaceIDListStr))
  1560. {
  1561. newPlaceList.Add((int)EMIS.ViewModel.EM_TeachingPlace.Multimedia);
  1562. }
  1563. else
  1564. {
  1565. //授课地点可为多个(可用顿号隔开)
  1566. List<string> list = en.TeachingPlaceIDListStr.Split('、').Where(x => !string.IsNullOrEmpty(x))
  1567. .Select(x => x.Trim()).Distinct().ToList();
  1568. foreach (var item in list)
  1569. {
  1570. var teachingPlace = teachingPlaceList.Where(x => x.Name == item.Trim()).SingleOrDefault();
  1571. if (teachingPlace == null)
  1572. {
  1573. errCount++;
  1574. errorMsgStr = "授课地点(" + item.Trim() + ")不存在,请检查(存在多个授课地点时,可用顿号隔开)";
  1575. en.ErrorMessage = errorMsgStr;
  1576. errList.Add(en);
  1577. errorMsg.AppendLine(errorMsgStr);
  1578. isListPass = false;
  1579. break;
  1580. }
  1581. }
  1582. if (isListPass)
  1583. {
  1584. newPlaceList = teachingPlaceList.Where(x => list.Contains(x.Name))
  1585. .Select(x => x.Value.Value).ToList();
  1586. }
  1587. else
  1588. {
  1589. isListPass = true;
  1590. continue;
  1591. }
  1592. }
  1593. //是否启用(默认为是)
  1594. newSpecialtyCourse.IsEnable = true;
  1595. //备注
  1596. if (string.IsNullOrWhiteSpace(en.Remark))
  1597. {
  1598. //不考虑
  1599. }
  1600. else
  1601. {
  1602. newSpecialtyCourse.Remark = en.Remark;
  1603. }
  1604. ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
  1605. //for (int j = i + 1; j < enlist.Count; j++)
  1606. //{
  1607. // SpecialtyCourseView enA = enlist[j];
  1608. // //根据Excel表中的业务主键进行去重(专业信息ID、开课学期、课程信息ID唯一)
  1609. // if (en.No == enA.No && en.Name == enA.Name)
  1610. // {
  1611. // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
  1612. // }
  1613. //}
  1614. //数据表重复性验证(专业信息ID、开课学期、课程信息ID唯一)
  1615. var specialtyCourseVerify = newSpecialtyCourseList.Where(x => x.SpecialtyID == newSpecialtyCourse.SpecialtyID
  1616. && x.StarttermID == newSpecialtyCourse.StarttermID
  1617. && x.CoursematerialID == newSpecialtyCourse.CoursematerialID).SingleOrDefault();
  1618. if (specialtyCourseVerify == null)
  1619. {
  1620. //新增
  1621. if (!newSpecialtyCourseInList.Any(x => x.SpecialtyID == newSpecialtyCourse.SpecialtyID
  1622. && x.StarttermID == newSpecialtyCourse.StarttermID
  1623. && x.CoursematerialID == newSpecialtyCourse.CoursematerialID))
  1624. {
  1625. newSpecialtyCourse.SpecialtyCourseID = Guid.NewGuid();
  1626. SetNewStatus(newSpecialtyCourse);
  1627. newSpecialtyCourseInList.Add(newSpecialtyCourse);
  1628. newTeachingSetting.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
  1629. newTeachingSetting.TheoryWeeklyNum = 0;
  1630. newTeachingSetting.PracticeWeeklyNum = 0;
  1631. newTeachingSetting.TrialWeeklyNum = 0;
  1632. newTeachingSetting.WeeklyHours = 0;
  1633. newTeachingSetting.WeeklyNum = 0;
  1634. newTeachingSetting.StartWeeklyNum = 1;
  1635. newTeachingSetting.EndWeeklyNum = 18;
  1636. newTeachingSettingInList.Add(newTeachingSetting);
  1637. if (newModeTypeList != null && newModeTypeList.Count() > 0)
  1638. {
  1639. foreach (var newModeTypeID in newModeTypeList)
  1640. {
  1641. var newTeachingModeType = new EM_TeachingModeType();
  1642. newTeachingModeType.TeachingModeTypeID = Guid.NewGuid();
  1643. newTeachingModeType.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
  1644. newTeachingModeType.TeachingModeID = newModeTypeID;
  1645. this.SetNewStatus(newTeachingModeType);
  1646. newTeachingModeTypeInList.Add(newTeachingModeType);
  1647. }
  1648. }
  1649. if (newPlaceList != null && newPlaceList.Count() > 0)
  1650. {
  1651. foreach (var newPlaceID in newPlaceList)
  1652. {
  1653. var newTeachingPlace = new EMIS.Entities.EM_TeachingPlace();
  1654. newTeachingPlace.TeachingPlaceID = Guid.NewGuid();
  1655. newTeachingPlace.SpecialtyCourseID = newSpecialtyCourse.SpecialtyCourseID;
  1656. newTeachingPlace.TeachingPlace = newPlaceID;
  1657. this.SetNewStatus(newTeachingPlace);
  1658. newTeachingPlaceInList.Add(newTeachingPlace);
  1659. }
  1660. }
  1661. inCount++;
  1662. }
  1663. else
  1664. {
  1665. //Excel表重复性验证
  1666. //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中,目前暂不考虑)
  1667. inCount++;
  1668. }
  1669. }
  1670. else
  1671. {
  1672. //更新(Excel有重复时,以最后一条记录的更新为准)
  1673. specialtyCourseVerify.CourseStructureID = newSpecialtyCourse.CourseStructureID;
  1674. specialtyCourseVerify.CourseCategoryID = newSpecialtyCourse.CourseCategoryID;
  1675. specialtyCourseVerify.CourseTypeID = newSpecialtyCourse.CourseTypeID;
  1676. specialtyCourseVerify.CourseQualityID = newSpecialtyCourse.CourseQualityID;
  1677. specialtyCourseVerify.DepartmentID = newSpecialtyCourse.DepartmentID;
  1678. specialtyCourseVerify.IsSpecialtycore = newSpecialtyCourse.IsSpecialtycore;
  1679. specialtyCourseVerify.IsCooperation = newSpecialtyCourse.IsCooperation;
  1680. specialtyCourseVerify.IsRequired = newSpecialtyCourse.IsRequired;
  1681. specialtyCourseVerify.IsElective = newSpecialtyCourse.IsElective;
  1682. specialtyCourseVerify.IsNetworkCourse = newSpecialtyCourse.IsNetworkCourse;
  1683. specialtyCourseVerify.IsMainCourse = newSpecialtyCourse.IsMainCourse;
  1684. specialtyCourseVerify.IsNeedMaterial = newSpecialtyCourse.IsNeedMaterial;
  1685. specialtyCourseVerify.CourseFineID = newSpecialtyCourse.CourseFineID;
  1686. specialtyCourseVerify.PracticeTypeID = newSpecialtyCourse.PracticeTypeID;
  1687. specialtyCourseVerify.TeachinglanguageID = newSpecialtyCourse.TeachinglanguageID;
  1688. specialtyCourseVerify.ExaminationModeID = newSpecialtyCourse.ExaminationModeID;
  1689. specialtyCourseVerify.ResultTypeID = newSpecialtyCourse.ResultTypeID;
  1690. specialtyCourseVerify.HandleModeID = newSpecialtyCourse.HandleModeID;
  1691. //specialtyCourseVerify.IsEnable = newSpecialtyCourse.IsEnable;
  1692. specialtyCourseVerify.Remark = newSpecialtyCourse.Remark;
  1693. SetModifyStatus(specialtyCourseVerify);
  1694. newSpecialtyCourseUpList.Add(specialtyCourseVerify);
  1695. if (specialtyCourseVerify.EM_SpecialtyCourseTeachingSetting == null)
  1696. {
  1697. if (newTeachingSettingInList.Any(x => x.SpecialtyCourseID == specialtyCourseVerify.SpecialtyCourseID))
  1698. {
  1699. newTeachingSettingInList.RemoveAll(x => x.SpecialtyCourseID == specialtyCourseVerify.SpecialtyCourseID);
  1700. }
  1701. newTeachingSetting.SpecialtyCourseID = specialtyCourseVerify.SpecialtyCourseID;
  1702. newTeachingSetting.TheoryWeeklyNum = 0;
  1703. newTeachingSetting.PracticeWeeklyNum = 0;
  1704. newTeachingSetting.TrialWeeklyNum = 0;
  1705. newTeachingSetting.WeeklyHours = 0;
  1706. newTeachingSetting.WeeklyNum = 0;
  1707. newTeachingSetting.StartWeeklyNum = 1;
  1708. newTeachingSetting.EndWeeklyNum = 16;
  1709. newTeachingSettingInList.Add(newTeachingSetting);
  1710. }
  1711. else
  1712. {
  1713. specialtyCourseVerify.EM_SpecialtyCourseTeachingSetting.Credit = newTeachingSetting.Credit;
  1714. specialtyCourseVerify.EM_SpecialtyCourseTeachingSetting.TheoryCourse = newTeachingSetting.TheoryCourse;
  1715. specialtyCourseVerify.EM_SpecialtyCourseTeachingSetting.Practicehours = newTeachingSetting.Practicehours;
  1716. specialtyCourseVerify.EM_SpecialtyCourseTeachingSetting.Trialhours = newTeachingSetting.Trialhours;
  1717. newTeachingSettingUpList.Add(specialtyCourseVerify.EM_SpecialtyCourseTeachingSetting);
  1718. }
  1719. if (newModeTypeList != null && newModeTypeList.Count() > 0)
  1720. {
  1721. if (newTeachingModeTypeInList.Any(x => x.SpecialtyCourseID == specialtyCourseVerify.SpecialtyCourseID))
  1722. {
  1723. newTeachingModeTypeInList.RemoveAll(x => x.SpecialtyCourseID == specialtyCourseVerify.SpecialtyCourseID);
  1724. }
  1725. specialtyCourseTMDelList.Add(specialtyCourseVerify.SpecialtyCourseID);
  1726. foreach (var newModeTypeID in newModeTypeList)
  1727. {
  1728. var newTeachingModeType = new EM_TeachingModeType();
  1729. newTeachingModeType.TeachingModeTypeID = Guid.NewGuid();
  1730. newTeachingModeType.SpecialtyCourseID = specialtyCourseVerify.SpecialtyCourseID;
  1731. newTeachingModeType.TeachingModeID = newModeTypeID;
  1732. this.SetNewStatus(newTeachingModeType);
  1733. newTeachingModeTypeInList.Add(newTeachingModeType);
  1734. }
  1735. }
  1736. else
  1737. {
  1738. specialtyCourseTMDelList.Add(specialtyCourseVerify.SpecialtyCourseID);
  1739. }
  1740. if (newPlaceList != null && newPlaceList.Count() > 0)
  1741. {
  1742. if (newTeachingPlaceInList.Any(x => x.SpecialtyCourseID == specialtyCourseVerify.SpecialtyCourseID))
  1743. {
  1744. newTeachingPlaceInList.RemoveAll(x => x.SpecialtyCourseID == specialtyCourseVerify.SpecialtyCourseID);
  1745. }
  1746. specialtyCourseTPDelList.Add(specialtyCourseVerify.SpecialtyCourseID);
  1747. foreach (var newPlace in newPlaceList)
  1748. {
  1749. var newTeachingPlace = new EMIS.Entities.EM_TeachingPlace();
  1750. newTeachingPlace.TeachingPlaceID = Guid.NewGuid();
  1751. newTeachingPlace.SpecialtyCourseID = specialtyCourseVerify.SpecialtyCourseID;
  1752. newTeachingPlace.TeachingPlace = newPlace;
  1753. this.SetNewStatus(newTeachingPlace);
  1754. newTeachingPlaceInList.Add(newTeachingPlace);
  1755. }
  1756. }
  1757. else
  1758. {
  1759. specialtyCourseTPDelList.Add(specialtyCourseVerify.SpecialtyCourseID);
  1760. }
  1761. upCount++;
  1762. }
  1763. }
  1764. using (TransactionScope ts = new TransactionScope())
  1765. {
  1766. //删除
  1767. UnitOfWork.Delete<EMIS.Entities.EM_TeachingPlace>(x => specialtyCourseTPDelList.Contains(x.SpecialtyCourseID));
  1768. UnitOfWork.Delete<EM_TeachingModeType>(x => specialtyCourseTMDelList.Contains(x.SpecialtyCourseID));
  1769. //批量插入
  1770. UnitOfWork.BulkInsert(newSpecialtyCourseInList);
  1771. UnitOfWork.BulkInsert(newTeachingSettingInList);
  1772. UnitOfWork.BulkInsert(newTeachingModeTypeInList);
  1773. UnitOfWork.BulkInsert(newTeachingPlaceInList);
  1774. //批量统一提交更新
  1775. if (newSpecialtyCourseUpList != null && newSpecialtyCourseUpList.Count() > 0)
  1776. {
  1777. UnitOfWork.BatchUpdate(newSpecialtyCourseUpList);
  1778. }
  1779. //批量统一提交更新
  1780. if (newTeachingSettingUpList != null && newTeachingSettingUpList.Count() > 0)
  1781. {
  1782. UnitOfWork.BatchUpdate(newTeachingSettingUpList);
  1783. }
  1784. ts.Complete();
  1785. }
  1786. errdataList = errList.Distinct().ToList(); //错误列表List
  1787. }
  1788. catch (Exception)
  1789. {
  1790. throw;
  1791. }
  1792. }
  1793. }
  1794. }