123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.MinorManage.MinorSetting;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.MinorManage.MinorSetting;
- namespace EMIS.CommonLogic.MinorManage.MinorSetting
- {
- public class MinorControlServices : BaseServices, IMinorControlServices
- {
- public MinorControlDAL minorControlDAL { get; set; }
- /// <summary>
- /// 获取辅修控制列表
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="GradeyearID"></param>
- /// <param name="collegeID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<MinorControlView> GetMinorControlViewList(ConfiguretView configuretView, Guid? schoolyearID, int? GradeyearID, Guid? collegeID, int pageIndex, int pageSize)
- {
- Expression<Func<ER_MinorControl, bool>> exp = x => true;
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (GradeyearID.HasValue)
- {
- exp = exp.And(x => x.GradeyearID == GradeyearID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- var query = minorControlDAL.GetMinorControlViewQueryable(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- }
- query = query.OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.StartDate);
- return query.ToGridResultSet<MinorControlView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的辅修控制信息
- /// </summary>
- /// <param name="retakeOpenControlID"></param>
- /// <returns></returns>
- public MinorControlView GetMinorControlView(Guid? minorControlID)
- {
- var query = minorControlDAL.GetMinorControlViewQueryable(x => x.MinorControlID == minorControlID);
- return query.FirstOrDefault();
- }
- /// <summary>
- /// 辅修控制编辑(新增、修改)
- /// </summary>
- /// <param name="retakeOpenControlView"></param>
- public void MinorControlEdit(MinorControlView minorControlView)
- {
- try
- {
- ER_MinorControl minorControl = new ER_MinorControl();
- if (minorControlView.MinorControlID == null || minorControlView.MinorControlID == Guid.Empty)
- {
- //新增、复制新增
- minorControl = minorControlDAL.minorControlRepository
- .GetSingle(x => x.SchoolyearID == minorControlView.SchoolyearID && x.CollegeID == minorControlView.CollegeID && x.GradeyearID == minorControlView.GradeYearID);
- if (minorControl != null)
- {
- throw new Exception("院系所下已存在相同学年学期的辅修控制信息");
- }
- minorControl = new ER_MinorControl();
- minorControl.MinorControlID = Guid.NewGuid();
- minorControl.SchoolyearID = minorControlView.SchoolyearID;
- minorControl.GradeyearID = minorControlView.GradeYearID;
- minorControl.CollegeID = minorControlView.CollegeID;
- minorControl.StartDate = minorControlView.StartDate;
- minorControl.EndDate = minorControlView.EndDate;
- SetNewStatus(minorControl);
- UnitOfWork.Add(minorControl);
- }
- else
- {
- //修改
- minorControl = minorControlDAL.minorControlRepository
- .GetSingle(x => x.MinorControlID != minorControlView.MinorControlID
- && x.SchoolyearID == minorControlView.SchoolyearID && x.CollegeID == minorControlView.CollegeID && x.GradeyearID == minorControlView.GradeYearID);
- if (minorControl != null)
- {
- throw new Exception("院系所下已存在相同学年学期的重修控制信息。");
- }
- minorControl = minorControlDAL.minorControlRepository
- .GetSingle(x => x.MinorControlID == minorControlView.MinorControlID);
- if (minorControl == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- minorControl.SchoolyearID = minorControlView.SchoolyearID;
- minorControl.GradeyearID = minorControlView.GradeYearID;
- minorControl.CollegeID = minorControlView.CollegeID;
- minorControl.StartDate = minorControlView.StartDate;
- minorControl.EndDate = minorControlView.EndDate;
- SetModifyStatus(minorControl);
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 辅修控制删除
- /// </summary>
- /// <param name="openControlIDList"></param>
- public void MinorControlDelete(IList<Guid?> minorControlIDList)
- {
- try
- {
- if (minorControlIDList.Count > 0)
- {
- UnitOfWork.Delete<ER_MinorControl>(x => minorControlIDList.Contains(x.MinorControlID));
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|