123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- 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.Entities;
- using EMIS.DataLogic.PaymentManage;
- namespace EMIS.CommonLogic.PaymentManage
- {
- public class WorktimeRateServices : BaseServices, IWorktimeRateServices
- {
- public WorktimeRateDAL WorktimeRateDAL { get; set; }
- public IGridResultSet<WorktimeRateView> GetWorktimeRateViewList(ConfiguretView worktimeRateConditionView,
- Guid? collegeID, int? teachingModeID, int? teachingMethodID, int? paymentLevelID, int? pageIndex, int? pageSize)
- {
- Expression<Func<TP_WorktimeRate, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (teachingModeID.HasValue)
- {
- exp = exp.And(x => x.TeachingModeID == teachingModeID);
- }
- if (teachingMethodID.HasValue)
- {
- exp = exp.And(x => x.TeachingMethodID == teachingMethodID);
- }
- if (paymentLevelID.HasValue)
- {
- exp = exp.And(x => x.PaymentLevelID == paymentLevelID);
- }
- var query = WorktimeRateDAL.GetWorktimeRateViewQueryable(exp);
- if (!string.IsNullOrEmpty(worktimeRateConditionView.ConditionValue) && !string.IsNullOrEmpty(worktimeRateConditionView.Attribute))
- query = query.DynamicWhere(worktimeRateConditionView.Attribute, worktimeRateConditionView.Condition, worktimeRateConditionView.ConditionValue);
- query = this.GetQueryByDataRangeByCollege(query);
- query = query.OrderBy(x => x.CollegeNo.Length)
- .ThenBy(x => x.CollegeNo)
- .ThenBy(x => x.TeachingModeID)
- .ThenBy(x => x.TeachingMethodID)
- .ThenBy(x => x.PaymentLevelID)
- .ThenBy(x => x.StudentCountStart);
- return query.ToGridResultSet(pageIndex, pageSize);
- }
- public List<WorktimeRateView> GetWorktimeRateViewList(ConfiguretView worktimeRateConditionView,
- Guid? collegeID, int? teachingModeID, int? teachingMethodID, int? paymentLevelID)
- {
- Expression<Func<TP_WorktimeRate, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (teachingModeID.HasValue)
- {
- exp = exp.And(x => x.TeachingModeID == teachingModeID);
- }
- if (teachingMethodID.HasValue)
- {
- exp = exp.And(x => x.TeachingMethodID == teachingMethodID);
- }
- if (paymentLevelID.HasValue)
- {
- exp = exp.And(x => x.PaymentLevelID == paymentLevelID);
- }
- var query = WorktimeRateDAL.GetWorktimeRateViewQueryable(exp);
- if (!string.IsNullOrEmpty(worktimeRateConditionView.ConditionValue) && !string.IsNullOrEmpty(worktimeRateConditionView.Attribute))
- query = query.DynamicWhere(worktimeRateConditionView.Attribute, worktimeRateConditionView.Condition, worktimeRateConditionView.ConditionValue);
- query = this.GetQueryByDataRangeByCollege(query);
- query = query.OrderBy(x => x.CollegeNo.Length)
- .ThenBy(x => x.CollegeNo)
- .ThenBy(x => x.TeachingModeID)
- .ThenBy(x => x.TeachingMethodID)
- .ThenBy(x => x.PaymentLevelID)
- .ThenBy(x => x.StudentCountStart);
- return query.ToList();
- }
- public WorktimeRateView GetWorktimeRateView(Guid? worktimeRateID)
- {
- var query = WorktimeRateDAL.GetWorktimeRateViewQueryable(x => x.WorktimeRateID == worktimeRateID);
- return query.FirstOrDefault();
- }
- public void Save(WorktimeRateView worktimeRateView)
- {
- TP_WorktimeRate worktimeRate = new TP_WorktimeRate();
- var dupWorktimeRate = WorktimeRateDAL.WorktimeRateRepository.GetSingle(x => x.CollegeID == worktimeRateView.CollegeID
- && x.TeachingModeID == worktimeRateView.TeachingModeID && x.TeachingMethodID == worktimeRateView.TeachingMethodID
- && x.PaymentLevelID == worktimeRateView.PaymentLevelID
- && (
- (worktimeRateView.StudentCountEnd == null || x.StudentCountStart <= worktimeRateView.StudentCountEnd)
- && (x.StudentCountEnd == null || x.StudentCountEnd >= worktimeRateView.StudentCountStart)
- )
- && x.WorktimeRateID != worktimeRateView.WorktimeRateID
- );
- if (dupWorktimeRate != null)
- {
- throw new Exception("已有相同的工作量系数设置,请勿重复设置。");
- }
- if (worktimeRateView.WorktimeRateID == null || worktimeRateView.WorktimeRateID == Guid.Empty)
- {
- worktimeRate = new TP_WorktimeRate();
- worktimeRate.WorktimeRateID = Guid.NewGuid();
- SetNewStatus(worktimeRate);
- UnitOfWork.Add(worktimeRate);
- }
- else
- {
- worktimeRate = WorktimeRateDAL.WorktimeRateRepository.GetSingle(x => x.WorktimeRateID == worktimeRateView.WorktimeRateID);
- if (worktimeRate == null)
- {
- throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。");
- }
- SetModifyStatus(worktimeRate);
- }
- worktimeRate.CollegeID = worktimeRateView.CollegeID;
- worktimeRate.TeachingModeID = worktimeRateView.TeachingModeID;
- worktimeRate.TeachingMethodID = worktimeRateView.TeachingMethodID;
- worktimeRate.PaymentLevelID = worktimeRateView.PaymentLevelID;
- worktimeRate.StudentCountStart = worktimeRateView.StudentCountStart;
- worktimeRate.StudentCountEnd = worktimeRateView.StudentCountEnd;
- worktimeRate.WorktimeRate = worktimeRateView.WorktimeRate;
- UnitOfWork.Commit();
- }
- public void Delete(IList<Guid?> worktimeRateIDList)
- {
- if (worktimeRateIDList.Count > 0)
- {
- UnitOfWork.Delete<TP_WorktimeRate>(x => worktimeRateIDList.Contains(x.WorktimeRateID));
- }
- }
- }
- }
|