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.ViewModel.PaymentManage; using EMIS.ViewModel; using EMIS.DataLogic.PaymentManage; using EMIS.Entities; namespace EMIS.CommonLogic.PaymentManage { public class LevelStandardServices : BaseServices, ILevelStandardServices { public LevelStandardDAL LevelStandardDAL { get; set; } public IGridResultSet GetLevelStandardViewList(ConfiguretView levelStandardConditionView, int? employmentTypeID, int? teacherTypeID, int? paymentLevel, int pageIndex, int pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (teacherTypeID.HasValue) { exp = exp.And(x => x.TeacherType == teacherTypeID); } if (paymentLevel.HasValue) { exp = exp.And(x => x.PaymentLevelID == paymentLevel); } var query = LevelStandardDAL.GetLevelStandardViewQueryable(exp); if (employmentTypeID.HasValue) { query = query.Where(x => x.EmploymentTypeID == employmentTypeID); } if (!string.IsNullOrEmpty(levelStandardConditionView.ConditionValue) && !string.IsNullOrEmpty(levelStandardConditionView.Attribute)) query = query.DynamicWhere(levelStandardConditionView.Attribute, levelStandardConditionView.Condition, levelStandardConditionView.ConditionValue); query = query.OrderBy(x => x.EmploymentTypeID).ThenBy(x => x.TeacherType).ThenBy(x => x.PaymentLevelID); return query.ToGridResultSet(pageIndex, pageSize); } public List GetLevelStandardViewList(ConfiguretView levelStandardConditionView, int? employmentTypeID, int? teacherTypeID, int? paymentLevel) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (teacherTypeID.HasValue) { exp = exp.And(x => x.TeacherType == teacherTypeID); } if (paymentLevel.HasValue) { exp = exp.And(x => x.PaymentLevelID == paymentLevel); } var query = LevelStandardDAL.GetLevelStandardViewQueryable(exp); if (employmentTypeID.HasValue) { query = query.Where(x => x.EmploymentTypeID == employmentTypeID); } if (!string.IsNullOrEmpty(levelStandardConditionView.ConditionValue) && !string.IsNullOrEmpty(levelStandardConditionView.Attribute)) query = query.DynamicWhere(levelStandardConditionView.Attribute, levelStandardConditionView.Condition, levelStandardConditionView.ConditionValue); query = query.OrderBy(x => x.EmploymentTypeID).ThenBy(x => x.TeacherType).ThenBy(x => x.PaymentLevelID); return query.ToList(); } /// /// 获取考试时间信息 /// /// 考试时间ID /// public LevelStandardView GetLevelStandardView(Guid? levelStandardID) { var query = LevelStandardDAL.GetLevelStandardViewQueryable(x => x.LevelStandardID == levelStandardID); return query.FirstOrDefault(); } /// /// 保存 /// /// 实体 /// public void Save(LevelStandardView levelStandardView) { TP_LevelStandard levelStandard = new TP_LevelStandard(); if (levelStandardView.LevelStandardID == null || levelStandardView.LevelStandardID == Guid.Empty) { levelStandard = LevelStandardDAL.LevelStandardRepository.GetSingle(x => x.PaymentLevelID == levelStandardView.PaymentLevelID && x.TeacherType == levelStandardView.TeacherType); if (levelStandard != null) { throw new Exception("已有相同的标准课酬设置,请勿重复设置。"); } levelStandard = new TP_LevelStandard(); levelStandard.LevelStandardID = Guid.NewGuid(); SetNewStatus(levelStandard); UnitOfWork.Add(levelStandard); } else { levelStandard = LevelStandardDAL.LevelStandardRepository.GetSingle(x => x.LevelStandardID != levelStandardView.LevelStandardID && x.PaymentLevelID == levelStandardView.PaymentLevelID && x.TeacherType == levelStandardView.TeacherType); if (levelStandard != null) { throw new Exception("已有相同的标准课酬设置,请勿重复设置。"); } levelStandard = LevelStandardDAL.LevelStandardRepository.GetSingle(x => x.LevelStandardID == levelStandardView.LevelStandardID); if (levelStandard == null) { throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。"); } SetModifyStatus(levelStandard); } levelStandard.PaymentLevelID = levelStandardView.PaymentLevelID; levelStandard.TeacherType = levelStandardView.TeacherType; levelStandard.Amount = levelStandardView.Amount; UnitOfWork.Commit(); } public void Delete(IList levelStandardIDList) { if (levelStandardIDList.Count > 0) { UnitOfWork.Delete(x => levelStandardIDList.Contains(x.LevelStandardID)); } } } }