using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.PaymentManage; using Bowin.Common.Linq.Entity; using EMIS.ViewModel.PaymentManage; using EMIS.ViewModel; using System.Linq.Expressions; using EMIS.Entities; namespace EMIS.CommonLogic.PaymentManage { public class PaymentStandardServices : BaseServices, IPaymentStandardServices { public PaymentStandardDAL PaymentStandardDAL { get; set; } public IGridResultSet GetPaymentStandardViewList(ConfiguretView paymentStandardConditionView, int pageIndex, int pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = PaymentStandardDAL.GetPaymentStandardViewQueryable(exp); if (!string.IsNullOrEmpty(paymentStandardConditionView.ConditionValue) && !string.IsNullOrEmpty(paymentStandardConditionView.Attribute)) query = query.DynamicWhere(paymentStandardConditionView.Attribute, paymentStandardConditionView.Condition, paymentStandardConditionView.ConditionValue); query = query.OrderBy(x => x.TitleID).ThenBy(x => x.TeacherType); return query.ToGridResultSet(pageIndex, pageSize); } public List GetPaymentStandardViewList() { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = PaymentStandardDAL.GetPaymentStandardViewQueryable(exp); query = query.OrderBy(x => x.TitleID).ThenBy(x => x.TeacherType); return query.ToList(); } /// /// 获取考试时间信息 /// /// 考试时间ID /// public PaymentStandardView GetPaymentStandardView(Guid? paymentStandardID) { var query = PaymentStandardDAL.GetPaymentStandardViewQueryable(x => x.PaymentStandardID == paymentStandardID); return query.FirstOrDefault(); } /// /// 保存 /// /// 实体 /// public void Save(PaymentStandardView paymentStandardView) { TP_PaymentStandard paymentStandard = new TP_PaymentStandard(); if (paymentStandardView.PaymentStandardID == null || paymentStandardView.PaymentStandardID == Guid.Empty) { paymentStandard = PaymentStandardDAL.PaymentStandardRepository.GetSingle(x => x.Title == paymentStandardView.TitleID && x.TeacherType == paymentStandardView.TeacherType); if (paymentStandard != null) { throw new Exception("已有相同的标准课酬设置,请勿重复设置。"); } paymentStandard = new TP_PaymentStandard(); paymentStandard.PaymentStandardID = Guid.NewGuid(); SetNewStatus(paymentStandard); UnitOfWork.Add(paymentStandard); } else { paymentStandard = PaymentStandardDAL.PaymentStandardRepository.GetSingle(x => x.PaymentStandardID != paymentStandardView.PaymentStandardID && x.Title == paymentStandardView.TitleID && x.TeacherType == paymentStandardView.TeacherType); if (paymentStandard != null) { throw new Exception("已有相同的标准课酬设置,请勿重复设置。"); } paymentStandard = PaymentStandardDAL.PaymentStandardRepository.GetSingle(x => x.PaymentStandardID == paymentStandardView.PaymentStandardID); if (paymentStandard == null) { throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。"); } SetModifyStatus(paymentStandard); } paymentStandard.Title = paymentStandardView.TitleID; paymentStandard.TeacherType = paymentStandardView.TeacherType; paymentStandard.Amount = paymentStandardView.Amount; UnitOfWork.Commit(); } public void Delete(IList paymentStandardIDList) { if (paymentStandardIDList.Count > 0) { UnitOfWork.Delete(x => paymentStandardIDList.Contains(x.PaymentStandardID)); } } } }