LevelScoreServices.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.ScoreManage;
  6. using EMIS.ViewModel.ScoreManage;
  7. using EMIS.Entities;
  8. using System.Linq.Expressions;
  9. using EMIS.ViewModel;
  10. using Bowin.Common.Linq;
  11. using Bowin.Common.Linq.Entity;
  12. using Bowin.Common.DataTime;
  13. using Bowin.Common.Utility;
  14. using System.Text.RegularExpressions;
  15. using EMIS.DataLogic.Repositories;
  16. using EMIS.DataLogic.ExaminationApply;
  17. using EMIS.DataLogic.Common.CalendarManage;
  18. using EMIS.ViewModel.CacheManage;
  19. namespace EMIS.CommonLogic.ScoreManage
  20. {
  21. public class LevelScoreServices : BaseServices, ILevelScoreServices
  22. {
  23. public LevelScoreDAL levelScoreDAL { get; set; }
  24. public StudentRepository studentRepository { get; set; }
  25. public ExaminationSubjectDAL examinationSubjectDAL { get; set; }
  26. public SchoolYearDAL schoolYearDAL { get; set; }
  27. public LevelSettingDAL levelSettingDAL { get; set; }
  28. //学生版过级成绩
  29. public Bowin.Common.Linq.Entity.IGridResultSet<LevelScoreView> GetStudentLevelScoreGrid(ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? ExaminationSubjectID,Guid userId, int pageIndex, int pageSize)
  30. {
  31. Expression<Func<ER_LevelScore, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  32. exp=(x=>x.UserID==userId);
  33. var query = levelScoreDAL.GetLevelScoreViewQueryable(exp);
  34. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  35. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  36. //query = query.GroupBy(x => new { x.LevelScoreID, x.SchoolyearCode, x.ExaminationSubjectName,x.ClassmajorName })
  37. // .Select(g => new
  38. // {
  39. // LevelScoreID = g.Key.LevelScoreID,
  40. // SchoolyearCode = g.Key.SchoolyearCode,
  41. // ExaminationSubjectName = g.Key.ExaminationSubjectName,
  42. // ClassmajorName = g.Key.ClassmajorName
  43. // });
  44. var queryLevelName = levelSettingDAL.GetLevelSettingViewQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  45. var result = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeName).ThenBy(x => x.ClassmajorName).ThenBy(x => x.LoginID).ToGridResultSet<LevelScoreView>(pageIndex, pageSize);
  46. result.rows.ForEach(x =>
  47. x.LevelName = queryLevelName.Where(t =>
  48. t.MaxScore >= x.TotalScore &&
  49. t.MinScore <= x.TotalScore &&
  50. t.ExaminationSubjectName == x.ExaminationSubjectName).OrderByDescending(o => o.MaxScore).ThenByDescending(o => o.MinScore).Select(w => w.LevelName).FirstOrDefault());
  51. //return (query).OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.ExaminationSubjectName).ThenByDescending(x => x.ClassmajorName).ToGridResultSet<LevelScoreView>(pageIndex, pageSize);
  52. return result;
  53. }
  54. //教师版过级成绩
  55. public Bowin.Common.Linq.Entity.IGridResultSet<LevelScoreView> GetLevelScoreGrid(ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? collegeID, int? Years, int? standardID, Guid? ClassmajorID, Guid? ExaminationSubjectID, int? learningformID, int? education, string LearnSystem, Guid? levelSettingID, int pageIndex, int pageSize)
  56. {
  57. Expression<Func<ER_LevelScore, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  58. if (learningformID.HasValue)
  59. exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID);
  60. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  61. {
  62. var LearnSystems = Convert.ToDecimal(LearnSystem);
  63. exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
  64. }
  65. if (education.HasValue)
  66. {
  67. exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
  68. }
  69. if (schoolYearID.HasValue)
  70. {
  71. exp = exp.And(x => x.SchoolyearID == schoolYearID);
  72. }
  73. if (Years.HasValue)
  74. {
  75. exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == Years);
  76. }
  77. if (collegeID.HasValue)
  78. {
  79. exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CF_College.CollegeID == collegeID);
  80. }
  81. if (standardID.HasValue)
  82. {
  83. exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  84. }
  85. if (ClassmajorID.HasValue)
  86. {
  87. exp = exp.And(x => x.CF_Student.CF_Classmajor.ClassmajorID == ClassmajorID);
  88. }
  89. LevelSettingView levelSetting = null;
  90. if (levelSettingID.HasValue)
  91. {
  92. levelSetting = levelSettingDAL.GetLevelSettingViewQueryable(x => x.LevelSettingID == levelSettingID).FirstOrDefault();
  93. }
  94. var query = levelScoreDAL.GetLevelScoreViewQueryable(exp);
  95. if (ExaminationSubjectID.HasValue)
  96. {
  97. query = query.Where(x => x.ExaminationSubjectID == ExaminationSubjectID);
  98. if (levelSetting != null)
  99. {
  100. query = query.Where(x => x.TotalScore >= levelSetting.MinScore && x.TotalScore <= levelSetting.MaxScore);
  101. }
  102. }
  103. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  104. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  105. //query = query.GroupBy(x => new { x.LevelScoreID, x.SchoolyearCode, x.ExaminationSubjectName,x.ClassmajorName })
  106. // .Select(g => new
  107. // {
  108. // LevelScoreID = g.Key.LevelScoreID,
  109. // SchoolyearCode = g.Key.SchoolyearCode,
  110. // ExaminationSubjectName = g.Key.ExaminationSubjectName,
  111. // ClassmajorName = g.Key.ClassmajorName
  112. // });
  113. var queryLevelName = levelSettingDAL.GetLevelSettingViewQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  114. var result = GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeName).ThenBy(x => x.ClassmajorName).ThenBy(x => x.LoginID).ToGridResultSet<LevelScoreView>(pageIndex, pageSize);
  115. result.rows.ForEach(x =>
  116. x.LevelName = queryLevelName.Where(t =>
  117. t.MaxScore >= x.TotalScore &&
  118. t.MinScore <= x.TotalScore &&
  119. t.ExaminationSubjectName == x.ExaminationSubjectName).OrderByDescending(o => o.MaxScore).ThenByDescending(o => o.MinScore).Select(w => w.LevelName).FirstOrDefault());
  120. //return (query).OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.ExaminationSubjectName).ThenByDescending(x => x.ClassmajorName).ToGridResultSet<LevelScoreView>(pageIndex, pageSize);
  121. return result;
  122. }
  123. public List<LevelScoreView> GetLevelScoreList(ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? collegeID, int? Years, int? standardID, Guid? ClassmajorID, Guid? ExaminationSubjectID,int? learningformID,int? education,string LearnSystem)
  124. {
  125. Expression<Func<ER_LevelScore, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  126. if (learningformID.HasValue)
  127. exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID);
  128. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  129. {
  130. var LearnSystems = Convert.ToDecimal(LearnSystem);
  131. exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
  132. }
  133. if (education.HasValue)
  134. {
  135. exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
  136. }
  137. var query = levelScoreDAL.GetLevelScoreViewQueryable(exp);
  138. if (schoolYearID.HasValue)
  139. query = query.Where(x => x.SchoolyearID == schoolYearID);
  140. if (Years.HasValue)
  141. query = query.Where(x => x.Years == Years);
  142. if (collegeID.HasValue)
  143. query = query.Where(x => x.CollegeID == collegeID);
  144. if (standardID.HasValue)
  145. query = query.Where(x => x.StandardID == standardID);
  146. if (ClassmajorID.HasValue)
  147. query = query.Where(x => x.ClassmajorID == ClassmajorID);
  148. if (ExaminationSubjectID.HasValue)
  149. query = query.Where(x => x.ExaminationSubjectID == ExaminationSubjectID);
  150. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  151. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  152. var queryLevelName = levelSettingDAL.GetLevelSettingViewQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  153. var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeName).ThenBy(x => x.ClassmajorName).ThenBy(x => x.LoginID).ToList();
  154. result.ForEach(x =>
  155. x.LevelName = queryLevelName.Where(t =>
  156. t.MaxScore >= x.TotalScore &&
  157. t.MinScore <= x.TotalScore &&
  158. t.ExaminationSubjectName == x.ExaminationSubjectName).OrderByDescending(o => o.MaxScore).ThenByDescending(o => o.MinScore).Select(w => w.LevelName).FirstOrDefault());
  159. return result;
  160. //return (query).OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.ExaminationSubjectName).ThenByDescending(x => x.ClassmajorName).ToList();
  161. }
  162. public LevelScoreView GetLevelScoreView(Guid? LevelScoreID)
  163. {
  164. var query = levelScoreDAL.GetLevelScoreViewQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).Where(x => x.LevelScoreID == LevelScoreID).FirstOrDefault();
  165. return query;
  166. }
  167. public ER_LevelScore GetLevelScoreEntity(Guid? LevelScoreID)
  168. {
  169. return levelScoreDAL.levelScoreRepository.GetSingle(x => x.LevelScoreID == LevelScoreID);
  170. }
  171. public void Save(LevelScoreView LevelScoreView)
  172. {
  173. try
  174. {
  175. //同一学期同一学号同一科目重复。
  176. ER_LevelScore levelScoreRepeat = levelScoreDAL.levelScoreRepository.Entities.Where(x =>
  177. x.SchoolyearID == LevelScoreView.SchoolyearID &&
  178. x.UserID == LevelScoreView.UserID&&
  179. x.ExaminationSubjectID == LevelScoreView.ExaminationSubjectID).FirstOrDefault();
  180. ER_LevelScore LevelScoreEntity = null;
  181. if (LevelScoreView.LevelScoreID == null || LevelScoreView.LevelScoreID == Guid.Empty)
  182. {
  183. if (levelScoreRepeat!=null)
  184. throw new Exception("已存在该学生成绩,请核查。");
  185. LevelScoreEntity = new ER_LevelScore();
  186. LevelScoreEntity.LevelScoreID = Guid.NewGuid();
  187. SetNewStatus(LevelScoreEntity);
  188. UnitOfWork.Add(LevelScoreEntity);
  189. }
  190. else
  191. {
  192. if (levelScoreRepeat != null && levelScoreRepeat.LevelScoreID != LevelScoreView.LevelScoreID)
  193. throw new Exception("已存在该学生成绩,请核查。");
  194. LevelScoreEntity = GetLevelScoreEntity(LevelScoreView.LevelScoreID);
  195. if (LevelScoreEntity == null)
  196. throw new Exception("未找到相对应的等级成绩!");
  197. SetModifyStatus(LevelScoreEntity);
  198. }
  199. LevelScoreEntity.ScoreNo = LevelScoreView.ScoreNo;
  200. LevelScoreEntity.ExaminationSubjectID = LevelScoreView.ExaminationSubjectID;
  201. LevelScoreEntity.SchoolyearID = LevelScoreView.SchoolyearID;
  202. LevelScoreEntity.ExaminationDate = LevelScoreView.ExaminationDate;
  203. //LevelScoreEntity.ValidDate = LevelScoreView.ValidDate;
  204. LevelScoreEntity.UserID = LevelScoreView.UserID;
  205. LevelScoreEntity.TotalScore = LevelScoreView.TotalScore;
  206. LevelScoreEntity.Remark = LevelScoreView.Remark;
  207. UnitOfWork.Commit();
  208. }
  209. catch (Exception)
  210. {
  211. throw;
  212. }
  213. }
  214. public void Delete(IList<Guid?> LevelScoreID)
  215. {
  216. if (LevelScoreID.Count > 0)
  217. {
  218. UnitOfWork.Delete<ER_LevelScore>(x => LevelScoreID.Contains(x.LevelScoreID));
  219. }
  220. }
  221. public void LevelScoreImport(Dictionary<string, string> cellheader, out int OkCount, out List<LevelScoreView> errdataList, out int ErrCount, string sourcePhysicalPath)
  222. {
  223. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  224. List<LevelScoreView> errList = new List<LevelScoreView>(); //错误数据行
  225. DataTimeHelper dth = new DataTimeHelper();
  226. #region 1.1解析文件,存放到一个List集合里
  227. // 1.1解析文件,存放到一个List集合里
  228. cellheader.Remove("ErrorMessage");//去除异常列、导入操作不需要
  229. List<LevelScoreView> enlist =
  230. NpoiExcelHelper.ExcelToEntityList<LevelScoreView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
  231. cellheader.Add("ErrorMessage", "错误信息");//还原字典项
  232. #endregion
  233. #region 1.2 将Excel数据写入数据库中
  234. #region 1.2.1 对List集合进行有效性校验
  235. if (enlist.Count() <= 0)
  236. {
  237. throw new Exception("请填写Excel模板信息数据。");
  238. }
  239. #region 1.2.1.1数据逻辑验证
  240. var loginIDList = enlist.Select(x => x.LoginID).Distinct().ToList();
  241. var schoolyearCodeList = enlist.Select(x => x.SchoolyearCode).Distinct().ToList();
  242. var subjectNameList = enlist.Select(x => x.ExaminationSubjectName).Distinct().ToList();
  243. var studentList = studentRepository.GetList(x => loginIDList.Contains(x.Sys_User.LoginID), (x => x.Sys_User)).ToList();
  244. var schoolyearList = schoolYearDAL.schoolyearRepository.GetList(x => schoolyearCodeList.Contains(x.Code)).ToList();
  245. var subjectList = examinationSubjectDAL.ExaminationSubjectRepository.GetList(x => subjectNameList.Contains(x.Name)).ToList();
  246. var levelScoreKeyList = (from ls in enlist.GroupBy(x => new { x.SchoolyearCode, x.LoginID, x.ExaminationSubjectName })
  247. join u in studentList on ls.Key.LoginID equals u.Sys_User.LoginID
  248. join sy in schoolyearList on ls.Key.SchoolyearCode equals sy.Code
  249. join s in subjectList on ls.Key.ExaminationSubjectName equals s.Name
  250. select new { sy.SchoolyearID, u.UserID, s.ExaminationSubjectID }).ToList();
  251. var dbLevelScoreList = levelScoreDAL.levelScoreRepository.Entities.SelectByKeys(levelScoreKeyList);
  252. for (int i = 0; i < enlist.Count; i++)
  253. {
  254. LevelScoreView en = enlist[i];
  255. string errorMsgStr = "第" + (i + 1) + "行数据检测异常:";
  256. bool isHaveNoInputValue = false; // 是否含有未输入项
  257. #region 检测必填项是否必填
  258. if (string.IsNullOrEmpty(en.LoginID))
  259. {
  260. errorMsgStr += "学号不能为空;";
  261. en.ErrorMessage = errorMsgStr;
  262. isHaveNoInputValue = true;
  263. }
  264. if (string.IsNullOrEmpty(en.ExaminationSubjectName))
  265. {
  266. errorMsgStr += "考试科目不能为空;";
  267. en.ErrorMessage = errorMsgStr;
  268. isHaveNoInputValue = true;
  269. }
  270. if (string.IsNullOrEmpty(en.SchoolyearCode))
  271. {
  272. errorMsgStr += "学年学期不能为空;";
  273. en.ErrorMessage = errorMsgStr;
  274. isHaveNoInputValue = true;
  275. }
  276. if (en.TotalScore==null)
  277. {
  278. errorMsgStr += "总成绩不能为空;";
  279. en.ErrorMessage = errorMsgStr;
  280. isHaveNoInputValue = true;
  281. }
  282. #endregion
  283. #region 验证数据格式
  284. //总成绩
  285. Regex reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$");
  286. if (!string.IsNullOrEmpty(en.TotalScore.ToString()))
  287. {
  288. if (!reg.IsMatch(en.TotalScore + ""))
  289. {
  290. errorMsgStr += "总成绩格式不正确;";
  291. en.ErrorMessage = errorMsgStr;
  292. isHaveNoInputValue = true;
  293. }
  294. }
  295. //考试日期
  296. //reg = new Regex(@"^[-/:0-9]+$");
  297. DateTime result;
  298. if (!string.IsNullOrEmpty(en.ExaminationDateStr))
  299. {
  300. if (!DateTime.TryParse(en.ExaminationDateStr, out result))
  301. {
  302. errorMsgStr += "考试日期格式不正确;";
  303. en.ErrorMessage = errorMsgStr;
  304. isHaveNoInputValue = true;
  305. }
  306. }
  307. //有效日期
  308. //reg = new Regex(@"^[-/:0-9]+$");
  309. if (!string.IsNullOrEmpty(en.ValidDateStr))
  310. {
  311. if (!DateTime.TryParse(en.ValidDateStr, out result))
  312. {
  313. errorMsgStr += "有效日期格式不正确;";
  314. en.ErrorMessage = errorMsgStr;
  315. isHaveNoInputValue = true;
  316. }
  317. }
  318. #endregion
  319. #region 信息是否存在
  320. if (!string.IsNullOrEmpty(en.LoginID))
  321. {
  322. CF_Student student = studentList.Where(x => x.Sys_User.LoginID == en.LoginID).FirstOrDefault();
  323. if (student == null)
  324. {
  325. errorMsgStr += "该学号的学生信息不存在;";
  326. en.ErrorMessage = errorMsgStr;
  327. isHaveNoInputValue = true;
  328. }
  329. else
  330. en.UserID = student.UserID;
  331. }
  332. if (!string.IsNullOrEmpty(en.SchoolyearCode))
  333. {
  334. EMIS.Entities.CF_Schoolyear Schoolyear = schoolyearList.Where(x => x.Code == en.SchoolyearCode).FirstOrDefault();
  335. if (Schoolyear == null)
  336. {
  337. errorMsgStr += "该学年学期信息不存在;";
  338. en.ErrorMessage = errorMsgStr;
  339. isHaveNoInputValue = true;
  340. }
  341. else
  342. en.SchoolyearID = Schoolyear.SchoolyearID;
  343. }
  344. if ( !string.IsNullOrEmpty(en.ExaminationSubjectName))
  345. {
  346. EX_ExaminationSubject examinationSubject = subjectList.Where(x => x.Name == en.ExaminationSubjectName).FirstOrDefault();
  347. if (examinationSubject == null)
  348. {
  349. errorMsgStr += "该考试科目信息不存在;";
  350. en.ErrorMessage = errorMsgStr;
  351. isHaveNoInputValue = true;
  352. }
  353. else
  354. en.ExaminationSubjectID = examinationSubject.ExaminationSubjectID;
  355. }
  356. //验证同一学期同一学号同一科目重复
  357. if (en.ExaminationSubjectID != null && en.SchoolyearID != null && en.UserID != null)
  358. {
  359. //导入的信息中的重复
  360. var enlistRepeat = enlist.Where(x =>
  361. x.SchoolyearID == en.SchoolyearID &&
  362. x.UserID == en.UserID &&
  363. x.ExaminationSubjectID == en.ExaminationSubjectID);
  364. if (enlistRepeat != null && enlistRepeat.Count() > 1)
  365. {
  366. errorMsgStr += "导入的信息中该学生成绩有重复,已导入其中一条;";
  367. en.ErrorMessage = errorMsgStr;
  368. isHaveNoInputValue = true;
  369. }
  370. //导入信息和数据库的重复
  371. ER_LevelScore levelScoreRepeat = dbLevelScoreList.Where(x =>
  372. x.SchoolyearID == en.SchoolyearID &&
  373. x.UserID == en.UserID &&
  374. x.ExaminationSubjectID == en.ExaminationSubjectID).FirstOrDefault();
  375. if (levelScoreRepeat != null)
  376. {
  377. errorMsgStr += "已存在该学生成绩;";
  378. en.ErrorMessage = errorMsgStr;
  379. isHaveNoInputValue = true;
  380. }
  381. }
  382. #endregion 唯一值
  383. //if (!string.IsNullOrEmpty(en.UserID.ToString()) && !string.IsNullOrEmpty(en.ExaminationSubjectID.ToString()))
  384. //{
  385. // ER_LevelScore levelScoreEnetey = levelScoreDAL.levelScoreRepository.Entities.Where(x => x.UserID == en.UserID && x.ExaminationSubjectID == en.ExaminationSubjectID).FirstOrDefault();
  386. // if (levelScoreEnetey != null)
  387. // {
  388. // errorMsgStr += "对应的学号和考试科目已经存在;";
  389. // en.ErrorMessage = errorMsgStr;
  390. // isHaveNoInputValue = true;
  391. // }
  392. //}
  393. if (isHaveNoInputValue) // 若必填项有值未填
  394. {
  395. en.IsExcelVaildateOK = false;
  396. en.ErrorMessage = errorMsgStr;
  397. errList.Add(en);
  398. errorMsg.AppendLine(errorMsgStr);
  399. }
  400. }
  401. #endregion
  402. // TODO:其他检测
  403. #region 1.2.1.3 循环写入验证成功的数据
  404. List<ER_LevelScore> levelScoreList = new List<ER_LevelScore>();
  405. for (int i = 0; i < enlist.Count; i++)
  406. {
  407. LevelScoreView enA = enlist[i];
  408. if (enA.IsExcelVaildateOK == false) // 上面验证不通过,不进行此步验证
  409. {
  410. continue;
  411. }
  412. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  413. ER_LevelScore levelScore = new ER_LevelScore();
  414. levelScore.LevelScoreID = Guid.NewGuid();
  415. levelScore.UserID = enA.UserID;
  416. levelScore.ScoreNo = enA.ScoreNo;
  417. levelScore.ExaminationSubjectID = enA.ExaminationSubjectID;
  418. levelScore.TotalScore = enA.TotalScore;
  419. levelScore.Remark = enA.Remark;
  420. //if (!string.IsNullOrEmpty(enA.ExaminationDateStr))
  421. //levelScore.ExaminationDate = Convert.ToDateTime(dth.ToDateTimeValue(enA.ExaminationDateStr));
  422. if (!string.IsNullOrEmpty(enA.ExaminationDateStr))
  423. {
  424. if (dth.ToDateTimeValue(enA.ExaminationDateStr) != string.Empty)
  425. levelScore.ExaminationDate = Convert.ToDateTime(dth.ToDateTimeValue(enA.ExaminationDateStr));
  426. else
  427. levelScore.ExaminationDate = Convert.ToDateTime(enA.ExaminationDateStr);
  428. }
  429. //levelScore.ExaminationDate = enA.ExaminationDateStr;
  430. //levelScore.ExaminationDate = Convert.ToDateTime(enA.ExaminationDateStr);
  431. if (!string.IsNullOrEmpty(enA.ValidDateStr))
  432. {
  433. //if (dth.ToDateTimeValue(enA.ValidDateStr) != string.Empty)
  434. // levelScore.ValidDate = Convert.ToDateTime(dth.ToDateTimeValue(enA.ValidDateStr));
  435. //else
  436. // levelScore.ValidDate = Convert.ToDateTime(enA.ValidDateStr);
  437. }
  438. levelScore.SchoolyearID = enA.SchoolyearID;
  439. SetNewStatus(levelScore);
  440. levelScoreList.Add(levelScore);
  441. }
  442. #endregion
  443. UnitOfWork.BulkInsert(levelScoreList);//统一写入
  444. #endregion
  445. #endregion
  446. #region 1.3 返回各项数据值
  447. OkCount = enlist.Distinct().Count() - errList.Distinct().Count();//共条数减去失败条数
  448. errdataList = errList.Distinct().ToList();
  449. ErrCount = errList.Distinct().Count();
  450. #endregion
  451. }
  452. }
  453. }