using System; using System.Collections.Generic; using System.Linq; using System.Text; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.ViewModel.PaymentManage; using EMIS.ViewModel; using EMIS.Entities; using EMIS.DataLogic.PaymentManage; using System.Linq.Expressions; namespace EMIS.CommonLogic.PaymentManage { public class WorktimeAdditionServices : BaseServices, IWorktimeAdditionServices { public WorktimeAdditionDAL WorktimeAdditionDAL { get; set; } public IGridResultSet GetWorktimeAdditionViewList(ConfiguretView worktimeAdditionConditionView, Guid? schoolyearID, Guid? collegeID, Guid? teacherUserID, Guid? studentCollegeID, Guid? courseCollegeID, int? year, int? standard, int? teachingModeID,int? month, int? pageIndex, int? pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> departmentExp = (x => true); Expression> gradeExp = (x => true); Expression> facultyExp = (x => true); if (schoolyearID.HasValue) { exp = exp.And(x => x.SchoolyearID == schoolyearID); } if (collegeID.HasValue) { departmentExp = departmentExp.And(x => x.CollegeID == collegeID); } if (teacherUserID.HasValue) { exp = exp.And(x => x.UserID == teacherUserID); } if (studentCollegeID.HasValue) { facultyExp = facultyExp.And(x => x.CollegeID == studentCollegeID); } if (courseCollegeID.HasValue) { exp = exp.And(x => x.CourseCollegeID == courseCollegeID); } if (year.HasValue) { gradeExp = gradeExp.And(x => x.GradeID == year); } if (standard.HasValue) { facultyExp = facultyExp.And(x => x.StandardID == standard); } if (teachingModeID.HasValue) { exp = exp.And(x => x.TeachingModeID == teachingModeID); } if(month.HasValue) { exp = exp.And(x => x.Month == month); } var query = WorktimeAdditionDAL.GetWorktimeAdditionViewQueryable(exp, departmentExp, gradeExp, facultyExp); if (!string.IsNullOrEmpty(worktimeAdditionConditionView.ConditionValue) && !string.IsNullOrEmpty(worktimeAdditionConditionView.Attribute)) query = query.DynamicWhere(worktimeAdditionConditionView.Attribute, worktimeAdditionConditionView.Condition, worktimeAdditionConditionView.ConditionValue); query = query.OrderByDescending(x => x.SchoolyearCode) .ThenBy(x => x.TeacherName) .ThenBy(x => x.CourseCode) .ThenBy(x => x.TeachingModeID); return query.ToGridResultSet(pageIndex, pageSize); } public List GetWorktimeAdditionViewList(ConfiguretView worktimeAdditionConditionView, Guid? schoolyearID, Guid? collegeID, Guid? teacherUserID, Guid? studentCollegeID, Guid? courseCollegeID, int? year, int? standard, int? teachingModeID, int? month) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> departmentExp = (x => true); Expression> gradeExp = (x => true); Expression> facultyExp = (x => true); if (schoolyearID.HasValue) { exp = exp.And(x => x.SchoolyearID == schoolyearID); } if (collegeID.HasValue) { departmentExp = departmentExp.And(x => x.CollegeID == collegeID); } if (teacherUserID.HasValue) { exp = exp.And(x => x.UserID == teacherUserID); } if (studentCollegeID.HasValue) { facultyExp = facultyExp.And(x => x.CollegeID == studentCollegeID); } if (courseCollegeID.HasValue) { exp = exp.And(x => x.CourseCollegeID == courseCollegeID); } if (year.HasValue) { gradeExp = gradeExp.And(x => x.GradeID == year); } if (standard.HasValue) { facultyExp = facultyExp.And(x => x.StandardID == standard); } if (teachingModeID.HasValue) { exp = exp.And(x => x.TeachingModeID == teachingModeID); } if (month.HasValue) { exp = exp.And(x => x.Month == month); } var query = WorktimeAdditionDAL.GetWorktimeAdditionViewQueryable(exp, departmentExp, gradeExp, facultyExp); if (!string.IsNullOrEmpty(worktimeAdditionConditionView.ConditionValue) && !string.IsNullOrEmpty(worktimeAdditionConditionView.Attribute)) query = query.DynamicWhere(worktimeAdditionConditionView.Attribute, worktimeAdditionConditionView.Condition, worktimeAdditionConditionView.ConditionValue); query = query.OrderByDescending(x => x.SchoolyearCode) .ThenBy(x => x.TeacherName) .ThenBy(x => x.CourseCode) .ThenBy(x => x.TeachingModeID); return query.ToList(); } public WorktimeAdditionView GetWorktimeAdditionView(Guid? worktimeAdditionID) { var query = WorktimeAdditionDAL.GetWorktimeAdditionViewQueryable(x => x.WorktimeAdditionID == worktimeAdditionID, (x => true), (x => true), (x => true)); return query.FirstOrDefault(); } public void Save(WorktimeAdditionView worktimeAdditionView) { TP_WorktimeAddition worktimeAddition = new TP_WorktimeAddition(); if (worktimeAdditionView.WorktimeAdditionID == null || worktimeAdditionView.WorktimeAdditionID == Guid.Empty) { worktimeAddition = new TP_WorktimeAddition(); worktimeAddition.WorktimeAdditionID = Guid.NewGuid(); SetNewStatus(worktimeAddition); UnitOfWork.Add(worktimeAddition); } else { worktimeAddition = WorktimeAdditionDAL.WorktimeAdditionRepository.GetSingle(x => x.WorktimeAdditionID == worktimeAdditionView.WorktimeAdditionID); if (worktimeAddition == null) { throw new Exception("未能找到需要修改的数据,数据可能已被其他用户更改。"); } SetModifyStatus(worktimeAddition); } worktimeAddition.UserID = worktimeAdditionView.UserID; worktimeAddition.SchoolyearID = worktimeAdditionView.SchoolyearID; worktimeAddition.GrademajorID = worktimeAdditionView.GrademajorID; worktimeAddition.CoursematerialID = worktimeAdditionView.CoursematerialID; worktimeAddition.CourseCollegeID = worktimeAdditionView.CourseCollegeID; worktimeAddition.EducationMissionClassName = worktimeAdditionView.EducationMissionClassName; worktimeAddition.TeachingModeID = worktimeAdditionView.TeachingModeID; worktimeAddition.TeachType = worktimeAdditionView.TeachType; worktimeAddition.StudentCount = worktimeAdditionView.StudentCount; worktimeAddition.CourseTime = worktimeAdditionView.CourseTime; worktimeAddition.Month = worktimeAdditionView.Month; worktimeAddition.Remark = worktimeAdditionView.Remark; UnitOfWork.Commit(); } public void Delete(IList worktimeAdditionIDList) { if (worktimeAdditionIDList.Count > 0) { UnitOfWork.Delete(x => worktimeAdditionIDList.Contains(x.WorktimeAdditionID)); } } } }