InschoolOtherStatusServices.cs 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Common.Students.HighBaseTable;
  6. using EMIS.DataLogic.SystemSetting;
  7. using EMIS.DataLogic.Common.CalendarManage;
  8. using EMIS.ViewModel;
  9. using EMIS.Entities;
  10. using System.Transactions;
  11. namespace EMIS.CommonLogic.Students.HighBaseTable
  12. {
  13. public class InschoolOtherStatusServices : BaseServices, IInschoolOtherStatusServices
  14. {
  15. public InschoolOtherStatusDAL InschoolOtherStatusDAL { get; set; }
  16. public DictionaryItemDAL DictionaryItemDAL { get; set; }
  17. public SchoolYearDAL SchoolYearDAL { get; set; }
  18. public void Update(int SchoolYear)
  19. {
  20. try
  21. {
  22. var schoolYear = SchoolYearDAL.GetSchoolYearQueryable(x => x.IsCurrent).FirstOrDefault().Years;
  23. var nation = DictionaryItemDAL.GetDictionaryItemViewQueryable(x => x.DictionaryCode == typeof(CF_Nation).Name).Select(x => x.Value).ToList();
  24. var educationType = DictionaryItemDAL.GetDictionaryItemViewQueryable(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_EducationType).Name).Select(x => x.Value).ToList();
  25. //共产党员统计
  26. var CommunistList = InschoolOtherStatusDAL.GetInschoolOtherStatusPoliticsCount(x => x.PoliticsID == (int)EMIS.ViewModel.CF_Politics.Communist, SchoolYear).ToList();
  27. //共青团员统计
  28. var YouthLeagueList = InschoolOtherStatusDAL.GetInschoolOtherStatusPoliticsCount(x => x.PoliticsID == (int)EMIS.ViewModel.CF_Politics.YouthLeague, SchoolYear).ToList();
  29. //少数民族统计
  30. var minorityList = InschoolOtherStatusDAL.GetInschoolOtherStatusMinorityCount(SchoolYear).ToList();
  31. List<HB_InschoolOtherStatus> inschoolOtherStatusList = new List<HB_InschoolOtherStatus>();
  32. foreach (var t in educationType)
  33. {
  34. HB_InschoolOtherStatus inschoolOtherStatus = new HB_InschoolOtherStatus();
  35. inschoolOtherStatus.InschoolOtherStatusID = Guid.NewGuid();
  36. inschoolOtherStatus.Year = SchoolYear;
  37. inschoolOtherStatus.EducationTypeID = t;
  38. inschoolOtherStatus.CommunistCount = CommunistList.Where(x => x.EducationTypeID == t).Select(x => x.PoliticsCount).FirstOrDefault();
  39. inschoolOtherStatus.YouthLeagueCount = YouthLeagueList.Where(x => x.EducationTypeID == t).Select(x => x.PoliticsCount).FirstOrDefault();
  40. inschoolOtherStatus.Minority = minorityList.Where(x => x.EducationTypeID == t).Select(x => x.Minority).Sum();
  41. SetNewStatus(inschoolOtherStatus);
  42. inschoolOtherStatusList.Add(inschoolOtherStatus);
  43. }
  44. using (TransactionScope ts = new TransactionScope())
  45. {
  46. UnitOfWork.Delete<HB_InschoolOtherStatus>(x => x.Year == SchoolYear);
  47. UnitOfWork.BulkInsert(inschoolOtherStatusList);//统一写入
  48. ts.Complete();
  49. }
  50. }
  51. catch (Exception ex)
  52. {
  53. throw new Exception(ex.Message);
  54. }
  55. }
  56. public List<string> SchoolYearDropDownList()
  57. {
  58. var item = InschoolOtherStatusDAL.InschoolOtherStatusRepository.Entities.Select(x => x.Year.ToString()).Distinct().ToList();
  59. return item;
  60. }
  61. }
  62. }