using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using EMIS.Entities; using EMIS.ViewModel.UniversityManage.TeacherManage; using EMIS.ViewModel.SystemManage.UserManage; using EMIS.DataLogic.Repositories; namespace EMIS.DataLogic.UniversityManage.TeacherManage { public class StaffDAL { public StaffRepository staffRepository { get; set; } public StaffProfileRepository staffProfileRepository { get; set; } public CollegeRepository CollegeRepository { get; set; } public DepartmentRepository DepartmentRepository { get; set; } public UserRepository UserRepository { get; set; } public RoleRepository RoleRepository { get; set; } public StudentRepository StudentRepository { get; set; } public ParameterRepository ParameterRepository { get; set; } /// /// 查询教师信息StaffView(根据教师信息) /// /// /// public IQueryable GetStaffViewQueryable(Expression> exp) { var query = from sf in staffRepository.GetList(exp) join pr in staffProfileRepository.Entities on sf.UserID equals pr.UserID into temppr from sfpr in temppr.DefaultIfEmpty() join col in CollegeRepository.Entities on sf.CollegeID equals col.CollegeID into tempcol from sfcol in tempcol.DefaultIfEmpty() join dep in DepartmentRepository.Entities on sf.DepartmentID equals dep.DepartmentID into tempdep from sfdep in tempdep.DefaultIfEmpty() join us in UserRepository.Entities on sf.UserID equals us.UserID select new StaffView { UserID = sf.UserID, StaffCode = us.LoginID, Name = us.Name, UsedName = sfpr.UsedName, CampusID = sfcol.CampusID, CampusCode = sfcol.CF_Campus.No, CampusName = sfcol.CF_Campus.Name, CollegeID = sf.CollegeID, CollegeNo = sfcol.No, CollegeName = sfcol.Name, DepartmentID = sf.DepartmentID, DepartmentCode = sfdep.No, DepartmentName = sfdep.Name, Nationality = sfpr.Nationality, Place = sfpr.Place, SexID = sf.SexID, BirthDate = sf.BirthDate, NationID = sf.NationID, PoliticsID = sf.PoliticsID, CertificatesType = sf.CertificatesType, CertificatesNum = sf.CertificatesNum, TeacherTypeID = sf.TeacherTypeID, IncumbencyState = sf.IncumbencyState, SituationID = sf.SituationID, TitleID = sf.TitleID, LiteracyLevelID = sf.LiteracyLevelID, LearnPositionID = sf.LearnPositionID, IsDualTeacher = sf.IsDualTeacher ?? false, PaymentLevelID = sf.PaymentLevelID, WorkDate = sf.WorkDate, ComeSchoolDate = sf.ComeSchoolDate, Email = sfpr.Email, ZIPCode = sfpr.ZIPCode, WeChatNum = sfpr.WeChatNum, QQ = sfpr.QQ, Telephone = sfpr.Telephone, OfficeTelephone = sfpr.OfficeTelephone, HousePhone = sfpr.HousePhone, Mobile = sfpr.Mobile, Speciality = sfpr.Speciality, HealthStateID = sfpr.HealthStateID, ReligionID = sfpr.ReligionID, Account = sfpr.Account, Residence = sfpr.Residence, HomeAddress = sfpr.HomeAddress, Address = sfpr.Address, NowAddress = sfpr.NowAddress, PhotoUrl = sf.PhotoUrl, PhotoHasValue = (sf.PhotoUrl == null || sf.PhotoUrl == "") ? false : true, Profile = sf.Profile, RoleCount = us.Sys_Role.Count() == null ? 0 : us.Sys_Role.Count(), AccountStatus = us.RecordStatus, Remark = sf.Remark, RecordStatus = sf.RecordStatus, CreateUserID = sf.CreateUserID, CreateTime = sf.CreateTime, ModifyUserID = sf.ModifyUserID, ModifyTime = sf.ModifyTime }; return query; } /// /// 查询教师信息CF_Staff(根据用户信息) /// /// /// public IQueryable GetStaffQueryable(Expression> expUser) { var query = from us in UserRepository.GetList(expUser) join sf in staffRepository.Entities on us.UserID equals sf.UserID select sf; return query; } /// /// 查询教师对应的校区信息CF_Campus /// /// /// public IQueryable GetUserInChargeCampus(Expression> exp) { var query = from sf in staffRepository.GetList(exp) from smc in sf.CF_StaffManageCampus select smc.CF_Campus; return query; } /// /// 查询教师对应的院系所信息CF_College /// /// /// public IQueryable GetUserInChargeCollege(Expression> exp) { var query = from sf in staffRepository.GetList(exp) from smc in sf.CF_StaffManageCollege select smc.CF_College; return query; } /// /// 查询教师对应的教研室信息CF_Department /// /// /// public IQueryable GetUserInChargeDepartment(Expression> exp) { var query = from sf in staffRepository.GetList(exp) from smd in sf.CF_StaffManageDepartment select smd.CF_Department; return query; } /// /// 查询教师对应的角色信息UserView /// /// /// public IQueryable GetStaffRoleViewQueryable(Expression> exp) { var query = from sf in staffRepository.GetList(exp) join us in UserRepository.Entities on sf.UserID equals us.UserID from rl in us.Sys_Role select new UserView { UserID = sf.UserID, LoginID = us.LoginID, Name = us.Name, SexID = sf.SexID, BirthDate = sf.BirthDate, CampusID = sf.CF_College.CampusID, CampusCode = sf.CF_College.CF_Campus.No, CampusName = sf.CF_College.CF_Campus.Name, CollegeID = sf.CollegeID, CollegeCode = sf.CF_College.No, CollegeName = sf.CF_College.Name, DepartmentID = sf.DepartmentID, DepartmentCode = sf.CF_Department.No, DepartmentName = sf.CF_Department.Name, RoleID = rl.RoleID, RoleOrderNo = rl.OrderNo, RoleName = rl.RoleName, TypeID = rl.TypeID, DataRange = rl.DefaultDataRange, RoleStatus = rl.RecordStatus, Remark = sf.Remark, RecordStatus = us.RecordStatus, CreateUserID = us.CreateUserID, CreateTime = us.CreateTime, ModifyUserID = us.ModifyUserID, ModifyTime = us.ModifyTime }; return query; } } }