ExaminationSubjectServices.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using Bowin.Common.Linq;
  7. using Bowin.Common.Linq.Entity;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. using EMIS.DataLogic.ExaminationApply;
  11. using EMIS.ViewModel.ExaminationApply;
  12. using Bowin.Common.Utility;
  13. using System.Text.RegularExpressions;
  14. namespace EMIS.CommonLogic.ExaminationApply
  15. {
  16. public class ExaminationSubjectServices : BaseServices, IExaminationSubjectServices
  17. {
  18. public ExaminationSubjectDAL ExaminationSubjectDAL { get; set; }
  19. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.ExaminationApply.ExaminationSubjectView> GetExaminationSubjectViewList(ViewModel.ConfiguretView examinationSubjectView,
  20. Guid? examinationTypeID, Guid? examinationSubjectID, Guid? schoolYearID, int pageIndex, int pageSize)
  21. {
  22. Expression<Func<EX_ExaminationSubject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  23. if (examinationTypeID.HasValue)
  24. {
  25. exp = exp.And(x => x.ExaminationTypeID == examinationTypeID);
  26. }
  27. //要排除的科目,考试科目的要求通过科目下拉,一般排除当前科目,如英语四级选择要求通过科目时,不能选择英语四级
  28. if (examinationSubjectID.HasValue)
  29. {
  30. exp = exp.And(x => x.ExaminationSubjectID != examinationSubjectID);
  31. }
  32. if (schoolYearID.HasValue)
  33. {
  34. exp = exp.And(x => x.SchoolyearID == schoolYearID);
  35. }
  36. var q = ExaminationSubjectDAL.GetExaminationSubjectView(exp);
  37. if (!string.IsNullOrEmpty(examinationSubjectView.ConditionValue) && !string.IsNullOrEmpty(examinationSubjectView.Attribute))
  38. q = q.DynamicWhere(examinationSubjectView.Attribute, examinationSubjectView.Condition, examinationSubjectView.ConditionValue);
  39. return q.OrderBy(x => x.Name).ToGridResultSet<ExaminationSubjectView>(pageIndex, pageSize);
  40. }
  41. public IList<ViewModel.ExaminationApply.ExaminationSubjectView> GetExaminationSubjectViewList(ViewModel.ConfiguretView examinationSubjectView, Guid? examinationTypeID, Guid? examinationSubjectID)
  42. {
  43. Expression<Func<EX_ExaminationSubject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  44. if (examinationTypeID.HasValue)
  45. {
  46. exp = exp.And(x => x.ExaminationTypeID == examinationTypeID);
  47. }
  48. //要排除的科目,考试科目的要求通过科目下拉,一般排除当前科目,如英语四级选择要求通过科目时,不能选择英语四级
  49. if (examinationSubjectID.HasValue)
  50. {
  51. exp = exp.And(x => x.ExaminationSubjectID != examinationSubjectID);
  52. }
  53. var q = ExaminationSubjectDAL.GetExaminationSubjectView(exp);
  54. if (!string.IsNullOrEmpty(examinationSubjectView.ConditionValue) && !string.IsNullOrEmpty(examinationSubjectView.Attribute))
  55. q = q.DynamicWhere(examinationSubjectView.Attribute, examinationSubjectView.Condition, examinationSubjectView.ConditionValue);
  56. return q.OrderBy(x => x.Name).ToList();
  57. }
  58. public ViewModel.ExaminationApply.ExaminationSubjectView GetExaminationSubjectViewInfo(Guid? examinationSubjectID)
  59. {
  60. return ExaminationSubjectDAL.GetExaminationSubjectView(x => x.ExaminationSubjectID == examinationSubjectID).FirstOrDefault();
  61. }
  62. public void Save(ViewModel.ExaminationApply.ExaminationSubjectView examinationSubjectView)
  63. {
  64. if (examinationSubjectView.PreposeSubjectName == examinationSubjectView.Name)
  65. throw new Exception("考试科目和要求通过科目不能相同,请核查");
  66. if (examinationSubjectView.PreposeSubjectID!=null && examinationSubjectView.PreposeScoreLimit==null)
  67. throw new Exception("要求通过最低成绩不能为空,请核查");
  68. var examinationSubjectEntity = ExaminationSubjectDAL.ExaminationSubjectRepository.GetSingle(x => x.ExaminationSubjectID == examinationSubjectView.ExaminationSubjectID);
  69. //考试科目名字唯一
  70. var RepeatSubject= ExaminationSubjectDAL.ExaminationSubjectRepository.GetSingle(x =>
  71. //x.ExaminationTypeID == examinationSubjectView.ExaminationTypeID &&
  72. //x.ExaminationFormID == examinationSubjectView.ExaminationFormID &&
  73. //x.SchoolyearID == examinationSubjectView.SchoolyearID &&
  74. x.Name == examinationSubjectView.Name);
  75. if (examinationSubjectEntity != null)
  76. {
  77. if (RepeatSubject != null && examinationSubjectEntity.ExaminationSubjectID != RepeatSubject.ExaminationSubjectID)
  78. { //考试科目,判断考试类型、考试类别、学年学期、考试科目名称不能重复
  79. throw new Exception("已存在【" + RepeatSubject.Name + "】考试科目,请核查");
  80. }
  81. examinationSubjectEntity.ExaminationTypeID = examinationSubjectView.ExaminationTypeID;
  82. examinationSubjectEntity.SchoolyearID = examinationSubjectView.SchoolyearID;
  83. examinationSubjectEntity.ExaminationFormID = examinationSubjectView.ExaminationFormID;
  84. examinationSubjectEntity.Name = examinationSubjectView.Name;
  85. examinationSubjectEntity.PreposeSubjectID = examinationSubjectView.PreposeSubjectID;
  86. examinationSubjectEntity.PreposeScoreLimit = examinationSubjectView.PreposeScoreLimit;
  87. examinationSubjectEntity.ExaminationDate = examinationSubjectView.ExaminationDate;
  88. examinationSubjectEntity.PeopleNumLimit = examinationSubjectView.PeopleNumLimit;
  89. examinationSubjectEntity.Cost = examinationSubjectView.Cost;
  90. examinationSubjectEntity.Remark = examinationSubjectView.Remark;
  91. this.SetModifyStatus(examinationSubjectEntity);
  92. }
  93. else
  94. {
  95. if (RepeatSubject != null)
  96. { //考试科目,判断考试类型、考试类别、学年学期、名称不能重复
  97. throw new Exception("已存在【" + RepeatSubject.Name + "】考试科目,请核查");
  98. }
  99. examinationSubjectEntity = new EX_ExaminationSubject();
  100. examinationSubjectEntity.ExaminationSubjectID = Guid.NewGuid();
  101. examinationSubjectEntity.ExaminationTypeID = examinationSubjectView.ExaminationTypeID;
  102. examinationSubjectEntity.SchoolyearID = examinationSubjectView.SchoolyearID;
  103. examinationSubjectEntity.ExaminationFormID = examinationSubjectView.ExaminationFormID;
  104. examinationSubjectEntity.Name = examinationSubjectView.Name;
  105. examinationSubjectEntity.PreposeSubjectID = examinationSubjectView.PreposeSubjectID;
  106. examinationSubjectEntity.PreposeScoreLimit = examinationSubjectView.PreposeScoreLimit;
  107. examinationSubjectEntity.ExaminationDate = examinationSubjectView.ExaminationDate;
  108. examinationSubjectEntity.PeopleNumLimit = examinationSubjectView.PeopleNumLimit;
  109. examinationSubjectEntity.Cost = examinationSubjectView.Cost;
  110. examinationSubjectEntity.Remark = examinationSubjectView.Remark;
  111. this.SetNewStatus(examinationSubjectEntity);
  112. UnitOfWork.Add(examinationSubjectEntity);
  113. }
  114. UnitOfWork.Commit();
  115. }
  116. public void Delete(IList<Guid?> examinationSubjectID)
  117. {
  118. if (examinationSubjectID.Count > 0)
  119. {
  120. UnitOfWork.Delete<EX_ExaminationSubject>(x => examinationSubjectID.Contains(x.ExaminationSubjectID));
  121. }
  122. }
  123. public IList<StudentListView> GetExaminationSubjectStudentListView(ConfiguretView conditions,
  124. Guid? subjectID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID, Guid? examinationTypeID, Guid? schoolYearID,bool? IsPay)
  125. {
  126. Expression<Func<EX_ExaminationRegistration, bool>> exr = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  127. Expression<Func<EX_ExaminationSubject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  128. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  129. //if (schoolYearID.HasValue)
  130. //{
  131. // exr = exr.And(x => x.SchoolyearID == schoolYearID);
  132. //}
  133. //ExaminationSchoolyearID应该才是考试学年学期
  134. if (schoolYearID.HasValue)
  135. {
  136. exr = exr.And(x => x.ExaminationSchoolyearID == schoolYearID);
  137. }
  138. if (examinationTypeID.HasValue)
  139. {
  140. exp = exp.And(x => x.ExaminationTypeID == examinationTypeID);
  141. }
  142. if (subjectID.HasValue)
  143. {
  144. exp = exp.And(x => x.ExaminationSubjectID == subjectID.Value);
  145. }
  146. if (collegeID.HasValue)
  147. {
  148. expStudent = expStudent.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  149. }
  150. if (year.HasValue)
  151. {
  152. expStudent = expStudent.And(x => x.CF_Classmajor.CF_Grademajor.GradeID == year);
  153. }
  154. if (standardID.HasValue)
  155. {
  156. expStudent = expStudent.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  157. }
  158. if (classmajorID.HasValue)
  159. {
  160. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  161. }
  162. if (IsPay.HasValue)
  163. {
  164. if (IsPay == false)
  165. {
  166. exr = exr.And(x => x.IsPay == IsPay || x.IsPay == null);
  167. }
  168. else
  169. {
  170. exr = exr.And(x => x.IsPay == IsPay);
  171. }
  172. }
  173. var q = ExaminationSubjectDAL.GetRegistedListView(exp, expStudent, exr);
  174. if (!string.IsNullOrEmpty(conditions.ConditionValue) && !string.IsNullOrEmpty(conditions.Attribute))
  175. q = q.DynamicWhere(conditions.Attribute, conditions.Condition, conditions.ConditionValue);
  176. return GetQueryByDataRangeByCollege(q).OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.SubjectName).ThenBy(x => x.StudentNo).ToList();
  177. }
  178. IGridResultSet<StudentListView> IExaminationSubjectServices.GetExaminationSubjectStudentListView(ConfiguretView conditions,
  179. Guid? subjectID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID, Guid? examinationTypeID, Guid? schoolYearID, bool? IsPay, int pageIndex, int pageSize)
  180. {
  181. Expression<Func<EX_ExaminationRegistration, bool>> exr = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  182. Expression<Func<EX_ExaminationSubject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  183. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  184. if (schoolYearID.HasValue)
  185. {
  186. exr = exr.And(x => x.ExaminationSchoolyearID == schoolYearID);
  187. }
  188. if (examinationTypeID.HasValue)
  189. {
  190. exp = exp.And(x => x.ExaminationTypeID == examinationTypeID);
  191. }
  192. if (subjectID.HasValue)
  193. {
  194. exp = exp.And(x => x.ExaminationSubjectID == subjectID.Value);
  195. }
  196. if (collegeID.HasValue)
  197. {
  198. expStudent = expStudent.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  199. }
  200. if (year.HasValue)
  201. {
  202. expStudent = expStudent.And(x => x.CF_Classmajor.CF_Grademajor.GradeID == year);
  203. }
  204. if (standardID.HasValue)
  205. {
  206. expStudent = expStudent.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  207. }
  208. if (classmajorID.HasValue)
  209. {
  210. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  211. }
  212. if (IsPay.HasValue)
  213. {
  214. if(IsPay==false){
  215. exr = exr.And(x => x.IsPay == IsPay||x.IsPay==null);
  216. }
  217. else{
  218. exr = exr.And(x => x.IsPay == IsPay);
  219. }
  220. }
  221. var q = ExaminationSubjectDAL.GetRegistedListView(exp, expStudent,exr);
  222. if (!string.IsNullOrEmpty(conditions.ConditionValue) && !string.IsNullOrEmpty(conditions.Attribute))
  223. q = q.DynamicWhere(conditions.Attribute, conditions.Condition, conditions.ConditionValue);
  224. return GetQueryByDataRangeByCollege(q).OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.SubjectName).ThenBy(x => x.StudentNo).ToGridResultSet(pageIndex, pageSize);
  225. }
  226. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.ExaminationApply.ExaminationSubjectView> GetExaminationSubjectNameViewList(ViewModel.ConfiguretView examinationSubjectView,
  227. int pageIndex, int pageSize)
  228. {
  229. Expression<Func<EX_ExaminationSubject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  230. var q = ExaminationSubjectDAL.GetExaminationSubjectView1(exp);
  231. if (!string.IsNullOrEmpty(examinationSubjectView.ConditionValue) && !string.IsNullOrEmpty(examinationSubjectView.Attribute))
  232. q = q.DynamicWhere(examinationSubjectView.Attribute, examinationSubjectView.Condition, examinationSubjectView.ConditionValue);
  233. return q.OrderBy(x=>x.Name).ToGridResultSet<ExaminationSubjectView>(pageIndex, pageSize);
  234. }
  235. /// <summary>
  236. /// 考试报名班级学生统计
  237. /// </summary>
  238. /// <param name="subjectID"></param>
  239. /// <param name="schoolYearID"></param>
  240. /// <param name="pageIndex"></param>
  241. /// <param name="pageSize"></param>
  242. /// <returns></returns>
  243. public IGridResultSet<ExaminationClassStudentStatisticsView> GetExaminationSubjectClassStudentStatisticsListView(Guid? subjectID, int? schoolYear, Guid? schoolYearID, int pageIndex, int pageSize, Guid? campusID, Guid? collegeID, Guid? classmajorID, int? standardID)
  244. {
  245. Expression<Func<EX_ExaminationRegistration, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  246. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  247. if (campusID.HasValue)
  248. expStudent = expStudent.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CF_College.CampusID == campusID);
  249. if (collegeID.HasValue)
  250. expStudent = expStudent.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  251. if (classmajorID.HasValue)
  252. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  253. if (standardID.HasValue)
  254. expStudent = expStudent.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  255. if(schoolYear.HasValue&&schoolYear!=-1)
  256. {
  257. expStudent = expStudent.And(x => x.CF_Classmajor.CF_Grademajor.GradeID == schoolYear);
  258. }
  259. if (schoolYearID.HasValue)
  260. {
  261. exp = exp.And(x => x.ExaminationSchoolyearID == schoolYearID);
  262. }
  263. if (subjectID.HasValue)
  264. {
  265. exp = exp.And(x => x.ExaminationSubjectID == subjectID.Value);
  266. }
  267. var q = ExaminationSubjectDAL.GetRegistedClassStudentStatisticsListView(exp, expStudent);
  268. return q.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.ExaminationSchoolyearCode).ThenBy(x => x.Year).ThenBy(x => x.SubjectName).ThenBy(x => x.ClassmajorName).ThenBy(x => x.Cost).ToGridResultSet(pageIndex, pageSize);
  269. }
  270. /// <summary>
  271. /// 考试报名班级学生统计
  272. /// </summary>
  273. /// <param name="subjectID"></param>
  274. /// <param name="schoolYearID"></param>
  275. /// <returns></returns>
  276. public List<ExaminationClassStudentStatisticsView> GetExaminationSubjectClassStudentStatisticsList(Guid? subjectID, Guid? schoolYearID)
  277. {
  278. Expression<Func<EX_ExaminationRegistration, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  279. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  280. if (schoolYearID.HasValue)
  281. {
  282. exp = exp.And(x => x.SchoolyearID == schoolYearID);
  283. }
  284. if (subjectID.HasValue)
  285. {
  286. exp = exp.And(x => x.ExaminationSubjectID == subjectID.Value);
  287. }
  288. var q = ExaminationSubjectDAL.GetRegistedClassStudentStatisticsListView(exp, expStudent);
  289. return q.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.SubjectName).ThenBy(x => x.ClassmajorName).ThenBy(x => x.Cost).ToList();
  290. }
  291. public string[] Validation(List<Guid?> ExaminationTypeIDs, List<Guid?> SchoolyearIDs, List<int?> ExaminationFormIDs, List<string> names)
  292. {
  293. try
  294. {
  295. for (int i = 0; i < ExaminationTypeIDs.Count; i++)
  296. {
  297. Guid? ExaminationTypeID = ExaminationTypeIDs[0];
  298. Guid? SchoolyearID = SchoolyearIDs[0];
  299. int? ExaminationFormID = ExaminationFormIDs[0];
  300. string name = names[0];
  301. //var SubjectCountLimit = SubjectCountLimitDAL.ExaminationSubjectCountLimitRepository.Entities.Where(x =>
  302. // x.ExaminationTypeID == examinationType.Value && x.FacultymajorID == facultymajorIDs[0].Value &&
  303. // x.Years == years[0].Value).FirstOrDefault();
  304. var Subject = ExaminationSubjectDAL.GetExaminationSubjectView(x =>
  305. x.ExaminationTypeID == ExaminationTypeID && x.SchoolyearID == SchoolyearID &&
  306. x.ExaminationFormID == ExaminationFormID && x.Name == name).FirstOrDefault();
  307. if (Subject != null)
  308. return new[] { "false", "科目【" + Subject.Name + "】" + Subject.SchoolyearCode + "学年学期的" + Subject.ExaminationTypeName + "类型、" + Subject.ExaminationFormName + "类别数据已存在。" };
  309. }
  310. }
  311. catch (Exception ex)
  312. {
  313. return new[] { "false", ex.Message };
  314. }
  315. return new[] { "true", "成功" };
  316. }
  317. public void ExaminationSubjectStudentImport(Dictionary<string, string> cellheader, out int OkCount, out List<StudentListView> errdataList, out int ErrCount, string sourcePhysicalPath)
  318. {
  319. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  320. List<StudentListView> errList = new List<StudentListView>();
  321. #region 1.1解析文件,存放到一个List集合里
  322. cellheader.Remove("ErrorMessage");//去除异常列、导入操作不需要
  323. // 1.1解析文件,存放到一个List集合里
  324. List<StudentListView> enlist =
  325. NpoiExcelHelper.ExcelToEntityList<StudentListView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
  326. cellheader.Add("ErrorMessage", "错误信息");//还原字典项
  327. if (enlist.Count() <= 0)
  328. {
  329. throw new Exception("请填写Excel模板信息数据。");
  330. }
  331. List<string> SchoolYear = enlist.Select(x => x.SchoolyearCode).ToList();
  332. List<string> StudentNoList = enlist.Select(x => x.StudentNo).ToList();
  333. //List<string> StudentID = enlist.Select(x => x.IDNumber).ToList();
  334. List<string> SubjectNameList = enlist.Select(x => x.SubjectName).ToList();
  335. #endregion
  336. var SchoolYearList = ExaminationSubjectDAL.SchoolyearRepository.Entities.Where(x => SchoolYear.Contains(x.Code)).ToList();
  337. List<Guid> SchoolYearId = ExaminationSubjectDAL.SchoolyearRepository.Entities.Where(x => SchoolYear.Contains(x.Code)).Select(w=>w.SchoolyearID).ToList();
  338. List<EX_ExaminationRegistration> exaList = new List<EX_ExaminationRegistration>();
  339. Expression<Func<EX_ExaminationRegistration, bool>> exr = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE&&SchoolYearId.Contains((Guid)x.ExaminationSchoolyearID));
  340. Expression<Func<EX_ExaminationSubject, bool>> exp = x => SubjectNameList.Contains(x.Name);
  341. Expression<Func<CF_Student, bool>> studentExp = x => StudentNoList.Contains(x.Sys_User.LoginID);
  342. List<StudentListView> dbList = ExaminationSubjectDAL.GetRegistedStudentListView(exp, studentExp,exr).ToList();
  343. var examiantionRegistIDList = dbList.Select(x => x.ExaminationRegistrationID).ToList();
  344. exaList = ExaminationSubjectDAL.ExaminationRegistrationRepository.GetList(x => examiantionRegistIDList.Contains(x.ExaminationRegistrationID)).ToList();
  345. for (int i = 0; i < enlist.Count();i++ )
  346. {
  347. string errorMsgStr = "第" + (i + 2) + "行数据检测异常:";
  348. StudentListView en = enlist[i];
  349. bool isHaveNoInputValue = false;
  350. en.IsExcelVaildateOK = true;
  351. #region 检查是否有未填的值
  352. if (string.IsNullOrEmpty(en.StudentNo))
  353. {
  354. errorMsgStr += "学号不能为空;";
  355. isHaveNoInputValue = true;
  356. }
  357. if (string.IsNullOrEmpty(en.IsPay))
  358. {
  359. errorMsgStr += "是否交费不能为空;";
  360. isHaveNoInputValue = true;
  361. }
  362. if (string.IsNullOrEmpty(en.SchoolyearCode))
  363. {
  364. errorMsgStr += "考试学年学期不能为空;";
  365. isHaveNoInputValue = true;
  366. }
  367. if (string.IsNullOrEmpty(en.SubjectName))
  368. {
  369. errorMsgStr += "科目名称不能为空;";
  370. isHaveNoInputValue = true;
  371. }
  372. #endregion
  373. #region 检查数据是否存在
  374. var enSchoolYear=SchoolYearList.Where(x=>x.Code==en.SchoolyearCode).Select(w=>w.SchoolyearID).FirstOrDefault();
  375. if (enSchoolYear != null)
  376. {
  377. var Students = dbList.Where(x => x.StudentNo == en.StudentNo && x.SubjectName == en.SubjectName&&x.ExaminationSchoolyearID==enSchoolYear).FirstOrDefault();
  378. if (Students == null)
  379. {
  380. errorMsgStr += "无法匹配对应的数据,请检查;";
  381. isHaveNoInputValue = true;
  382. }
  383. else
  384. {
  385. enlist[i] = Students;
  386. }
  387. }
  388. else
  389. {
  390. errorMsgStr += "考试学年学期不存在;";
  391. isHaveNoInputValue = true;
  392. }
  393. if (en.IsPay != "是" && en.IsPay != "否")
  394. {
  395. errorMsgStr += "是否交费填写的字段不正确;";
  396. isHaveNoInputValue = true;
  397. }
  398. else
  399. {
  400. enlist[i].IsPay = en.IsPay;
  401. }
  402. #endregion
  403. if (isHaveNoInputValue)
  404. {
  405. en.IsExcelVaildateOK = false;
  406. en.ErrorMessage = errorMsgStr;
  407. errList.Add(en);
  408. }
  409. else
  410. {
  411. enlist[i].IsExcelVaildateOK = true;
  412. }
  413. }
  414. for (int i = 0; i < enlist.Count(); i++)
  415. {
  416. StudentListView enA = enlist[i];
  417. if (enA.IsExcelVaildateOK == false)
  418. {
  419. continue;
  420. }
  421. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  422. bool ispay = enA.IsPay=="是"?true:false;
  423. EX_ExaminationRegistration examinationRegistration = exaList.FirstOrDefault(x => x.ExaminationRegistrationID == enA.ExaminationRegistrationID);
  424. examinationRegistration.ExaminationSubjectID = enA.ExaminationSubjectID;
  425. //报名学年学期
  426. examinationRegistration.SchoolyearID = enA.SchoolyearID;
  427. examinationRegistration.UserID = enA.UserID;
  428. examinationRegistration.CertificatesType = enA.CertificatesType;
  429. examinationRegistration.IDNumber = enA.IDNumber;
  430. //考试学年学期
  431. examinationRegistration.ExaminationSchoolyearID = enA.ExaminationSchoolyearID;
  432. examinationRegistration.IsPay = ispay;
  433. examinationRegistration.RecordStatus=(int)SYS_STATUS.USABLE;
  434. this.SetModifyStatus(examinationRegistration);
  435. //UnitOfWork.Update(examinationRegistration);
  436. }
  437. ErrCount = errList.Distinct().Count();//共条数减去失败条数
  438. errdataList = errList.Distinct().ToList();
  439. OkCount = enlist.Distinct().Count() - errList.Distinct().Count();
  440. //UnitOfWork.Commit();
  441. UnitOfWork.BatchUpdate(exaList);
  442. }
  443. }
  444. }