EvaluationStaffScoreServices.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using System.Transactions;
  7. using Bowin.Common.Linq;
  8. using Bowin.Common.Data;
  9. using Bowin.Common.Linq.Entity;
  10. using EMIS.Entities;
  11. using EMIS.ViewModel;
  12. using EMIS.ViewModel.EvaluationManage.EvaluationResult;
  13. using EMIS.DataLogic.EvaluationManage.EvaluationResult;
  14. using EMIS.DataLogic.EvaluationManage.StudentEvaluation;
  15. using EMIS.CommonLogic.EvaluationManage.EvaluationManage;
  16. namespace EMIS.CommonLogic.EvaluationManage.EvaluationResult
  17. {
  18. public class EvaluationStaffScoreServices : BaseServices, IEvaluationStaffScoreServices
  19. {
  20. public Lazy<EvaluationStaffScoreDAL> EvaluationStaffScoreDAL { get; set; }
  21. public Lazy<EvaluationStudentSettingDAL> EvaluationStudentSettingDAL { get; set; }
  22. public Lazy<IEvaluationStudentScoreServices> EvaluationStudentScoreServices { get; set; }
  23. public Lazy<IEvaluationCollegeScoreServices> EvaluationCollegeScoreServices { get; set; }
  24. /// <summary>
  25. /// 查询对应的教师评分信息View
  26. /// </summary>
  27. /// <param name="configuretView"></param>
  28. /// <param name="schoolyearID"></param>
  29. /// <param name="campusID"></param>
  30. /// <param name="collegeID"></param>
  31. /// <param name="departmentID"></param>
  32. /// <param name="userID"></param>
  33. /// <param name="incumbencyState"></param>
  34. /// <param name="coursematerialID"></param>
  35. /// <param name="pageIndex"></param>
  36. /// <param name="pageSize"></param>
  37. /// <returns></returns>
  38. public IGridResultSet<EvaluationStaffScoreView> GetEvaluationStaffScoreViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID,
  39. Guid? departmentID, Guid? userID, int? incumbencyState, Guid? coursematerialID, int pageIndex, int pageSize)
  40. {
  41. Expression<Func<EM_EvaluationStaffScore, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  42. if (schoolyearID.HasValue)
  43. {
  44. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  45. }
  46. if (departmentID.HasValue)
  47. {
  48. exp = exp.And(x => x.DepartmentID == departmentID);
  49. }
  50. if (userID.HasValue)
  51. {
  52. exp = exp.And(x => x.UserID == userID);
  53. }
  54. if (coursematerialID.HasValue)
  55. {
  56. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  57. }
  58. var query = EvaluationStaffScoreDAL.Value.GetEvaluationStaffScoreViewQueryable(exp);
  59. if (campusID.HasValue)
  60. {
  61. query = query.Where(x => x.CampusID == campusID);
  62. }
  63. if (collegeID.HasValue)
  64. {
  65. query = query.Where(x => x.CollegeID == collegeID);
  66. }
  67. if (incumbencyState.HasValue)
  68. {
  69. query = query.Where(x => x.IncumbencyState == incumbencyState);
  70. }
  71. //查询条件
  72. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  73. {
  74. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  75. }
  76. return this.GetQueryByDataRange(query, x => x.UserID).OrderByDescending(x => x.SchoolyearValue).ThenBy(x => x.DepartmentNo.Length)
  77. .ThenBy(x => x.DepartmentNo).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.StaffCode).ToGridResultSet<EvaluationStaffScoreView>(pageIndex, pageSize);
  78. }
  79. /// <summary>
  80. /// 查询对应的教师评分信息List
  81. /// </summary>
  82. /// <param name="configuretView"></param>
  83. /// <param name="schoolyearID"></param>
  84. /// <param name="campusID"></param>
  85. /// <param name="collegeID"></param>
  86. /// <param name="departmentID"></param>
  87. /// <param name="userID"></param>
  88. /// <param name="incumbencyState"></param>
  89. /// <param name="coursematerialID"></param>
  90. /// <returns></returns>
  91. public IList<EvaluationStaffScoreView> GetEvaluationStaffScoreViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID,
  92. Guid? departmentID, Guid? userID, int? incumbencyState, Guid? coursematerialID)
  93. {
  94. Expression<Func<EM_EvaluationStaffScore, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  95. if (schoolyearID.HasValue)
  96. {
  97. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  98. }
  99. if (departmentID.HasValue)
  100. {
  101. exp = exp.And(x => x.DepartmentID == departmentID);
  102. }
  103. if (userID.HasValue)
  104. {
  105. exp = exp.And(x => x.UserID == userID);
  106. }
  107. if (coursematerialID.HasValue)
  108. {
  109. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  110. }
  111. var query = EvaluationStaffScoreDAL.Value.GetEvaluationStaffScoreViewQueryable(exp);
  112. if (campusID.HasValue)
  113. {
  114. query = query.Where(x => x.CampusID == campusID);
  115. }
  116. if (collegeID.HasValue)
  117. {
  118. query = query.Where(x => x.CollegeID == collegeID);
  119. }
  120. if (incumbencyState.HasValue)
  121. {
  122. query = query.Where(x => x.IncumbencyState == incumbencyState);
  123. }
  124. //查询条件
  125. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  126. {
  127. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  128. }
  129. return this.GetQueryByDataRange(query, x => x.UserID).OrderByDescending(x => x.SchoolyearValue).ThenBy(x => x.DepartmentNo.Length)
  130. .ThenBy(x => x.DepartmentNo).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.StaffCode).ToList();
  131. }
  132. /// <summary>
  133. /// 查询对应的教师评分信息EvaluationStaffScoreView
  134. /// </summary>
  135. /// <param name="evaluationStaffScoreID"></param>
  136. /// <returns></returns>
  137. public EvaluationStaffScoreView GetEvaluationStaffScoreView(Guid? evaluationStaffScoreID)
  138. {
  139. try
  140. {
  141. Expression<Func<EM_EvaluationStaffScore, bool>> exp = (x => x.EvaluationStaffScoreID == evaluationStaffScoreID);
  142. var query = EvaluationStaffScoreDAL.Value.GetEvaluationStaffScoreViewQueryable(exp).SingleOrDefault();
  143. return query;
  144. }
  145. catch (Exception ex)
  146. {
  147. throw new Exception(ex.Message);
  148. }
  149. }
  150. /// <summary>
  151. /// 评分生成
  152. /// </summary>
  153. /// <param name="campusID"></param>
  154. /// <param name="collegeID"></param>
  155. /// <param name="departmentID"></param>
  156. /// <param name="coursematerialID"></param>
  157. /// <param name="userID"></param>
  158. /// <param name="schoolyearID"></param>
  159. /// <returns></returns>
  160. public string EvaluationStaffScoreCreate(Guid? campusID, Guid? collegeID, Guid? departmentID, Guid? coursematerialID, Guid? userID, Guid? schoolyearID)
  161. {
  162. try
  163. {
  164. var schoolyear = EvaluationStaffScoreDAL.Value.SchoolyearRepository.GetList(x => x.SchoolyearID == schoolyearID).SingleOrDefault();
  165. if (schoolyear == null)
  166. {
  167. throw new Exception("选择的学年学期有误,请核查。");
  168. }
  169. var stuPassNoEndStatusID = EvaluationStudentScoreServices.Value.GetPassNoEndStatus();
  170. if (stuPassNoEndStatusID == null)
  171. {
  172. throw new Exception("工作流平台中,学生评分流程通过环节未配置,请核查。");
  173. }
  174. var colPassNoEndStatusID = EvaluationCollegeScoreServices.Value.GetPassNoEndStatus();
  175. if (colPassNoEndStatusID == null)
  176. {
  177. throw new Exception("工作流平台中,院系评分流程通过环节未配置,请核查。");
  178. }
  179. Expression<Func<EM_EducationMissionClass, bool>> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  180. expEducationMissionClass = expEducationMissionClass.And(x => x.RecordStatus == (int)EM_EducationMissionClassStatus.Submitted || x.RecordStatus == (int)EM_EducationMissionClassStatus.Scheduled);
  181. if (coursematerialID.HasValue)
  182. {
  183. expEducationMissionClass = expEducationMissionClass.And(x => x.CoursematerialID == coursematerialID);
  184. }
  185. var query = EvaluationStudentSettingDAL.Value.GetEvaluationMissionStaffViewQueryable(expEducationMissionClass).Distinct().AsQueryable();
  186. if (schoolyearID.HasValue)
  187. {
  188. query = query.Where(x => x.SchoolyearID == schoolyearID);
  189. }
  190. if (campusID.HasValue)
  191. {
  192. query = query.Where(x => x.CampusID == campusID);
  193. }
  194. if (collegeID.HasValue)
  195. {
  196. query = query.Where(x => x.CollegeID == collegeID);
  197. }
  198. if (departmentID.HasValue)
  199. {
  200. query = query.Where(x => x.DepartmentID == departmentID);
  201. }
  202. if (userID.HasValue)
  203. {
  204. query = query.Where(x => x.UserID == userID);
  205. }
  206. var evaluationMissionStaffViewList = this.GetQueryByDataRangeByDepartment(query).ToList();
  207. if (evaluationMissionStaffViewList == null || evaluationMissionStaffViewList.Count() <= 0)
  208. {
  209. throw new Exception("对应的教学任务信息为空,请核查(如:任务状态为未提交)。");
  210. }
  211. var schoolyearIDList = evaluationMissionStaffViewList.Select(x => x.SchoolyearID).Distinct().ToList();
  212. var evaluationStaffScoreList = EvaluationStaffScoreDAL.Value.EvaluationStaffScoreRepository.GetList(x => schoolyearIDList.Contains(x.SchoolyearID), (x => x.EM_EvaluationStaffScoreDetail)).ToList();
  213. var evaluationStudentScoreList = EvaluationStaffScoreDAL.Value.EvaluationStudentScoreRepository.GetList(x => schoolyearIDList.Contains(x.SchoolyearID)).ToList();
  214. var evaluationCollegeScoreList = EvaluationStaffScoreDAL.Value.EvaluationCollegeScoreRepository.GetList(x => schoolyearIDList.Contains(x.SchoolyearID)).ToList();
  215. int inSuccess = 0;
  216. int upSuccess = 0;
  217. string tipMessage = null;
  218. var evaluationStaffScoreInList = new List<EM_EvaluationStaffScore>();
  219. var evaluationStaffScoreUpList = new List<EM_EvaluationStaffScore>();
  220. var evaluationStaffScoreDetailInList = new List<EM_EvaluationStaffScoreDetail>();
  221. List<Guid?> evaluationStaffScoreIDDelList = new List<Guid?>();
  222. foreach (var evaluationMissionStaffView in evaluationMissionStaffViewList)
  223. {
  224. var evaluationStaffScore = evaluationStaffScoreList.Where(x => x.SchoolyearID == evaluationMissionStaffView.SchoolyearID && x.UserID == evaluationMissionStaffView.UserID
  225. && x.CoursematerialID == evaluationMissionStaffView.CoursematerialID && x.DepartmentID == evaluationMissionStaffView.DepartmentID).SingleOrDefault();
  226. var evaluationStudentScore = evaluationStudentScoreList.Where(x => x.SchoolyearID == evaluationMissionStaffView.SchoolyearID && x.UserID == evaluationMissionStaffView.UserID
  227. && x.CoursematerialID == evaluationMissionStaffView.CoursematerialID && x.DepartmentID == evaluationMissionStaffView.DepartmentID && x.ApprovalStatus == stuPassNoEndStatusID).SingleOrDefault();
  228. var evaluationCollegeScore = evaluationCollegeScoreList.Where(x => x.SchoolyearID == evaluationMissionStaffView.SchoolyearID && x.UserID == evaluationMissionStaffView.UserID
  229. && x.CoursematerialID == evaluationMissionStaffView.CoursematerialID && x.DepartmentID == evaluationMissionStaffView.DepartmentID && x.ApprovalStatus == colPassNoEndStatusID).SingleOrDefault();
  230. if (evaluationStaffScore == null)
  231. {
  232. var newEvaluationStaffScore = new EM_EvaluationStaffScore();
  233. newEvaluationStaffScore.EvaluationStaffScoreID = Guid.NewGuid();
  234. newEvaluationStaffScore.SchoolyearID = evaluationMissionStaffView.SchoolyearID;
  235. newEvaluationStaffScore.UserID = evaluationMissionStaffView.UserID;
  236. newEvaluationStaffScore.CoursematerialID = evaluationMissionStaffView.CoursematerialID;
  237. newEvaluationStaffScore.DepartmentID = evaluationMissionStaffView.DepartmentID;
  238. if (evaluationStudentScore != null)
  239. {
  240. if (evaluationCollegeScore != null)
  241. {
  242. newEvaluationStaffScore.TotalScore = Math.Round(((evaluationStudentScore.TotalScore ?? 0) * (decimal)0.7) + ((evaluationCollegeScore.TotalScore ?? 0) * (decimal)0.3), 2, MidpointRounding.AwayFromZero);
  243. }
  244. else
  245. {
  246. newEvaluationStaffScore.TotalScore = Math.Round(((evaluationStudentScore.TotalScore ?? 0) * (decimal)0.7), 2, MidpointRounding.AwayFromZero);
  247. }
  248. }
  249. else
  250. {
  251. if (evaluationCollegeScore != null)
  252. {
  253. newEvaluationStaffScore.TotalScore = Math.Round(((evaluationCollegeScore.TotalScore ?? 0) * (decimal)0.3), 2, MidpointRounding.AwayFromZero);
  254. }
  255. else
  256. {
  257. newEvaluationStaffScore.TotalScore = 0;
  258. }
  259. }
  260. newEvaluationStaffScore.Remark = null;
  261. SetNewStatus(newEvaluationStaffScore);
  262. evaluationStaffScoreInList.Add(newEvaluationStaffScore);
  263. var newEvaStuStaffScoreDetail = new EM_EvaluationStaffScoreDetail();
  264. newEvaStuStaffScoreDetail.EvaluationStaffScoreDetailID = Guid.NewGuid();
  265. newEvaStuStaffScoreDetail.EvaluationStaffScoreID = newEvaluationStaffScore.EvaluationStaffScoreID;
  266. newEvaStuStaffScoreDetail.EvaluationScoreTypeID = (int)EMIS.ViewModel.EM_EvaluationScoreType.StudentScore;
  267. if (evaluationStudentScore != null)
  268. {
  269. newEvaStuStaffScoreDetail.Score = evaluationStudentScore.TotalScore;
  270. }
  271. else
  272. {
  273. newEvaStuStaffScoreDetail.Score = 0;
  274. }
  275. SetNewStatus(newEvaStuStaffScoreDetail);
  276. evaluationStaffScoreDetailInList.Add(newEvaStuStaffScoreDetail);
  277. var newEvaColStaffScoreDetail = new EM_EvaluationStaffScoreDetail();
  278. newEvaColStaffScoreDetail.EvaluationStaffScoreDetailID = Guid.NewGuid();
  279. newEvaColStaffScoreDetail.EvaluationStaffScoreID = newEvaluationStaffScore.EvaluationStaffScoreID;
  280. newEvaColStaffScoreDetail.EvaluationScoreTypeID = (int)EMIS.ViewModel.EM_EvaluationScoreType.CollegeScore;
  281. if (evaluationCollegeScore != null)
  282. {
  283. newEvaColStaffScoreDetail.Score = evaluationCollegeScore.TotalScore;
  284. }
  285. else
  286. {
  287. newEvaColStaffScoreDetail.Score = 0;
  288. }
  289. SetNewStatus(newEvaColStaffScoreDetail);
  290. evaluationStaffScoreDetailInList.Add(newEvaColStaffScoreDetail);
  291. inSuccess++;
  292. }
  293. else
  294. {
  295. if (evaluationStudentScore != null)
  296. {
  297. if (evaluationCollegeScore != null)
  298. {
  299. evaluationStaffScore.TotalScore = Math.Round(((evaluationStudentScore.TotalScore ?? 0) * (decimal)0.7) + ((evaluationCollegeScore.TotalScore ?? 0) * (decimal)0.3), 2, MidpointRounding.AwayFromZero);
  300. }
  301. else
  302. {
  303. evaluationStaffScore.TotalScore = Math.Round(((evaluationStudentScore.TotalScore ?? 0) * (decimal)0.7), 2, MidpointRounding.AwayFromZero);
  304. }
  305. }
  306. else
  307. {
  308. if (evaluationCollegeScore != null)
  309. {
  310. evaluationStaffScore.TotalScore = Math.Round(((evaluationCollegeScore.TotalScore ?? 0) * (decimal)0.3), 2, MidpointRounding.AwayFromZero);
  311. }
  312. else
  313. {
  314. evaluationStaffScore.TotalScore = 0;
  315. }
  316. }
  317. SetModifyStatus(evaluationStaffScore);
  318. evaluationStaffScoreUpList.Add(evaluationStaffScore);
  319. if (evaluationStaffScore.EM_EvaluationStaffScoreDetail.Count() > 0)
  320. {
  321. evaluationStaffScoreIDDelList.Add(evaluationStaffScore.EvaluationStaffScoreID);
  322. }
  323. var newEvaStuStaffScoreDetail = new EM_EvaluationStaffScoreDetail();
  324. newEvaStuStaffScoreDetail.EvaluationStaffScoreDetailID = Guid.NewGuid();
  325. newEvaStuStaffScoreDetail.EvaluationStaffScoreID = evaluationStaffScore.EvaluationStaffScoreID;
  326. newEvaStuStaffScoreDetail.EvaluationScoreTypeID = (int)EMIS.ViewModel.EM_EvaluationScoreType.StudentScore;
  327. if (evaluationStudentScore != null)
  328. {
  329. newEvaStuStaffScoreDetail.Score = evaluationStudentScore.TotalScore;
  330. }
  331. else
  332. {
  333. newEvaStuStaffScoreDetail.Score = 0;
  334. }
  335. SetNewStatus(newEvaStuStaffScoreDetail);
  336. evaluationStaffScoreDetailInList.Add(newEvaStuStaffScoreDetail);
  337. var newEvaColStaffScoreDetail = new EM_EvaluationStaffScoreDetail();
  338. newEvaColStaffScoreDetail.EvaluationStaffScoreDetailID = Guid.NewGuid();
  339. newEvaColStaffScoreDetail.EvaluationStaffScoreID = evaluationStaffScore.EvaluationStaffScoreID;
  340. newEvaColStaffScoreDetail.EvaluationScoreTypeID = (int)EMIS.ViewModel.EM_EvaluationScoreType.CollegeScore;
  341. if (evaluationCollegeScore != null)
  342. {
  343. newEvaColStaffScoreDetail.Score = evaluationCollegeScore.TotalScore;
  344. }
  345. else
  346. {
  347. newEvaColStaffScoreDetail.Score = 0;
  348. }
  349. SetNewStatus(newEvaColStaffScoreDetail);
  350. evaluationStaffScoreDetailInList.Add(newEvaColStaffScoreDetail);
  351. upSuccess++;
  352. }
  353. }
  354. using (TransactionScope ts = new TransactionScope())
  355. {
  356. UnitOfWork.Delete<EM_EvaluationStaffScoreDetail>(x => evaluationStaffScoreIDDelList.Contains(x.EvaluationStaffScoreID));
  357. UnitOfWork.BulkInsert(evaluationStaffScoreInList);
  358. if (evaluationStaffScoreUpList != null && evaluationStaffScoreUpList.Count() > 0)
  359. {
  360. UnitOfWork.BatchUpdate(evaluationStaffScoreUpList);
  361. }
  362. UnitOfWork.BulkInsert(evaluationStaffScoreDetailInList);
  363. ts.Complete();
  364. }
  365. if (inSuccess > 0 && upSuccess <= 0)
  366. {
  367. tipMessage = inSuccess + "条";
  368. }
  369. else
  370. {
  371. tipMessage = inSuccess + "条,更新成功" + upSuccess + "条";
  372. }
  373. return tipMessage;
  374. }
  375. catch (Exception ex)
  376. {
  377. throw new Exception(ex.Message);
  378. }
  379. }
  380. /// <summary>
  381. /// 编辑
  382. /// </summary>
  383. /// <param name="evaluationStaffScoreView"></param>
  384. public void EvaluationStaffScoreEdit(EvaluationStaffScoreView evaluationStaffScoreView)
  385. {
  386. try
  387. {
  388. var evaluationStaffScoreVerify = EvaluationStaffScoreDAL.Value.EvaluationStaffScoreRepository.GetList(x => x.EvaluationStaffScoreID != evaluationStaffScoreView.EvaluationStaffScoreID && x.SchoolyearID == evaluationStaffScoreView.SchoolyearID
  389. && x.UserID == evaluationStaffScoreView.UserID && x.CoursematerialID == evaluationStaffScoreView.CoursematerialID && x.DepartmentID == evaluationStaffScoreView.DepartmentID).SingleOrDefault();
  390. if (evaluationStaffScoreVerify == null)
  391. {
  392. var evaluationStaffScoreInList = new List<EM_EvaluationStaffScore>();
  393. var evaluationStaffScoreUpList = new List<EM_EvaluationStaffScore>();
  394. var evaluationStaffScoreDetailInList = new List<EM_EvaluationStaffScoreDetail>();
  395. List<Guid?> evaluationStaffScoreIDDelList = new List<Guid?>();
  396. if (evaluationStaffScoreView.EvaluationStaffScoreID != Guid.Empty)
  397. {
  398. var evaluationStaffScore = EvaluationStaffScoreDAL.Value.EvaluationStaffScoreRepository.GetList(x => x.EvaluationStaffScoreID == evaluationStaffScoreView.EvaluationStaffScoreID).SingleOrDefault();
  399. if (evaluationStaffScore == null)
  400. {
  401. throw new Exception("数据有误,请核查。");
  402. }
  403. else
  404. {
  405. //表示修改
  406. evaluationStaffScore.SchoolyearID = evaluationStaffScoreView.SchoolyearID;
  407. evaluationStaffScore.UserID = evaluationStaffScoreView.UserID;
  408. evaluationStaffScore.CoursematerialID = evaluationStaffScoreView.CoursematerialID;
  409. evaluationStaffScore.DepartmentID = evaluationStaffScoreView.DepartmentID;
  410. evaluationStaffScore.TotalScore = evaluationStaffScoreView.TotalScore;
  411. evaluationStaffScore.Remark = evaluationStaffScoreView.Remark;
  412. SetModifyStatus(evaluationStaffScore);
  413. evaluationStaffScoreUpList.Add(evaluationStaffScore);
  414. evaluationStaffScoreIDDelList.Add(evaluationStaffScore.EvaluationStaffScoreID);
  415. var newEvaStuStaffScoreDetail = new EM_EvaluationStaffScoreDetail();
  416. newEvaStuStaffScoreDetail.EvaluationStaffScoreDetailID = Guid.NewGuid();
  417. newEvaStuStaffScoreDetail.EvaluationStaffScoreID = evaluationStaffScore.EvaluationStaffScoreID;
  418. newEvaStuStaffScoreDetail.EvaluationScoreTypeID = (int)EMIS.ViewModel.EM_EvaluationScoreType.StudentScore;
  419. newEvaStuStaffScoreDetail.Score = evaluationStaffScoreView.StudentScore;
  420. SetNewStatus(newEvaStuStaffScoreDetail);
  421. evaluationStaffScoreDetailInList.Add(newEvaStuStaffScoreDetail);
  422. var newEvaColStaffScoreDetail = new EM_EvaluationStaffScoreDetail();
  423. newEvaColStaffScoreDetail.EvaluationStaffScoreDetailID = Guid.NewGuid();
  424. newEvaColStaffScoreDetail.EvaluationStaffScoreID = evaluationStaffScore.EvaluationStaffScoreID;
  425. newEvaColStaffScoreDetail.EvaluationScoreTypeID = (int)EMIS.ViewModel.EM_EvaluationScoreType.CollegeScore;
  426. newEvaColStaffScoreDetail.Score = evaluationStaffScoreView.CollegeScore;
  427. SetNewStatus(newEvaColStaffScoreDetail);
  428. evaluationStaffScoreDetailInList.Add(newEvaColStaffScoreDetail);
  429. }
  430. }
  431. else
  432. {
  433. //表示新增
  434. var newEvaluationStaffScore = new EM_EvaluationStaffScore();
  435. newEvaluationStaffScore.EvaluationStaffScoreID = Guid.NewGuid();
  436. newEvaluationStaffScore.SchoolyearID = evaluationStaffScoreView.SchoolyearID;
  437. newEvaluationStaffScore.UserID = evaluationStaffScoreView.UserID;
  438. newEvaluationStaffScore.CoursematerialID = evaluationStaffScoreView.CoursematerialID;
  439. newEvaluationStaffScore.DepartmentID = evaluationStaffScoreView.DepartmentID;
  440. newEvaluationStaffScore.TotalScore = evaluationStaffScoreView.TotalScore;
  441. newEvaluationStaffScore.Remark = evaluationStaffScoreView.Remark;
  442. SetNewStatus(newEvaluationStaffScore);
  443. evaluationStaffScoreInList.Add(newEvaluationStaffScore);
  444. var newEvaStuStaffScoreDetail = new EM_EvaluationStaffScoreDetail();
  445. newEvaStuStaffScoreDetail.EvaluationStaffScoreDetailID = Guid.NewGuid();
  446. newEvaStuStaffScoreDetail.EvaluationStaffScoreID = newEvaluationStaffScore.EvaluationStaffScoreID;
  447. newEvaStuStaffScoreDetail.EvaluationScoreTypeID = (int)EMIS.ViewModel.EM_EvaluationScoreType.StudentScore;
  448. newEvaStuStaffScoreDetail.Score = evaluationStaffScoreView.StudentScore;
  449. SetNewStatus(newEvaStuStaffScoreDetail);
  450. evaluationStaffScoreDetailInList.Add(newEvaStuStaffScoreDetail);
  451. var newEvaColStaffScoreDetail = new EM_EvaluationStaffScoreDetail();
  452. newEvaColStaffScoreDetail.EvaluationStaffScoreDetailID = Guid.NewGuid();
  453. newEvaColStaffScoreDetail.EvaluationStaffScoreID = newEvaluationStaffScore.EvaluationStaffScoreID;
  454. newEvaColStaffScoreDetail.EvaluationScoreTypeID = (int)EMIS.ViewModel.EM_EvaluationScoreType.CollegeScore;
  455. newEvaColStaffScoreDetail.Score = evaluationStaffScoreView.CollegeScore;
  456. SetNewStatus(newEvaColStaffScoreDetail);
  457. evaluationStaffScoreDetailInList.Add(newEvaColStaffScoreDetail);
  458. }
  459. using (TransactionScope ts = new TransactionScope())
  460. {
  461. UnitOfWork.Delete<EM_EvaluationStaffScoreDetail>(x => evaluationStaffScoreIDDelList.Contains(x.EvaluationStaffScoreID));
  462. UnitOfWork.BulkInsert(evaluationStaffScoreInList);
  463. if (evaluationStaffScoreUpList != null && evaluationStaffScoreUpList.Count() > 0)
  464. {
  465. UnitOfWork.BatchUpdate(evaluationStaffScoreUpList);
  466. }
  467. UnitOfWork.BulkInsert(evaluationStaffScoreDetailInList);
  468. ts.Complete();
  469. }
  470. }
  471. else
  472. {
  473. throw new Exception("已存在相同的教师评分信息(学年学期、学生信息、课程信息唯一),请核查。");
  474. }
  475. }
  476. catch (Exception ex)
  477. {
  478. throw new Exception(ex.Message);
  479. }
  480. }
  481. /// <summary>
  482. /// 删除
  483. /// </summary>
  484. /// <param name="evaluationStaffScoreIDs"></param>
  485. /// <returns></returns>
  486. public bool EvaluationStaffScoreDelete(List<Guid?> evaluationStaffScoreIDs)
  487. {
  488. try
  489. {
  490. using (TransactionScope ts = new TransactionScope())
  491. {
  492. UnitOfWork.Delete<EM_EvaluationStaffScoreDetail>(x => evaluationStaffScoreIDs.Contains(x.EvaluationStaffScoreID));
  493. UnitOfWork.Delete<EM_EvaluationStaffScore>(x => evaluationStaffScoreIDs.Contains(x.EvaluationStaffScoreID));
  494. ts.Complete();
  495. return true;
  496. }
  497. }
  498. catch (Exception)
  499. {
  500. throw;
  501. }
  502. }
  503. }
  504. }