123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- 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; }
- /// <summary>
- /// 查询课程时间信息
- /// </summary>
- /// <param name="configuretView">查询条件实体</param>
- /// <param name="timesSegment">时间段</param>
- /// <param name="pageIndex">页码</param>
- /// <param name="pageSize">显示页数</param>
- /// <returns></returns>
- public IGridResultSet<CourseTimeHoursView> GetCoursesTimeViewGrid(ConfiguretView configuretView, int? year, Guid? CoursesTimeID, int pageIndex, int pageSize)
- {
- Expression<Func<EM_CoursesTime, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<TP_CourseTimeHours, bool>> 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<CourseTimeHoursView>(pageIndex, pageSize);
- return query.OrderByDescending(x => x.Year).ToGridResultSet<CourseTimeHoursView>(pageIndex, pageSize);
- }
- //查询学时转换
- public CourseTimeHoursView GetCourseTimeHoursView(Guid? id) {
- Expression<Func<EM_CoursesTime, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<TP_CourseTimeHours, bool>> 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<Func<EM_CoursesTime, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<TP_CourseTimeHours, bool>> 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<Guid> id) {
- UnitOfWork.Remove<TP_CourseTimeHours>(x => id.Contains(x.CourseTimeHoursID));
- UnitOfWork.Commit();
- }
- }
- }
|