OpenControlServices.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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.DataLogic.ExaminationApply;
  9. //using EMIS.ViewModel.ExaminationApply;
  10. //using EMIS.Entities;
  11. //using EMIS.ViewModel;
  12. //namespace EMIS.CommonLogic.ExaminationApply
  13. //{
  14. // public class OpenControlServices : BaseServices, IOpenControlServices
  15. // {
  16. // public OpenControlDAL OpenControlDAL { get; set; }
  17. // public ExaminationSubjectDAL ExaminationSubjectDAL { get; set; }
  18. // public ExaminationSubjectServices ExaminationSubjectServices { get; set; }
  19. // public Bowin.Common.Linq.Entity.IGridResultSet<OpenControlView> GetOpenControlViewList(ViewModel.ConfiguretView openControlView, Guid? examinationTypeID,
  20. // Guid? examinationSubjectID, int? yearNum, int? studentType, int pageIndex, int pageSize)
  21. // {
  22. // Expression<Func<EX_ExaminationOpenControl, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  23. // if (examinationTypeID.HasValue)
  24. // {
  25. // exp = exp.And(x => x.EX_ExaminationSubject.ExaminationTypeID == examinationTypeID);
  26. // }
  27. // if (examinationSubjectID.HasValue)
  28. // {
  29. // exp = exp.And(x => x.ExaminationSubjectID == examinationSubjectID);
  30. // }
  31. // if (yearNum.HasValue)
  32. // {
  33. // exp = exp.And(x => x.SchoolyearNumID == yearNum);
  34. // }
  35. // if (studentType.HasValue)
  36. // {
  37. // exp = exp.And(x => x.StudentType == studentType);
  38. // }
  39. // var q = OpenControlDAL.GetOpenControlView(exp);
  40. // if (!string.IsNullOrEmpty(openControlView.ConditionValue) && !string.IsNullOrEmpty(openControlView.Attribute))
  41. // q = q.DynamicWhere(openControlView.Attribute, openControlView.Condition, openControlView.ConditionValue);
  42. // return q.ToGridResultSet<OpenControlView>(pageIndex, pageSize);
  43. // }
  44. // public IList<OpenControlView> GetOpenControlViewList(ViewModel.ConfiguretView openControlView, Guid? examinationTypeID, Guid? examinationSubjectID, int? yearNum, int? studentType)
  45. // {
  46. // Expression<Func<EX_ExaminationOpenControl, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  47. // if (examinationTypeID.HasValue)
  48. // {
  49. // exp = exp.And(x => x.EX_ExaminationSubject.ExaminationTypeID == examinationTypeID);
  50. // }
  51. // if (examinationSubjectID.HasValue)
  52. // {
  53. // exp = exp.And(x => x.ExaminationSubjectID == examinationSubjectID);
  54. // }
  55. // if (yearNum.HasValue)
  56. // {
  57. // exp = exp.And(x => x.SchoolyearNumID == yearNum);
  58. // }
  59. // if (studentType.HasValue)
  60. // {
  61. // exp = exp.And(x => x.StudentType == studentType);
  62. // }
  63. // var q = OpenControlDAL.GetOpenControlView(exp);
  64. // if (!string.IsNullOrEmpty(openControlView.ConditionValue) && !string.IsNullOrEmpty(openControlView.Attribute))
  65. // q = q.DynamicWhere(openControlView.Attribute, openControlView.Condition, openControlView.ConditionValue);
  66. // return q.ToList();
  67. // }
  68. // public ViewModel.ExaminationApply.OpenControlView GetOpenControlViewInfo(Guid? openControlID)
  69. // {
  70. // return OpenControlDAL.GetOpenControlView(x => x.ExaminationOpenControlID == openControlID).FirstOrDefault();
  71. // }
  72. // public void Save(ViewModel.ExaminationApply.OpenControlView openControlView)
  73. // {
  74. // EX_ExaminationSubject examinationSubject = null;
  75. // if (openControlView.StudentTypeID.Count == 0)
  76. // throw new Exception("请选择学生类别");
  77. // if (openControlView.ExaminationSubjectEditID != null)
  78. // {
  79. // examinationSubject = ExaminationSubjectDAL.ExaminationSubjectRepository.Entities.Where(x => x.ExaminationSubjectID == openControlView.ExaminationSubjectEditID).FirstOrDefault();
  80. // }
  81. // else
  82. // {
  83. // examinationSubject = ExaminationSubjectDAL.ExaminationSubjectRepository.Entities.Where(x => x.ExaminationSubjectID == openControlView.ExaminationSubjectID).FirstOrDefault();
  84. // }
  85. // if (examinationSubject != null && examinationSubject.ExaminationDate <= openControlView.EndDate)
  86. // {
  87. // throw new Exception("报名截止时间不能大于考试时间。");
  88. // }
  89. // if (openControlView.StartDate > openControlView.EndDate)
  90. // {
  91. // throw new Exception("报名时间开始不能大于结束时间。");
  92. // }
  93. // ////验证限定人数是否超过最大报名数
  94. // //if (openControlView.ExaminationSubjectID != null)
  95. // //{
  96. // // //1.0该科目的最大报名数
  97. // // int? peopleNumLimit = OpenControlDAL.ExaminationSubjectRepository.Entities.Where(x => x.ExaminationSubjectID == openControlView.ExaminationSubjectID).FirstOrDefault().PeopleNumLimit;
  98. // // //2.0 获取同一科目,学生类别,年级数汇总限定人数
  99. // // var query = OpenControlDAL.ExaminationOpenControlRepository.Entities
  100. // // .Where(x => x.ExaminationSubjectID == openControlView.ExaminationSubjectID
  101. // // && openControlView.StudentTypeID.Contains(x.StudentType.Value));
  102. // // var peopleNumLimitSumCountList = query.GroupBy(x => x.StudentType).Select(x => x.Sum(w => w.PeopleNumLimit)).ToList();
  103. // // //int? peopleNumLimitSumCount = OpenControlDAL.ExaminationOpenControlRepository.Entities
  104. // // // .Where(x => x.ExaminationSubjectID == openControlView.ExaminationSubjectID
  105. // // // && x.StudentType == openControlView.StudentType )
  106. // // // .Select(w => w.PeopleNumLimit).Sum();
  107. // // //if (openControlView.PeopleNumLimit > peopleNumLimit)
  108. // // //{
  109. // // // throw new Exception("限定人数超过该科目的最大报名数。");
  110. // // //}
  111. // // foreach (var peopleNumLimitSumCount in peopleNumLimitSumCountList)
  112. // // {
  113. // // if (peopleNumLimitSumCount + openControlView.PeopleNumLimit > peopleNumLimit)
  114. // // {
  115. // // throw new Exception("该学生类别及年级数汇总限定人数超过该科目的最大报名数。");
  116. // // }
  117. // // }
  118. // //}
  119. // var openControlEntity = OpenControlDAL.ExaminationOpenControlRepository.GetSingle(x => x.ExaminationOpenControlID == openControlView.ExaminationOpenControlID);
  120. // int? type = openControlView.StudentTypeID[0];
  121. // if (openControlEntity != null)
  122. // {
  123. // var RepeatOpenControl = OpenControlDAL.ExaminationOpenControlRepository.GetSingle(x =>
  124. // x.ExaminationSubjectID == openControlView.ExaminationSubjectEditID &&
  125. // x.StudentType == type &&
  126. // //openControlView.StudentTypeID.Contains(x.StudentType.Value) &&
  127. // x.SchoolyearNumID == openControlView.SchoolyearNumID);
  128. // if (RepeatOpenControl != null && openControlEntity.ExaminationOpenControlID != RepeatOpenControl.ExaminationOpenControlID)
  129. // { //判断考试科目、学生类别、年级数不能重复
  130. // throw new Exception("已存在相同的考试科目、学生类别、年级数,请核查");
  131. // }
  132. // openControlEntity.ExaminationSubjectID = openControlView.ExaminationSubjectEditID;
  133. // openControlEntity.StudentType = openControlView.StudentTypeID[0];
  134. // openControlEntity.SchoolyearNumID = openControlView.SchoolyearNumID;
  135. // openControlEntity.StartDate = openControlView.StartDate;
  136. // openControlEntity.EndDate = openControlView.EndDate;
  137. // openControlEntity.PeopleNumLimit = openControlView.PeopleNumLimit;
  138. // this.SetModifyStatus(openControlEntity);
  139. // }
  140. // else
  141. // {
  142. // var RepeatOpenControl = OpenControlDAL.ExaminationOpenControlRepository.GetSingle(x =>
  143. // x.ExaminationSubjectID == openControlView.ExaminationSubjectID &&
  144. // //x.StudentType == openControlView.StudentType &&
  145. // openControlView.StudentTypeID.Contains(x.StudentType.Value) &&
  146. // x.SchoolyearNumID == openControlView.SchoolyearNumID);
  147. // if (RepeatOpenControl != null)
  148. // { //判断考试科目、学生类别、年级数不能重复
  149. // throw new Exception("已存在相同的考试科目、学生类别、年级数,请核查");
  150. // }
  151. // if (openControlView.ExaminationSubjectID == null)//考试科目选择全部
  152. // {
  153. // //批量以考试科目增加数据
  154. // if (openControlView.ExaminationTypeID != null)
  155. // {
  156. // List<ExaminationSubjectView> subjectList = ExaminationSubjectDAL.GetExaminationSubjectView(x => x.ExaminationTypeID == openControlView.ExaminationTypeID).ToList();
  157. // if (openControlView.StudentTypeID.Count > 0)
  158. // {
  159. // subjectList.ForEach(w =>
  160. // {
  161. // openControlView.StudentTypeID.ForEach(x =>
  162. // {
  163. // openControlEntity = new EX_ExaminationOpenControl();
  164. // openControlEntity.ExaminationOpenControlID = Guid.NewGuid();
  165. // openControlEntity.ExaminationSubjectID = w.ExaminationSubjectID;
  166. // openControlEntity.StudentType = x;
  167. // openControlEntity.SchoolyearNumID = openControlView.SchoolyearNumID;
  168. // openControlEntity.StartDate = openControlView.StartDate;
  169. // openControlEntity.EndDate = openControlView.EndDate;
  170. // openControlEntity.PeopleNumLimit = openControlView.PeopleNumLimit;
  171. // this.SetNewStatus(openControlEntity);
  172. // UnitOfWork.Add(openControlEntity);
  173. // });
  174. // });
  175. // }
  176. // }
  177. // }
  178. // else
  179. // {
  180. // if (openControlView.StudentTypeID.Count > 0)
  181. // {
  182. // openControlView.StudentTypeID.ForEach(x =>
  183. // {
  184. // openControlEntity = new EX_ExaminationOpenControl();
  185. // openControlEntity.ExaminationOpenControlID = Guid.NewGuid();
  186. // openControlEntity.ExaminationSubjectID = openControlView.ExaminationSubjectID;
  187. // openControlEntity.StudentType = x;
  188. // openControlEntity.SchoolyearNumID = openControlView.SchoolyearNumID;
  189. // openControlEntity.StartDate = openControlView.StartDate;
  190. // openControlEntity.EndDate = openControlView.EndDate;
  191. // openControlEntity.PeopleNumLimit = openControlView.PeopleNumLimit;
  192. // this.SetNewStatus(openControlEntity);
  193. // UnitOfWork.Add(openControlEntity);
  194. // });
  195. // }
  196. // }
  197. // }
  198. // UnitOfWork.Commit();
  199. // }
  200. // public void Delete(IList<Guid?> openControlID)
  201. // {
  202. // if (openControlID.Count > 0)
  203. // {
  204. // UnitOfWork.Delete<EX_ExaminationOpenControl>(x => openControlID.Contains(x.ExaminationOpenControlID));
  205. // }
  206. // }
  207. // //获取学生类别信息
  208. // public List<string> GetStudentType(Guid? openControlID)
  209. // {
  210. // return OpenControlDAL.GetStudentTypeQueryble(openControlID);
  211. // }
  212. // }
  213. //}