MinorSpecialtyCourseServices.cs 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common.Linq.Entity;
  6. using EMIS.ViewModel.MinorManage.MinorCourseManage;
  7. using EMIS.ViewModel;
  8. using System.Linq.Expressions;
  9. using EMIS.Entities;
  10. using Bowin.Common.Linq;
  11. using EMIS.DataLogic.MinorManage.MinorCourseManage;
  12. using Bowin.Common.Utility;
  13. using EMIS.ViewModel.CacheManage;
  14. using EMIS.DataLogic.Common.Cultureplan;
  15. using EMIS.DataLogic.Repositories;
  16. using System.Text.RegularExpressions;
  17. using EMIS.DataLogic.MinorManage.MinorPlanManage;
  18. namespace EMIS.CommonLogic.MinorManage
  19. {
  20. public class MinorSpecialtyCourseServices : BaseServices, IMinorSpecialtyCourseServices
  21. {
  22. public MinorSpecialtyCourseDAL minorSpecialtyCourseDAL { get; set; }
  23. public Lazy<CoursematerialDAL> CoursematerialDAL { get; set; }
  24. public MinorPlanApplyDAL MinorPlanApplyDAL { get; set; }
  25. public Lazy<DepartmentRepository> DepartmentRepository { get; set; }
  26. /// <summary>
  27. /// 查询所有辅修专业课程
  28. /// </summary>
  29. /// <param name="configuretView">查询条件实体</param>
  30. /// <param name="standardID">专业名称</param>
  31. /// <param name="CoursematerialID">课程名称</param>
  32. /// <param name="SchoolyearNumID">开课学年</param>
  33. /// <param name="StarttermID">开课学期</param>
  34. /// <param name="DepartmentID">教研室</param>
  35. /// <param name="IsEnable">是否启用</param>
  36. /// <param name="pageIndex">页码</param>
  37. /// <param name="pageSize">显示条数</param>
  38. /// <returns></returns>
  39. public IGridResultSet<MinorSpecialtyCourseView> GetMinorSpecialtyCourseViewGrid(ConfiguretView configuretView, int? standardID, Guid? CoursematerialID, int? SchoolyearNumID, int? SchoolcodeID, Guid? DepartmentID, int? IsEnable, int pageIndex, int pageSize)
  40. {
  41. Expression<Func<EM_MinorCourse, bool>> exp = (x => true);
  42. if (standardID.HasValue)
  43. exp = exp.And(x =>x.StandardID==standardID);
  44. if (CoursematerialID.HasValue)
  45. exp = exp.And(x => x.CoursematerialID == CoursematerialID);
  46. if (SchoolyearNumID.HasValue)
  47. exp = exp.And(x => x.SchoolyearNumID == SchoolyearNumID);
  48. if (SchoolcodeID.HasValue)
  49. exp = exp.And(x => x.SchoolcodeID == SchoolcodeID);
  50. if (DepartmentID.HasValue)
  51. exp = exp.And(x => x.DepartmentID == DepartmentID);
  52. if (IsEnable.HasValue)
  53. {
  54. bool Enable = true;
  55. if(IsEnable==0)
  56. {
  57. Enable = false;
  58. }
  59. exp = exp.And(x => x.IsEnable == Enable);
  60. }
  61. var query = minorSpecialtyCourseDAL.GetMinorSpecialtyCourseViewQueryable(exp);
  62. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  63. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  64. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).OrderBy(x=>x.SchoolyearNumID)
  65. .OrderBy(x => x.SchoolcodeID).ToGridResultSet<MinorSpecialtyCourseView>(pageIndex, pageSize);
  66. }
  67. /// <summary>
  68. /// 查询所有辅修专业课程
  69. /// </summary>
  70. /// <param name="configuretView">查询条件实体</param>
  71. /// <param name="standardID">专业名称</param>
  72. /// <param name="CoursematerialID">课程名称</param>
  73. /// <param name="SchoolyearNumID">开课学年</param>
  74. /// <param name="StarttermID">开课学期</param>
  75. /// <param name="DepartmentID">教研室</param>
  76. /// <param name="IsEnable">是否启用</param>
  77. /// <param name="MinorCourseIDList">辅修课程ID</param>
  78. /// <returns></returns>
  79. public List<MinorSpecialtyCourseView> GetMinorCourseViewList(ConfiguretView configuretView, int? standardID, Guid? CoursematerialID, int? SchoolyearNumID, int? SchoolcodeID, Guid? DepartmentID, int? IsEnable, List<Guid?> MinorCourseIDList)
  80. {
  81. Expression<Func<EM_MinorCourse, bool>> exp = (x => true);
  82. if (MinorCourseIDList != null)
  83. exp = exp.And(x => MinorCourseIDList.Contains(x.MinorCourseID));
  84. if (standardID.HasValue)
  85. exp = exp.And(x => x.StandardID == standardID);
  86. if (CoursematerialID.HasValue)
  87. exp = exp.And(x => x.CoursematerialID == CoursematerialID);
  88. if (SchoolyearNumID.HasValue)
  89. exp = exp.And(x => x.SchoolyearNumID == SchoolyearNumID);
  90. if (SchoolcodeID.HasValue)
  91. exp = exp.And(x => x.SchoolcodeID == SchoolcodeID);
  92. if (DepartmentID.HasValue)
  93. exp = exp.And(x => x.DepartmentID == DepartmentID);
  94. if (IsEnable.HasValue)
  95. {
  96. bool Enable = true;
  97. if (IsEnable == 0)
  98. {
  99. Enable = false;
  100. }
  101. exp = exp.And(x => x.IsEnable == Enable);
  102. }
  103. var query = minorSpecialtyCourseDAL.GetMinorSpecialtyCourseViewQueryable(exp);
  104. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  105. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  106. return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).OrderBy(x => x.SchoolyearNumID)
  107. .OrderBy(x => x.SchoolcodeID).ToList();
  108. }
  109. /// <summary>
  110. /// 查询辅修课程信息
  111. /// </summary>
  112. /// <param name="MinorCourseID">辅修课程ID</param>
  113. /// <returns></returns>
  114. public MinorSpecialtyCourseView GetMinorSpecialtyCourseView(Guid? MinorCourseID)
  115. {
  116. Expression<Func<EM_MinorCourse, bool>> exp = (x =>x.MinorCourseID==MinorCourseID);
  117. var MinorSpecialtyCourse = minorSpecialtyCourseDAL.GetMinorSpecialtyCourseViewQueryable(exp).FirstOrDefault();
  118. return MinorSpecialtyCourse;
  119. }
  120. /// <summary>
  121. /// 根据专业课程获取授课方式
  122. /// </summary>
  123. /// <param name="MinorCourseID">辅修课程</param>
  124. /// <returns></returns>
  125. public List<string> GetTeachingModeType(Guid? MinorCourseID)
  126. {
  127. return minorSpecialtyCourseDAL.GetTeachingModeTypeQueryble(MinorCourseID);
  128. }
  129. /// <summary>
  130. /// 获取课程资料信息
  131. /// </summary>
  132. /// <param name="MinorCourseID">辅修课程</param>
  133. /// <returns></returns>
  134. public Entities.EM_MinorCourse GetMinorSpecialtyCourse(Guid? MinorCourseID)
  135. {
  136. //查询条件
  137. System.Linq.Expressions.Expression<Func<EM_MinorCourse, bool>> expression = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  138. expression = (x => x.MinorCourseID == MinorCourseID);
  139. return minorSpecialtyCourseDAL.MinorCourseRepository.GetSingle(expression, (x => x.CF_Department),(x => x.EM_Coursematerial), (x => x.EM_MinorCourseTeachingSetting));
  140. }
  141. /// <summary>
  142. /// 专业课程教学设置表
  143. /// </summary>
  144. /// <param name="MinorCourseID">辅修课程ID</param>
  145. /// <returns></returns>
  146. public EM_MinorCourseTeachingSetting GetSpecialtyCourseTeachingSetting(Guid? MinorCourseID)
  147. {
  148. //查询条件
  149. System.Linq.Expressions.Expression<Func<EM_MinorCourseTeachingSetting, bool>> expression = (x => true);
  150. expression = (x => x.MinorCourseID == MinorCourseID);
  151. return minorSpecialtyCourseDAL.MinorCourseTeachingSettingRepository.GetSingle(expression);
  152. }
  153. /// <summary>
  154. /// 根据专业课程获取授课地点
  155. /// </summary>
  156. /// <param name="MinorCourseID">辅修课程ID</param>
  157. /// <returns></returns>
  158. public List<string> GetTeachingPlace(Guid? MinorCourseID)
  159. {
  160. return minorSpecialtyCourseDAL.GetTeachingPlaceQueryble(MinorCourseID);
  161. }
  162. public void MinorSpecialtyCourseAdd(MinorSpecialtyCourseView minorSpecialtyCourseView)
  163. {
  164. try
  165. {
  166. if (minorSpecialtyCourseDAL.MinorCourseRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  167. && x.StandardID == minorSpecialtyCourseView.StandardID && x.CoursematerialID == minorSpecialtyCourseView.CoursematerialID
  168. && x.SchoolyearNumID == minorSpecialtyCourseView.SchoolyearNumID && x.SchoolcodeID == minorSpecialtyCourseView.SchoolcodeID
  169. &&x.MinorCourseID!=minorSpecialtyCourseView.MinorCourseID).Count() > 0)
  170. {
  171. throw new Exception("该标准专业课程已经存在,请重新输入!");
  172. }
  173. EM_MinorCourse MinorCourse = null;
  174. EM_MinorCourseTeachingSetting MinorCourseTeachingSetting = null;
  175. if (minorSpecialtyCourseView.MinorCourseID == null || minorSpecialtyCourseView.MinorCourseID == Guid.Empty)
  176. {
  177. MinorCourse = new EM_MinorCourse();
  178. MinorCourse.MinorCourseID = Guid.NewGuid();
  179. MinorCourse.StandardID = minorSpecialtyCourseView.StandardID;
  180. MinorCourse.DepartmentID = minorSpecialtyCourseView.DepartmentID;
  181. MinorCourse.CoursematerialID = minorSpecialtyCourseView.CoursematerialID;
  182. MinorCourse.CourseStructureID = minorSpecialtyCourseView.CourseStructureID;
  183. MinorCourse.CourseCategoryID = minorSpecialtyCourseView.CourseCategoryID;
  184. MinorCourse.CourseTypeID = minorSpecialtyCourseView.CourseTypeID;
  185. MinorCourse.CourseQualityID = minorSpecialtyCourseView.CourseQualityID;
  186. MinorCourse.PracticeTypeID = minorSpecialtyCourseView.PracticeTypeID;
  187. MinorCourse.ExaminationModeID = minorSpecialtyCourseView.ExaminationModeID;
  188. MinorCourse.TeachinglanguageID = minorSpecialtyCourseView.TeachinglanguageID;
  189. MinorCourse.SchoolyearNumID = minorSpecialtyCourseView.SchoolyearNumID;
  190. MinorCourse.SchoolcodeID = minorSpecialtyCourseView.SchoolcodeID;
  191. MinorCourse.CourseFineID = minorSpecialtyCourseView.CourseFineID;
  192. MinorCourse.IsSpecialtycore = minorSpecialtyCourseView.IsSpecialtycore;
  193. MinorCourse.IsCooperation = minorSpecialtyCourseView.IsCooperation;
  194. MinorCourse.IsRequired = minorSpecialtyCourseView.IsRequired;
  195. MinorCourse.IsElective = minorSpecialtyCourseView.IsElective;
  196. MinorCourse.IsNetworkCourse = minorSpecialtyCourseView.IsNetworkCourse;
  197. MinorCourse.IsMainCourse = minorSpecialtyCourseView.IsMainCourse;
  198. MinorCourse.IsEnable = minorSpecialtyCourseView.IsEnable;
  199. MinorCourse.ResultTypeID = minorSpecialtyCourseView.ResultTypeID;
  200. MinorCourse.Remarks = minorSpecialtyCourseView.Remarks;
  201. SetNewStatus(MinorCourse);
  202. UnitOfWork.Add(MinorCourse);
  203. MinorCourseTeachingSetting = new EM_MinorCourseTeachingSetting();
  204. MinorCourseTeachingSetting.MinorCourseID = MinorCourse.MinorCourseID;
  205. MinorCourseTeachingSetting.Credit = minorSpecialtyCourseView.Credit;
  206. MinorCourseTeachingSetting.TheoryCourse = minorSpecialtyCourseView.TheoryCourse;
  207. MinorCourseTeachingSetting.Practicehours = minorSpecialtyCourseView.Practicehours;
  208. MinorCourseTeachingSetting.Trialhours = minorSpecialtyCourseView.Trialhours;
  209. MinorCourseTeachingSetting.WeeklyNum = minorSpecialtyCourseView.WeeklyNum;
  210. MinorCourseTeachingSetting.TheoryWeeklyNum = minorSpecialtyCourseView.TheoryWeeklyNum;
  211. MinorCourseTeachingSetting.PracticeWeeklyNum = minorSpecialtyCourseView.PracticeWeeklyNum;
  212. MinorCourseTeachingSetting.TrialWeeklyNum = minorSpecialtyCourseView.TrialWeeklyNum;
  213. MinorCourseTeachingSetting.StartWeeklyNum = minorSpecialtyCourseView.StartWeeklyNum;
  214. MinorCourseTeachingSetting.EndWeeklyNum = minorSpecialtyCourseView.EndWeeklyNum;
  215. MinorCourseTeachingSetting.WeeklyHours = minorSpecialtyCourseView.WeeklyHours;
  216. UnitOfWork.Add(MinorCourseTeachingSetting);
  217. if (minorSpecialtyCourseView.TeachingModeID != null)
  218. {
  219. UnitOfWork.Delete<EM_MinorCourseTeachingModeType>(x => x.MinorCourseID == MinorCourse.MinorCourseID);
  220. foreach (var i in minorSpecialtyCourseView.TeachingModeID)
  221. {
  222. EM_MinorCourseTeachingModeType MinorCourseTeachingModeType = new EM_MinorCourseTeachingModeType();
  223. MinorCourseTeachingModeType.MinorCourseTeachingModeTypeID = Guid.NewGuid();
  224. MinorCourseTeachingModeType.MinorCourseID = MinorCourse.MinorCourseID;
  225. MinorCourseTeachingModeType.TeachingModeID = i;
  226. SetNewStatus(MinorCourseTeachingModeType);
  227. UnitOfWork.Add(MinorCourseTeachingModeType);
  228. }
  229. }
  230. if (minorSpecialtyCourseView.TeachingPlaceID != null)
  231. {
  232. UnitOfWork.Delete<EMIS.Entities.EM_MinorCourseTeachingPlace>(x => x.MinorCourseID == MinorCourse.MinorCourseID);
  233. foreach (var i in minorSpecialtyCourseView.TeachingPlaceID)
  234. {
  235. EMIS.Entities.EM_MinorCourseTeachingPlace MinorCourseTeachingPlace = new EMIS.Entities.EM_MinorCourseTeachingPlace();
  236. MinorCourseTeachingPlace.MinorCourseTeachingPlaceID = Guid.NewGuid();
  237. MinorCourseTeachingPlace.MinorCourseID = MinorCourse.MinorCourseID;
  238. MinorCourseTeachingPlace.TeachingPlace = i;
  239. SetNewStatus(MinorCourseTeachingPlace);
  240. UnitOfWork.Add(MinorCourseTeachingPlace);
  241. }
  242. }
  243. }
  244. else
  245. {
  246. MinorCourse = GetMinorSpecialtyCourse(minorSpecialtyCourseView.MinorCourseID);
  247. MinorCourseTeachingSetting = GetSpecialtyCourseTeachingSetting(minorSpecialtyCourseView.MinorCourseID);
  248. MinorCourse.StandardID = minorSpecialtyCourseView.StandardID;
  249. MinorCourse.DepartmentID = minorSpecialtyCourseView.DepartmentID;
  250. MinorCourse.CoursematerialID = minorSpecialtyCourseView.CoursematerialID;
  251. MinorCourse.CourseStructureID = minorSpecialtyCourseView.CourseStructureID;
  252. MinorCourse.CourseCategoryID = minorSpecialtyCourseView.CourseCategoryID;
  253. MinorCourse.CourseTypeID = minorSpecialtyCourseView.CourseTypeID;
  254. MinorCourse.CourseQualityID = minorSpecialtyCourseView.CourseQualityID;
  255. MinorCourse.PracticeTypeID = minorSpecialtyCourseView.PracticeTypeID;
  256. MinorCourse.ExaminationModeID = minorSpecialtyCourseView.ExaminationModeID;
  257. MinorCourse.TeachinglanguageID = minorSpecialtyCourseView.TeachinglanguageID;
  258. MinorCourse.SchoolyearNumID = minorSpecialtyCourseView.SchoolyearNumID;
  259. MinorCourse.SchoolcodeID = minorSpecialtyCourseView.SchoolcodeID;
  260. MinorCourse.CourseFineID = minorSpecialtyCourseView.CourseFineID;
  261. MinorCourse.IsSpecialtycore = minorSpecialtyCourseView.IsSpecialtycore;
  262. MinorCourse.IsCooperation = minorSpecialtyCourseView.IsCooperation;
  263. MinorCourse.IsRequired = minorSpecialtyCourseView.IsRequired;
  264. MinorCourse.IsElective = minorSpecialtyCourseView.IsElective;
  265. MinorCourse.IsNetworkCourse = minorSpecialtyCourseView.IsNetworkCourse;
  266. MinorCourse.IsMainCourse = minorSpecialtyCourseView.IsMainCourse;
  267. MinorCourse.IsEnable = minorSpecialtyCourseView.IsEnable;
  268. MinorCourse.ResultTypeID = minorSpecialtyCourseView.ResultTypeID;
  269. MinorCourse.Remarks = minorSpecialtyCourseView.Remarks;
  270. SetModifyStatus(MinorCourse);
  271. MinorCourseTeachingSetting.Credit = minorSpecialtyCourseView.Credit;
  272. MinorCourseTeachingSetting.TheoryCourse = minorSpecialtyCourseView.TheoryCourse;
  273. MinorCourseTeachingSetting.Practicehours = minorSpecialtyCourseView.Practicehours;
  274. MinorCourseTeachingSetting.Trialhours = minorSpecialtyCourseView.Trialhours;
  275. MinorCourseTeachingSetting.WeeklyNum = minorSpecialtyCourseView.WeeklyNum;
  276. MinorCourseTeachingSetting.TheoryWeeklyNum = minorSpecialtyCourseView.TheoryWeeklyNum;
  277. MinorCourseTeachingSetting.PracticeWeeklyNum = minorSpecialtyCourseView.PracticeWeeklyNum;
  278. MinorCourseTeachingSetting.TrialWeeklyNum = minorSpecialtyCourseView.TrialWeeklyNum;
  279. MinorCourseTeachingSetting.StartWeeklyNum = minorSpecialtyCourseView.StartWeeklyNum;
  280. MinorCourseTeachingSetting.EndWeeklyNum = minorSpecialtyCourseView.EndWeeklyNum;
  281. MinorCourseTeachingSetting.WeeklyHours = minorSpecialtyCourseView.WeeklyHours;
  282. UnitOfWork.Update(MinorCourseTeachingSetting);
  283. if (minorSpecialtyCourseView.TeachingModeID != null)
  284. {
  285. UnitOfWork.Delete<EM_MinorCourseTeachingModeType>(x => x.MinorCourseID == MinorCourse.MinorCourseID);
  286. foreach (var i in minorSpecialtyCourseView.TeachingModeID)
  287. {
  288. EM_MinorCourseTeachingModeType MinorCourseTeachingModeType = new EM_MinorCourseTeachingModeType();
  289. MinorCourseTeachingModeType.MinorCourseTeachingModeTypeID = Guid.NewGuid();
  290. MinorCourseTeachingModeType.MinorCourseID = MinorCourse.MinorCourseID;
  291. MinorCourseTeachingModeType.TeachingModeID = i;
  292. SetNewStatus(MinorCourseTeachingModeType);
  293. UnitOfWork.Add(MinorCourseTeachingModeType);
  294. }
  295. }
  296. if (minorSpecialtyCourseView.TeachingPlaceID != null)
  297. {
  298. UnitOfWork.Delete<EMIS.Entities.EM_MinorCourseTeachingPlace>(x => x.MinorCourseID == MinorCourse.MinorCourseID);
  299. foreach (var i in minorSpecialtyCourseView.TeachingPlaceID)
  300. {
  301. EMIS.Entities.EM_MinorCourseTeachingPlace MinorCourseTeachingPlace = new EMIS.Entities.EM_MinorCourseTeachingPlace();
  302. MinorCourseTeachingPlace.MinorCourseTeachingPlaceID = Guid.NewGuid();
  303. MinorCourseTeachingPlace.MinorCourseID = MinorCourse.MinorCourseID;
  304. MinorCourseTeachingPlace.TeachingPlace = i;
  305. SetNewStatus(MinorCourseTeachingPlace);
  306. UnitOfWork.Add(MinorCourseTeachingPlace);
  307. }
  308. }
  309. }
  310. UnitOfWork.Commit();
  311. }
  312. catch (Exception)
  313. {
  314. throw;
  315. }
  316. }
  317. /// <summary>
  318. /// 删除
  319. /// </summary>
  320. /// <param name="MinorCourseIDList"></param>
  321. /// <returns></returns>
  322. public bool MinorCourseDelete(List<Guid?> MinorCourseIDList)
  323. {
  324. try
  325. {
  326. var CourseIDList = minorSpecialtyCourseDAL.MinorCourseRepository.GetList(x => MinorCourseIDList.Contains(x.MinorCourseID)).Select(w=>w.CoursematerialID).ToList();
  327. var useCourseList = MinorPlanApplyDAL.MinorPlanApplicationRepository.GetList(x => CourseIDList.Contains(x.CoursematerialID)).FirstOrDefault();
  328. if (useCourseList!=null)
  329. {
  330. throw new Exception("删除失败,已存在关联数据,如不使用该课程,可修改是否启用字段。");
  331. }
  332. if (MinorCourseIDList.Count > 0)
  333. {
  334. UnitOfWork.Delete<EM_MinorCourseTeachingSetting>(x => MinorCourseIDList.Contains(x.MinorCourseID));
  335. UnitOfWork.Delete<EM_MinorCourseTeachingModeType>(x => MinorCourseIDList.Contains(x.MinorCourseID));
  336. UnitOfWork.Delete<EM_MinorCourseTeachingPlace>(x => MinorCourseIDList.Contains(x.MinorCourseID));
  337. UnitOfWork.Delete<EM_MinorCourse>(x => MinorCourseIDList.Contains(x.MinorCourseID));
  338. }
  339. return true;
  340. }
  341. catch (Exception)
  342. {
  343. throw;
  344. }
  345. }
  346. public void MinorSpecialtyCourseImport(Dictionary<string, string> cellheader, out int OkCount, out List<MinorSpecialtyCourseView> errdataList, out int ErrCount, string sourcePhysicalPath)
  347. {
  348. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  349. List<MinorSpecialtyCourseView> errList = new List<MinorSpecialtyCourseView>();
  350. #region 1.1解析文件,存放到一个List集合里
  351. cellheader.Remove("ErrorMessage");//去除异常列、导入操作不需要
  352. // 1.1解析文件,存放到一个List集合里
  353. List<MinorSpecialtyCourseView> enlist =
  354. NpoiExcelHelper.ExcelToEntityList<MinorSpecialtyCourseView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
  355. cellheader.Add("ErrorMessage", "错误信息");//还原字典项
  356. #endregion
  357. #region 读取数据库数据
  358. //专业字典
  359. var StandardList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Standard.ToString()).ToList();
  360. //课程
  361. var CoursematerialList = CoursematerialDAL.Value.CoursematerialRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  362. //教研室
  363. var DepartmentList = DepartmentRepository.Value.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  364. //授课年级字典
  365. var SchoolyearNumList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_SchoolyearNum.ToString()).ToList();
  366. //学期字典
  367. var SchoolcodeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Semester.ToString()).ToList();
  368. //课程类型字典
  369. var CourseTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseType.ToString()).ToList();
  370. //课程属性字典
  371. var CourseCategoryList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseCategory.ToString()).ToList();
  372. //课程性质字典
  373. var CourseQualityList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseQuality.ToString()).ToList();
  374. //课程结构字典
  375. var CourseStructureList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseStructure.ToString()).ToList();
  376. //实践类型字典
  377. var PracticeTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.EM_PracticeType.ToString()).ToList();
  378. //考试方式字典
  379. var ExaminationModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ExaminationMode.ToString()).ToList();
  380. //通用是或否字典
  381. var YesOrNoStatusList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_YesOrNoStatus.ToString()).ToList();
  382. //精品课程字典
  383. var CourseFineList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseFine.ToString()).ToList();
  384. //授课语言字典
  385. var TeachinglanguageList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Teachinglanguage.ToString()).ToList();
  386. //授课方式字典
  387. var TeachingModeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_TeachingMode.ToString()).ToList();
  388. //授课地点字典
  389. var TeachingPlaceList = IdNameExt.GetDictionaryItem(DictionaryItem.EM_TeachingPlace.ToString()).ToList();
  390. //成绩类型字典
  391. var ResultTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ResultType.ToString()).ToList();
  392. //辅修课程List
  393. var MinorCourseList = minorSpecialtyCourseDAL.MinorCourseRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  394. #endregion
  395. #region 1.2 检验数据合格性
  396. if (enlist.Count() <= 0)
  397. {
  398. throw new Exception("请填写Excel模板信息数据。");
  399. }
  400. #region 验证
  401. //Regex reg = new Regex(@"^[0-9]*$");
  402. Regex reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$");
  403. for (int i = 0; i < enlist.Count; i++)
  404. {
  405. MinorSpecialtyCourseView en = enlist[i];
  406. string errorMsgStr = "第" + (i + 2) + "行数据检测异常:";
  407. bool isHaveNoInputValue = false; // 是否含有未输入项
  408. #region 专业代码
  409. if (string.IsNullOrEmpty(en.SpecialtyCodeStr))
  410. {
  411. errorMsgStr += "专业代码不能为空;";
  412. en.ErrorMessage = errorMsgStr;
  413. isHaveNoInputValue = true;
  414. }
  415. #endregion
  416. #region 专业名称
  417. if (string.IsNullOrEmpty(en.StandardNameStr))
  418. {
  419. errorMsgStr += "专业名称不能为空;";
  420. en.ErrorMessage = errorMsgStr;
  421. isHaveNoInputValue = true;
  422. }
  423. if (!string.IsNullOrEmpty(en.StandardNameStr) && !string.IsNullOrEmpty(en.SpecialtyCodeStr))
  424. {
  425. var Standard = StandardList.Where(x => x.Name == en.StandardNameStr.Trim() && x.Code == en.SpecialtyCodeStr.Trim()).FirstOrDefault();
  426. if (Standard == null)
  427. {
  428. errorMsgStr += "专业代码与专业名称不符;";
  429. en.ErrorMessage = errorMsgStr;
  430. isHaveNoInputValue = true;
  431. }
  432. }
  433. #endregion
  434. #region 课程名称
  435. if (string.IsNullOrEmpty(en.CourseCode))
  436. {
  437. errorMsgStr += "课程代码不能为空;";
  438. en.ErrorMessage = errorMsgStr;
  439. isHaveNoInputValue = true;
  440. }
  441. if (!string.IsNullOrEmpty(en.CourseCode))
  442. {
  443. if (CoursematerialList.Where(x => x.CourseCode == en.CourseCode.Trim()).FirstOrDefault() == null)
  444. {
  445. errorMsgStr += "该课程代码不存在;";
  446. en.ErrorMessage = errorMsgStr;
  447. isHaveNoInputValue = true;
  448. }
  449. }
  450. #endregion
  451. #region 教研室
  452. if (string.IsNullOrEmpty(en.DepartmentName))
  453. {
  454. errorMsgStr += "教研室不能为空;";
  455. en.ErrorMessage = errorMsgStr;
  456. isHaveNoInputValue = true;
  457. }
  458. if (!string.IsNullOrEmpty(en.DepartmentName))
  459. {
  460. if (DepartmentList.Where(x => x.Name == en.DepartmentName.Trim()).FirstOrDefault() == null)
  461. {
  462. errorMsgStr += "教研室不存在;";
  463. en.ErrorMessage = errorMsgStr;
  464. isHaveNoInputValue = true;
  465. }
  466. else
  467. {
  468. en.DepartmentID = DepartmentList.Where(x => x.Name == en.DepartmentName.Trim()).FirstOrDefault().DepartmentID;
  469. }
  470. }
  471. #endregion
  472. #region 授课年级
  473. if (string.IsNullOrEmpty(en.SchoolyearNumNameStr))
  474. {
  475. errorMsgStr += "授课年级不能为空;";
  476. en.ErrorMessage = errorMsgStr;
  477. isHaveNoInputValue = true;
  478. }
  479. else
  480. {
  481. if (SchoolyearNumList.Where(x => x.Name.Trim() == en.SchoolyearNumNameStr.Trim()).FirstOrDefault() == null)
  482. {
  483. errorMsgStr += "授课年级不存在;";
  484. en.ErrorMessage = errorMsgStr;
  485. isHaveNoInputValue = true;
  486. }
  487. }
  488. #endregion
  489. #region 学期
  490. if (string.IsNullOrEmpty(en.SchoolcodeStr))
  491. {
  492. errorMsgStr += "学期不能为空;";
  493. en.ErrorMessage = errorMsgStr;
  494. isHaveNoInputValue = true;
  495. }
  496. if (!string.IsNullOrEmpty(en.SchoolcodeStr))
  497. {
  498. if (SchoolcodeList.Where(x => x.Name == en.SchoolcodeStr).FirstOrDefault() == null)
  499. {
  500. errorMsgStr += "学期不存在;";
  501. en.ErrorMessage = errorMsgStr;
  502. isHaveNoInputValue = true;
  503. }
  504. else
  505. {
  506. en.SchoolcodeID = SchoolcodeList.Where(x => x.Name == en.SchoolcodeStr).FirstOrDefault().Value;
  507. }
  508. }
  509. #endregion
  510. #region 课程类型
  511. if (string.IsNullOrEmpty(en.CourseTypeStr))
  512. {
  513. errorMsgStr += "课程类型不能为空;";
  514. en.ErrorMessage = errorMsgStr;
  515. isHaveNoInputValue = true;
  516. }
  517. if (!string.IsNullOrEmpty(en.CourseTypeStr))
  518. {
  519. if (CourseTypeList.Where(x => x.Name == en.CourseTypeStr).FirstOrDefault() == null)
  520. {
  521. errorMsgStr += "课程类型不存在;";
  522. en.ErrorMessage = errorMsgStr;
  523. isHaveNoInputValue = true;
  524. }
  525. else
  526. {
  527. en.CourseTypeID = CourseTypeList.Where(x => x.Name == en.CourseTypeStr).FirstOrDefault().Value;
  528. }
  529. }
  530. #endregion
  531. #region 课程属性
  532. if (string.IsNullOrEmpty(en.CourseCategoryNameStr))
  533. {
  534. errorMsgStr += "课程属性不能为空;";
  535. en.ErrorMessage = errorMsgStr;
  536. isHaveNoInputValue = true;
  537. }
  538. if (!string.IsNullOrEmpty(en.CourseCategoryNameStr))
  539. {
  540. if (CourseCategoryList.Where(x => x.Name == en.CourseCategoryNameStr).FirstOrDefault() == null)
  541. {
  542. errorMsgStr += "课程属性不存在;";
  543. en.ErrorMessage = errorMsgStr;
  544. isHaveNoInputValue = true;
  545. }
  546. else
  547. {
  548. en.CourseCategoryID = CourseCategoryList.Where(x => x.Name == en.CourseCategoryNameStr).FirstOrDefault().Value;
  549. }
  550. }
  551. #endregion
  552. #region 课程性质
  553. if (string.IsNullOrEmpty(en.CourseQualityNameStr))
  554. {
  555. errorMsgStr += "课程性质不能为空;";
  556. en.ErrorMessage = errorMsgStr;
  557. isHaveNoInputValue = true;
  558. }
  559. if (!string.IsNullOrEmpty(en.CourseQualityNameStr))
  560. {
  561. if (CourseQualityList.Where(x => x.Name == en.CourseQualityNameStr).FirstOrDefault() == null)
  562. {
  563. errorMsgStr += "课程性质不存在;";
  564. en.ErrorMessage = errorMsgStr;
  565. isHaveNoInputValue = true;
  566. }
  567. else
  568. {
  569. en.CourseQualityID = CourseQualityList.Where(x => x.Name == en.CourseQualityNameStr).FirstOrDefault().Value;
  570. }
  571. }
  572. #endregion
  573. #region 课程结构
  574. if (!string.IsNullOrEmpty(en.CourseStructureNameStr))
  575. {
  576. if (CourseStructureList.Where(x => x.Name == en.CourseStructureNameStr).FirstOrDefault() == null)
  577. {
  578. errorMsgStr += "课程结构不存在;";
  579. en.ErrorMessage = errorMsgStr;
  580. isHaveNoInputValue = true;
  581. }
  582. else
  583. {
  584. en.CourseStructureID = CourseStructureList.Where(x => x.Name == en.CourseStructureNameStr).FirstOrDefault().Value;
  585. }
  586. }
  587. #endregion
  588. #region 学分
  589. if (string.IsNullOrEmpty(en.CreditStr))
  590. {
  591. errorMsgStr += "学分不能为空;";
  592. en.ErrorMessage = errorMsgStr;
  593. isHaveNoInputValue = true;
  594. }
  595. if (!string.IsNullOrEmpty(en.CreditStr))
  596. {
  597. if (!reg.IsMatch(en.CreditStr))
  598. {
  599. errorMsgStr += "学分格式不正确;";
  600. en.ErrorMessage = errorMsgStr;
  601. isHaveNoInputValue = true;
  602. }
  603. else
  604. {
  605. en.Credit = Convert.ToDecimal(en.CreditStr);
  606. }
  607. }
  608. #endregion
  609. #region 理论学时
  610. if (string.IsNullOrEmpty(en.TheoryCourseStr))
  611. {
  612. errorMsgStr += "理论学时不能为空;";
  613. en.ErrorMessage = errorMsgStr;
  614. isHaveNoInputValue = true;
  615. }
  616. if (!string.IsNullOrEmpty(en.TheoryCourseStr))
  617. {
  618. if (!reg.IsMatch(en.TheoryCourseStr))
  619. {
  620. errorMsgStr += "理论学时格式不正确;";
  621. en.ErrorMessage = errorMsgStr;
  622. isHaveNoInputValue = true;
  623. }
  624. else
  625. {
  626. en.TheoryCourse = Convert.ToInt32(en.TheoryCourseStr);
  627. }
  628. }
  629. #endregion
  630. #region 实践学时
  631. if (string.IsNullOrEmpty(en.PracticehoursStr))
  632. {
  633. errorMsgStr += "实践学时不能为空;";
  634. en.ErrorMessage = errorMsgStr;
  635. isHaveNoInputValue = true;
  636. }
  637. if (!string.IsNullOrEmpty(en.PracticehoursStr))
  638. {
  639. if (!reg.IsMatch(en.PracticehoursStr))
  640. {
  641. errorMsgStr += "实践学时格式不正确;";
  642. en.ErrorMessage = errorMsgStr;
  643. isHaveNoInputValue = true;
  644. }
  645. else
  646. {
  647. en.Practicehours = Convert.ToInt32(en.PracticehoursStr);
  648. }
  649. }
  650. #endregion
  651. #region 实验学时
  652. if (string.IsNullOrEmpty(en.TrialhoursStr))
  653. {
  654. errorMsgStr += "实验学时不能为空;";
  655. en.ErrorMessage = errorMsgStr;
  656. isHaveNoInputValue = true;
  657. }
  658. if (!string.IsNullOrEmpty(en.TrialhoursStr))
  659. {
  660. if (!reg.IsMatch(en.TrialhoursStr))
  661. {
  662. errorMsgStr += "实验学时格式不正确;";
  663. en.ErrorMessage = errorMsgStr;
  664. isHaveNoInputValue = true;
  665. }
  666. else
  667. {
  668. en.Trialhours = Convert.ToInt32(en.TrialhoursStr);
  669. }
  670. }
  671. #endregion
  672. #region 实践方式
  673. if (!string.IsNullOrEmpty(en.PracticeTypeNameStr))
  674. {
  675. if (PracticeTypeList.Where(x => x.Name == en.PracticeTypeNameStr).FirstOrDefault() == null)
  676. {
  677. errorMsgStr += "实践方式不存在;";
  678. en.ErrorMessage = errorMsgStr;
  679. isHaveNoInputValue = true;
  680. }
  681. else
  682. {
  683. en.PracticeTypeID = PracticeTypeList.Where(x => x.Name == en.PracticeTypeNameStr).FirstOrDefault().Value;
  684. }
  685. }
  686. #endregion
  687. #region 考试方式
  688. if (string.IsNullOrEmpty(en.ExaminationModeNameStr))
  689. {
  690. errorMsgStr += "考试方式不能为空;";
  691. en.ErrorMessage = errorMsgStr;
  692. isHaveNoInputValue = true;
  693. }
  694. if (!string.IsNullOrEmpty(en.ExaminationModeNameStr))
  695. {
  696. if (ExaminationModeList.Where(x => x.Name == en.ExaminationModeNameStr).FirstOrDefault() == null)
  697. {
  698. errorMsgStr += "考试方式不存在;";
  699. en.ErrorMessage = errorMsgStr;
  700. isHaveNoInputValue = true;
  701. }
  702. else
  703. {
  704. en.ExaminationModeID = ExaminationModeList.Where(x => x.Name == en.ExaminationModeNameStr).FirstOrDefault().Value;
  705. }
  706. }
  707. #endregion
  708. #region 成绩类型
  709. if (string.IsNullOrEmpty(en.ResultTypeNameStr))
  710. {
  711. errorMsgStr += "成绩类型不能为空;";
  712. en.ErrorMessage = errorMsgStr;
  713. isHaveNoInputValue = true;
  714. }
  715. if (!string.IsNullOrEmpty(en.ResultTypeNameStr))
  716. {
  717. if (ResultTypeList.Where(x => x.Name == en.ResultTypeNameStr).FirstOrDefault() == null)
  718. {
  719. errorMsgStr += "成绩类型不存在;";
  720. en.ErrorMessage = errorMsgStr;
  721. isHaveNoInputValue = true;
  722. }
  723. else
  724. {
  725. en.ResultTypeID = ResultTypeList.Where(x => x.Name == en.ResultTypeNameStr).FirstOrDefault().Value;
  726. }
  727. }
  728. #endregion
  729. #region 是否专业核心
  730. if (!string.IsNullOrEmpty(en.IsSpecialtycoreName))
  731. {
  732. //var t = typeof(MinorSpecialtyCourseView);
  733. //var pName = t.GetProperty(en.IsSpecialtycoreName);
  734. ////4.0或以上版本
  735. //var displayName = pName.GetCustomAttributes<DisplayNameAttribute>();
  736. if (YesOrNoStatusList.Where(x => x.Name == en.IsSpecialtycoreName).FirstOrDefault() == null)
  737. {
  738. errorMsgStr += "是否专业核心不存在;";
  739. en.ErrorMessage = errorMsgStr;
  740. isHaveNoInputValue = true;
  741. }
  742. else
  743. {
  744. en.IsSpecialtycore = en.IsSpecialtycoreName == "是" ? true : false;
  745. }
  746. }
  747. #endregion
  748. #region 是否校企开发
  749. if (!string.IsNullOrEmpty(en.IsCooperationName))
  750. {
  751. if (YesOrNoStatusList.Where(x => x.Name == en.IsCooperationName).FirstOrDefault() == null)
  752. {
  753. errorMsgStr += "是否校企开发不存在;";
  754. en.ErrorMessage = errorMsgStr;
  755. isHaveNoInputValue = true;
  756. }
  757. else
  758. {
  759. en.IsCooperation = en.IsCooperationName == "是" ? true : false;
  760. }
  761. }
  762. #endregion
  763. #region 是否课证融通
  764. if (!string.IsNullOrEmpty(en.IsRequiredName))
  765. {
  766. if (YesOrNoStatusList.Where(x => x.Name == en.IsRequiredName).FirstOrDefault() == null)
  767. {
  768. errorMsgStr += "是否课证融通不存在;";
  769. en.ErrorMessage = errorMsgStr;
  770. isHaveNoInputValue = true;
  771. }
  772. else
  773. {
  774. en.IsRequired = en.IsRequiredName == "是" ? true : false;
  775. }
  776. }
  777. #endregion
  778. #region 是否学位主干
  779. if (!string.IsNullOrEmpty(en.IsMainCourseName))
  780. {
  781. if (YesOrNoStatusList.Where(x => x.Name == en.IsMainCourseName).FirstOrDefault() == null)
  782. {
  783. errorMsgStr += "是否学位主干不存在;";
  784. en.ErrorMessage = errorMsgStr;
  785. isHaveNoInputValue = true;
  786. }
  787. else
  788. {
  789. en.IsMainCourse = en.IsMainCourseName == "是" ? true : false;
  790. }
  791. }
  792. #endregion
  793. #region 是否选修
  794. if (!string.IsNullOrEmpty(en.IsElectiveName))
  795. {
  796. if (YesOrNoStatusList.Where(x => x.Name == en.IsElectiveName).FirstOrDefault() == null)
  797. {
  798. errorMsgStr += "是否选修不存在;";
  799. en.ErrorMessage = errorMsgStr;
  800. isHaveNoInputValue = true;
  801. }
  802. else
  803. {
  804. en.IsElective = en.IsElectiveName == "是" ? true : false;
  805. }
  806. }
  807. #endregion
  808. #region 是否网络
  809. if (!string.IsNullOrEmpty(en.IsNetworkCourseName))
  810. {
  811. if (YesOrNoStatusList.Where(x => x.Name == en.IsNetworkCourseName).FirstOrDefault() == null)
  812. {
  813. errorMsgStr += "是否网络不存在;";
  814. en.ErrorMessage = errorMsgStr;
  815. isHaveNoInputValue = true;
  816. }
  817. else
  818. {
  819. en.IsNetworkCourse = en.IsNetworkCourseName == "是" ? true : false;
  820. }
  821. }
  822. #endregion
  823. #region 精品课程
  824. if (!string.IsNullOrEmpty(en.CourseFineNameStr))
  825. {
  826. if (CourseFineList.Where(x => x.Name == en.CourseFineNameStr).FirstOrDefault() == null)
  827. {
  828. errorMsgStr += "精品课程不存在;";
  829. en.ErrorMessage = errorMsgStr;
  830. isHaveNoInputValue = true;
  831. }
  832. else
  833. {
  834. en.CourseFineID = CourseFineList.Where(x => x.Name == en.CourseFineNameStr).FirstOrDefault().Value;
  835. }
  836. }
  837. #endregion
  838. #region 授课语言
  839. if (!string.IsNullOrEmpty(en.TeachinglanguageNameStr))
  840. {
  841. if (TeachinglanguageList.Where(x => x.Name == en.TeachinglanguageNameStr).FirstOrDefault() == null)
  842. {
  843. errorMsgStr += "授课语言不存在;";
  844. en.ErrorMessage = errorMsgStr;
  845. isHaveNoInputValue = true;
  846. }
  847. else
  848. {
  849. en.TeachinglanguageID = TeachinglanguageList.Where(x => x.Name == en.TeachinglanguageNameStr).FirstOrDefault().Value;
  850. }
  851. }
  852. #endregion
  853. #region 授课方式
  854. if (string.IsNullOrEmpty(en.TeachingModeStr))
  855. {
  856. errorMsgStr += "授课方式不能为空;";
  857. en.ErrorMessage = errorMsgStr;
  858. isHaveNoInputValue = true;
  859. }
  860. if (!string.IsNullOrEmpty(en.TeachingModeStr))
  861. {
  862. bool IsExists = true;//是否存在!
  863. string[] StrArry = null;
  864. if (en.TeachingModeStr.Contains(","))
  865. {
  866. StrArry = en.TeachingModeStr.Split(',');
  867. }
  868. if (en.TeachingModeStr.Contains(","))
  869. {
  870. StrArry = en.TeachingModeStr.Split(',');
  871. }
  872. if (en.TeachingModeStr.Contains(",") && en.TeachingModeStr.Contains(","))
  873. {
  874. StrArry = new string[1];
  875. StrArry[0] = en.TeachingModeStr.ToString();
  876. }
  877. if (StrArry != null)
  878. {
  879. foreach (var Str in StrArry)
  880. {
  881. if (TeachingModeList.Where(x => x.Name == Str).FirstOrDefault() == null && !string.IsNullOrEmpty(Str))
  882. {
  883. IsExists = false;
  884. }
  885. }
  886. }
  887. else
  888. {
  889. if (TeachingModeList.Where(x => x.Name == en.TeachingModeStr).FirstOrDefault() == null && !string.IsNullOrEmpty(en.TeachingModeStr))
  890. {
  891. IsExists = false;
  892. }
  893. }
  894. if (!IsExists)
  895. {
  896. errorMsgStr += "授课方式不存在;";
  897. en.ErrorMessage = errorMsgStr;
  898. isHaveNoInputValue = true;
  899. }
  900. else
  901. {
  902. List<int> TeachingModesList = new List<int>();
  903. if (StrArry != null)
  904. {
  905. foreach (var Str in StrArry)
  906. {
  907. if (!string.IsNullOrEmpty(Str))
  908. {
  909. int? TeachingModeID = TeachingModeList.Where(x => x.Name == Str).FirstOrDefault().Value;
  910. TeachingModesList.Add((int)TeachingModeID);
  911. }
  912. }
  913. }
  914. else
  915. {
  916. if (!string.IsNullOrEmpty(en.TeachingModeStr))
  917. {
  918. int? TeachingModeID = TeachingModeList.Where(x => x.Name == en.TeachingModeStr).FirstOrDefault().Value;
  919. TeachingModesList.Add((int)TeachingModeID);
  920. }
  921. }
  922. en.TeachingModeID = TeachingModesList.Distinct().ToList();
  923. }
  924. }
  925. #endregion
  926. #region 授课地点
  927. if (!string.IsNullOrEmpty(en.TeachingPlaceStr))
  928. {
  929. string[] StrArry = null;
  930. if (en.TeachingPlaceStr.Contains(","))
  931. {
  932. StrArry = en.TeachingPlaceStr.Split(',');
  933. }
  934. if (en.TeachingPlaceStr.Contains(","))
  935. {
  936. StrArry = en.TeachingPlaceStr.Split(',');
  937. }
  938. if (en.TeachingPlaceStr.Contains(",") && en.TeachingPlaceStr.Contains(","))
  939. {
  940. StrArry = new string[1];
  941. StrArry[0] = en.TeachingPlaceStr.ToString();
  942. }
  943. bool IsExists = true;//是否存在!
  944. if (StrArry != null)
  945. {
  946. foreach (var Str in StrArry)
  947. {
  948. if (TeachingPlaceList.Where(x => x.Name == Str).FirstOrDefault() == null && !string.IsNullOrEmpty(Str))
  949. {
  950. IsExists = false;
  951. }
  952. }
  953. }
  954. else
  955. {
  956. if (TeachingPlaceList.Where(x => x.Name == en.TeachingPlaceStr).FirstOrDefault() == null && !string.IsNullOrEmpty(en.TeachingPlaceStr))
  957. {
  958. IsExists = false;
  959. }
  960. }
  961. if (!IsExists)
  962. {
  963. errorMsgStr += "授课地点不存在;";
  964. en.ErrorMessage = errorMsgStr;
  965. isHaveNoInputValue = true;
  966. }
  967. else
  968. {
  969. List<int> TeachingsPlaceList = new List<int>();
  970. if (StrArry != null)
  971. {
  972. foreach (var Str in StrArry)
  973. {
  974. if (!string.IsNullOrEmpty(Str))
  975. {
  976. int? TeachingPlaceID = TeachingPlaceList.Where(x => x.Name == Str).FirstOrDefault().Value;
  977. TeachingsPlaceList.Add((int)TeachingPlaceID);
  978. }
  979. }
  980. }
  981. else
  982. {
  983. if (!string.IsNullOrEmpty(en.TeachingPlaceStr))
  984. {
  985. int? TeachingPlaceID = TeachingPlaceList.Where(x => x.Name == en.TeachingPlaceStr).FirstOrDefault().Value;
  986. TeachingsPlaceList.Add((int)TeachingPlaceID);
  987. }
  988. }
  989. en.TeachingPlaceID = TeachingsPlaceList.Distinct().ToList();
  990. }
  991. }
  992. #endregion
  993. //唯一值 专业信息+课程+开课学期
  994. #region 唯一值
  995. if (!isHaveNoInputValue)
  996. {
  997. int? standardID = StandardList.Where(x => x.Name == en.StandardNameStr.Trim() && x.Code == en.SpecialtyCodeStr.Trim()).FirstOrDefault().Value;
  998. //学期
  999. int? schoolcodeID = SchoolcodeList.Where(x => x.Name == en.SchoolcodeStr).FirstOrDefault().Value;
  1000. //开课年级
  1001. int? schoolyearNum = SchoolyearNumList.Where(x => x.Name == en.SchoolyearNumNameStr).FirstOrDefault().Value;
  1002. //以开课年级+学期 得出对应的 开课学期
  1003. EM_Coursematerial CoursematerialEntity = CoursematerialList.Where(x => x.CourseCode == en.CourseCode.Trim()).FirstOrDefault();
  1004. if (CoursematerialEntity == null)
  1005. {
  1006. isHaveNoInputValue = true;
  1007. }
  1008. else
  1009. {
  1010. if (MinorCourseList.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1011. && x.StandardID == standardID && x.CoursematerialID == CoursematerialEntity.CoursematerialID
  1012. && x.SchoolyearNumID == schoolyearNum && x.SchoolcodeID == schoolcodeID).Count() > 0)
  1013. {
  1014. errorMsgStr += "该标准专业课程已经存在;";
  1015. en.ErrorMessage = errorMsgStr;
  1016. isHaveNoInputValue = true;
  1017. // throw new Exception("该标准专业课程已经存在,请重新输入!");
  1018. }
  1019. else
  1020. {
  1021. en.StandardID = standardID;
  1022. en.CoursematerialID = CoursematerialEntity.CoursematerialID;
  1023. en.SchoolcodeID = schoolcodeID;
  1024. en.SchoolyearNumID = schoolyearNum;
  1025. }
  1026. }
  1027. }
  1028. if (isHaveNoInputValue) // 若必填项有值未填
  1029. {
  1030. en.IsExcelVaildateOK = false;
  1031. en.ErrorMessage = errorMsgStr;
  1032. errList.Add(en);
  1033. errorMsg.AppendLine(errorMsgStr);
  1034. }
  1035. }
  1036. #endregion
  1037. #endregion
  1038. #region 插入数据
  1039. List<EM_MinorCourse> MinorCourseLists = new List<EM_MinorCourse>();
  1040. List<EM_MinorCourseTeachingSetting> MinorCourseTeachingSettingList = new List<EM_MinorCourseTeachingSetting>();
  1041. List<EM_MinorCourseTeachingPlace> MinorCourseTeachingPlaceList = new List<EM_MinorCourseTeachingPlace>();
  1042. List<EM_MinorCourseTeachingModeType> MinorCourseTeachingModeTypeList = new List<EM_MinorCourseTeachingModeType>();
  1043. for (int i = 0; i < enlist.Count; i++)
  1044. {
  1045. MinorSpecialtyCourseView enA = enlist[i];
  1046. if (enA.IsExcelVaildateOK == false) // 上面验证不通过,不进行此步验证
  1047. {
  1048. continue;
  1049. }
  1050. EM_MinorCourse MinorCourse = null;
  1051. EM_MinorCourseTeachingSetting MinorCourseTeachingSetting = null;
  1052. if (enA != null)
  1053. {
  1054. MinorCourse = new EM_MinorCourse();
  1055. MinorCourse.MinorCourseID = Guid.NewGuid();
  1056. MinorCourse.StandardID = enA.StandardID;
  1057. MinorCourse.DepartmentID = enA.DepartmentID;
  1058. MinorCourse.CoursematerialID = enA.CoursematerialID;
  1059. MinorCourse.CourseStructureID = enA.CourseStructureID;
  1060. MinorCourse.CourseCategoryID = enA.CourseCategoryID;
  1061. MinorCourse.CourseTypeID = enA.CourseTypeID;
  1062. MinorCourse.CourseQualityID = enA.CourseQualityID;
  1063. MinorCourse.PracticeTypeID = enA.PracticeTypeID;
  1064. MinorCourse.ExaminationModeID = enA.ExaminationModeID;
  1065. MinorCourse.TeachinglanguageID = enA.TeachinglanguageID;
  1066. MinorCourse.SchoolyearNumID = enA.SchoolyearNumID;
  1067. MinorCourse.SchoolcodeID = enA.SchoolcodeID;
  1068. MinorCourse.CourseFineID = enA.CourseFineID;
  1069. MinorCourse.IsSpecialtycore = enA.IsSpecialtycore;
  1070. MinorCourse.IsCooperation = enA.IsCooperation;
  1071. MinorCourse.IsRequired = enA.IsRequired;
  1072. MinorCourse.IsElective = enA.IsElective;
  1073. MinorCourse.IsNetworkCourse = enA.IsNetworkCourse;
  1074. MinorCourse.IsMainCourse = enA.IsMainCourse;
  1075. MinorCourse.IsEnable = true;//默认启用
  1076. MinorCourse.ResultTypeID = enA.ResultTypeID;
  1077. MinorCourse.Remarks = enA.Remarks;
  1078. SetNewStatus(MinorCourse);
  1079. MinorCourseLists.Add(MinorCourse);
  1080. MinorCourseTeachingSetting = new EM_MinorCourseTeachingSetting();
  1081. MinorCourseTeachingSetting.MinorCourseID = MinorCourse.MinorCourseID;
  1082. MinorCourseTeachingSetting.Credit = enA.Credit;
  1083. MinorCourseTeachingSetting.TheoryCourse = enA.TheoryCourse;
  1084. MinorCourseTeachingSetting.Practicehours = enA.Practicehours;
  1085. MinorCourseTeachingSetting.Trialhours = enA.Trialhours;
  1086. MinorCourseTeachingSetting.WeeklyNum = enA.WeeklyNum;
  1087. MinorCourseTeachingSetting.TheoryWeeklyNum = enA.TheoryWeeklyNum;
  1088. MinorCourseTeachingSetting.PracticeWeeklyNum = enA.PracticeWeeklyNum;
  1089. MinorCourseTeachingSetting.TrialWeeklyNum = enA.TrialWeeklyNum;
  1090. MinorCourseTeachingSetting.StartWeeklyNum = enA.StartWeeklyNum;
  1091. MinorCourseTeachingSetting.EndWeeklyNum = enA.EndWeeklyNum;
  1092. MinorCourseTeachingSetting.WeeklyHours = enA.WeeklyHours;
  1093. MinorCourseTeachingSettingList.Add(MinorCourseTeachingSetting);
  1094. if (enA.TeachingModeID != null)
  1095. {
  1096. foreach (var item in enA.TeachingModeID)
  1097. {
  1098. EM_MinorCourseTeachingModeType teachingModeType = new EM_MinorCourseTeachingModeType();
  1099. teachingModeType.MinorCourseTeachingModeTypeID = Guid.NewGuid();
  1100. teachingModeType.MinorCourseID = MinorCourse.MinorCourseID;
  1101. teachingModeType.TeachingModeID = item;
  1102. SetNewStatus(teachingModeType);
  1103. MinorCourseTeachingModeTypeList.Add(teachingModeType);
  1104. }
  1105. }
  1106. if (enA.TeachingPlaceID != null)
  1107. {
  1108. foreach (var item in enA.TeachingPlaceID)
  1109. {
  1110. EM_MinorCourseTeachingPlace teachingPlace = new EM_MinorCourseTeachingPlace();
  1111. teachingPlace.MinorCourseTeachingPlaceID = Guid.NewGuid();
  1112. teachingPlace.MinorCourseID = MinorCourse.MinorCourseID;
  1113. teachingPlace.TeachingPlace = item;
  1114. SetNewStatus(teachingPlace);
  1115. MinorCourseTeachingPlaceList.Add(teachingPlace);
  1116. }
  1117. }
  1118. }
  1119. }
  1120. #endregion
  1121. #endregion
  1122. #region 1.3 返回各项数据值
  1123. UnitOfWork.BulkInsert(MinorCourseLists);//统一写入
  1124. UnitOfWork.BulkInsert(MinorCourseTeachingSettingList);//统一写入
  1125. UnitOfWork.BulkInsert(MinorCourseTeachingPlaceList);//统一写入
  1126. UnitOfWork.BulkInsert(MinorCourseTeachingModeTypeList);//统一写入
  1127. OkCount = enlist.Distinct().Count() - errList.Distinct().Count();//共条数减去失败条数
  1128. errdataList = errList.Distinct().ToList();
  1129. ErrCount = errList.Distinct().Count();
  1130. #endregion
  1131. }
  1132. }
  1133. }