GrademajorRequirementServices.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.GraduationManage.GraduationRequirement;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.GraduationManage.GraduationRequirement;
  8. using EMIS.ViewModel;
  9. using Bowin.Common.Linq;
  10. using System.Linq.Expressions;
  11. using EMIS.Entities;
  12. namespace EMIS.CommonLogic.GraduationManage.GraduationRequirement
  13. {
  14. public class GrademajorRequirementServices:BaseServices,IGrademajorRequirementServices
  15. {
  16. public GrademajorRequirementDAL GrademajorRequirementDAL { get; set; }
  17. /// <summary>
  18. /// 查询毕业专业学分信息View
  19. /// </summary>
  20. /// <param name="configuretView"></param>
  21. /// <param name="gradSchoolyearID"></param>
  22. /// <param name="collegeID"></param>
  23. /// <param name="yearID"></param>
  24. /// <param name="standardID"></param>
  25. /// <param name="educationID"></param>
  26. /// <param name="learningformID"></param>
  27. /// <param name="learnSystem"></param>
  28. /// <param name="pageIndex"></param>
  29. /// <param name="pageSize"></param>
  30. /// <returns></returns>
  31. public IGridResultSet<GrademajorRequirementView> GetGradGrademajorRequirementViewGird(ConfiguretView configuretView,
  32. Guid? gradSchoolyearID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID,
  33. string learnSystem, int pageIndex, int pageSize)
  34. {
  35. //毕业专业学分
  36. Expression<Func<ER_GraduationRequirement, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  37. var query = GrademajorRequirementDAL.GetGradGrademajorRequirementQueryable(exp);
  38. if (gradSchoolyearID.HasValue)
  39. {
  40. query = query.Where(x => x.GraduatingSemesterID == gradSchoolyearID);
  41. }
  42. if (collegeID.HasValue)
  43. {
  44. query = query.Where(x => x.CollegeID == collegeID);
  45. }
  46. if (yearID.HasValue)
  47. {
  48. query = query.Where(x => x.SchoolyearID == yearID);
  49. }
  50. if (standardID.HasValue)
  51. {
  52. query = query.Where(x => x.StandardID == standardID);
  53. }
  54. if (educationID.HasValue)
  55. {
  56. query = query.Where(x => x.EducationID == educationID);
  57. }
  58. if (learningformID.HasValue)
  59. {
  60. query = query.Where(x => x.LearningformID == learningformID);
  61. }
  62. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  63. {
  64. var LearnSystems = Convert.ToDecimal(learnSystem);
  65. query = query.Where(x => x.LearnSystem == LearnSystems);
  66. }
  67. //查询条件
  68. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  69. {
  70. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  71. }
  72. return this.GetQueryByDataRangeByCollege(query)
  73. .OrderByDescending(x => x.SchoolyearID).OrderBy(x => x.StandardID)
  74. .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID)
  75. .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  76. .ToGridResultSet<GrademajorRequirementView>(pageIndex, pageSize);
  77. }
  78. /// <summary>
  79. /// 查询毕业专业学分信息List
  80. /// </summary>
  81. /// <param name="configuretView"></param>
  82. /// <param name="gradSchoolyearID"></param>
  83. /// <param name="collegeID"></param>
  84. /// <param name="yearID"></param>
  85. /// <param name="standardID"></param>
  86. /// <param name="educationID"></param>
  87. /// <param name="learningformID"></param>
  88. /// <param name="learnSystem"></param>
  89. /// <returns></returns>
  90. public IList<GrademajorRequirementView> GetGradGrademajorRequirementViewList(ConfiguretView configuretView, Guid? gradSchoolyearID,
  91. Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem)
  92. {
  93. //毕业专业学分
  94. Expression<Func<ER_GraduationRequirement, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  95. var query = GrademajorRequirementDAL.GetGradGrademajorRequirementQueryable(exp);
  96. if (gradSchoolyearID.HasValue)
  97. {
  98. query = query.Where(x => x.GraduatingSemesterID == gradSchoolyearID);
  99. }
  100. if (collegeID.HasValue)
  101. {
  102. query = query.Where(x => x.CollegeID == collegeID);
  103. }
  104. if (yearID.HasValue)
  105. {
  106. query = query.Where(x => x.SchoolyearID == yearID);
  107. }
  108. if (standardID.HasValue)
  109. {
  110. query = query.Where(x => x.StandardID == standardID);
  111. }
  112. if (educationID.HasValue)
  113. {
  114. query = query.Where(x => x.EducationID == educationID);
  115. }
  116. if (learningformID.HasValue)
  117. {
  118. query = query.Where(x => x.LearningformID == learningformID);
  119. }
  120. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  121. {
  122. var LearnSystems = Convert.ToDecimal(learnSystem);
  123. query = query.Where(x => x.LearnSystem == LearnSystems);
  124. }
  125. //查询条件
  126. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  127. {
  128. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  129. }
  130. return this.GetQueryByDataRangeByCollege(query)
  131. .OrderByDescending(x => x.SchoolyearID).OrderBy(x => x.StandardID)
  132. .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID)
  133. .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
  134. .ToList();
  135. }
  136. /// <summary>
  137. /// 根据毕业专业学分ID查询对应的毕业专业学分信息GrademajorRequirementView
  138. /// </summary>
  139. /// <param name="GraduationRequirementID"></param>
  140. /// <returns></returns>
  141. public GrademajorRequirementView GetGradGrademajorRequirementView(Guid? GraduationRequirementID)
  142. {
  143. try
  144. {
  145. var query = GrademajorRequirementDAL
  146. .GetGradGrademajorRequirementQueryable(x => x.GraduationRequirementID == GraduationRequirementID)
  147. .SingleOrDefault();
  148. return query;
  149. }
  150. catch (Exception ex)
  151. {
  152. throw new Exception(ex.Message);
  153. }
  154. }
  155. /// <summary>
  156. /// 编辑(新增、修改)
  157. /// </summary>
  158. /// <param name="grademajorRequirementView"></param>
  159. public void GradGrademajorRequirementEdit(GrademajorRequirementView grademajorRequirementView)
  160. {
  161. try
  162. {
  163. //查询数据库进行验证
  164. var grademajorRequirementVerification = GrademajorRequirementDAL.GraduationRequirementRepository
  165. .GetList(x => x.GraduationRequirementID != grademajorRequirementView.GraduationRequirementID
  166. && x.GrademajorID == grademajorRequirementView.GrademajorID)
  167. .SingleOrDefault();
  168. if (grademajorRequirementVerification == null)
  169. {
  170. //数据有误验证
  171. if (grademajorRequirementView.GraduationRequirementID != Guid.Empty)
  172. {
  173. var grademajorRequirement = GrademajorRequirementDAL.GraduationRequirementRepository
  174. .GetList(x => x.GraduationRequirementID == grademajorRequirementView.GraduationRequirementID)
  175. .SingleOrDefault();
  176. if (grademajorRequirement == null)
  177. {
  178. throw new Exception("数据有误,请核查");
  179. }
  180. else
  181. {
  182. //表示修改
  183. grademajorRequirement.GrademajorID = grademajorRequirementView.GrademajorID;
  184. grademajorRequirement.OptionalCourseCredit = grademajorRequirementView.OptionalCourseCredit;
  185. grademajorRequirement.RequiredCredit = grademajorRequirementView.RequiredCredit;
  186. grademajorRequirement.TotalCredit = grademajorRequirementView.TotalCredit;
  187. SetModifyStatus(grademajorRequirement);
  188. }
  189. }
  190. else
  191. {
  192. //表示新增
  193. ER_GraduationRequirement grademajorRequirement = new ER_GraduationRequirement();
  194. grademajorRequirement.GraduationRequirementID = Guid.NewGuid();
  195. grademajorRequirement.GrademajorID = grademajorRequirementView.GrademajorID;
  196. grademajorRequirement.OptionalCourseCredit = grademajorRequirementView.OptionalCourseCredit;
  197. grademajorRequirement.RequiredCredit = grademajorRequirementView.RequiredCredit;
  198. grademajorRequirement.TotalCredit = grademajorRequirementView.TotalCredit;
  199. SetNewStatus(grademajorRequirement);
  200. UnitOfWork.Add(grademajorRequirement);
  201. }
  202. }
  203. else
  204. {
  205. throw new Exception("已存在相同的专业学分,请核查");
  206. }
  207. //事务提交
  208. UnitOfWork.Commit();
  209. }
  210. catch (Exception ex)
  211. {
  212. throw new Exception(ex.Message);
  213. }
  214. }
  215. /// <summary>
  216. /// 删除
  217. /// </summary>
  218. /// <param name="graduationRequirementIDList"></param>
  219. /// <returns></returns>
  220. public bool GradGrademajorRequirementDelete(IList<Guid?> graduationRequirementIDList)
  221. {
  222. try
  223. {
  224. UnitOfWork.Delete<ER_GraduationRequirement>(x => graduationRequirementIDList.Contains(x.GraduationRequirementID));
  225. UnitOfWork.Commit();
  226. return true;
  227. }
  228. catch (Exception ex)
  229. {
  230. throw new Exception(ex.Message);
  231. }
  232. }
  233. }
  234. }