123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Repositories;
- using EMIS.ViewModel.TeachingMaterial;
- using EMIS.Entities;
- using System.Linq.Expressions;
- using EMIS.ViewModel;
- using System.Data;
- using EMIS.ViewModel.Cultureplan;
- using EMIS.DataLogic.Common.Cultureplan;
- namespace EMIS.DataLogic.Common.TeachingMaterial
- {
- public class TeachingMaterialPoolDAL
- {
- public TeachingMaterialPoolRepository TeachingMaterialPoolRepository { get; set; }
- public UserRepository UserRepository { get; set; }
- public CoursematerialRepository CoursematerialRepository { get; set; }
- public DictionaryItemRepository DictionaryItemRepository { get; set; }
- public PublishRepository PublishRepository { get; set; }
- public OptionalCoursePlanRepository OptionalCoursePlanRepository { get; set; }
- public StudentRepository StudentRepository { get; set; }
- public SpecialtyPlanRepository SpecialtyPlanRepository { get; set; }
- public GrademajorRepository GrademajorRepository { get; set; }
- public SpecialtyCourseRepository SpecialtyCourseRepository { get; set; }
- public Lazy<CoursematerialDAL> CoursematerialDAL { get; set; }
- /// <summary>
- /// 获取教材总库信息列表
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<TeachingMaterialPoolView> GetTeachingMaterialPoolGridView(Expression<Func<CF_TeachingMaterialPool, bool>> exp)
- {
- var view = (from l in TeachingMaterialPoolRepository.Entities.Where(exp)
- //join d in DictionaryItemRepository.Entities
- //on new { l.TeachingMaterialTypeID, DictionaryCode = DictionaryItem.CF_TeachingMaterialType.ToString() } equals new { TeachingMaterialTypeID = d.Value, d.DictionaryCode }
- //into tdic
- //from tbdic in tdic.DefaultIfEmpty()
- join u in UserRepository.Entities on l.CreateUserID equals u.UserID
- join p in PublishRepository.Entities on l.PublishID equals p.PublishID
- into up
- from gup in up.DefaultIfEmpty()
- select new TeachingMaterialPoolView
- {
- Author = l.Author,
- ISBN = l.ISBN,
- CoursematerialEntityList = l.EM_Coursematerial,
- Price = l.Price,
- TeachingMaterialCode = l.TeachingMaterialCode,
- TeachingMaterialName = l.TeachingMaterialName,
- TeachingMaterialShorName = l.TeachingMaterialShorName,
- TeachingMaterialPoolID = l.TeachingMaterialPoolID,
- TeachingMaterialTypeID = l.TeachingMaterialTypeID,
- //TeachingMaterialTypeName = tbdic.Name,
- PublishID = l.PublishID,
- PublishName = gup.UnitName,
- PublishTime = l.PublishTime,
- CreateTime = l.CreateTime,
- CreateUserName = u.Name,
- Desc = l.Desc,
- IsLate = l.IsLate.Value,
- ModifyTime = l.ModifyTime,
- IsLateName = l.IsLate == true ? "是" : "否",
- OrderQty = 1
- });
- return view;
- }
- /// <summary>
- /// 获取教材总库
- /// </summary>
- /// <returns></returns>
- public TeachingMaterialPoolView GetSingleTeachingMaterialPool(Guid teachingMaterialPoolID)
- {
- var teachingMaterialPool = TeachingMaterialPoolRepository.GetSingle(x => x.TeachingMaterialPoolID == teachingMaterialPoolID,
- (x => x.EM_Coursematerial), (x => x.CF_Publish));
- var teachingMaterialPoolView = new TeachingMaterialPoolView()
- {
- Author = teachingMaterialPool.Author,
- IsLate = teachingMaterialPool.IsLate.GetValueOrDefault(),
- ISBN = teachingMaterialPool.ISBN,
- Price = teachingMaterialPool.Price,
- PublishID = teachingMaterialPool.PublishID,
- TeachingMaterialPoolID = teachingMaterialPool.TeachingMaterialPoolID,
- PublishTime = teachingMaterialPool.PublishTime,
- TeachingMaterialCode = teachingMaterialPool.TeachingMaterialCode,
- Desc = teachingMaterialPool.Desc,
- CoursematerialEntityList = teachingMaterialPool.EM_Coursematerial,
- WnningLevel = teachingMaterialPool.WnningLevel == null ? -1 : teachingMaterialPool.WnningLevel,
- TeachingMaterialTypeID = teachingMaterialPool.TeachingMaterialTypeID,
- TeachingMaterialShorName = teachingMaterialPool.TeachingMaterialShorName,
- TeachingMaterialName = teachingMaterialPool.TeachingMaterialName,
- MinInventory = teachingMaterialPool.MinInventory
- };
- return teachingMaterialPoolView;
- }
- /// <summary>
- /// 获取教材总库信息列表(用于学生征订)
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public IQueryable<TeachingMaterialPoolForOrderView> GetTeachingMaterialPoolForOrder(Expression<Func<CF_TeachingMaterialPool, bool>> exp, Guid? coursematerialID)
- {
- var view = (from l in TeachingMaterialPoolRepository.Entities.Where(exp)
- join p in PublishRepository.Entities on l.PublishID equals p.PublishID
- into lp
- from slp in lp.DefaultIfEmpty()
- select new TeachingMaterialPoolForOrderView
- {
- Author = l.Author,
- ISBN = l.ISBN,
- CoursematerialEntityList = l.EM_Coursematerial,
- Price = l.Price,
- TeachingMaterialCode = l.TeachingMaterialCode,
- TeachingMaterialName = l.TeachingMaterialName,
- TeachingMaterialPoolID = l.TeachingMaterialPoolID,
- PublishID = l.PublishID,
- PublishName = slp.UnitName,
- PublishTime = l.PublishTime,
- OrderID = l.EM_Coursematerial.Any(x => x.CoursematerialID == coursematerialID) ? 0 : 1
- });
- return view;
- }
- public IQueryable<StudentTeachingMaterialView> GetStudentTeachingMaterialView(Expression<Func<CF_Student, bool>> studentExp)
- {
- var user = StudentRepository.GetSingle(studentExp, (x => x.CF_Classmajor.CF_Grademajor));
- var q = (from sc in
- (from gm in GrademajorRepository.GetList(x => x.GrademajorID == user.CF_Classmajor.CF_Grademajor.GrademajorID)
- join sp in SpecialtyPlanRepository.GetList(x => x.IsNeedMaterial == true) on gm.GrademajorID equals sp.GrademajorID
- select new { Schoolyear = sp.CF_Schoolyear, SpecialtyPlan = sp })
- //.Union(
- //from gm in GrademajorRepository.GetList(x => x.GrademajorID == user.CF_Classmajor.CF_Grademajor.GrademajorID)
- //join op in OptionalCoursePlanRepository.GetList(x => x.IsNeedMaterial == true) on gm.GrademajorID equals op.GrademajorID
- //join sc in SpecialtyCourseRepository.Entities on op.SpecialtyCourseID equals sc.SpecialtyCourseID
- //select new { Schoolyear = op.CF_Schoolyear, SpecialtyCourse = sc })
- from tmp in sc.SpecialtyPlan.EM_Coursematerial.CF_TeachingMaterialPool
- select new StudentTeachingMaterialView
- {
- SchoolYearID = sc.Schoolyear.SchoolyearID,
- SchoolYearCode = sc.Schoolyear.Code,
- SchoolYearValue = sc.Schoolyear.Value,
- CoursematerialID = sc.SpecialtyPlan.EM_Coursematerial.CoursematerialID,
- CourseName = sc.SpecialtyPlan.EM_Coursematerial.CourseName,
- TeachingMaterialPoolID = tmp.TeachingMaterialPoolID,
- TeachingMaterialName = tmp.TeachingMaterialName,
- PublishTime = tmp.PublishTime,
- ISBN = tmp.ISBN,
- PublishID = tmp.PublishID,
- PublishName = tmp.CF_Publish.UnitName,
- Price = tmp.Price
- }
- );
- return q;
- }
- /// <summary>
- /// 判断是否已经录入
- /// </summary>
- /// <param name="dataSource"></param>
- /// <param name="errorSource"></param>
- private void AddErrorAndExceptExistingDataRow(DataTable dataSource, DataTable errorSource)
- {
- //foreach (DataRow dr in dataSource.Rows)
- //{
- // string loginID = dr["学号"].ToString();
- // var user = listUser.Where(x => x.LoginID == loginID).FirstOrDefault();
- // if (user == null)
- // {
- // AddError(errorSource, dr, "该学号不存在当前录入班级,请检查!");
- // }
- //}
- }
- public IQueryable<CoursematerialView> GetTeachingMaterialPoolCoursematerialView(Expression<Func<CF_TeachingMaterialPool, bool>> exp)
- {
- var query = (from tmp in TeachingMaterialPoolRepository.GetList(exp)
- from cm in tmp.EM_Coursematerial
- join cmv in CoursematerialDAL.Value.GetCoursematerialViewQueryable(x => true)
- on cm.CoursematerialID equals cmv.CoursematerialID
- select cmv);
- return query;
- }
- }
- }
|