123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- 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<WorktimeAdditionView> 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<Func<TP_WorktimeAddition, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<CF_Department, bool>> departmentExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
- Expression<Func<CF_Facultymajor, bool>> 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<WorktimeAdditionView> GetWorktimeAdditionViewList(ConfiguretView worktimeAdditionConditionView,
- Guid? schoolyearID, Guid? collegeID, Guid? teacherUserID, Guid? studentCollegeID, Guid? courseCollegeID, int? year, int? standard,
- int? teachingModeID, int? month)
- {
- Expression<Func<TP_WorktimeAddition, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<CF_Department, bool>> departmentExp = (x => true);
- Expression<Func<CF_Grademajor, bool>> gradeExp = (x => true);
- Expression<Func<CF_Facultymajor, bool>> 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<Guid?> worktimeAdditionIDList)
- {
- if (worktimeAdditionIDList.Count > 0)
- {
- UnitOfWork.Delete<TP_WorktimeAddition>(x => worktimeAdditionIDList.Contains(x.WorktimeAdditionID));
- }
- }
- }
- }
|