using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.SchedulingManage.SchedulingSettings; using Bowin.Common.Linq.Entity; using Bowin.Common.Linq; using EMIS.ViewModel.SchedulingManage.SchedulingSettings; using System.Linq.Expressions; using EMIS.Entities; using EMIS.DataLogic.UniversityManage.ClassroomManage; using EMIS.ViewModel; using EMIS.Utility; namespace EMIS.CommonLogic.SchedulingManage.SchedulingSettings { public class CourseTimeHoursServices:BaseServices,ICourseTimeHoursServices { public CourseTimeHoursDAL CourseTimeHoursDAL { get; set; } /// /// 查询课程时间信息 /// /// 查询条件实体 /// 时间段 /// 页码 /// 显示页数 /// public IGridResultSet GetCoursesTimeViewGrid(ConfiguretView configuretView, int? year, Guid? CoursesTimeID, int pageIndex, int pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> exps = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if(CoursesTimeID.HasValue){ exp = exp.And(x => x.CoursesTimeID == CoursesTimeID); } if(year.HasValue&&year!=-1) { exps = exps.And(x => x.Years == year); } var query = CourseTimeHoursDAL.GetCoursesTimeQueryable(exp, exps); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).ToGridResultSet(pageIndex, pageSize); return query.OrderByDescending(x => x.Year).ToGridResultSet(pageIndex, pageSize); } //查询学时转换 public CourseTimeHoursView GetCourseTimeHoursView(Guid? id) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> exps = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE&&x.CourseTimeHoursID==id); var query=CourseTimeHoursDAL.GetCoursesTimeQueryable(exp, exps).FirstOrDefault(); if(query!=null){ CourseTimeHoursView CourseTimeHoursView=new CourseTimeHoursView(); CourseTimeHoursView.CourseTimeHoursID=query.CourseTimeHoursID; CourseTimeHoursView.CoursesTimeID=query.CoursesTimeID; CourseTimeHoursView.Year = query.Year; CourseTimeHoursView.Hours = query.Hours; return CourseTimeHoursView; } return null; } //保存 public void save(CourseTimeHoursView CourseTimeHoursView) { TP_CourseTimeHours TP_CourseTimeHours; try { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> exps = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.CoursesTimeID == CourseTimeHoursView.CoursesTimeID&&x.Years==CourseTimeHoursView.Year&&x.CourseTimeHoursID!=CourseTimeHoursView.CourseTimeHoursID); var query = CourseTimeHoursDAL.GetCoursesTimeQueryable(exp, exps).ToList(); if(query.Count()>0) { throw new Exception(CourseTimeHoursView.Year+"级在改时间段已存在请重新输入!"); } if (CourseTimeHoursView.CourseTimeHoursID != null) { TP_CourseTimeHours = new Entities.TP_CourseTimeHours(); TP_CourseTimeHours.CourseTimeHoursID = (Guid)CourseTimeHoursView.CourseTimeHoursID; TP_CourseTimeHours.CoursesTimeID = CourseTimeHoursView.CoursesTimeID; TP_CourseTimeHours.Hours = CourseTimeHoursView.Hours; TP_CourseTimeHours.Years = CourseTimeHoursView.Year; TP_CourseTimeHours.RecordStatus = (int)SYS_STATUS.USABLE; UnitOfWork.Update(TP_CourseTimeHours); SetNewStatus(TP_CourseTimeHours); } else { TP_CourseTimeHours = new Entities.TP_CourseTimeHours(); TP_CourseTimeHours.CourseTimeHoursID = Guid.NewGuid(); TP_CourseTimeHours.CoursesTimeID = CourseTimeHoursView.CoursesTimeID; TP_CourseTimeHours.Hours = CourseTimeHoursView.Hours; TP_CourseTimeHours.Years = CourseTimeHoursView.Year; TP_CourseTimeHours.RecordStatus = (int)SYS_STATUS.USABLE; UnitOfWork.Add(TP_CourseTimeHours); SetNewStatus(TP_CourseTimeHours); } } catch (Exception) { throw; } this.UnitOfWork.Commit(); } //删除 public void Delete(List id) { UnitOfWork.Remove(x => id.Contains(x.CourseTimeHoursID)); UnitOfWork.Commit(); } } }