123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- 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; }
- /// <summary>
- /// 查询对应的学位控制信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="graduatingSemesterID"></param>
- /// <param name="degreeBatchID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<DegreeOpenControlView> GetDegreeOpenControlViewGrid(ConfiguretView configuretView, Guid? graduatingSemesterID, int? degreeBatchID, int pageIndex, int pageSize)
- {
- //学位控制
- Expression<Func<ER_DegreeOpenControl, bool>> 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<DegreeOpenControlView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的学位控制信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="graduatingSemesterID"></param>
- /// <param name="degreeBatchID"></param>
- /// <returns></returns>
- public IList<DegreeOpenControlView> GetDegreeOpenControlViewList(ConfiguretView configuretView, Guid? graduatingSemesterID, int? degreeBatchID)
- {
- //学位控制
- Expression<Func<ER_DegreeOpenControl, bool>> 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();
- }
- /// <summary>
- /// 根据学位控制ID查询对应的学位控制信息DegreeOpenControlView
- /// </summary>
- /// <param name="degreeOpenControlID"></param>
- /// <returns></returns>
- 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);
- }
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="degreeOpenControlView"></param>
- 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);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="degreeOpenControlIDList"></param>
- /// <returns></returns>
- public bool DegreeOpenControlDelete(IList<Guid?> degreeOpenControlIDList)
- {
- try
- {
- UnitOfWork.Delete<ER_DegreeOpenControl>(x => degreeOpenControlIDList.Contains(x.DegreeOpenControlID));
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|