MinorPlanApplyServices.cs 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  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.MinorPlanManage;
  7. using EMIS.ViewModel;
  8. using EMIS.CommonLogic.SystemServices;
  9. using EMIS.Entities;
  10. using System.Linq.Expressions;
  11. using Bowin.Common.Linq;
  12. using EMIS.DataLogic.MinorManage.MinorPlanManage;
  13. using EMIS.DataLogic.Common.CalendarManage;
  14. namespace EMIS.CommonLogic.MinorManage.MinorPlanManage
  15. {
  16. public class MinorPlanApplyServices : BaseWorkflowServices<CF_GrademinorApplication>, IMinorPlanApplyServices
  17. {
  18. public MinorPlanApplyDAL MinorPlanApplyDAL{get;set;}
  19. public SchoolYearDAL schoolYearDAL { get; set; }
  20. public IGridResultSet<MinorPlanApplyView> GetMinorPlanApplyViewGrid(ConfiguretView configuretView, int? yearID, int? standardID, Guid? collegeID, int? approvalStatus, int pageIndex, int pageSize)
  21. {
  22. var statusList = this.GetStatusViewList();
  23. Expression<Func<CF_GrademinorApplication, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  24. if (yearID.HasValue)
  25. exp = exp.And(x => x.YearID == yearID);
  26. if (standardID.HasValue)
  27. exp = exp.And(x => x.StandardID == standardID);
  28. if (collegeID.HasValue)
  29. exp = exp.And(x => x.CollegeID == collegeID);
  30. if (approvalStatus.HasValue)
  31. exp = exp.And(x => x.RecordStatus == approvalStatus);
  32. var query = MinorPlanApplyDAL.GetMinorPlanApplyViewQueryable(exp);
  33. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  34. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  35. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x=>x.SchoolyearCode).ThenBy(x => x.YearID).ThenBy(x=>x.StandardID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  36. .ThenByDescending(x => x.CreateTime).ToGridResultSet<MinorPlanApplyView>(pageIndex, pageSize);
  37. result.rows.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  38. return result;
  39. }
  40. public List<MinorPlanApplyView> GetMinorPlanApplyViewList(ConfiguretView configuretView, int? yearID, int? standardID, Guid? collegeID, int? approvalStatus, List<Guid?> GradeMinorApplicationIDList)
  41. {
  42. Expression<Func<CF_GrademinorApplication, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  43. if (GradeMinorApplicationIDList != null)
  44. exp = exp.And(x => GradeMinorApplicationIDList.Contains(x.GradeMinorApplicationID));
  45. if (yearID.HasValue)
  46. exp = exp.And(x => x.YearID == yearID);
  47. if (standardID.HasValue)
  48. exp = exp.And(x => x.StandardID == standardID);
  49. if (collegeID.HasValue)
  50. exp = exp.And(x => x.CollegeID == collegeID);
  51. if (approvalStatus.HasValue)
  52. exp = exp.And(x => x.RecordStatus == approvalStatus);
  53. var query = MinorPlanApplyDAL.GetMinorPlanApplyViewQueryable(exp);
  54. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  55. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  56. return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.YearID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  57. .ThenByDescending(x => x.StandardID).ThenByDescending(x => x.CreateTime).ToList();
  58. }
  59. public IGridResultSet<MinorPlanApplyView> StandardAndMinorSpecialtyCourseViewGrid(int? yearID, int? standardID, int pageIndex, int pageSize)
  60. {
  61. Expression<Func<EM_MinorCourse, bool>> exp = (x => x.IsEnable==true);
  62. var query = MinorPlanApplyDAL.StandardAndMinorSpecialtyCourseView(exp, yearID);
  63. if (standardID.HasValue)
  64. {
  65. query = query.Where(x => x.StandardID == standardID);
  66. }
  67. return this.GetQueryByDataRangeByCollege(query)
  68. .OrderBy(x => x.SchoolyearNumID).ThenBy(x => x.CourseCode)
  69. .ToGridResultSet<MinorPlanApplyView>(pageIndex, pageSize);
  70. }
  71. public IGridResultSet<MinorPlanApplyView> existStandardAndMinorSpecialtyCourseViewGrid(Guid? GradeMinorApplicationID, int pageIndex, int pageSize)
  72. {
  73. Expression<Func<CF_GrademinorApplication, bool>> exp = (x => x.GradeMinorApplicationID==GradeMinorApplicationID);
  74. var query = MinorPlanApplyDAL.existStandardAndMinorSpecialtyCourseView(exp);
  75. return this.GetQueryByDataRangeByCollege(query)
  76. .OrderBy(x => x.StarttermID).ThenBy(x => x.CourseCode)
  77. .ToGridResultSet<MinorPlanApplyView>(pageIndex, pageSize);
  78. }
  79. public void MinorPlanAdd(MinorPlanApplyView minorPlanApplyView, List<MinorPlanApplyView> minorSpecialCourseViewList)
  80. {
  81. try
  82. {
  83. var existGrademinorApplication = MinorPlanApplyDAL.GrademinorApplicationRepository.GetList(x => x.YearID == minorPlanApplyView.YearID && x.StandardID == minorPlanApplyView.StandardID).FirstOrDefault();
  84. if (existGrademinorApplication!=null)
  85. {
  86. throw new Exception(minorPlanApplyView.YearID+"级"+minorPlanApplyView.StandardName+"的辅修申请已存在。");
  87. }
  88. var graduatingSemester = EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID;
  89. if (graduatingSemester == null)
  90. {
  91. throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查");
  92. }
  93. var SchoolcodeID = Convert.ToInt32(graduatingSemester);
  94. var schoolYearList = this.schoolYearDAL.schoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  95. var minorSpecialCourseIDList = minorSpecialCourseViewList.Select(x => x.MinorCourseID).ToList();
  96. var minorSpecialCourseTeachModeTypeList = MinorPlanApplyDAL.MinorCourseTeachingModeTypeRepository.GetList(x => minorSpecialCourseIDList.Contains(x.MinorCourseID)).ToList();
  97. var minorSpecialCourseTeachPlaceList = MinorPlanApplyDAL.MinorCourseTeachingPlaceRepository.GetList(x => minorSpecialCourseIDList.Contains(x.MinorCourseID)).ToList();
  98. var nowSchoolYear = schoolYearList.Where(x => x.IsCurrent == true).FirstOrDefault();
  99. CF_GrademinorApplication GrademinorApplication = new CF_GrademinorApplication();
  100. GrademinorApplication.GradeMinorApplicationID = Guid.NewGuid();
  101. GrademinorApplication.SchoolyearID = nowSchoolYear.SchoolyearID;
  102. GrademinorApplication.CollegeID = minorPlanApplyView.CollegeID;
  103. GrademinorApplication.StandardID = minorPlanApplyView.StandardID;
  104. GrademinorApplication.YearID = minorPlanApplyView.YearID;
  105. GrademinorApplication.StudentLimit = minorPlanApplyView.StudentLimit;
  106. SetNewStatus(GrademinorApplication);
  107. UnitOfWork.Add(GrademinorApplication);
  108. UnitOfWork.Commit();
  109. List<EM_MinorPlanApplication> insertList = new List<EM_MinorPlanApplication>();
  110. List<EM_MinorPlanApplicationTeachingSetting> insertSettingList = new List<EM_MinorPlanApplicationTeachingSetting>();
  111. List<EM_MinorPlanApplicationTeachingModeType> insertTeachingModeTypeList = new List<EM_MinorPlanApplicationTeachingModeType>();
  112. List<EM_MinorPlanApplicationTeachingPlace> insertTeachingPlaceList = new List<EM_MinorPlanApplicationTeachingPlace>();
  113. foreach (var specialtyCourse in minorSpecialCourseViewList)
  114. {
  115. var startSchoolyear = schoolYearList.FirstOrDefault(x => x.Years == minorPlanApplyView.YearID && x.SchoolcodeID == SchoolcodeID);
  116. if (startSchoolyear == null)
  117. {
  118. throw new Exception("未能匹配到学年学期,请设置学年学期。");
  119. }
  120. var courseSchoolyear = schoolYearList.FirstOrDefault(x => x.Value == (startSchoolyear.Value + ((specialtyCourse.SchoolyearNumID - 1) * 2) + (specialtyCourse.SchoolcodeID == SchoolcodeID ? 0 : 1)));
  121. if (courseSchoolyear == null)
  122. {
  123. throw new Exception("课程" + specialtyCourse.CourseName + "的开课学年学期尚未设置,请先前往校历管理设置相应的学年学期。");
  124. }
  125. EM_MinorPlanApplication MinorPlanApplication = new EM_MinorPlanApplication();
  126. MinorPlanApplication.MinorPlanApplicationID = Guid.NewGuid();
  127. MinorPlanApplication.GrademinorApplicationID = GrademinorApplication.GradeMinorApplicationID;
  128. MinorPlanApplication.StarttermID = specialtyCourse.StarttermID;
  129. MinorPlanApplication.DepartmentID = specialtyCourse.DepartmentID;
  130. MinorPlanApplication.CoursematerialID = specialtyCourse.CoursematerialID;
  131. MinorPlanApplication.CourseStructureID = specialtyCourse.CourseStructureID;
  132. MinorPlanApplication.CourseCategoryID = specialtyCourse.CourseCategoryID;
  133. MinorPlanApplication.CourseTypeID = specialtyCourse.CourseTypeID;
  134. MinorPlanApplication.CourseQualityID = specialtyCourse.CourseQualityID;
  135. MinorPlanApplication.PracticeTypeID = specialtyCourse.PracticeTypeID;
  136. MinorPlanApplication.ExaminationModeID = specialtyCourse.ExaminationModeID;
  137. MinorPlanApplication.CourseFineID = specialtyCourse.CourseFineID;
  138. MinorPlanApplication.IsSpecialtycore = specialtyCourse.IsSpecialtycore;
  139. MinorPlanApplication.IsCooperation = specialtyCourse.IsCooperation;
  140. MinorPlanApplication.IsRequired = specialtyCourse.IsRequired;
  141. MinorPlanApplication.IsElective = specialtyCourse.IsElective;
  142. MinorPlanApplication.IsNetworkCourse = specialtyCourse.IsNetworkCourse;
  143. MinorPlanApplication.IsMainCourse = specialtyCourse.IsMainCourse;
  144. MinorPlanApplication.TeachinglanguageID = specialtyCourse.TeachinglanguageID;
  145. MinorPlanApplication.HandleModeID = specialtyCourse.HandleModeID;
  146. MinorPlanApplication.IsNeedMaterial = specialtyCourse.IsNeedMaterial;
  147. MinorPlanApplication.ResultTypeID = specialtyCourse.ResultTypeID;
  148. MinorPlanApplication.Remarks = minorPlanApplyView.Remarks;
  149. SetNewStatus(MinorPlanApplication);
  150. insertList.Add(MinorPlanApplication);
  151. EM_MinorPlanApplicationTeachingSetting MinorPlanApplicationTeachingSetting = new EM_MinorPlanApplicationTeachingSetting();
  152. MinorPlanApplicationTeachingSetting.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID;
  153. MinorPlanApplicationTeachingSetting.Credit = specialtyCourse.Credit;
  154. MinorPlanApplicationTeachingSetting.TheoryCourse = specialtyCourse.TheoryCourse;
  155. MinorPlanApplicationTeachingSetting.Practicehours = specialtyCourse.Practicehours;
  156. MinorPlanApplicationTeachingSetting.Trialhours = specialtyCourse.Trialhours;
  157. MinorPlanApplicationTeachingSetting.WeeklyNum = specialtyCourse.WeeklyNum;
  158. MinorPlanApplicationTeachingSetting.TheoryWeeklyNum = specialtyCourse.TheoryWeeklyNum;
  159. MinorPlanApplicationTeachingSetting.PracticeWeeklyNum = specialtyCourse.PracticeWeeklyNum;
  160. MinorPlanApplicationTeachingSetting.TrialWeeklyNum = specialtyCourse.TrialWeeklyNum;
  161. MinorPlanApplicationTeachingSetting.StartWeeklyNum = specialtyCourse.StartWeeklyNum;
  162. MinorPlanApplicationTeachingSetting.EndWeeklyNum = specialtyCourse.EndWeeklyNum;
  163. MinorPlanApplicationTeachingSetting.WeeklyHours = specialtyCourse.WeeklyHours;
  164. insertSettingList.Add(MinorPlanApplicationTeachingSetting);
  165. minorSpecialCourseTeachModeTypeList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x =>
  166. {
  167. EM_MinorPlanApplicationTeachingModeType specialtyTeachingModeType = new EM_MinorPlanApplicationTeachingModeType();
  168. specialtyTeachingModeType.MinorPlanApplicationTeachingModeTypeID = Guid.NewGuid();
  169. specialtyTeachingModeType.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID;
  170. specialtyTeachingModeType.TeachingModeID = x.TeachingModeID;
  171. this.SetNewStatus(specialtyTeachingModeType);
  172. insertTeachingModeTypeList.Add(specialtyTeachingModeType);
  173. });
  174. minorSpecialCourseTeachPlaceList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x =>
  175. {
  176. EM_MinorPlanApplicationTeachingPlace specialtyTeachingPlace = new EM_MinorPlanApplicationTeachingPlace();
  177. specialtyTeachingPlace.MinorPlanApplicationTeachingPlaceID = Guid.NewGuid();
  178. specialtyTeachingPlace.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID;
  179. specialtyTeachingPlace.TeachingPlace = x.TeachingPlace;
  180. this.SetNewStatus(specialtyTeachingPlace);
  181. insertTeachingPlaceList.Add(specialtyTeachingPlace);
  182. });
  183. }
  184. UnitOfWork.BulkInsert(insertList);
  185. UnitOfWork.BulkInsert(insertSettingList);
  186. UnitOfWork.BulkInsert(insertTeachingModeTypeList);
  187. UnitOfWork.BulkInsert(insertTeachingPlaceList);
  188. }
  189. catch (Exception)
  190. {
  191. throw;
  192. }
  193. }
  194. public void MinorPlanEdit(MinorPlanApplyView minorPlanApplyView, List<MinorPlanApplyView> minorSpecialCourseViewList)
  195. {
  196. try
  197. {
  198. var existGrademinorApplication = MinorPlanApplyDAL.GrademinorApplicationRepository.GetList(x => x.YearID == minorPlanApplyView.YearID && x.StandardID == minorPlanApplyView.StandardID && x.GradeMinorApplicationID != minorPlanApplyView.GradeMinorApplicationID).FirstOrDefault();
  199. if (existGrademinorApplication != null)
  200. {
  201. throw new Exception(minorPlanApplyView.YearID + "级" + minorPlanApplyView.StandardName + "的辅修申请已存在。");
  202. }
  203. var graduatingSemester = EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID;
  204. if (graduatingSemester == null)
  205. {
  206. throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查");
  207. }
  208. var SchoolcodeID = Convert.ToInt32(graduatingSemester);
  209. var schoolYearList = this.schoolYearDAL.schoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  210. var GrademinorApplication = MinorPlanApplyDAL.GrademinorApplicationRepository.GetList(x => x.GradeMinorApplicationID == minorPlanApplyView.GradeMinorApplicationID).FirstOrDefault();
  211. var minorSpecialCourseIDList = minorSpecialCourseViewList.Select(x => x.MinorCourseID).ToList();
  212. var MinorPlanApplicationIDList = MinorPlanApplyDAL.MinorPlanApplicationRepository.GetList(x => x.GrademinorApplicationID == minorPlanApplyView.GradeMinorApplicationID).Select(x => x.MinorPlanApplicationID).ToList();
  213. var minorSpecialCourseTeachModeTypeList = MinorPlanApplyDAL.MinorCourseTeachingModeTypeRepository.GetList(x => minorSpecialCourseIDList.Contains(x.MinorCourseID)).ToList();
  214. var minorSpecialCourseTeachPlaceList = MinorPlanApplyDAL.MinorCourseTeachingPlaceRepository.GetList(x => minorSpecialCourseIDList.Contains(x.MinorCourseID)).ToList();
  215. var minorSpecialCourseList=MinorPlanApplyDAL.MinorCourseRepository.GetList(x=>minorSpecialCourseIDList.Contains(x.MinorCourseID));
  216. var nowSchoolYear = schoolYearList.Where(x => x.IsCurrent == true).FirstOrDefault();
  217. var isother = minorSpecialCourseList.Where(x => x.StandardID != minorPlanApplyView.StandardID).FirstOrDefault();
  218. if (isother!=null)
  219. {
  220. throw new Exception("所选课程中有其他专业的课程请重新选择");
  221. }
  222. if (MinorPlanApplicationIDList.Count>0)
  223. {
  224. UnitOfWork.Delete<EM_MinorPlanApplicationTeachingSetting>(x =>MinorPlanApplicationIDList.Contains(x.MinorPlanApplicationID));
  225. UnitOfWork.Delete<EM_MinorPlanApplicationTeachingModeType>(x => MinorPlanApplicationIDList.Contains((Guid)x.MinorPlanApplicationID));
  226. UnitOfWork.Delete<EM_MinorPlanApplicationTeachingPlace>(x => MinorPlanApplicationIDList.Contains((Guid)x.MinorPlanApplicationID));
  227. UnitOfWork.Delete<EM_MinorPlanApplication>(x => MinorPlanApplicationIDList.Contains(x.MinorPlanApplicationID));
  228. }
  229. if (GrademinorApplication != null)
  230. {
  231. CF_GrademinorApplication GrademinorApplications = GrademinorApplication;
  232. GrademinorApplications.StudentLimit = minorPlanApplyView.StudentLimit;
  233. GrademinorApplications.CollegeID = minorPlanApplyView.CollegeID;
  234. SetModifyStatus(GrademinorApplication);
  235. UnitOfWork.Commit();
  236. List<EM_MinorPlanApplication> insertList = new List<EM_MinorPlanApplication>();
  237. List<EM_MinorPlanApplicationTeachingSetting> insertSettingList = new List<EM_MinorPlanApplicationTeachingSetting>();
  238. List<EM_MinorPlanApplicationTeachingModeType> insertTeachingModeTypeList = new List<EM_MinorPlanApplicationTeachingModeType>();
  239. List<EM_MinorPlanApplicationTeachingPlace> insertTeachingPlaceList = new List<EM_MinorPlanApplicationTeachingPlace>();
  240. foreach (var specialtyCourse in minorSpecialCourseViewList)
  241. {
  242. var startSchoolyear = schoolYearList.FirstOrDefault(x => x.Years == minorPlanApplyView.YearID && x.SchoolcodeID == SchoolcodeID);
  243. if (startSchoolyear == null)
  244. {
  245. throw new Exception("未能匹配到学年学期,请设置学年学期。");
  246. }
  247. var courseSchoolyear = schoolYearList.FirstOrDefault(x => x.Value == (startSchoolyear.Value + ((specialtyCourse.SchoolyearNumID - 1) * 2) + (specialtyCourse.SchoolcodeID == SchoolcodeID ? 0 : 1)));
  248. if (courseSchoolyear == null)
  249. {
  250. throw new Exception("课程" + specialtyCourse.CourseName + "的开课学年学期尚未设置,请先前往校历管理设置相应的学年学期。");
  251. }
  252. EM_MinorPlanApplication MinorPlanApplication = new EM_MinorPlanApplication();
  253. MinorPlanApplication.MinorPlanApplicationID = Guid.NewGuid();
  254. MinorPlanApplication.GrademinorApplicationID = minorPlanApplyView.GradeMinorApplicationID;
  255. MinorPlanApplication.StarttermID = specialtyCourse.StarttermID;
  256. MinorPlanApplication.DepartmentID = specialtyCourse.DepartmentID;
  257. MinorPlanApplication.CoursematerialID = specialtyCourse.CoursematerialID;
  258. MinorPlanApplication.CourseStructureID = specialtyCourse.CourseStructureID;
  259. MinorPlanApplication.CourseCategoryID = specialtyCourse.CourseCategoryID;
  260. MinorPlanApplication.CourseTypeID = specialtyCourse.CourseTypeID;
  261. MinorPlanApplication.CourseQualityID = specialtyCourse.CourseQualityID;
  262. MinorPlanApplication.PracticeTypeID = specialtyCourse.PracticeTypeID;
  263. MinorPlanApplication.ExaminationModeID = specialtyCourse.ExaminationModeID;
  264. MinorPlanApplication.CourseFineID = specialtyCourse.CourseFineID;
  265. MinorPlanApplication.IsSpecialtycore = specialtyCourse.IsSpecialtycore;
  266. MinorPlanApplication.IsCooperation = specialtyCourse.IsCooperation;
  267. MinorPlanApplication.IsRequired = specialtyCourse.IsRequired;
  268. MinorPlanApplication.IsElective = specialtyCourse.IsElective;
  269. MinorPlanApplication.IsNetworkCourse = specialtyCourse.IsNetworkCourse;
  270. MinorPlanApplication.IsMainCourse = specialtyCourse.IsMainCourse;
  271. MinorPlanApplication.TeachinglanguageID = specialtyCourse.TeachinglanguageID;
  272. MinorPlanApplication.HandleModeID = specialtyCourse.HandleModeID;
  273. MinorPlanApplication.IsNeedMaterial = specialtyCourse.IsNeedMaterial;
  274. MinorPlanApplication.ResultTypeID = specialtyCourse.ResultTypeID;
  275. MinorPlanApplication.Remarks = minorPlanApplyView.Remarks;
  276. SetNewStatus(MinorPlanApplication);
  277. insertList.Add(MinorPlanApplication);
  278. EM_MinorPlanApplicationTeachingSetting MinorPlanApplicationTeachingSetting = new EM_MinorPlanApplicationTeachingSetting();
  279. MinorPlanApplicationTeachingSetting.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID;
  280. MinorPlanApplicationTeachingSetting.Credit = specialtyCourse.Credit;
  281. MinorPlanApplicationTeachingSetting.TheoryCourse = specialtyCourse.TheoryCourse;
  282. MinorPlanApplicationTeachingSetting.Practicehours = specialtyCourse.Practicehours;
  283. MinorPlanApplicationTeachingSetting.Trialhours = specialtyCourse.Trialhours;
  284. MinorPlanApplicationTeachingSetting.WeeklyNum = specialtyCourse.WeeklyNum;
  285. MinorPlanApplicationTeachingSetting.TheoryWeeklyNum = specialtyCourse.TheoryWeeklyNum;
  286. MinorPlanApplicationTeachingSetting.PracticeWeeklyNum = specialtyCourse.PracticeWeeklyNum;
  287. MinorPlanApplicationTeachingSetting.TrialWeeklyNum = specialtyCourse.TrialWeeklyNum;
  288. MinorPlanApplicationTeachingSetting.StartWeeklyNum = specialtyCourse.StartWeeklyNum;
  289. MinorPlanApplicationTeachingSetting.EndWeeklyNum = specialtyCourse.EndWeeklyNum;
  290. MinorPlanApplicationTeachingSetting.WeeklyHours = specialtyCourse.WeeklyHours;
  291. insertSettingList.Add(MinorPlanApplicationTeachingSetting);
  292. minorSpecialCourseTeachModeTypeList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x =>
  293. {
  294. EM_MinorPlanApplicationTeachingModeType specialtyTeachingModeType = new EM_MinorPlanApplicationTeachingModeType();
  295. specialtyTeachingModeType.MinorPlanApplicationTeachingModeTypeID = Guid.NewGuid();
  296. specialtyTeachingModeType.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID;
  297. specialtyTeachingModeType.TeachingModeID = x.TeachingModeID;
  298. this.SetNewStatus(specialtyTeachingModeType);
  299. insertTeachingModeTypeList.Add(specialtyTeachingModeType);
  300. });
  301. minorSpecialCourseTeachPlaceList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x =>
  302. {
  303. EM_MinorPlanApplicationTeachingPlace specialtyTeachingPlace = new EM_MinorPlanApplicationTeachingPlace();
  304. specialtyTeachingPlace.MinorPlanApplicationTeachingPlaceID = Guid.NewGuid();
  305. specialtyTeachingPlace.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID;
  306. specialtyTeachingPlace.TeachingPlace = x.TeachingPlace;
  307. this.SetNewStatus(specialtyTeachingPlace);
  308. insertTeachingPlaceList.Add(specialtyTeachingPlace);
  309. });
  310. }
  311. UnitOfWork.BulkInsert(insertList);
  312. UnitOfWork.BulkInsert(insertSettingList);
  313. UnitOfWork.BulkInsert(insertTeachingModeTypeList);
  314. UnitOfWork.BulkInsert(insertTeachingPlaceList);
  315. }
  316. else
  317. {
  318. CF_GrademinorApplication GrademinorApplications = new CF_GrademinorApplication() ;
  319. GrademinorApplications.GradeMinorApplicationID = Guid.NewGuid();
  320. GrademinorApplications.SchoolyearID = nowSchoolYear.SchoolyearID;
  321. GrademinorApplications.CollegeID = minorPlanApplyView.CollegeID;
  322. GrademinorApplications.StandardID = minorPlanApplyView.StandardID;
  323. GrademinorApplications.YearID = minorPlanApplyView.YearID;
  324. GrademinorApplications.StudentLimit = minorPlanApplyView.StudentLimit;
  325. SetNewStatus(GrademinorApplications);
  326. UnitOfWork.Add(GrademinorApplications);
  327. UnitOfWork.Commit();
  328. List<EM_MinorPlanApplication> insertList = new List<EM_MinorPlanApplication>();
  329. List<EM_MinorPlanApplicationTeachingSetting> insertSettingList = new List<EM_MinorPlanApplicationTeachingSetting>();
  330. List<EM_MinorPlanApplicationTeachingModeType> insertTeachingModeTypeList = new List<EM_MinorPlanApplicationTeachingModeType>();
  331. List<EM_MinorPlanApplicationTeachingPlace> insertTeachingPlaceList = new List<EM_MinorPlanApplicationTeachingPlace>();
  332. foreach (var specialtyCourse in minorSpecialCourseViewList)
  333. {
  334. var startSchoolyear = schoolYearList.FirstOrDefault(x => x.Years == minorPlanApplyView.YearID && x.SchoolcodeID == SchoolcodeID);
  335. if (startSchoolyear == null)
  336. {
  337. throw new Exception("未能匹配到学年学期,请设置学年学期。");
  338. }
  339. var courseSchoolyear = schoolYearList.FirstOrDefault(x => x.Value == (startSchoolyear.Value + ((specialtyCourse.SchoolyearNumID - 1) * 2) + (specialtyCourse.SchoolcodeID == SchoolcodeID ? 0 : 1)));
  340. if (courseSchoolyear == null)
  341. {
  342. throw new Exception("课程" + specialtyCourse.CourseName + "的开课学年学期尚未设置,请先前往校历管理设置相应的学年学期。");
  343. }
  344. EM_MinorPlanApplication MinorPlanApplication = new EM_MinorPlanApplication();
  345. MinorPlanApplication.MinorPlanApplicationID = Guid.NewGuid();
  346. MinorPlanApplication.GrademinorApplicationID = GrademinorApplications.GradeMinorApplicationID;
  347. MinorPlanApplication.StarttermID = specialtyCourse.StarttermID;
  348. MinorPlanApplication.DepartmentID = specialtyCourse.DepartmentID;
  349. MinorPlanApplication.CoursematerialID = specialtyCourse.CoursematerialID;
  350. MinorPlanApplication.CourseStructureID = specialtyCourse.CourseStructureID;
  351. MinorPlanApplication.CourseCategoryID = specialtyCourse.CourseCategoryID;
  352. MinorPlanApplication.CourseTypeID = specialtyCourse.CourseTypeID;
  353. MinorPlanApplication.CourseQualityID = specialtyCourse.CourseQualityID;
  354. MinorPlanApplication.PracticeTypeID = specialtyCourse.PracticeTypeID;
  355. MinorPlanApplication.ExaminationModeID = specialtyCourse.ExaminationModeID;
  356. MinorPlanApplication.CourseFineID = specialtyCourse.CourseFineID;
  357. MinorPlanApplication.IsSpecialtycore = specialtyCourse.IsSpecialtycore;
  358. MinorPlanApplication.IsCooperation = specialtyCourse.IsCooperation;
  359. MinorPlanApplication.IsRequired = specialtyCourse.IsRequired;
  360. MinorPlanApplication.IsElective = specialtyCourse.IsElective;
  361. MinorPlanApplication.IsNetworkCourse = specialtyCourse.IsNetworkCourse;
  362. MinorPlanApplication.IsMainCourse = specialtyCourse.IsMainCourse;
  363. MinorPlanApplication.TeachinglanguageID = specialtyCourse.TeachinglanguageID;
  364. MinorPlanApplication.HandleModeID = specialtyCourse.HandleModeID;
  365. MinorPlanApplication.IsNeedMaterial = specialtyCourse.IsNeedMaterial;
  366. MinorPlanApplication.ResultTypeID = specialtyCourse.ResultTypeID;
  367. MinorPlanApplication.Remarks = minorPlanApplyView.Remarks;
  368. SetNewStatus(MinorPlanApplication);
  369. insertList.Add(MinorPlanApplication);
  370. EM_MinorPlanApplicationTeachingSetting MinorPlanApplicationTeachingSetting = new EM_MinorPlanApplicationTeachingSetting();
  371. MinorPlanApplicationTeachingSetting.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID;
  372. MinorPlanApplicationTeachingSetting.Credit = specialtyCourse.Credit;
  373. MinorPlanApplicationTeachingSetting.TheoryCourse = specialtyCourse.TheoryCourse;
  374. MinorPlanApplicationTeachingSetting.Practicehours = specialtyCourse.Practicehours;
  375. MinorPlanApplicationTeachingSetting.Trialhours = specialtyCourse.Trialhours;
  376. MinorPlanApplicationTeachingSetting.WeeklyNum = specialtyCourse.WeeklyNum;
  377. MinorPlanApplicationTeachingSetting.TheoryWeeklyNum = specialtyCourse.TheoryWeeklyNum;
  378. MinorPlanApplicationTeachingSetting.PracticeWeeklyNum = specialtyCourse.PracticeWeeklyNum;
  379. MinorPlanApplicationTeachingSetting.TrialWeeklyNum = specialtyCourse.TrialWeeklyNum;
  380. MinorPlanApplicationTeachingSetting.StartWeeklyNum = specialtyCourse.StartWeeklyNum;
  381. MinorPlanApplicationTeachingSetting.EndWeeklyNum = specialtyCourse.EndWeeklyNum;
  382. MinorPlanApplicationTeachingSetting.WeeklyHours = specialtyCourse.WeeklyHours;
  383. insertSettingList.Add(MinorPlanApplicationTeachingSetting);
  384. minorSpecialCourseTeachModeTypeList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x =>
  385. {
  386. EM_MinorPlanApplicationTeachingModeType specialtyTeachingModeType = new EM_MinorPlanApplicationTeachingModeType();
  387. specialtyTeachingModeType.MinorPlanApplicationTeachingModeTypeID = Guid.NewGuid();
  388. specialtyTeachingModeType.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID;
  389. specialtyTeachingModeType.TeachingModeID = x.TeachingModeID;
  390. this.SetNewStatus(specialtyTeachingModeType);
  391. insertTeachingModeTypeList.Add(specialtyTeachingModeType);
  392. });
  393. minorSpecialCourseTeachPlaceList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x =>
  394. {
  395. EM_MinorPlanApplicationTeachingPlace specialtyTeachingPlace = new EM_MinorPlanApplicationTeachingPlace();
  396. specialtyTeachingPlace.MinorPlanApplicationTeachingPlaceID = Guid.NewGuid();
  397. specialtyTeachingPlace.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID;
  398. specialtyTeachingPlace.TeachingPlace = x.TeachingPlace;
  399. this.SetNewStatus(specialtyTeachingPlace);
  400. insertTeachingPlaceList.Add(specialtyTeachingPlace);
  401. });
  402. }
  403. UnitOfWork.BulkInsert(insertList);
  404. UnitOfWork.BulkInsert(insertSettingList);
  405. UnitOfWork.BulkInsert(insertTeachingModeTypeList);
  406. UnitOfWork.BulkInsert(insertTeachingPlaceList);
  407. }
  408. }
  409. catch (Exception)
  410. {
  411. throw;
  412. }
  413. }
  414. public MinorPlanApplyView GetMinorPlanApplyView(Guid? GradeMinorApplicationIDs)
  415. {
  416. Expression<Func<CF_GrademinorApplication, bool>> exp = (x => x.GradeMinorApplicationID == GradeMinorApplicationIDs);
  417. var MinorApplication = MinorPlanApplyDAL.GetMinorPlanApplyViewQueryable(exp).FirstOrDefault();
  418. return MinorApplication;
  419. }
  420. /// <summary>
  421. /// 复制年级
  422. /// </summary>
  423. /// <param name="specialtyPlan"></param>
  424. /// <returns></returns>
  425. public string SpecialtyPlanCopyByGrade(MinorPlanApplyView minorPlanApplyView)
  426. {
  427. try
  428. {
  429. var graduatingSemester = EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID;
  430. if (graduatingSemester == null)
  431. {
  432. throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查");
  433. }
  434. var SchoolcodeID = Convert.ToInt32(graduatingSemester);
  435. var specialtyCourseList = MinorPlanApplyDAL.MinorCourseRepository.GetList(x => true).ToList();
  436. var schoolYearList = this.schoolYearDAL.schoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  437. var nowSchoolYear = schoolYearList.Where(x => x.IsCurrent == true).FirstOrDefault();
  438. //找复制源的辅修专业
  439. var sourceList = MinorPlanApplyDAL.GrademinorApplicationRepository.GetList(x => x.YearID == minorPlanApplyView.GrademajorBeForeYear).ToList();
  440. if (minorPlanApplyView.BeForeCollegeID.HasValue)
  441. {
  442. sourceList = sourceList.Where(x => x.CollegeID == minorPlanApplyView.BeForeCollegeID).ToList();
  443. }
  444. List<Guid?> sourceIDList=new List<Guid?>();
  445. foreach(var sourceID in sourceList)
  446. {
  447. Guid? ID= sourceID.GradeMinorApplicationID;
  448. sourceIDList.Add(ID);
  449. }
  450. //找复制源的辅修计划
  451. var sourceCourseList = MinorPlanApplyDAL.MinorPlanApplicationRepository.GetList(x => sourceIDList.Contains(x.GrademinorApplicationID)).ToList();
  452. var sourceCourseIDList = sourceCourseList.Select(x => x.MinorPlanApplicationID).ToList();
  453. var minorSpecialCourseTeachingSettingList = MinorPlanApplyDAL.MinorPlanApplicationTeachingSettingRepository.GetList(x => sourceCourseIDList.Contains((Guid)x.MinorPlanApplicationID)).ToList();
  454. var minorSpecialCourseTeachModeTypeList = MinorPlanApplyDAL.MinorPlanApplicationTeachingModeTypeRepository.GetList(x => sourceCourseIDList.Contains((Guid)x.MinorPlanApplicationID)).ToList();
  455. var minorSpecialCourseTeachPlaceList = MinorPlanApplyDAL.MinorPlanApplicationTeachingPlaceRepository.GetList(x => sourceCourseIDList.Contains((Guid)x.MinorPlanApplicationID)).ToList();
  456. //找复制源的专业计划
  457. //找到目标辅修专业
  458. var targetList = MinorPlanApplyDAL.GrademinorApplicationRepository.GetList(x => x.YearID == minorPlanApplyView.GrademajorAfterYear).ToList();
  459. int existCount = 0;
  460. int copyCount = 0;
  461. foreach (var source in sourceList)
  462. {
  463. var isCanCopy = targetList.Where(x => x.StandardID == source.StandardID).FirstOrDefault();
  464. if (isCanCopy!=null)
  465. {
  466. existCount = existCount+1;
  467. }
  468. else
  469. {
  470. CF_GrademinorApplication GrademinorApplication = new CF_GrademinorApplication();
  471. GrademinorApplication.GradeMinorApplicationID = Guid.NewGuid();
  472. GrademinorApplication.SchoolyearID = nowSchoolYear.SchoolyearID;
  473. GrademinorApplication.CollegeID = source.CollegeID;
  474. GrademinorApplication.StandardID = source.StandardID;
  475. GrademinorApplication.YearID = minorPlanApplyView.GrademajorAfterYear;
  476. GrademinorApplication.StudentLimit = source.StudentLimit;
  477. SetNewStatus(GrademinorApplication);
  478. UnitOfWork.Add(GrademinorApplication);
  479. copyCount = copyCount +1;
  480. List<EM_MinorPlanApplication> insertList = new List<EM_MinorPlanApplication>();
  481. List<EM_MinorPlanApplicationTeachingSetting> insertSettingList = new List<EM_MinorPlanApplicationTeachingSetting>();
  482. List<EM_MinorPlanApplicationTeachingModeType> insertTeachingModeTypeList = new List<EM_MinorPlanApplicationTeachingModeType>();
  483. List<EM_MinorPlanApplicationTeachingPlace> insertTeachingPlaceList = new List<EM_MinorPlanApplicationTeachingPlace>();
  484. #region 插入数据到列表中,准备批量插入
  485. foreach (var specialtyCourse in sourceCourseList)
  486. {
  487. if (specialtyCourse.GrademinorApplicationID == source.GradeMinorApplicationID)
  488. {
  489. var startSchoolyear = schoolYearList.FirstOrDefault(x => x.Years == minorPlanApplyView.GrademajorAfterYear && x.SchoolcodeID == SchoolcodeID);
  490. if (startSchoolyear == null)
  491. {
  492. throw new Exception("未能匹配到学年学期,请设置学年学期。");
  493. }
  494. var courseSchoolyear = schoolYearList.FirstOrDefault(x => x.Value == (startSchoolyear.Value + specialtyCourse.StarttermID - 1));
  495. if (courseSchoolyear == null)
  496. {
  497. throw new Exception("课程" + specialtyCourse.EM_Coursematerial.CourseName + "的开课学年学期尚未设置,请先前往校历管理设置相应的学年学期。");
  498. }
  499. EM_MinorPlanApplication MinorPlanApplication = new EM_MinorPlanApplication();
  500. MinorPlanApplication.MinorPlanApplicationID = Guid.NewGuid();
  501. MinorPlanApplication.GrademinorApplicationID = GrademinorApplication.GradeMinorApplicationID;
  502. MinorPlanApplication.StarttermID = specialtyCourse.StarttermID;
  503. MinorPlanApplication.DepartmentID = specialtyCourse.DepartmentID;
  504. MinorPlanApplication.CoursematerialID = specialtyCourse.CoursematerialID;
  505. MinorPlanApplication.CourseStructureID = specialtyCourse.CourseStructureID;
  506. MinorPlanApplication.CourseCategoryID = specialtyCourse.CourseCategoryID;
  507. MinorPlanApplication.CourseTypeID = specialtyCourse.CourseTypeID;
  508. MinorPlanApplication.CourseQualityID = specialtyCourse.CourseQualityID;
  509. MinorPlanApplication.PracticeTypeID = specialtyCourse.PracticeTypeID;
  510. MinorPlanApplication.ExaminationModeID = specialtyCourse.ExaminationModeID;
  511. MinorPlanApplication.CourseFineID = specialtyCourse.CourseFineID;
  512. MinorPlanApplication.IsSpecialtycore = specialtyCourse.IsSpecialtycore;
  513. MinorPlanApplication.IsCooperation = specialtyCourse.IsCooperation;
  514. MinorPlanApplication.IsRequired = specialtyCourse.IsRequired;
  515. MinorPlanApplication.IsElective = specialtyCourse.IsElective;
  516. MinorPlanApplication.IsNetworkCourse = specialtyCourse.IsNetworkCourse;
  517. MinorPlanApplication.IsMainCourse = specialtyCourse.IsMainCourse;
  518. MinorPlanApplication.TeachinglanguageID = specialtyCourse.TeachinglanguageID;
  519. MinorPlanApplication.HandleModeID = minorPlanApplyView.HandleModeID;
  520. MinorPlanApplication.IsNeedMaterial = minorPlanApplyView.IsNeedMaterial;
  521. MinorPlanApplication.ResultTypeID = specialtyCourse.ResultTypeID;
  522. MinorPlanApplication.Remarks = minorPlanApplyView.Remarks;
  523. SetNewStatus(MinorPlanApplication);
  524. insertList.Add(MinorPlanApplication);
  525. var minorSpecialCourseTeachingSetting = minorSpecialCourseTeachingSettingList.Where(x => x.MinorPlanApplicationID == specialtyCourse.MinorPlanApplicationID).FirstOrDefault();
  526. EM_MinorPlanApplicationTeachingSetting MinorPlanApplicationTeachingSetting = new EM_MinorPlanApplicationTeachingSetting();
  527. MinorPlanApplicationTeachingSetting.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID;
  528. MinorPlanApplicationTeachingSetting.Credit = minorSpecialCourseTeachingSetting.Credit;
  529. MinorPlanApplicationTeachingSetting.TheoryCourse = minorSpecialCourseTeachingSetting.TheoryCourse;
  530. MinorPlanApplicationTeachingSetting.Practicehours = minorSpecialCourseTeachingSetting.Practicehours;
  531. MinorPlanApplicationTeachingSetting.Trialhours = minorSpecialCourseTeachingSetting.Trialhours;
  532. MinorPlanApplicationTeachingSetting.WeeklyNum = minorSpecialCourseTeachingSetting.WeeklyNum;
  533. MinorPlanApplicationTeachingSetting.TheoryWeeklyNum = minorSpecialCourseTeachingSetting.TheoryWeeklyNum;
  534. MinorPlanApplicationTeachingSetting.PracticeWeeklyNum = minorSpecialCourseTeachingSetting.PracticeWeeklyNum;
  535. MinorPlanApplicationTeachingSetting.TrialWeeklyNum = minorSpecialCourseTeachingSetting.TrialWeeklyNum;
  536. MinorPlanApplicationTeachingSetting.StartWeeklyNum = minorSpecialCourseTeachingSetting.StartWeeklyNum;
  537. MinorPlanApplicationTeachingSetting.EndWeeklyNum = minorSpecialCourseTeachingSetting.EndWeeklyNum;
  538. MinorPlanApplicationTeachingSetting.WeeklyHours = minorSpecialCourseTeachingSetting.WeeklyHours;
  539. insertSettingList.Add(MinorPlanApplicationTeachingSetting);
  540. minorSpecialCourseTeachModeTypeList.Where(x => x.MinorPlanApplicationID == specialtyCourse.MinorPlanApplicationID).ToList().ForEach(x =>
  541. {
  542. EM_MinorPlanApplicationTeachingModeType specialtyTeachingModeType = new EM_MinorPlanApplicationTeachingModeType();
  543. specialtyTeachingModeType.MinorPlanApplicationTeachingModeTypeID = Guid.NewGuid();
  544. specialtyTeachingModeType.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID;
  545. specialtyTeachingModeType.TeachingModeID = x.TeachingModeID;
  546. this.SetNewStatus(specialtyTeachingModeType);
  547. insertTeachingModeTypeList.Add(specialtyTeachingModeType);
  548. });
  549. minorSpecialCourseTeachPlaceList.Where(x => x.MinorPlanApplicationID == specialtyCourse.MinorPlanApplicationID).ToList().ForEach(x =>
  550. {
  551. EM_MinorPlanApplicationTeachingPlace specialtyTeachingPlace = new EM_MinorPlanApplicationTeachingPlace();
  552. specialtyTeachingPlace.MinorPlanApplicationTeachingPlaceID = Guid.NewGuid();
  553. specialtyTeachingPlace.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID;
  554. specialtyTeachingPlace.TeachingPlace = x.TeachingPlace;
  555. this.SetNewStatus(specialtyTeachingPlace);
  556. insertTeachingPlaceList.Add(specialtyTeachingPlace);
  557. });
  558. }
  559. }
  560. #endregion
  561. UnitOfWork.BulkInsert(insertList);
  562. UnitOfWork.BulkInsert(insertSettingList);
  563. UnitOfWork.BulkInsert(insertTeachingModeTypeList);
  564. UnitOfWork.BulkInsert(insertTeachingPlaceList);
  565. UnitOfWork.Commit();
  566. }
  567. }
  568. string Success = "";
  569. if (existCount == 0)
  570. {
  571. Success = "复制成功,一共复制了" + copyCount + "条。";
  572. }
  573. else
  574. {
  575. Success = "复制成功,一共复制了" + copyCount + "条,有" + existCount+"条已存在没有复制。";
  576. }
  577. return Success;
  578. }
  579. catch (Exception)
  580. {
  581. throw;
  582. }
  583. }
  584. /// <summary>
  585. /// 删除
  586. /// </summary>
  587. /// <param name="ids"></param>
  588. /// <returns></returns>
  589. public bool GradeMinorApplicationDelete(List<Guid?> ids)
  590. {
  591. try
  592. {
  593. if (ids.Count > 0)
  594. {
  595. var MinorPlanApplicationIDList = MinorPlanApplyDAL.MinorPlanApplicationRepository.GetList(x => ids.Contains(x.GrademinorApplicationID)).Select(x => x.MinorPlanApplicationID).ToList();
  596. if (MinorPlanApplicationIDList.Count > 0)
  597. {
  598. UnitOfWork.Delete<EM_MinorPlanApplicationTeachingModeType>(x => MinorPlanApplicationIDList.Contains((Guid)x.MinorPlanApplicationID));
  599. UnitOfWork.Delete<EM_MinorPlanApplicationTeachingPlace>(x => MinorPlanApplicationIDList.Contains((Guid)x.MinorPlanApplicationID));
  600. UnitOfWork.Delete<EM_MinorPlanApplicationTeachingSetting>(x => MinorPlanApplicationIDList.Contains(x.MinorPlanApplicationID));
  601. UnitOfWork.Delete<EM_MinorPlanApplication>(x => MinorPlanApplicationIDList.Contains(x.MinorPlanApplicationID));
  602. }
  603. UnitOfWork.Delete<CF_GrademinorApplication>(x => ids.Contains(x.GradeMinorApplicationID));
  604. }
  605. return true;
  606. }
  607. catch (Exception)
  608. {
  609. throw;
  610. }
  611. }
  612. public int GetStandardID_MinorPlanApplication_MinorSpecialtyPlanCount(List<Guid> ids)
  613. {
  614. return MinorPlanApplyDAL.GetStandardID_MinorPlanApplication_MinorSpecialtyPlan(ids);
  615. }
  616. /// <summary>
  617. /// 提交申请
  618. /// </summary>
  619. /// <param name="planApplicationIDs">计划申请ID</param>
  620. /// <param name="userID">提交人</param>
  621. /// <param name="comment">备注</param>
  622. public void SubmitPlanApplicationApply(List<Guid> GradeMinorApplicationIDs, Guid userID, List<string> status, string comment = "")
  623. {
  624. //在计划申请提交时验证课程的专业计划有无重复
  625. if (GradeMinorApplicationIDs.Count > 0)
  626. {
  627. var startStatus = this.GetStartStatus();
  628. var backPointStatusList = this.GetBackpointStatus();
  629. var MinorPlanApplyList = MinorPlanApplyDAL.GetMinorPlanApplyViewQueryable
  630. (x => GradeMinorApplicationIDs.Contains(x.GradeMinorApplicationID)).ToList();
  631. var wrongStatusList = MinorPlanApplyList.Where(x => x.ApprovalStatus != startStatus && !backPointStatusList.Contains(x.ApprovalStatus)).ToList();
  632. if (wrongStatusList.Count > 0)
  633. {
  634. throw new Exception("只能处理未提交和已退回的记录,请检查选择的项。");
  635. }
  636. var duplicatePlanList = MinorPlanApplyDAL
  637. .GetDuplicateSpecialtyPlanApplyView(x => GradeMinorApplicationIDs.Contains(x.GradeMinorApplicationID)).ToList();
  638. var submitList = MinorPlanApplyList.Where(x => x.ApprovalStatus == (int)startStatus).Select(x => (Guid)x.GradeMinorApplicationID).ToList();
  639. var resubmitList = MinorPlanApplyList.Where(x => backPointStatusList.Contains(x.ApprovalStatus) && !submitList.Contains((Guid)x.GradeMinorApplicationID)).Select(x => (Guid)x.GradeMinorApplicationID).ToList();
  640. if (duplicatePlanList.Count > 0)
  641. {
  642. throw new Exception(string.Join(";", duplicatePlanList.Select(x => x.YearID + "年" + x.StandardName + "专业已经有辅修专业计划,不能重复生成。")));
  643. }
  644. try
  645. {
  646. StartUp(submitList, userID, comment);
  647. Approve(resubmitList, userID, Guid.Empty, comment);
  648. }
  649. catch (Exception)
  650. {
  651. throw;
  652. }
  653. }
  654. }
  655. }
  656. }