123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.RetakeManage;
- using EMIS.ViewModel;
- using EMIS.Entities;
- using EMIS.DataLogic.RetakeManage;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.CommonLogic.CalendarManage;
- namespace EMIS.CommonLogic.RetakeManage
- {
- public class RetakeOpenControlServices : BaseServices, IRetakeOpenControlServices
- {
- public RetakeOpenControlDAL RetakeOpenControlDAL { get; set; }
- public Lazy<IParameterServices> ParameterServices { get; set; }
- public Lazy<ISchoolYearServices> ISchoolYearServices { get; set; }
- /// <summary>
- /// 查询重修控制信息View
- /// </summary>
- /// <param name="openControlConditionView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<RetakeOpenControlView> GetRetakeOpenControlViewList(ConfiguretView openControlConditionView, Guid? schoolyearID, int pageIndex, int pageSize)
- {
- Expression<Func<ER_RetakeOpenControl, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- var query = RetakeOpenControlDAL.GetRetakeOpenControlViewQuery(exp);
- if (!string.IsNullOrEmpty(openControlConditionView.ConditionValue) && !string.IsNullOrEmpty(openControlConditionView.Attribute))
- {
- query = query.DynamicWhere(openControlConditionView.Attribute, openControlConditionView.Condition, openControlConditionView.ConditionValue);
- }
- query = query.OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.StartDate);
- return query.ToGridResultSet<RetakeOpenControlView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询重修控制信息List
- /// </summary>
- /// <param name="openControlConditionView"></param>
- /// <param name="schoolyearID"></param>
- /// <returns></returns>
- public List<RetakeOpenControlView> GetRetakeOpenControlViewList(ConfiguretView openControlConditionView, Guid? schoolyearID)
- {
- Expression<Func<ER_RetakeOpenControl, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- var query = RetakeOpenControlDAL.GetRetakeOpenControlViewQuery(exp);
- if (!string.IsNullOrEmpty(openControlConditionView.ConditionValue) && !string.IsNullOrEmpty(openControlConditionView.Attribute))
- {
- query = query.DynamicWhere(openControlConditionView.Attribute, openControlConditionView.Condition, openControlConditionView.ConditionValue);
- }
- query = query.OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.StartDate);
- return query.ToList();
- }
- /// <summary>
- /// 查询对应的重修控制信息
- /// </summary>
- /// <param name="retakeOpenControlID"></param>
- /// <returns></returns>
- public RetakeOpenControlView GetRetakeOpenControlView(Guid? retakeOpenControlID)
- {
- var query = RetakeOpenControlDAL.GetRetakeOpenControlViewQuery(x => x.RetakeOpenControlID == retakeOpenControlID);
- return query.FirstOrDefault();
- }
- /// <summary>
- /// 查询对应的重修控制信息(根据重修学年学期)
- /// </summary>
- /// <param name="schoolyearID"></param>
- /// <returns></returns>
- public RetakeOpenControlView GetRetakeOpenControlViewBySchoolyearID(Guid? schoolyearID)
- {
- var query = RetakeOpenControlDAL.GetRetakeOpenControlViewQuery(x => x.SchoolyearID == schoolyearID);
- return query.SingleOrDefault();
- }
- /// <summary>
- /// 重修控制编辑(新增、修改)
- /// </summary>
- /// <param name="retakeOpenControlView"></param>
- public void RetakeOpenControlEdit(RetakeOpenControlView retakeOpenControlView)
- {
- try
- {
- ER_RetakeOpenControl openControl = new ER_RetakeOpenControl();
- if (retakeOpenControlView.RetakeOpenControlID == null || retakeOpenControlView.RetakeOpenControlID == Guid.Empty)
- {
- openControl = RetakeOpenControlDAL.RetakeOpenControlRepository
- .GetSingle(x => x.SchoolyearID == retakeOpenControlView.SchoolyearID);
- if (openControl != null)
- {
- throw new Exception("已存在相同学年学期的重修控制信息。");
- }
- openControl = new ER_RetakeOpenControl();
- openControl.RetakeOpenControlID = Guid.NewGuid();
- openControl.SchoolyearID = retakeOpenControlView.SchoolyearID;
- openControl.StartDate = retakeOpenControlView.StartDate;
- openControl.EndDate = retakeOpenControlView.EndDate;
- SetNewStatus(openControl);
- UnitOfWork.Add(openControl);
- }
- else
- {
- openControl = RetakeOpenControlDAL.RetakeOpenControlRepository
- .GetSingle(x => x.RetakeOpenControlID != retakeOpenControlView.RetakeOpenControlID
- && x.SchoolyearID == retakeOpenControlView.SchoolyearID);
- if (openControl != null)
- {
- throw new Exception("已存在相同学年学期的重修控制信息。");
- }
- openControl = RetakeOpenControlDAL.RetakeOpenControlRepository
- .GetSingle(x => x.RetakeOpenControlID == retakeOpenControlView.RetakeOpenControlID);
- if (openControl == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- openControl.SchoolyearID = retakeOpenControlView.SchoolyearID;
- openControl.StartDate = retakeOpenControlView.StartDate;
- openControl.EndDate = retakeOpenControlView.EndDate;
- SetModifyStatus(openControl);
- }
-
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 重修控制删除
- /// </summary>
- /// <param name="openControlIDList"></param>
- public void RetakeOpenControlDelete(IList<Guid?> openControlIDList)
- {
- try
- {
- if (openControlIDList.Count > 0)
- {
- UnitOfWork.Delete<ER_RetakeOpenControl>(x => openControlIDList.Contains(x.RetakeOpenControlID));
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询重修学年学期对应的重修控制信息(根据对应重修学年学期查询)
- /// </summary>
- /// <param name="schoolyearID"></param>
- /// <returns></returns>
- public ER_RetakeOpenControl GetRetakeOpenControl(Guid? schoolyearID)
- {
- try
- {
- Expression<Func<ER_RetakeOpenControl, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- var query = RetakeOpenControlDAL.RetakeOpenControlRepository.GetSingle(exp);
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询重修学年学期对应的重修开放控制信息
- /// </summary>
- /// <param name="schoolyearID"></param>
- /// <returns></returns>
- public string GetRetakeApplyDateTime(Guid? schoolyearID)
- {
- var retakeOpenControl = GetRetakeOpenControl(schoolyearID);
- if (retakeOpenControl == null)
- {
- return "未开放";
- }
- else
- {
- if (retakeOpenControl.StartDate > DateTime.Now)
- {
- return Convert.ToDateTime(retakeOpenControl.StartDate).ToString("yyyy-MM-dd hh:mm:ss")
- + " 至 " + Convert.ToDateTime(retakeOpenControl.EndDate).ToString("yyyy-MM-dd hh:mm:ss")
- + " (即将开始)";
- }
- else if (retakeOpenControl.EndDate < DateTime.Now)
- {
- return Convert.ToDateTime(retakeOpenControl.StartDate).ToString("yyyy-MM-dd hh:mm:ss")
- + " 至 " + Convert.ToDateTime(retakeOpenControl.EndDate).ToString("yyyy-MM-dd hh:mm:ss")
- + " (报名结束)";
- }
- else
- {
- return Convert.ToDateTime(retakeOpenControl.StartDate).ToString("yyyy-MM-dd hh:mm:ss")
- + " 至 " + Convert.ToDateTime(retakeOpenControl.EndDate).ToString("yyyy-MM-dd hh:mm:ss")
- + " (开始报名)";
- }
- }
- }
- }
- }
|