StudentChargePaymenDAL.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using EMIS.DataLogic.Repositories;
  7. using EMIS.Entities;
  8. using EMIS.ViewModel.ChargeManage.ChargeSituation;
  9. namespace EMIS.DataLogic.ChargeManage.ChargeSituation
  10. {
  11. public class StudentChargePaymenDAL
  12. {
  13. public StudentChargePaymentRepository StudentChargePaymentRepository { get; set; }
  14. public StudentChargeRepository StudentChargeRepository { get; set; }
  15. public UserRepository UserRepository { get; set; }
  16. public ChargeProjectRepository ChargeProjectRepository { get; set; }
  17. public ChargeStandardRepository ChargeStandardRepository { get; set; }
  18. public StudentRepository StudentRepository { get; set; }
  19. public ClassmajorRepository ClassmajorRepository { get; set; }
  20. public GrademajorRepository GrademajorRepository { get; set; }
  21. public FacultymajorRepository FacultymajorRepository { get; set; }
  22. /// <summary>
  23. /// 查询学生缴费信息View
  24. /// </summary>
  25. /// <param name="expStudentChargePayment"></param>
  26. /// <param name="expStudentCharge"></param>
  27. /// <param name="expStudent"></param>
  28. /// <returns></returns>
  29. public IQueryable<StudentChargePaymenView> GetStudentChargePaymentViewTable(Expression<Func<EC_StudentChargePayment, bool>> expStudentChargePayment,
  30. Expression<Func<EC_StudentCharge, bool>> expStudentCharge, Expression<Func<CF_Student, bool>> expStudent)
  31. {
  32. var query = from cp in StudentChargePaymentRepository.GetList(expStudentChargePayment)
  33. join sc in StudentChargeRepository.GetList(expStudentCharge)
  34. on cp.StudentChargeID equals sc.StudentChargeID
  35. join pr in ChargeProjectRepository.Entities
  36. on sc.ChargeProjectID equals pr.ChargeProjectID
  37. join stu in StudentRepository.GetList(expStudent)
  38. on sc.UserID equals stu.UserID
  39. join cl in ClassmajorRepository.Entities
  40. on stu.ClassmajorID equals cl.ClassmajorID
  41. join gr in GrademajorRepository.Entities
  42. on cl.GrademajorID equals gr.GrademajorID
  43. join fa in FacultymajorRepository.Entities
  44. on gr.FacultymajorID equals fa.FacultymajorID
  45. join us in UserRepository.Entities
  46. on sc.UserID equals us.UserID
  47. join totalcp in
  48. (
  49. from pay in StudentChargePaymentRepository.Entities
  50. group pay by pay.StudentChargeID into g
  51. select new
  52. {
  53. StudentChargeID = g.Key,
  54. AmountCount = g.Sum(x => x.Amount)
  55. }
  56. )
  57. on sc.StudentChargeID equals totalcp.StudentChargeID
  58. into tempcp
  59. from stucp in tempcp.DefaultIfEmpty()
  60. select new StudentChargePaymenView
  61. {
  62. StudentChargePaymentID = cp.StudentChargePaymentID,
  63. StudentChargeID = cp.StudentChargeID,
  64. ChargeYear = sc.ChargeYear,
  65. ChargeProjectID = sc.ChargeProjectID,
  66. ChargeProjectStr = pr.Name,
  67. ChargeTag = sc.ChargeTag,
  68. ChargeDate = cp.ChargeDate,
  69. Amount = cp.Amount,
  70. StandardAmount = sc.Amount,
  71. ChargeAmount = sc.ActualAmount - sc.Amount,
  72. ActualAmount = sc.ActualAmount,
  73. UserID = sc.UserID,
  74. StudentNo = us.LoginID,
  75. UserName = us.Name,
  76. SexID = stu.SexID,
  77. IsDream = stu.CF_StudentProfile.IsDreamProject == true ? 1 : 0,
  78. InSchoolStatusID = stu.InSchoolStatusID,
  79. StudentStatusID = stu.StudentStatus,
  80. ClassID = stu.ClassmajorID,
  81. ClassNo = cl.No,
  82. ClassName = cl.Name,
  83. GradeStr = gr.GradeID,
  84. GradeMajorID = gr.GrademajorID,
  85. GradeMajorCode = gr.Code,
  86. GradeMajorStr = gr.Name,
  87. CollegeID = fa.CollegeID,
  88. CollegeCode = fa.CF_College.No,
  89. CollegeName = fa.CF_College.Name,
  90. StandardID = fa.StandardID,
  91. EducationID = fa.EducationID,
  92. LearningformID = fa.LearningformID,
  93. LearnSystem = fa.LearnSystem,
  94. Remark = cp.Remark,
  95. PaidAmount = stucp.AmountCount == null ? 0 : stucp.AmountCount
  96. };
  97. return query;
  98. }
  99. /// <summary>
  100. /// 查询学生缴费信息View(根据应收名单信息,统计对应的已缴金额)
  101. /// </summary>
  102. /// <param name="expStudentCharge"></param>
  103. /// <returns></returns>
  104. public IQueryable<StudentChargePaymenView> GetStudentChargePaymentView(Expression<Func<EC_StudentCharge, bool>> expStudentCharge)
  105. {
  106. var query = from cp in StudentChargePaymentRepository.Entities
  107. join sc in StudentChargeRepository.GetList(expStudentCharge)
  108. on cp.StudentChargeID equals sc.StudentChargeID
  109. join pr in ChargeProjectRepository.Entities
  110. on sc.ChargeProjectID equals pr.ChargeProjectID
  111. join stu in StudentRepository.Entities
  112. on sc.UserID equals stu.UserID
  113. join cl in ClassmajorRepository.Entities
  114. on stu.ClassmajorID equals cl.ClassmajorID
  115. join gr in GrademajorRepository.Entities
  116. on cl.GrademajorID equals gr.GrademajorID
  117. join fa in FacultymajorRepository.Entities
  118. on gr.FacultymajorID equals fa.FacultymajorID
  119. join us in UserRepository.Entities
  120. on sc.UserID equals us.UserID
  121. join totalcp in
  122. (
  123. from pay in StudentChargePaymentRepository.Entities
  124. group pay by pay.StudentChargeID into g
  125. select new
  126. {
  127. StudentChargeID = g.Key,
  128. PaidAmount = g.Sum(x => x.Amount)
  129. }
  130. )
  131. on cp.StudentChargeID equals totalcp.StudentChargeID
  132. into tempcp
  133. from stucp in tempcp.DefaultIfEmpty()
  134. select new StudentChargePaymenView
  135. {
  136. StudentChargePaymentID = cp.StudentChargePaymentID,
  137. StudentChargeID = cp.StudentChargeID,
  138. ChargeYear = sc.ChargeYear,
  139. ChargeProjectID = sc.ChargeProjectID,
  140. ChargeProjectStr = pr.Name,
  141. ChargeTag = sc.ChargeTag,
  142. ChargeDate = cp.ChargeDate,
  143. Amount = cp.Amount,
  144. StandardAmount = sc.Amount,
  145. ChargeAmount = sc.ActualAmount - sc.Amount,
  146. ActualAmount = sc.ActualAmount,
  147. PaidAmount = stucp.PaidAmount == null ? 0 : stucp.PaidAmount,
  148. UserID = sc.UserID,
  149. StudentNo = us.LoginID,
  150. UserName = us.Name,
  151. SexID = stu.SexID,
  152. IsDream = stu.CF_StudentProfile.IsDreamProject == true ? 1 : 0,
  153. InSchoolStatusID = stu.InSchoolStatusID,
  154. StudentStatusID = stu.StudentStatus,
  155. ClassID = stu.ClassmajorID,
  156. ClassNo = cl.No,
  157. ClassName = cl.Name,
  158. GradeStr = gr.GradeID,
  159. GradeMajorID = gr.GrademajorID,
  160. GradeMajorCode = gr.Code,
  161. GradeMajorStr = gr.Name,
  162. CollegeID = fa.CollegeID,
  163. CollegeCode = fa.CF_College.No,
  164. CollegeName = fa.CF_College.Name,
  165. StandardID = fa.StandardID,
  166. EducationID = fa.EducationID,
  167. LearningformID = fa.LearningformID,
  168. LearnSystem = fa.LearnSystem,
  169. Remark = cp.Remark
  170. };
  171. return query;
  172. }
  173. /// <summary>
  174. /// 查询应收名单信息View(根据应收名单信息,统计对应的已缴金额)
  175. /// </summary>
  176. /// <param name="expStudentCharge"></param>
  177. /// <returns></returns>
  178. public IQueryable<StudentChargeView> GetStudentChargeViewQueryAble(Expression<Func<EC_StudentCharge, bool>> expStudentCharge)
  179. {
  180. var query = from sc in StudentChargeRepository.GetList(expStudentCharge)
  181. join pr in ChargeProjectRepository.Entities
  182. on sc.ChargeProjectID equals pr.ChargeProjectID
  183. join stu in StudentRepository.Entities
  184. on sc.UserID equals stu.UserID
  185. join cl in ClassmajorRepository.Entities
  186. on stu.ClassmajorID equals cl.ClassmajorID
  187. join gr in GrademajorRepository.Entities
  188. on cl.GrademajorID equals gr.GrademajorID
  189. join fa in FacultymajorRepository.Entities
  190. on gr.FacultymajorID equals fa.FacultymajorID
  191. join us in UserRepository.Entities
  192. on sc.UserID equals us.UserID
  193. join stucp in
  194. (
  195. from cp in StudentChargePaymentRepository.Entities
  196. group cp by cp.StudentChargeID into g
  197. select new
  198. {
  199. StudentChargeID = g.Key,
  200. AmountCount = g.Sum(x => x.Amount)
  201. }
  202. )
  203. on sc.StudentChargeID equals stucp.StudentChargeID
  204. into tempcp
  205. from schcp in tempcp.DefaultIfEmpty()
  206. select new StudentChargeView
  207. {
  208. StudentChargeID = sc.StudentChargeID,
  209. ChargeYear = sc.ChargeYear,
  210. ChargeProjectID = sc.ChargeProjectID,
  211. ChargeProjectStr = sc.EC_ChargeProject.Name,
  212. Amount = sc.Amount,
  213. ChargeAmount = sc.ActualAmount - sc.Amount,
  214. ActualAmount = sc.ActualAmount,
  215. ChargeTag = sc.ChargeTag,
  216. UserID = sc.UserID,
  217. StudentNo = us.LoginID,
  218. UserName = us.Name,
  219. SexID = stu.SexID,
  220. IsDream = stu.CF_StudentProfile.IsDreamProject == true ? 1 : 0,
  221. InSchoolStatusID = stu.InSchoolStatusID,
  222. StudentStatusID = stu.StudentStatus,
  223. ClassID = stu.ClassmajorID,
  224. ClassNo = cl.No,
  225. ClassName = cl.Name,
  226. GradeStr = gr.GradeID,
  227. GradeMajorID = gr.GrademajorID,
  228. GradeMajorCode = gr.Code,
  229. GradeMajoyStr = gr.Name,
  230. CollegeID = fa.CollegeID,
  231. CollegeCode = fa.CF_College.No,
  232. CollegeStr = fa.CF_College.Name,
  233. StandardID = fa.StandardID,
  234. EducationID = fa.EducationID,
  235. LearningformID = fa.LearningformID,
  236. LearnSystem = fa.LearnSystem,
  237. Remark = sc.Remark,
  238. PaidAmount = schcp.AmountCount == null ? 0 : schcp.AmountCount
  239. };
  240. return query;
  241. }
  242. /// <summary>
  243. /// 查询学生缴费信息备注信息
  244. /// </summary>
  245. /// <param name="exp"></param>
  246. /// <returns></returns>
  247. public IQueryable<StudentChargePaymenView> GetRemarkViewTable(Expression<Func<EC_StudentChargePayment, bool>> exp)
  248. {
  249. var query = from a in StudentChargePaymentRepository.GetList(exp)
  250. select new StudentChargePaymenView
  251. {
  252. Remark = a.Remark
  253. };
  254. return query.Distinct();
  255. }
  256. }
  257. }