123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- 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<LevelStandardView> GetLevelStandardViewList(ConfiguretView levelStandardConditionView, int? employmentTypeID,
- int? teacherTypeID, int? paymentLevel, int pageIndex, int pageSize)
- {
- Expression<Func<TP_LevelStandard, bool>> 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<LevelStandardView>(pageIndex, pageSize);
- }
- public List<LevelStandardView> GetLevelStandardViewList(ConfiguretView levelStandardConditionView, int? employmentTypeID,
- int? teacherTypeID, int? paymentLevel)
- {
- Expression<Func<TP_LevelStandard, bool>> 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();
- }
- /// <summary>
- /// 获取考试时间信息
- /// </summary>
- /// <param name="levelStandardID">考试时间ID</param>
- /// <returns></returns>
- public LevelStandardView GetLevelStandardView(Guid? levelStandardID)
- {
- var query = LevelStandardDAL.GetLevelStandardViewQueryable(x => x.LevelStandardID == levelStandardID);
- return query.FirstOrDefault();
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="paymentStandard">实体</param>
- /// <returns></returns>
- 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<Guid?> levelStandardIDList)
- {
- if (levelStandardIDList.Count > 0)
- {
- UnitOfWork.Delete<TP_LevelStandard>(x => levelStandardIDList.Contains(x.LevelStandardID));
- }
- }
- }
- }
|