using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using Bowin.Common.Linq.Entity; using Bowin.Common.Linq; using EMIS.ViewModel; using EMIS.ViewModel.DegreeManage.DegreeSetting; using EMIS.Entities; using EMIS.DataLogic.DegreeManage.DegreeSetting; namespace EMIS.CommonLogic.DegreeManage.DegreeSetting { public class DegreeOpenControlServices : BaseServices, IDegreeOpenControlServices { public DegreeOpenControlDAL DegreeOpenControlDAL { get; set; } /// /// 查询对应的学位控制信息View /// /// /// /// /// /// /// public IGridResultSet GetDegreeOpenControlViewGrid(ConfiguretView configuretView, Guid? graduatingSemesterID, int? degreeBatchID, int pageIndex, int pageSize) { //学位控制 Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (graduatingSemesterID.HasValue) { exp = exp.And(x => x.GraduatingSemesterID == graduatingSemesterID); } if (degreeBatchID.HasValue) { exp = exp.And(x => x.DegreeBatchID == degreeBatchID); } var query = DegreeOpenControlDAL.GetDegreeOpenControlViewQueryable(exp); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query.OrderByDescending(x => x.GraduatingSemesterValue).ToGridResultSet(pageIndex, pageSize); } /// /// 查询对应的学位控制信息List /// /// /// /// /// public IList GetDegreeOpenControlViewList(ConfiguretView configuretView, Guid? graduatingSemesterID, int? degreeBatchID) { //学位控制 Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (graduatingSemesterID.HasValue) { exp = exp.And(x => x.GraduatingSemesterID == graduatingSemesterID); } if (degreeBatchID.HasValue) { exp = exp.And(x => x.DegreeBatchID == degreeBatchID); } var query = DegreeOpenControlDAL.GetDegreeOpenControlViewQueryable(exp); //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return query.OrderByDescending(x => x.GraduatingSemesterValue).ToList(); } /// /// 根据学位控制ID查询对应的学位控制信息DegreeOpenControlView /// /// /// public DegreeOpenControlView GetDegreeOpenControlView(Guid? degreeOpenControlID) { try { var query = DegreeOpenControlDAL.GetDegreeOpenControlViewQueryable(x => x.DegreeOpenControlID == degreeOpenControlID).SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 编辑(新增、修改) /// /// public void DegreeOpenControlViewEdit(DegreeOpenControlView degreeOpenControlView) { try { var degreeOpenControlVerify = DegreeOpenControlDAL.DegreeOpenControlRepository.GetList(x => x.DegreeOpenControlID != degreeOpenControlView.DegreeOpenControlID && x.GraduatingSemesterID == degreeOpenControlView.GraduatingSemesterID).SingleOrDefault(); if (degreeOpenControlVerify == null) { //数据有误验证 if (degreeOpenControlView.DegreeOpenControlID != Guid.Empty) { var degreeOpenControl = DegreeOpenControlDAL.DegreeOpenControlRepository.GetList(x => x.DegreeOpenControlID == degreeOpenControlView.DegreeOpenControlID).SingleOrDefault(); if (degreeOpenControl == null) { throw new Exception("数据有误,请核查。"); } else { //表示修改 degreeOpenControl.GraduatingSemesterID = degreeOpenControlView.GraduatingSemesterID; degreeOpenControl.DegreeBatchID = degreeOpenControlView.DegreeBatchID; degreeOpenControl.StartDate = degreeOpenControlView.StartDate; degreeOpenControl.EndDate = degreeOpenControlView.EndDate; SetModifyStatus(degreeOpenControl); } } else { //表示新增 ER_DegreeOpenControl degreeOpenControl = new ER_DegreeOpenControl(); degreeOpenControl.DegreeOpenControlID = Guid.NewGuid(); degreeOpenControl.GraduatingSemesterID = degreeOpenControlView.GraduatingSemesterID; degreeOpenControl.DegreeBatchID = degreeOpenControlView.DegreeBatchID; degreeOpenControl.StartDate = degreeOpenControlView.StartDate; degreeOpenControl.EndDate = degreeOpenControlView.EndDate; SetNewStatus(degreeOpenControl); UnitOfWork.Add(degreeOpenControl); } } else { throw new Exception("已存在相同的学位控制信息,请核查。"); } //事务提交 UnitOfWork.Commit(); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 删除 /// /// /// public bool DegreeOpenControlDelete(IList degreeOpenControlIDList) { try { UnitOfWork.Delete(x => degreeOpenControlIDList.Contains(x.DegreeOpenControlID)); return true; } catch (Exception) { throw; } } } }