//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.Entities; //using EMIS.ViewModel; //using EMIS.ViewModel.ExaminationApply; //namespace EMIS.CommonLogic.ExaminationApply //{ // public class SubjectCountLimitServices : BaseServices, ISubjectCountLimitServices // { // public SubjectCountLimitDAL SubjectCountLimitDAL { get; set; } // public Bowin.Common.Linq.Entity.IGridResultSet GetSubjectCountLimitViewList(ViewModel.ConfiguretView subjectCountLimitView, // Guid? examinationTypeID, Guid? facultymajorID, int? yearNum, int pageIndex, int pageSize) // { // Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); // if (examinationTypeID.HasValue) // { // exp = exp.And(x => x.ExaminationTypeID == examinationTypeID); // } // if (facultymajorID.HasValue) // { // exp = exp.And(x => x.FacultymajorID == facultymajorID); // } // if (yearNum.HasValue) // { // exp = exp.And(x => x.Years == yearNum); // } // var q = SubjectCountLimitDAL.GetSubjectCountLimitView(exp); // if (!string.IsNullOrEmpty(subjectCountLimitView.ConditionValue) && !string.IsNullOrEmpty(subjectCountLimitView.Attribute)) // q = q.DynamicWhere(subjectCountLimitView.Attribute, subjectCountLimitView.Condition, subjectCountLimitView.ConditionValue); // return GetQueryByDataRangeByCollege(q).OrderBy(x => x.ExaminationTypeName).ThenBy(x => x.FacultymajorName).ToGridResultSet(pageIndex, pageSize); // } // public IList GetSubjectCountLimitViewList(ViewModel.ConfiguretView subjectCountLimitView, Guid? examinationTypeID, Guid? facultymajorID) // { // Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); // if (examinationTypeID.HasValue) // { // exp = exp.And(x => x.ExaminationTypeID == examinationTypeID); // } // if (facultymajorID.HasValue) // { // exp = exp.And(x => x.FacultymajorID == facultymajorID); // } // var q = SubjectCountLimitDAL.GetSubjectCountLimitView(exp); // if (!string.IsNullOrEmpty(subjectCountLimitView.ConditionValue) && !string.IsNullOrEmpty(subjectCountLimitView.Attribute)) // q = q.DynamicWhere(subjectCountLimitView.Attribute, subjectCountLimitView.Condition, subjectCountLimitView.ConditionValue); // return GetQueryByDataRangeByCollege(q).OrderBy(x => x.ExaminationTypeName).ThenBy(x => x.FacultymajorName).ToList(); // } // public ViewModel.ExaminationApply.SubjectCountLimitView GetSubjectCountLimitViewInfo(Guid? subjectCountLimitID) // { // return SubjectCountLimitDAL.GetSubjectCountLimitView(x => x.ExaminationSubjectCountLimitID == subjectCountLimitID).FirstOrDefault(); // } // public void Save(ViewModel.ExaminationApply.SubjectCountLimitView subjectCountLimitView) // { // var subjectCountLimitEntity = SubjectCountLimitDAL.ExaminationSubjectCountLimitRepository.GetSingle(x => x.ExaminationSubjectCountLimitID == subjectCountLimitView.ExaminationSubjectCountLimitID); // var RepeatSubjectCountLimit = SubjectCountLimitDAL.ExaminationSubjectCountLimitRepository.GetSingle(x => // x.ExaminationTypeID == subjectCountLimitView.ExaminationTypeID && // x.FacultymajorID == subjectCountLimitView.FacultymajorID && x.Years == subjectCountLimitView.Years); // if (subjectCountLimitEntity != null) // { // if (RepeatSubjectCountLimit != null && subjectCountLimitEntity.ExaminationSubjectCountLimitID != RepeatSubjectCountLimit.ExaminationSubjectCountLimitID) // { //门数限定,判断考试类型、院系专业、年级数不能重复 // throw new Exception("已存在相同的考试类型、院系专业、年级数,请核查"); // } // subjectCountLimitEntity.ExaminationTypeID = subjectCountLimitView.ExaminationTypeID; // subjectCountLimitEntity.FacultymajorID = subjectCountLimitView.FacultymajorID; // subjectCountLimitEntity.Years = subjectCountLimitView.Years; // subjectCountLimitEntity.SubjectCountLimit = subjectCountLimitView.SubjectCountLimit; // this.SetModifyStatus(subjectCountLimitEntity); // } // else // { // if (RepeatSubjectCountLimit != null) // { //门数限定,判断考试类型、院系专业、年级数不能重复 // throw new Exception("已存在相同的考试类型、院系专业、年级数,请核查"); // } // subjectCountLimitEntity = new EX_ExaminationSubjectCountLimit(); // subjectCountLimitEntity.ExaminationSubjectCountLimitID = Guid.NewGuid(); // subjectCountLimitEntity.ExaminationTypeID = subjectCountLimitView.ExaminationTypeID; // subjectCountLimitEntity.FacultymajorID = subjectCountLimitView.FacultymajorID; // subjectCountLimitEntity.Years = subjectCountLimitView.Years; // subjectCountLimitEntity.SubjectCountLimit = subjectCountLimitView.SubjectCountLimit; // this.SetNewStatus(subjectCountLimitEntity); // UnitOfWork.Add(subjectCountLimitEntity); // } // UnitOfWork.Commit(); // } // public void Delete(IList subjectCountLimitID) // { // if (subjectCountLimitID.Count > 0) // { // UnitOfWork.Delete(x => subjectCountLimitID.Contains(x.ExaminationSubjectCountLimitID)); // } // } // /// // /// 批量修改前,验证门数限定表的院系专业、学年数、考试类型是否重复 // /// // /// 考试类型 // /// 院系专业 // /// 学年数 // /// // public string[] Validation(Guid? examinationType,List facultymajorIDs,List years) // { // try // { // for (int i = 0; i < facultymajorIDs.Count; i++) // { // Guid a = facultymajorIDs[0].Value; // int b = years[0].Value; // //var SubjectCountLimit = SubjectCountLimitDAL.ExaminationSubjectCountLimitRepository.Entities.Where(x => // // x.ExaminationTypeID == examinationType.Value && x.FacultymajorID == facultymajorIDs[0].Value && // // x.Years == years[0].Value).FirstOrDefault(); // var SubjectCountLimit = SubjectCountLimitDAL.GetSubjectCountLimitView(x => // x.ExaminationTypeID == examinationType.Value && x.FacultymajorID == a && // x.Years == b).FirstOrDefault(); // if (SubjectCountLimit != null) // return new[] { "false", "专业【"+SubjectCountLimit.FacultymajorName + "】第" + SubjectCountLimit.Years + "学年的【" + SubjectCountLimit.ExaminationTypeName + "】考试类型数据已存在。" }; // } // } // catch (Exception ex) // { // return new[] { "false", ex.Message }; // } // return new[] { "true", "成功" }; // } // } //}