using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.Repositories; using EMIS.ViewModel.SelectCourse; using System.Linq.Expressions; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.CultureplanManage.PlanManagement; namespace EMIS.DataLogic.ElectiveEnter { public class ElectiveCourseEnterDAL { public SelectCourseOpenControlSettingRepository SelectCourseOpenControlSettingRepository { get; set; } public ExecutableOptionalCourseRepository executableOptionalCourseRepository { get; set; } public SchoolyearRepository schoolyearRepository { get; set; } public GrademajorRepository grademajorRepository { get; set; } public DictionaryItemRepository DictionaryItemRepository { get; set; } public OptionalCoursePlanRepository OptionalCoursePlanRepository { get; set; } public SpecialtyCourseRepository specialtyCourseRepository { get; set; } public CoursematerialRepository coursematerialRepository { get; set; } public DepartmentRepository departmentRepository { get; set; } public ClassmajorRepository classmajorRepository { get; set; } public ExecutableOptionalCourseTeachingSettingRepository executableOptionalCourseTeachingSettingRepository { get; set; } public ExecutableOptionalCourseTeacherRepository executableOptionalCourseTeacherRepository { get; set; } public ExecutableOptionalCourseTeachingModeRepository executableOptionalCourseTeachingModeRepository { get; set; } public IQueryable GetOpenControlSettingView( Expression> openCourseSettingExp, Expression> exp, Expression> schoolYearExp, Expression> gradeMajorExp) { var q = from ocps in executableOptionalCourseRepository.GetList(openCourseSettingExp) join ocp in OptionalCoursePlanRepository.Entities on ocps.OptionalCourseID equals ocp.OptionalCourseID into tmp1 from ocpss in tmp1.DefaultIfEmpty() join gr in grademajorRepository.Entities on ocps.GrademajorID equals gr.GrademajorID from cl in ocps.CF_Classmajor.DefaultIfEmpty() //join cl in classmajorRepository.Entities on gr.GrademajorID equals cl.GrademajorID join sc in schoolyearRepository.Entities on new { Years = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value } equals new { Years = sc.Years, SchoolcodeID = sc.SchoolcodeID } join sc1 in schoolyearRepository.Entities on ocps.SchoolyearID equals sc1.SchoolyearID //from gr in gsPlan.DefaultIfEmpty() //join sp in specialtyRepository.Entities on ocp.SpecialtyID equals sp.SpecialtyID //join dr in dictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString()) // on sp.StandardID equals dr.Value // into gs //from sr in gs.DefaultIfEmpty() join co in coursematerialRepository.Entities on ocpss.CoursematerialID equals co.CoursematerialID join sc2 in specialtyCourseRepository.Entities on new { ocpss.CoursematerialID, ocpss.SpecialtyID } equals new { sc2.CoursematerialID, sc2.SpecialtyID } into tmp from gs in tmp.DefaultIfEmpty() join de in departmentRepository.Entities on ocps.DepartmentID equals de.DepartmentID select new OptionalCourseSettingView { ExecutableOptionalCourseID = ocps.ExecutableOptionalCourseID, OptionalCourseID = ocpss.OptionalCourseID, SchoolyearID = sc.SchoolyearID, DefaultClassName = ocps.DefaultClassName, ClassmajorID = cl.ClassmajorID, //StandardID=sp.StandardID, SchoolYearCode = sc1.Code, GSchoolYearCode = sc.Code, GrademajorID = gr.GrademajorID, GrademajorCode = gr.Code, GrademajorName = gr.Name, CampusID = gr.CF_Facultymajor.CF_College.CampusID, CollegeID = gr.CF_Facultymajor.CollegeID, CollegeName = gr.CF_Facultymajor.CF_College.Name, DepartmentID = ocps.DepartmentID, DepartmentName = de.Name, //SpecialtyCourseID = sc.SpecialtyCourseID, SpecialtyID = ocpss.SpecialtyID, StandardID = ocpss.CF_Specialty.StandardID, CoursematerialID = ocpss.CoursematerialID, CourseCode = co.CourseCode, CourseName = co.CourseName, //Credit = sc.EM_SpecialtyCourseTeachingSetting.Credit, //EndWeeklyNum = ocp.EM_SpecialtyCourse.EM_SpecialtyCourseTeachingSetting.EndWeeklyNum, ExaminationModeID = ocps.ExaminationModeID, TeachinglanguageID = ocps.TeachinglanguageID, //HandleModeID = ocp.HandleModeID, //No = ocp.No, //DefaultClassName = ocp.DefaultClassName, //SchoolyearID = ocp.SchoolyearID, //SchoolyearDesc = ocp.CF_Schoolyear.Code, //IsNeedMaterial = ocp.IsNeedMaterial ?? false, PeopleNumlower = ocps.PeopleNumlower, PeopleNumlimit = ocps.PeopleNumlimit, IsEnable = ocps.IsEnable ?? false, IsOpened = ocps.IsOpened ?? false, Remarks = ocps.Remarks, RecordStatus = ocps.RecordStatus, CreateUserID = ocps.CreateUserID, CreateTime = ocps.CreateTime, ModifyUserID = ocps.ModifyUserID, ModifyTime = ocps.ModifyTime, //Schoolyear = gs.SchoolyearID, //Sys_User = ocp.EM_OptionalCoursePlanStaff.Select(x => x.CF_Staff.Sys_User), CourseStructureID = ocps.CourseStructureID, CourseTypeID = ocps.CourseTypeID, Credit = gs.EM_SpecialtyCourseTeachingSetting.Credit, TheoryCourse = gs.EM_SpecialtyCourseTeachingSetting.TheoryCourse, Practicehours = gs.EM_SpecialtyCourseTeachingSetting.Practicehours, Trialhours = gs.EM_SpecialtyCourseTeachingSetting.Trialhours, SchoolyearNumID = ocpss.SchoolyearNumID, SchoolcodeID = ocpss.SchoolcodeID, //StarttermID = ((ocp.EM_SpecialtyCourse.SchoolyearNumID - 1) * 2) + (ocp.EM_SpecialtyCourse.SchoolcodeID == ocp.CF_Grademajor.SchoolcodeID ? 0 : 1) + 1, CourseCategoryID = ocps.CourseCategoryID, //IsMainCourse = ocp.EM_SpecialtyCourse.IsMainCourse ?? false, CourseQualityID = ocps.CourseQualityID, PracticeTypeID = ocps.PracticeTypeID }; //var q = (from scocs in SelectCourseOpenControlSettingRepository.GetList(openControlSettingExp) // join sy in SchoolyearRepository.GetList(schoolYearExp) on scocs.SchoolyearID equals sy.SchoolyearID // join gm in GrademajorRepository.GetList(gradeMajorExp) on scocs.GrademajorID equals gm.GrademajorID // join dis in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Standard).Name) on gm.CF_Facultymajor.StandardID equals dis.Value into ddis // from edis in ddis.DefaultIfEmpty() // join disy in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_Schoolyear).Name) on gm.SchoolyearID equals disy.Value into ddisy // from edisy in ddisy.DefaultIfEmpty() // select new SelectCourseOpenControlSettingView // { // SelectCourseOpenControlSettingID = scocs.SelectCourseOpenControlSettingID, // SchoolyearID = scocs.SchoolyearID, // SchoolyearCode = sy.Code, // GrademajorID = scocs.GrademajorID, // GrademajorName = gm.Name, // YearID = gm.SchoolyearID, // YearName = edisy.Name, // StandardID = gm.CF_Facultymajor.StandardID, // StandardDesc = edis.Name, // CollegeID = gm.CF_Facultymajor.CollegeID, // CollegeName = gm.CF_Facultymajor.CF_College.Name, // StartTime = scocs.StartTime, // EndTime = scocs.EndTime, // MaxSelectCount = scocs.MaxSelectCount, // MinSelectCount = scocs.MinSelectCount, // MaxCredit = scocs.MaxCredit, // MinCredit = scocs.MinCredit, // Remark = scocs.Remark, // RecordStatus = scocs.RecordStatus, // CreateUserID = scocs.CreateUserID, // CreateTime = scocs.CreateTime, // ModifyUserID = scocs.ModifyUserID, // ModifyTime = scocs.ModifyTime // }); return q; } } }