123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.MinorGraduation.MinorGraduationSetting;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.MinorGraduation.MinorGraduationSetting;
- using EMIS.CommonLogic.ChargeManage.ArrearsSituation;
- namespace EMIS.CommonLogic.MinorGraduation.MinorGraduationSetting
- {
- public class MinorGraduationConditionServices : BaseServices, IMinorGraduationConditionServices
- {
- public MinorGraduationConditionDAL minorGraduationConditionDAL { get; set; }
- public MinorGraduationStandardDAL minorGraduationStandardDAL { get; set; }
- public IArrearsListServices arrearsListServices { get; set; }
- /// <summary>
- /// 查询辅修条件
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="isCurrent"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<MinorGraduationConditionView> GetMinorGraduationConditionViewGrid(ConfiguretView configuretView, int? isCurrent, int pageIndex, int pageSize)
- {
- //辅修毕业条件
- Expression<Func<ER_MinorGraduationCondition, bool>> exp = (x => true);
- if (isCurrent.HasValue)
- {
- if (isCurrent == 1)
- {
- exp = exp.And(x => x.RecordStatus >= (int)SYS_STATUS.USABLE);
- }
- if (isCurrent == 0)
- {
- exp = exp.And(x => x.RecordStatus <= (int)SYS_STATUS.UNUSABLE);
- }
- }
- var query = minorGraduationConditionDAL.GetMinorGraduationConditionQueryable(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.Title.Length).OrderBy(x => x.Title).ToGridResultSet<MinorGraduationConditionView>(pageIndex, pageSize);
- }
- public List<MinorGraduationConditionView> GetGraduationViewList(ConfiguretView configuretView, int? isCurrent, List<Guid?> idList)
- {
- //毕业条件
- Expression<Func<ER_MinorGraduationCondition, bool>> exp = (x => true);
- if (isCurrent.HasValue)
- {
- if (isCurrent == 1)
- {
- exp = exp.And(x => x.RecordStatus >= (int)SYS_STATUS.USABLE);
- }
- if (isCurrent == 0)
- {
- exp = exp.And(x => x.RecordStatus <= (int)SYS_STATUS.UNUSABLE);
- }
- }
- if (idList != null && idList.Count > 0)
- {
- exp = exp.And(x => idList.Contains(x.MinorGraduationConditionID));
- }
- var query = minorGraduationConditionDAL.GetMinorGraduationConditionQueryable(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.Title.Length).OrderBy(x => x.Title).ToList();
- }
- /// <summary>
- /// 查询单个辅修条件
- /// </summary>
- /// <param name="minorGraduationConditionID"></param>
- /// <returns></returns>
- public MinorGraduationConditionView GetMinorGraduationConditionView(Guid? minorGraduationConditionID)
- {
- try
- {
- var query = minorGraduationConditionDAL
- .GetMinorGraduationConditionQueryable(x => x.MinorGraduationConditionID == minorGraduationConditionID)
- .SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="graduationConditionView"></param>
- public void MinorGraduationConditionEdit(MinorGraduationConditionView minorGraduationConditionView)
- {
- try
- {
- //查询数据库进行验证
- var minorGraduationConditionVerification = minorGraduationConditionDAL.minorGraduationConditionRepository
- .GetList(x => x.MinorGraduationConditionID != minorGraduationConditionView.MinorGraduationConditionID
- && x.Title == minorGraduationConditionView.Title)
- .SingleOrDefault();
- if (minorGraduationConditionVerification == null)
- {
- //数据有误验证
- if (minorGraduationConditionVerification.MinorGraduationConditionID != Guid.Empty)
- {
- var graduationCondition = minorGraduationConditionDAL.minorGraduationConditionRepository
- .GetList(x => x.MinorGraduationConditionID == minorGraduationConditionView.MinorGraduationConditionID)
- .SingleOrDefault();
- if (graduationCondition == null)
- {
- throw new Exception("数据有误,请核查");
- }
- else
- {
- //表示修改
- graduationCondition.Title = minorGraduationConditionView.Title;
- graduationCondition.RecordStatus = minorGraduationConditionView.IsEnable ? (int)SYS_STATUS.USABLE : (int)SYS_STATUS.UNUSABLE;
- SetModifyStatus(graduationCondition);
- }
- }
- else
- {
- //表示新增
- ER_MinorGraduationCondition minorGraduationCondition = new ER_MinorGraduationCondition();
- minorGraduationCondition.MinorGraduationConditionID = Guid.NewGuid();
- minorGraduationCondition.Title = minorGraduationConditionView.Title;
- minorGraduationCondition.MethodFullName = minorGraduationConditionView.MethodFullName;
- SetNewStatus(minorGraduationConditionView);
- UnitOfWork.Add(minorGraduationConditionView);
- }
- }
- else
- {
- throw new Exception("已存在相同条件名称的辅修毕业条件,请核查");
- }
- //事务提交
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 所学学分达到专业要求学分
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public bool PassGraduationCredit(Guid? userID)
- {
- try
- {
- var minorGraduationStandard = minorGraduationStandardDAL.GetMinorGraduationStandardViewByUserID(userID);
- if (minorGraduationStandard.FirstOrDefault() == null)
- {
- throw new Exception("未设置学生所在辅修专业的辅修专业标准");
- }
- else {
- var graduationCredit = minorGraduationStandard.FirstOrDefault().GraduationCredit;
- var studentScore = minorGraduationConditionDAL.GetFinallyScoreViewQueryableByUserID(userID);
- var scoreCredit = studentScore.Sum(x => x.ScoreCredit);
- if (scoreCredit != null && scoreCredit >= graduationCredit)
- {
- return true;
- }
- }
- return false;
- }
- catch (Exception)
- {
-
- throw;
- }
- }
- /// <summary>
- /// 没有欠费
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public bool NotArrearManage(Guid? userID)
- {
- try
- {
- var arrearListView = arrearsListServices.GetArrearListView(userID);
- if (arrearListView == null)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 无条件(测试)
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public bool NotCondition(Guid? userID)
- {
- return true;
- }
- }
- }
|