1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.Students.HighBaseTable;
- using EMIS.DataLogic.SystemSetting;
- using EMIS.DataLogic.Common.CalendarManage;
- using EMIS.ViewModel;
- using EMIS.Entities;
- using System.Transactions;
- namespace EMIS.CommonLogic.Students.HighBaseTable
- {
- public class InschoolOtherStatusServices : BaseServices, IInschoolOtherStatusServices
- {
- public InschoolOtherStatusDAL InschoolOtherStatusDAL { get; set; }
- public DictionaryItemDAL DictionaryItemDAL { get; set; }
- public SchoolYearDAL SchoolYearDAL { get; set; }
- public void Update(int SchoolYear)
- {
- try
- {
- var schoolYear = SchoolYearDAL.GetSchoolYearQueryable(x => x.IsCurrent).FirstOrDefault().Years;
- var nation = DictionaryItemDAL.GetDictionaryItemViewQueryable(x => x.DictionaryCode == typeof(CF_Nation).Name).Select(x => x.Value).ToList();
- var educationType = DictionaryItemDAL.GetDictionaryItemViewQueryable(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_EducationType).Name).Select(x => x.Value).ToList();
- //共产党员统计
- var CommunistList = InschoolOtherStatusDAL.GetInschoolOtherStatusPoliticsCount(x => x.PoliticsID == (int)EMIS.ViewModel.CF_Politics.Communist, SchoolYear).ToList();
- //共青团员统计
- var YouthLeagueList = InschoolOtherStatusDAL.GetInschoolOtherStatusPoliticsCount(x => x.PoliticsID == (int)EMIS.ViewModel.CF_Politics.YouthLeague, SchoolYear).ToList();
- //少数民族统计
- var minorityList = InschoolOtherStatusDAL.GetInschoolOtherStatusMinorityCount(SchoolYear).ToList();
- List<HB_InschoolOtherStatus> inschoolOtherStatusList = new List<HB_InschoolOtherStatus>();
- foreach (var t in educationType)
- {
- HB_InschoolOtherStatus inschoolOtherStatus = new HB_InschoolOtherStatus();
- inschoolOtherStatus.InschoolOtherStatusID = Guid.NewGuid();
- inschoolOtherStatus.Year = SchoolYear;
- inschoolOtherStatus.EducationTypeID = t;
- inschoolOtherStatus.CommunistCount = CommunistList.Where(x => x.EducationTypeID == t).Select(x => x.PoliticsCount).FirstOrDefault();
- inschoolOtherStatus.YouthLeagueCount = YouthLeagueList.Where(x => x.EducationTypeID == t).Select(x => x.PoliticsCount).FirstOrDefault();
- inschoolOtherStatus.Minority = minorityList.Where(x => x.EducationTypeID == t).Select(x => x.Minority).Sum();
- SetNewStatus(inschoolOtherStatus);
- inschoolOtherStatusList.Add(inschoolOtherStatus);
- }
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.Delete<HB_InschoolOtherStatus>(x => x.Year == SchoolYear);
- UnitOfWork.BulkInsert(inschoolOtherStatusList);//统一写入
- ts.Complete();
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- public List<string> SchoolYearDropDownList()
- {
- var item = InschoolOtherStatusDAL.InschoolOtherStatusRepository.Entities.Select(x => x.Year.ToString()).Distinct().ToList();
- return item;
- }
- }
- }
|