123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.DegreeManage.DegreeSetting;
- using EMIS.ViewModel;
- using EMIS.ViewModel.DegreeManage.DegreeSetting;
- using System.Linq.Expressions;
- using EMIS.Entities;
- namespace EMIS.CommonLogic.DegreeManage.DegreeSetting
- {
- public class DegreeConditionPackageServices : BaseServices, IDegreeConditionPackageServices
- {
- public DegreeConditionPackageDAL DegreeConditionPackageDAL { get; set; }
-
-
-
-
-
-
-
-
- public IGridResultSet<DegreeConditionPackageView> GetDegreeConditionPackageViewGrid(ConfiguretView configuretView,
- int? isDefault, int pageIndex, int pageSize)
- {
-
- Expression<Func<ER_DegreeConditionPackage, bool>> exp = (x => true);
- if (isDefault.HasValue)
- {
- if (isDefault == 1)
- {
- exp = exp.And(x => x.IsDefault.Value == true);
- }
- if (isDefault == 0)
- {
- exp = exp.And(x => x.IsDefault.Value != true);
- }
- }
- var query = DegreeConditionPackageDAL.GetDegreeConditionPackageViewQueryable(exp);
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderByDescending(x => x.Title).ThenBy(x => x.IsDefault)
- .ToGridResultSet<DegreeConditionPackageView>(pageIndex, pageSize);
- }
-
-
-
-
-
-
- public List<DegreeConditionPackageView> GetDegreeConditionPackageViewList(ConfiguretView configuretView, int? isDefault)
- {
-
- Expression<Func<ER_DegreeConditionPackage, bool>> exp = (x => true);
- if (isDefault.HasValue)
- {
- if (isDefault == 1)
- {
- exp = exp.And(x => x.IsDefault.Value == true);
- }
- if (isDefault == 0)
- {
- exp = exp.And(x => x.IsDefault.Value != true);
- }
- }
- var query = DegreeConditionPackageDAL.GetDegreeConditionPackageViewQueryable(exp);
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderByDescending(x => x.Title).ThenBy(x => x.IsDefault).ToList();
- }
-
-
-
-
-
- public DegreeConditionPackageView GetDegreeConditionPackageView(Guid? DegreeConditionPackageID)
- {
- try
- {
- var query = DegreeConditionPackageDAL
- .GetDegreeConditionPackageViewQueryable(x => x.DegreeConditionPackageID == DegreeConditionPackageID)
- .SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
-
-
-
- public List<DegreeConditionView> GetDegreeConditionList(Guid? DegreeConditionPackageID)
- {
- var query = DegreeConditionPackageDAL
- .GetDegreeConditionQueryable(x => x.DegreeConditionPackageID == DegreeConditionPackageID);
- return query.OrderBy(x => x.OrderNo).ToList();
- }
-
-
-
-
-
-
-
-
-
- public IGridResultSet<DegreeConditionView> GetDegreeConditionNoViewGrid(ConfiguretView configuretView,
- Guid? degreeConditionPackageID, int? isCurrent, int pageIndex, int pageSize)
- {
-
- Expression<Func<ER_DegreeCondition, bool>> expDegreeCondition = (x => true);
- if (isCurrent.HasValue)
- {
- if (isCurrent == 1)
- {
- expDegreeCondition = expDegreeCondition.And(x => x.RecordStatus >= (int)SYS_STATUS.USABLE);
- }
- if (isCurrent == 0)
- {
- expDegreeCondition = expDegreeCondition.And(x => x.RecordStatus <= (int)SYS_STATUS.UNUSABLE);
- }
- }
- var query = DegreeConditionPackageDAL.GetDegreeConditionNoQueryable(expDegreeCondition, degreeConditionPackageID);
-
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.OrderNo).ToGridResultSet<DegreeConditionView>(pageIndex, pageSize);
- }
-
-
-
-
-
-
- public IList<DegreeConditionView> GetDegreeConditionNoViewList(ConfiguretView configuretView,
- Guid? degreeConditionPackageID, int? isCurrent)
- {
-
- Expression<Func<ER_DegreeCondition, bool>> expDegreeCondition = (x => true);
- if (isCurrent.HasValue)
- {
- if (isCurrent == 1)
- {
- expDegreeCondition = expDegreeCondition.And(x => x.RecordStatus >= (int)SYS_STATUS.USABLE);
- }
- if (isCurrent == 0)
- {
- expDegreeCondition = expDegreeCondition.And(x => x.RecordStatus <= (int)SYS_STATUS.UNUSABLE);
- }
- }
- var query = DegreeConditionPackageDAL.GetDegreeConditionNoQueryable(expDegreeCondition, degreeConditionPackageID);
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.OrderNo).ToList();
- }
-
-
-
-
-
-
-
- public void DegreeConditionPackageEdit(DegreeConditionPackageView degreeConditionPackageView,
- IList<DegreeConditionView> degreeConditionViewList)
- {
- try
- {
-
- var degreeConditionPackageVerification = DegreeConditionPackageDAL.DegreeConditionPackageRepository
- .GetList(x => x.DegreeConditionPackageID != degreeConditionPackageView.DegreeConditionPackageID
- && x.Title == degreeConditionPackageView.Title)
- .SingleOrDefault();
-
- var degreeConditionIDList = degreeConditionViewList.Select(x => x.DegreeConditionID).ToList();
-
- var degreeConditionList = DegreeConditionPackageDAL.DegreeConditionRepository
- .GetList(x => degreeConditionIDList.Contains(x.DegreeConditionID)).ToList();
- if (degreeConditionPackageVerification == null)
- {
-
- if (degreeConditionPackageView.DegreeConditionPackageID != Guid.Empty)
- {
- var degreeConditionPackage = DegreeConditionPackageDAL.DegreeConditionPackageRepository
- .GetList(x => x.DegreeConditionPackageID == degreeConditionPackageView.DegreeConditionPackageID)
- .SingleOrDefault();
- if (degreeConditionPackage == null)
- {
- throw new Exception("数据有误,请核查");
- }
- else
- {
-
-
-
-
-
-
- if (degreeConditionPackageView.IsDefault)
- {
- var degreeConditionPackageList = DegreeConditionPackageDAL
- .DegreeConditionPackageRepository
- .GetList(x => x.StudentType == degreeConditionPackageView.StudentTypeID && x.IsDefault.Value
- && x.DegreeConditionPackageID != degreeConditionPackageView.DegreeConditionPackageID)
- .ToList();
- degreeConditionPackageList.ForEach(x => x.IsDefault = false);
- }
- degreeConditionPackage.Title = degreeConditionPackageView.Title;
- degreeConditionPackage.StudentType = degreeConditionPackageView.StudentTypeID;
- degreeConditionPackage.IsDefault = degreeConditionPackageView.IsDefault;
- SetModifyStatus(degreeConditionPackage);
-
-
-
-
-
-
-
-
-
-
- UnitOfWork.Delete(degreeConditionPackage, (x => x.ER_DegreeCondition));
-
- if (degreeConditionViewList != null && degreeConditionViewList.Count() > 0)
- {
- foreach (var degreeCondition in degreeConditionList)
- {
- degreeConditionPackage.ER_DegreeCondition.Add(degreeCondition);
- }
- }
- }
- }
- else
- {
-
-
- if (degreeConditionPackageView.IsDefault)
- {
- var degreeConditionPackageList = DegreeConditionPackageDAL
- .DegreeConditionPackageRepository
- .GetList(x => x.StudentType == degreeConditionPackageView.StudentTypeID && x.IsDefault.Value)
- .ToList();
- degreeConditionPackageList.ForEach(x => x.IsDefault = false);
- }
- ER_DegreeConditionPackage degreeConditionPackage = new ER_DegreeConditionPackage();
- degreeConditionPackage.DegreeConditionPackageID = Guid.NewGuid();
- degreeConditionPackage.Title = degreeConditionPackageView.Title;
- degreeConditionPackage.StudentType = degreeConditionPackageView.StudentTypeID;
- degreeConditionPackage.IsDefault = degreeConditionPackageView.IsDefault;
- SetNewStatus(degreeConditionPackage);
- UnitOfWork.Add(degreeConditionPackage);
-
- if (degreeConditionViewList != null && degreeConditionViewList.Count() > 0)
- {
- foreach (var degreeCondition in degreeConditionList)
- {
- degreeConditionPackage.ER_DegreeCondition.Add(degreeCondition);
- }
- }
- }
-
- UnitOfWork.Commit();
- }
- else
- {
- throw new Exception("已存在相同的学位公式,请核查");
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
-
-
-
- public bool DegreeConditionPackageDelete(List<Guid?> DegreeConditionPackageIDList)
- {
- try
- {
-
- var degreeApplyList = DegreeConditionPackageDAL.DegreeApplyRepository
- .GetList(x => DegreeConditionPackageIDList.Contains(x.DegreeConditionPackageID)).ToList();
- if (degreeApplyList != null && degreeApplyList.Count() > 0)
- {
- throw new Exception("存在与其有关联的数据,如:学位申请、学位审核、学位名单等");
- }
-
- var degreeConditionPackageList = DegreeConditionPackageDAL.DegreeConditionPackageRepository
- .GetList(x => DegreeConditionPackageIDList.Contains(x.DegreeConditionPackageID), x => x.ER_DegreeCondition)
- .ToList();
- foreach (var degreeConditionPackage in degreeConditionPackageList)
- {
-
- UnitOfWork.Delete(degreeConditionPackage, (x => x.ER_DegreeCondition));
- UnitOfWork.Delete<ER_DegreeConditionPackage>(x => x.DegreeConditionPackageID == degreeConditionPackage.DegreeConditionPackageID);
- }
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
-
-
-
- public DegreeConditionPackageView GetDegreeConditionPackageIsDefaultView(int? studentType)
- {
- try
- {
-
- Expression<Func<ER_DegreeConditionPackage, bool>> exp = (x => true);
- exp = exp.And(x => x.IsDefault.Value == true);
- exp = exp.And(x => x.StudentType == studentType);
- var degreeConditionPackageView = DegreeConditionPackageDAL
- .GetDegreeConditionPackageViewQueryable(exp).SingleOrDefault();
- return degreeConditionPackageView;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|