//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.DataLogic.ExaminationApply; //using EMIS.ViewModel.ExaminationApply; //using EMIS.Entities; //using EMIS.ViewModel; //namespace EMIS.CommonLogic.ExaminationApply //{ // public class OpenControlServices : BaseServices, IOpenControlServices // { // public OpenControlDAL OpenControlDAL { get; set; } // public ExaminationSubjectDAL ExaminationSubjectDAL { get; set; } // public ExaminationSubjectServices ExaminationSubjectServices { get; set; } // public Bowin.Common.Linq.Entity.IGridResultSet GetOpenControlViewList(ViewModel.ConfiguretView openControlView, Guid? examinationTypeID, // Guid? examinationSubjectID, int? yearNum, int? studentType, int pageIndex, int pageSize) // { // Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); // if (examinationTypeID.HasValue) // { // exp = exp.And(x => x.EX_ExaminationSubject.ExaminationTypeID == examinationTypeID); // } // if (examinationSubjectID.HasValue) // { // exp = exp.And(x => x.ExaminationSubjectID == examinationSubjectID); // } // if (yearNum.HasValue) // { // exp = exp.And(x => x.SchoolyearNumID == yearNum); // } // if (studentType.HasValue) // { // exp = exp.And(x => x.StudentType == studentType); // } // var q = OpenControlDAL.GetOpenControlView(exp); // if (!string.IsNullOrEmpty(openControlView.ConditionValue) && !string.IsNullOrEmpty(openControlView.Attribute)) // q = q.DynamicWhere(openControlView.Attribute, openControlView.Condition, openControlView.ConditionValue); // return q.ToGridResultSet(pageIndex, pageSize); // } // public IList GetOpenControlViewList(ViewModel.ConfiguretView openControlView, Guid? examinationTypeID, Guid? examinationSubjectID, int? yearNum, int? studentType) // { // Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); // if (examinationTypeID.HasValue) // { // exp = exp.And(x => x.EX_ExaminationSubject.ExaminationTypeID == examinationTypeID); // } // if (examinationSubjectID.HasValue) // { // exp = exp.And(x => x.ExaminationSubjectID == examinationSubjectID); // } // if (yearNum.HasValue) // { // exp = exp.And(x => x.SchoolyearNumID == yearNum); // } // if (studentType.HasValue) // { // exp = exp.And(x => x.StudentType == studentType); // } // var q = OpenControlDAL.GetOpenControlView(exp); // if (!string.IsNullOrEmpty(openControlView.ConditionValue) && !string.IsNullOrEmpty(openControlView.Attribute)) // q = q.DynamicWhere(openControlView.Attribute, openControlView.Condition, openControlView.ConditionValue); // return q.ToList(); // } // public ViewModel.ExaminationApply.OpenControlView GetOpenControlViewInfo(Guid? openControlID) // { // return OpenControlDAL.GetOpenControlView(x => x.ExaminationOpenControlID == openControlID).FirstOrDefault(); // } // public void Save(ViewModel.ExaminationApply.OpenControlView openControlView) // { // EX_ExaminationSubject examinationSubject = null; // if (openControlView.StudentTypeID.Count == 0) // throw new Exception("请选择学生类别"); // if (openControlView.ExaminationSubjectEditID != null) // { // examinationSubject = ExaminationSubjectDAL.ExaminationSubjectRepository.Entities.Where(x => x.ExaminationSubjectID == openControlView.ExaminationSubjectEditID).FirstOrDefault(); // } // else // { // examinationSubject = ExaminationSubjectDAL.ExaminationSubjectRepository.Entities.Where(x => x.ExaminationSubjectID == openControlView.ExaminationSubjectID).FirstOrDefault(); // } // if (examinationSubject != null && examinationSubject.ExaminationDate <= openControlView.EndDate) // { // throw new Exception("报名截止时间不能大于考试时间。"); // } // if (openControlView.StartDate > openControlView.EndDate) // { // throw new Exception("报名时间开始不能大于结束时间。"); // } // ////验证限定人数是否超过最大报名数 // //if (openControlView.ExaminationSubjectID != null) // //{ // // //1.0该科目的最大报名数 // // int? peopleNumLimit = OpenControlDAL.ExaminationSubjectRepository.Entities.Where(x => x.ExaminationSubjectID == openControlView.ExaminationSubjectID).FirstOrDefault().PeopleNumLimit; // // //2.0 获取同一科目,学生类别,年级数汇总限定人数 // // var query = OpenControlDAL.ExaminationOpenControlRepository.Entities // // .Where(x => x.ExaminationSubjectID == openControlView.ExaminationSubjectID // // && openControlView.StudentTypeID.Contains(x.StudentType.Value)); // // var peopleNumLimitSumCountList = query.GroupBy(x => x.StudentType).Select(x => x.Sum(w => w.PeopleNumLimit)).ToList(); // // //int? peopleNumLimitSumCount = OpenControlDAL.ExaminationOpenControlRepository.Entities // // // .Where(x => x.ExaminationSubjectID == openControlView.ExaminationSubjectID // // // && x.StudentType == openControlView.StudentType ) // // // .Select(w => w.PeopleNumLimit).Sum(); // // //if (openControlView.PeopleNumLimit > peopleNumLimit) // // //{ // // // throw new Exception("限定人数超过该科目的最大报名数。"); // // //} // // foreach (var peopleNumLimitSumCount in peopleNumLimitSumCountList) // // { // // if (peopleNumLimitSumCount + openControlView.PeopleNumLimit > peopleNumLimit) // // { // // throw new Exception("该学生类别及年级数汇总限定人数超过该科目的最大报名数。"); // // } // // } // //} // var openControlEntity = OpenControlDAL.ExaminationOpenControlRepository.GetSingle(x => x.ExaminationOpenControlID == openControlView.ExaminationOpenControlID); // int? type = openControlView.StudentTypeID[0]; // if (openControlEntity != null) // { // var RepeatOpenControl = OpenControlDAL.ExaminationOpenControlRepository.GetSingle(x => // x.ExaminationSubjectID == openControlView.ExaminationSubjectEditID && // x.StudentType == type && // //openControlView.StudentTypeID.Contains(x.StudentType.Value) && // x.SchoolyearNumID == openControlView.SchoolyearNumID); // if (RepeatOpenControl != null && openControlEntity.ExaminationOpenControlID != RepeatOpenControl.ExaminationOpenControlID) // { //判断考试科目、学生类别、年级数不能重复 // throw new Exception("已存在相同的考试科目、学生类别、年级数,请核查"); // } // openControlEntity.ExaminationSubjectID = openControlView.ExaminationSubjectEditID; // openControlEntity.StudentType = openControlView.StudentTypeID[0]; // openControlEntity.SchoolyearNumID = openControlView.SchoolyearNumID; // openControlEntity.StartDate = openControlView.StartDate; // openControlEntity.EndDate = openControlView.EndDate; // openControlEntity.PeopleNumLimit = openControlView.PeopleNumLimit; // this.SetModifyStatus(openControlEntity); // } // else // { // var RepeatOpenControl = OpenControlDAL.ExaminationOpenControlRepository.GetSingle(x => // x.ExaminationSubjectID == openControlView.ExaminationSubjectID && // //x.StudentType == openControlView.StudentType && // openControlView.StudentTypeID.Contains(x.StudentType.Value) && // x.SchoolyearNumID == openControlView.SchoolyearNumID); // if (RepeatOpenControl != null) // { //判断考试科目、学生类别、年级数不能重复 // throw new Exception("已存在相同的考试科目、学生类别、年级数,请核查"); // } // if (openControlView.ExaminationSubjectID == null)//考试科目选择全部 // { // //批量以考试科目增加数据 // if (openControlView.ExaminationTypeID != null) // { // List subjectList = ExaminationSubjectDAL.GetExaminationSubjectView(x => x.ExaminationTypeID == openControlView.ExaminationTypeID).ToList(); // if (openControlView.StudentTypeID.Count > 0) // { // subjectList.ForEach(w => // { // openControlView.StudentTypeID.ForEach(x => // { // openControlEntity = new EX_ExaminationOpenControl(); // openControlEntity.ExaminationOpenControlID = Guid.NewGuid(); // openControlEntity.ExaminationSubjectID = w.ExaminationSubjectID; // openControlEntity.StudentType = x; // openControlEntity.SchoolyearNumID = openControlView.SchoolyearNumID; // openControlEntity.StartDate = openControlView.StartDate; // openControlEntity.EndDate = openControlView.EndDate; // openControlEntity.PeopleNumLimit = openControlView.PeopleNumLimit; // this.SetNewStatus(openControlEntity); // UnitOfWork.Add(openControlEntity); // }); // }); // } // } // } // else // { // if (openControlView.StudentTypeID.Count > 0) // { // openControlView.StudentTypeID.ForEach(x => // { // openControlEntity = new EX_ExaminationOpenControl(); // openControlEntity.ExaminationOpenControlID = Guid.NewGuid(); // openControlEntity.ExaminationSubjectID = openControlView.ExaminationSubjectID; // openControlEntity.StudentType = x; // openControlEntity.SchoolyearNumID = openControlView.SchoolyearNumID; // openControlEntity.StartDate = openControlView.StartDate; // openControlEntity.EndDate = openControlView.EndDate; // openControlEntity.PeopleNumLimit = openControlView.PeopleNumLimit; // this.SetNewStatus(openControlEntity); // UnitOfWork.Add(openControlEntity); // }); // } // } // } // UnitOfWork.Commit(); // } // public void Delete(IList openControlID) // { // if (openControlID.Count > 0) // { // UnitOfWork.Delete(x => openControlID.Contains(x.ExaminationOpenControlID)); // } // } // //获取学生类别信息 // public List GetStudentType(Guid? openControlID) // { // return OpenControlDAL.GetStudentTypeQueryble(openControlID); // } // } //}