123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.DataLogic.GraduationManage.GraduationSetting;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.ViewModel.GraduationManage.GraduationSetting;
- namespace EMIS.CommonLogic.GraduationManage.GraduationSetting
- {
- public class GraduationSchoolYearServices: BaseServices, IGraduationSchoolYearServices
- {
- public GraduationSchoolYearDAL GraduationSchoolYearDAL { get; set; }
- public Lazy<IParameterServices> ParameterServices { get; set; }
- /// <summary>
- /// 查询毕业学期信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="years"></param>
- /// <param name="schoolcodeID"></param>
- /// <param name="isCurrent"></param>
- /// <param name="isEnable"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<GraduationSchoolYearView> GetGradSchoolYearViewGrid(ConfiguretView configuretView, int? years,
- int? schoolcodeID, int? isCurrent, int? isEnable, int pageIndex, int pageSize)
- {
- //查询设置的毕业学期Value
- var graduatingSemesterID = ParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.GraduationSchoolyear);
- //毕业学期设置信息
- Expression<Func<ER_GraduateSchoolyear, bool>> expGraduateSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = GraduationSchoolYearDAL.GetGraduationSchoolYearViewQueryable(expGraduateSchoolyear, graduatingSemesterID);
- if (years.HasValue)
- {
- query = query.Where(x => x.Years == years);
- }
- if (schoolcodeID.HasValue)
- {
- query = query.Where(x => x.SchoolcodeID == schoolcodeID);
- }
- if (isCurrent.HasValue)
- {
- if (isCurrent == 1)
- {
- query = query.Where(x => x.IsCurrent == true);
- }
- if (isCurrent == 0)
- {
- query = query.Where(x => x.IsCurrent != true);
- }
- }
- if (isEnable.HasValue)
- {
- if (isEnable == 1)
- {
- query = query.Where(x => x.IsEnable == true);
- }
- if (isEnable == 0)
- {
- query = query.Where(x => x.IsEnable != true);
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderByDescending(x => x.IsEnable)
- .ThenByDescending(x => x.GraduatingSemesterValue)
- .ToGridResultSet<GraduationSchoolYearView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询毕业学期信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="years"></param>
- /// <param name="schoolcodeID"></param>
- /// <param name="isCurrent"></param>
- /// <param name="isEnable"></param>
- /// <returns></returns>
- public IList<GraduationSchoolYearView> GetGradSchoolYearViewList(ConfiguretView configuretView, int? years,
- int? schoolcodeID, int? isCurrent, int? isEnable)
- {
- //查询设置的毕业学期Value
- var graduatingSemesterID = ParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.GraduationSchoolyear);
- //毕业学期设置信息
- Expression<Func<ER_GraduateSchoolyear, bool>> expGraduateSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = GraduationSchoolYearDAL.GetGraduationSchoolYearViewQueryable(expGraduateSchoolyear, graduatingSemesterID);
- if (years.HasValue)
- {
- query = query.Where(x => x.Years == years);
- }
- if (schoolcodeID.HasValue)
- {
- query = query.Where(x => x.SchoolcodeID == schoolcodeID);
- }
- if (isCurrent.HasValue)
- {
- if (isCurrent == 1)
- {
- query = query.Where(x => x.IsCurrent == true);
- }
- if (isCurrent == 0)
- {
- query = query.Where(x => x.IsCurrent != true);
- }
- }
- if (isEnable.HasValue)
- {
- if (isEnable == 1)
- {
- query = query.Where(x => x.IsEnable == true);
- }
- if (isEnable == 0)
- {
- query = query.Where(x => x.IsEnable != true);
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderByDescending(x => x.IsEnable)
- .ThenByDescending(x => x.GraduatingSemesterValue)
- .ToList();
- }
- /// <summary>
- /// 查询对应的毕业学期信息View(根据毕业学期设置信息ID)
- /// </summary>
- /// <param name="graduationSchoolYearSettingID"></param>
- /// <returns></returns>
- public GraduationSchoolYearView GetGradSchoolYearView(Guid? graduationSchoolYearSettingID)
- {
- try
- {
- //查询设置的毕业学期Value
- var graduatingSemesterID = ParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.GraduationSchoolyear);
- //毕业学期设置信息
- Expression<Func<ER_GraduateSchoolyear, bool>> expGraduateSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expGraduateSchoolyear = expGraduateSchoolyear.And(x => x.GraduateSchoolyearID == graduationSchoolYearSettingID);
- var query = GraduationSchoolYearDAL.GetGraduationSchoolYearViewQueryable(expGraduateSchoolyear, graduatingSemesterID)
- .SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:毕业学期设置信息ID)
- /// 判断启用状态(只有一种启用状态)
- /// </summary>
- /// <param name="graduationSchoolYearView"></param>
- public void GraduationSchoolYearEdit(GraduationSchoolYearView graduationSchoolYearView)
- {
- try
- {
- //查询数据库进行验证
- var gradSchoolYearVerification = GraduationSchoolYearDAL.GraduateSchoolyearRepository
- .GetList(x => x.GraduateSchoolyearID != graduationSchoolYearView.GraduationSchoolYearSettingID
- && x.SchoolyearID == graduationSchoolYearView.GraduatingSemesterID)
- .SingleOrDefault();
- if (gradSchoolYearVerification == null)
- {
- //数据有误验证
- if (graduationSchoolYearView.GraduationSchoolYearSettingID != Guid.Empty)
- {
- var gradSchoolYear = GraduationSchoolYearDAL.GraduateSchoolyearRepository
- .GetList(x => x.SchoolyearID == graduationSchoolYearView.GraduatingSemesterID)
- .SingleOrDefault();
- if (gradSchoolYear == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- //查询设置的毕业学期Value
- var graduatingSemesterID = ParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.GraduationSchoolyear);
- if (graduationSchoolYearView.GraduatingSemesterID == graduatingSemesterID)
- {
- if (!graduationSchoolYearView.IsEnable)
- {
- ParameterServices.Value.SaveTo(CF_ParameterType.GraduationSchoolyear, null);
- }
- }
- else
- {
- //设置对应的毕业学期
- if (graduationSchoolYearView.IsEnable)
- {
- ParameterServices.Value.SaveTo(CF_ParameterType.GraduationSchoolyear, graduationSchoolYearView.GraduatingSemesterID.Value);
- }
- }
- gradSchoolYear.GraduateDate = graduationSchoolYearView.GraduateDate;
- SetModifyStatus(gradSchoolYear);
- }
- }
- else
- {
- //表示新增
- //设置对应的毕业学期
- if (graduationSchoolYearView.IsEnable)
- {
- ParameterServices.Value.SaveTo(CF_ParameterType.GraduationSchoolyear, graduationSchoolYearView.GraduatingSemesterID.Value);
- }
- ER_GraduateSchoolyear newGraduateSchoolyear = new ER_GraduateSchoolyear();
- newGraduateSchoolyear.GraduateSchoolyearID = Guid.NewGuid();
- newGraduateSchoolyear.SchoolyearID = graduationSchoolYearView.GraduatingSemesterID;
- newGraduateSchoolyear.GraduateDate = graduationSchoolYearView.GraduateDate;
- SetNewStatus(newGraduateSchoolyear);
- UnitOfWork.Add(newGraduateSchoolyear);
- }
- }
- else
- {
- throw new Exception("已存在相同的毕业学期信息,请核查。");
- }
- //事务提交
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除(注:需对设置的毕业学期进行处理)
- /// </summary>
- /// <param name="graduationSchoolYearSettingIDs"></param>
- /// <returns></returns>
- public bool GraduationSchoolYearDelete(List<Guid?> graduationSchoolYearSettingIDs)
- {
- try
- {
- //查询设置的毕业学期Value
- var graduatingSemesterID = ParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.GraduationSchoolyear);
- //毕业学期设置信息
- Expression<Func<ER_GraduateSchoolyear, bool>> expGraduateSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expGraduateSchoolyear = expGraduateSchoolyear.And(x => graduationSchoolYearSettingIDs.Contains(x.GraduateSchoolyearID));
- var gradSchoolYearViewList = GraduationSchoolYearDAL
- .GetGraduationSchoolYearViewQueryable(expGraduateSchoolyear, graduatingSemesterID).ToList();
- foreach (var gradSchoolYearView in gradSchoolYearViewList)
- {
- if (gradSchoolYearView.IsEnable)
- {
- ParameterServices.Value.SaveTo(CF_ParameterType.GraduationSchoolyear, null);
- }
- }
- UnitOfWork.Delete<ER_GraduateSchoolyear>(x => graduationSchoolYearSettingIDs.Contains(x.GraduateSchoolyearID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|