123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.MinorManage.MinorSetting;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel;
- using EMIS.ViewModel.MinorManage.MinorSetting;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using EMIS.Entities;
- using EMIS.ViewModel.ScoreManage;
- namespace EMIS.CommonLogic.MinorManage.MinorSetting
- {
- public class MinorConditionServices : BaseServices, IMinorConditionServices
- {
- public MinorConditionDAL minorConditionDAL { get; set; }
- /// <summary>
- /// 查询辅修条件列表
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="isCurrent"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<MinorConditionView> MinorConditionViewGrid(ConfiguretView configuretView, int? isCurrent, int pageIndex, int pageSize)
- {
- Expression<Func<ER_MinorCondition, 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 = minorConditionDAL.GetMinorConditionViewQueryable(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.Title).ToGridResultSet<MinorConditionView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询辅修信息(Excel)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="isCurrent"></param>
- /// <param name="idList"></param>
- /// <returns></returns>
- public List<MinorConditionView> GetMinorConditionViewList(ConfiguretView configuretView, int? isCurrent, List<Guid?> idList)
- {
- //毕业条件
- Expression<Func<ER_MinorCondition, 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.Count > 0 && idList != null)
- {
- exp = exp.And(x => idList.Contains(x.MinorConditionID));
- }
- var query = minorConditionDAL.GetMinorConditionViewQueryable(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.Title).ToList();
- }
- /// <summary>
- /// 查询辅修条件(根据ID)
- /// </summary>
- /// <param name="minorConditionID"></param>
- /// <returns></returns>
- public MinorConditionView GetMinorConditionView(Guid? minorConditionID)
- {
- try
- {
- var query = minorConditionDAL
- .GetMinorConditionViewQueryable(x => x.MinorConditionID == minorConditionID)
- .SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 辅修条件编辑(新增、修改)
- /// </summary>
- /// <param name="minorConditionView"></param>
- public void MinorConditionEdit(MinorConditionView minorConditionView)
- {
- try
- {
- ER_MinorCondition minorCondition = new ER_MinorCondition();
- if (minorConditionView.MinorConditionID == null || minorConditionView.MinorConditionID == Guid.Empty)
- {
- //新增、复制新增
- minorCondition = minorConditionDAL.minorConditionRepository
- .GetSingle(x => x.Title == minorConditionView.Title);
- if (minorCondition != null)
- {
- throw new Exception("已存在相同的辅修条件。");
- }
- minorCondition = new ER_MinorCondition();
- minorCondition.MinorConditionID = Guid.NewGuid();
- minorCondition.Title = minorConditionView.Title;
- minorCondition.RecordStatus = minorConditionView.IsEnable ? 1 : 0;
- minorCondition.CreateTime = DateTime.Now;
- minorCondition.CreateUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
- minorCondition.ModifyTime = DateTime.Now;
- minorCondition.ModifyUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
- UnitOfWork.Add(minorCondition);
- }
- else
- {
- //修改
- minorCondition = minorConditionDAL.minorConditionRepository
- .GetSingle(x => x.MinorConditionID != minorConditionView.MinorConditionID
- && x.Title == minorConditionView.Title && x.MethodFullName == minorConditionView.MethodFullName);
- if (minorCondition != null)
- {
- throw new Exception("已存在相同的辅修条件。");
- }
- minorCondition = minorConditionDAL.minorConditionRepository
- .GetSingle(x => x.MinorConditionID == minorConditionView.MinorConditionID);
- if (minorCondition == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- minorCondition.Title = minorConditionView.Title;
- minorCondition.RecordStatus = minorConditionView.IsEnable ? 1 : 0;
- minorCondition.ModifyTime = DateTime.Now;
- minorCondition.ModifyUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 辅修条件删除
- /// </summary>
- /// <param name="minorConditionIDList"></param>
- public void MinorConditionDelete(IList<Guid?> minorConditionIDList)
- {
- try
- {
- if (minorConditionIDList.Count > 0)
- {
- UnitOfWork.Delete<ER_MinorCondition>(x => minorConditionIDList.Contains(x.MinorConditionID));
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 成绩全部及格
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public bool AllPass(Guid userID)
- {
- List<StudentScoreView> scoreList = new List<StudentScoreView>();
- if (minorConditionDAL.GetAllScore(userID) != null)
- {
- scoreList = minorConditionDAL.GetAllScore(userID).ToList();
- if (scoreList.Any(x => x.TotalScore < 60))
- {
- return false;
- }
- }
- return true;
- }
- /// <summary>
- /// 没有补考记录
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public bool NotResit(Guid userID)
- {
- List<StudentScoreView> scoreList = new List<StudentScoreView>();
- if (minorConditionDAL.GetAllScore(userID) != null)
- {
- scoreList = minorConditionDAL.GetAllScore(userID).ToList();
- if (scoreList.Any(x => x.ExamsCategoryID == (int)CF_ExamsCategory.Resit))
- {
- return false;
- }
- }
-
- return true;
- }
- }
- }
|