123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.SelectCourse;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.DataLogic.SelectCourse;
- namespace EMIS.CommonLogic.SelectCourse
- {
- public class ExaminationSubjectCollegeControlServices : BaseServices, IExaminationSubjectCollegeControlServices
- {
- public ExaminationSubjectCollegeControlDAL examinationSubjectCollegeControlDAL { get; set; }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="examinationTypeID"></param>
- /// <param name="examinationSubjectID"></param>
- /// <param name="collegeID"></param>
- /// <param name="facultymajorID"></param>
- /// <param name="schoolyearNumID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<ExaminationSubjectCollegeControlView> GetExaminationSubjectCollegeControlViewGrid(ConfiguretView configuretView, Guid? examinationTypeID, Guid? examinationSubjectID, Guid? collegeID, Guid? facultymajorID, int? schoolyearNumID, int pageIndex, int pageSize)
- {
- Expression<Func<EX_ExaminationSubjectCollegeControl, bool>> esccexp = x => true;
- Expression<Func<EX_ExaminationSubject, bool>> esexp= x => true;
- Expression<Func<CF_Facultymajor, bool>> fexp = x => true;
- if (examinationTypeID.HasValue)
- {
- esexp = esexp.And(x => x.ExaminationTypeID == examinationTypeID);
- }
- if (examinationSubjectID.HasValue)
- {
- esccexp = esccexp.And(x => x.ExaminationSubjectID == examinationSubjectID);
- }
- if (collegeID.HasValue)
- {
- fexp = fexp.And(x => x.CollegeID == collegeID);
- }
- if (facultymajorID.HasValue)
- {
- esccexp = esccexp.And(x => x.FacultymajorID == facultymajorID);
- }
- if (schoolyearNumID.HasValue)
- {
- esccexp = esccexp.And(x => x.SchoolyearNumID == schoolyearNumID);
- }
- var query = examinationSubjectCollegeControlDAL.GetExaminationSubjectCollegeControlView(esccexp, esexp, fexp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var result = GetQueryByDataRangeByCollege(query);
- return result.OrderBy(x => x.ExaminationSubjectName.Length).ThenBy(x => x.ExaminationSubjectName).ThenBy(x => x.CollegeName.Length).ThenBy(x => x.CollegeName).ThenBy(x => x.SchoolyearNumID).ToGridResultSet<ExaminationSubjectCollegeControlView>(pageIndex, pageSize);
- }
- /// <summary>
- /// excel导出
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="examinationTypeID"></param>
- /// <param name="examinationSubjectID"></param>
- /// <param name="collegeID"></param>
- /// <param name="facultymajorID"></param>
- /// <param name="schoolyearNumID"></param>
- /// <param name="idList"></param>
- /// <returns></returns>
- public List<ExaminationSubjectCollegeControlView> GetExaminationSubjectCollegeControlViewList(ConfiguretView configuretView, Guid? examinationTypeID, Guid? examinationSubjectID, Guid? collegeID, Guid? facultymajorID, int? schoolyearNumID, List<Guid?> idList)
- {
- Expression<Func<EX_ExaminationSubjectCollegeControl, bool>> esccexp = x => true;
- Expression<Func<EX_ExaminationSubject, bool>> esexp = x => true;
- Expression<Func<CF_Facultymajor, bool>> fexp = x => true;
- if (examinationTypeID.HasValue)
- {
- esexp = esexp.And(x => x.ExaminationTypeID == examinationTypeID);
- }
- if (examinationSubjectID.HasValue)
- {
- esccexp = esccexp.And(x => x.ExaminationSubjectID == examinationSubjectID);
- }
- if (collegeID.HasValue)
- {
- fexp = fexp.And(x => x.CollegeID == collegeID);
- }
- if (facultymajorID.HasValue)
- {
- esccexp = esccexp.And(x => x.FacultymajorID == facultymajorID);
- }
- if (schoolyearNumID.HasValue)
- {
- esccexp = esccexp.And(x => x.SchoolyearNumID == schoolyearNumID);
- }
- if (idList.Count > 0)
- {
- esccexp = esccexp.And(x => idList.Contains(x.ExaminationSubjectCollegeControlID));
- }
- var query = examinationSubjectCollegeControlDAL.GetExaminationSubjectCollegeControlView(esccexp, esexp, fexp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var result = GetQueryByDataRangeByCollege(query);
- return result.OrderBy(x => x.ExaminationSubjectName.Length).ThenBy(x => x.ExaminationSubjectName).ThenBy(x => x.CollegeName.Length).ThenBy(x => x.CollegeName).ThenBy(x => x.SchoolyearNumID).ToList();
- }
- public ExaminationSubjectCollegeControlView GetExaminationSubjectCollegeControlView(Guid? examinationSubjectCollegeControlID)
- {
- Expression<Func<EX_ExaminationSubjectCollegeControl, bool>> esccexp = x => x.ExaminationSubjectCollegeControlID == examinationSubjectCollegeControlID;
- var query = examinationSubjectCollegeControlDAL.GetExaminationSubjectCollegeControlView(esccexp, x => true, x => true).FirstOrDefault();
- return query;
- }
- /// <summary>
- /// 新增
- /// </summary>
- /// <param name="examinationSubjectCollegeControlView"></param>
- /// <param name="facultymajorIDList"></param>
- public void ExaminationSubjectCollegeControlAdd(ExaminationSubjectCollegeControlView examinationSubjectCollegeControlView, List<Guid> facultymajorIDList)
- {
- try
- {
- if (facultymajorIDList.Count > 0)
- {
- List<EX_ExaminationSubjectCollegeControl> examinationSubjectCollegeControlList = new List<EX_ExaminationSubjectCollegeControl>();
- foreach (Guid facultymajorID in facultymajorIDList)
- {
- EX_ExaminationSubjectCollegeControl examinationSubjectCollegeControl = new EX_ExaminationSubjectCollegeControl();
- //新增
- examinationSubjectCollegeControl = examinationSubjectCollegeControlDAL.examinationSubjectCollegeControlRepository
- .GetSingle(x => x.ExaminationSubjectID == examinationSubjectCollegeControlView.ExaminationSubjectID && x.FacultymajorID == examinationSubjectCollegeControlView.FacultymajorID
- && x.SchoolyearNumID == examinationSubjectCollegeControlView.SchoolyearNumID);
- if (examinationSubjectCollegeControl != null)
- {
- throw new Exception("已存在相同的专业报考限制信息。");
- }
- examinationSubjectCollegeControl = new EX_ExaminationSubjectCollegeControl();
- examinationSubjectCollegeControl.ExaminationSubjectCollegeControlID = Guid.NewGuid();
- examinationSubjectCollegeControl.ExaminationSubjectID = examinationSubjectCollegeControlView.ExaminationSubjectID;
- examinationSubjectCollegeControl.FacultymajorID = facultymajorID;
- examinationSubjectCollegeControl.SchoolyearNumID = examinationSubjectCollegeControlView.SchoolyearNumID == -1 ? null : examinationSubjectCollegeControlView.SchoolyearNumID;
- SetNewStatus(examinationSubjectCollegeControl);
- examinationSubjectCollegeControlList.Add(examinationSubjectCollegeControl);
- }
- UnitOfWork.BulkInsert(examinationSubjectCollegeControlList);
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="examinationSubjectCollegeControlView"></param>
- public void ExaminationSubjectCollegeControlEdit(ExaminationSubjectCollegeControlView examinationSubjectCollegeControlView)
- {
- try
- {
- EX_ExaminationSubjectCollegeControl examinationSubjectCollegeControl = new EX_ExaminationSubjectCollegeControl();
- //修改
- examinationSubjectCollegeControl = examinationSubjectCollegeControlDAL.examinationSubjectCollegeControlRepository
- .GetSingle(x => x.ExaminationSubjectCollegeControlID != examinationSubjectCollegeControlView.ExaminationSubjectCollegeControlID
- && x.ExaminationSubjectID == examinationSubjectCollegeControlView.ExaminationSubjectID && x.FacultymajorID == examinationSubjectCollegeControlView.FacultymajorID
- && x.SchoolyearNumID == examinationSubjectCollegeControlView.SchoolyearNumID);
- if (examinationSubjectCollegeControl != null)
- {
- throw new Exception("已存在相同的专业报考限制信息。");
- }
- examinationSubjectCollegeControl = examinationSubjectCollegeControlDAL.examinationSubjectCollegeControlRepository
- .GetSingle(x => x.ExaminationSubjectCollegeControlID == examinationSubjectCollegeControlView.ExaminationSubjectCollegeControlID);
- if (examinationSubjectCollegeControl == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- examinationSubjectCollegeControl.ExaminationSubjectID = examinationSubjectCollegeControlView.ExaminationSubjectID;
- examinationSubjectCollegeControl.FacultymajorID = examinationSubjectCollegeControlView.FacultymajorID;
- examinationSubjectCollegeControl.SchoolyearNumID = examinationSubjectCollegeControlView.SchoolyearNumID == -1 ? null : examinationSubjectCollegeControlView.SchoolyearNumID;
- SetModifyStatus(examinationSubjectCollegeControl);
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="examinationSubjectCollegeControlIDList"></param>
- public void ExaminationSubjectCollegeControlDelete(IList<Guid?> examinationSubjectCollegeControlIDList)
- {
- try
- {
- if (examinationSubjectCollegeControlIDList.Count > 0)
- {
- UnitOfWork.Delete<EX_ExaminationSubjectCollegeControl>(x => examinationSubjectCollegeControlIDList.Contains(x.ExaminationSubjectCollegeControlID));
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|