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 StaffStandardServices : BaseServices, IStaffStandardServices { public StaffStandardDAL StaffStandardDAL { get; set; } public IGridResultSet GetStaffStandardViewList(ConfiguretView staffStandardConditionView, Guid? collegeID, Guid? departmentID, Guid? userID, int? pageIndex, int? pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> collegeExp = (x => true); Expression> departmentExp = (x => true); if (collegeID.HasValue) { collegeExp = collegeExp.And(x => x.CollegeID == collegeID); } if (departmentID.HasValue) { departmentExp = departmentExp.And(x => x.DepartmentID == departmentID); } if (userID.HasValue) { exp = exp.And(x => x.UserID == userID); } var query = StaffStandardDAL.GetStaffStandardViewQueryable(exp, departmentExp, collegeExp); if (!string.IsNullOrEmpty(staffStandardConditionView.ConditionValue) && !string.IsNullOrEmpty(staffStandardConditionView.Attribute)) query = query.DynamicWhere(staffStandardConditionView.Attribute, staffStandardConditionView.Condition, staffStandardConditionView.ConditionValue); query = query.OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.DepartmentName) .ThenBy(x => x.LoginID); return query.ToGridResultSet(pageIndex, pageSize); } public List GetStaffStandardViewList(ConfiguretView staffStandardConditionView, Guid? collegeID, Guid? departmentID, Guid? userID) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> collegeExp = (x => true); Expression> departmentExp = (x => true); if (collegeID.HasValue) { collegeExp = collegeExp.And(x => x.CollegeID == collegeID); } if (departmentID.HasValue) { departmentExp = departmentExp.And(x => x.DepartmentID == departmentID); } if (userID.HasValue) { exp = exp.And(x => x.UserID == userID); } var query = StaffStandardDAL.GetStaffStandardViewQueryable(exp, departmentExp, collegeExp); if (!string.IsNullOrEmpty(staffStandardConditionView.ConditionValue) && !string.IsNullOrEmpty(staffStandardConditionView.Attribute)) query = query.DynamicWhere(staffStandardConditionView.Attribute, staffStandardConditionView.Condition, staffStandardConditionView.ConditionValue); query = query.OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.DepartmentName) .ThenBy(x => x.LoginID); return query.ToList(); } public StaffStandardView GetStaffStandardView(Guid? staffStandardID) { var query = StaffStandardDAL.GetStaffStandardViewQueryable(x => x.StaffStandardID == staffStandardID, (x => true), (x => true)); return query.FirstOrDefault(); } public void Save(StaffStandardView staffStandardView) { TP_StaffStandard staffStandard = new TP_StaffStandard(); staffStandard = StaffStandardDAL.StaffStandardRepository.GetSingle(x => x.UserID == staffStandardView.UserID && x.StaffStandardID != staffStandardView.StaffStandardID); if (staffStandard != null) { throw new Exception("已有相同的标准课酬设置,请勿重复设置。"); } if (staffStandardView.StaffStandardID == null || staffStandardView.StaffStandardID == Guid.Empty) { staffStandard = new TP_StaffStandard(); staffStandard.StaffStandardID = Guid.NewGuid(); SetNewStatus(staffStandard); UnitOfWork.Add(staffStandard); } else { staffStandard = StaffStandardDAL.StaffStandardRepository.GetSingle(x => x.StaffStandardID == staffStandardView.StaffStandardID); if (staffStandard == null) { throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。"); } SetModifyStatus(staffStandard); } staffStandard.UserID = staffStandardView.UserID; staffStandard.Amount = staffStandardView.Amount; UnitOfWork.Commit(); } public void Delete(IList staffStandardIDList) { if (staffStandardIDList.Count > 0) { UnitOfWork.Delete(x => staffStandardIDList.Contains(x.StaffStandardID)); } } } }