using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.GraduationManage.GraduationRequirement; using Bowin.Common.Linq.Entity; using EMIS.ViewModel.GraduationManage.GraduationRequirement; using EMIS.ViewModel; using Bowin.Common.Linq; using System.Linq.Expressions; using EMIS.Entities; namespace EMIS.CommonLogic.GraduationManage.GraduationRequirement { public class GrademajorRequirementServices:BaseServices,IGrademajorRequirementServices { public GrademajorRequirementDAL GrademajorRequirementDAL { get; set; } /// /// 查询毕业专业学分信息View /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetGradGrademajorRequirementViewGird(ConfiguretView configuretView, Guid? gradSchoolyearID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, int pageIndex, int pageSize) { //毕业专业学分 Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = GrademajorRequirementDAL.GetGradGrademajorRequirementQueryable(exp); if (gradSchoolyearID.HasValue) { query = query.Where(x => x.GraduatingSemesterID == gradSchoolyearID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (yearID.HasValue) { query = query.Where(x => x.SchoolyearID == yearID); } if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } if (educationID.HasValue) { query = query.Where(x => x.EducationID == educationID); } if (learningformID.HasValue) { query = query.Where(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); query = query.Where(x => x.LearnSystem == LearnSystems); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query) .OrderByDescending(x => x.SchoolyearID).OrderBy(x => x.StandardID) .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID) .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ToGridResultSet(pageIndex, pageSize); } /// /// 查询毕业专业学分信息List /// /// /// /// /// /// /// /// /// /// public IList GetGradGrademajorRequirementViewList(ConfiguretView configuretView, Guid? gradSchoolyearID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem) { //毕业专业学分 Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var query = GrademajorRequirementDAL.GetGradGrademajorRequirementQueryable(exp); if (gradSchoolyearID.HasValue) { query = query.Where(x => x.GraduatingSemesterID == gradSchoolyearID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (yearID.HasValue) { query = query.Where(x => x.SchoolyearID == yearID); } if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } if (educationID.HasValue) { query = query.Where(x => x.EducationID == educationID); } if (learningformID.HasValue) { query = query.Where(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); query = query.Where(x => x.LearnSystem == LearnSystems); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query) .OrderByDescending(x => x.SchoolyearID).OrderBy(x => x.StandardID) .ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID) .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ToList(); } /// /// 根据毕业专业学分ID查询对应的毕业专业学分信息GrademajorRequirementView /// /// /// public GrademajorRequirementView GetGradGrademajorRequirementView(Guid? GraduationRequirementID) { try { var query = GrademajorRequirementDAL .GetGradGrademajorRequirementQueryable(x => x.GraduationRequirementID == GraduationRequirementID) .SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 编辑(新增、修改) /// /// public void GradGrademajorRequirementEdit(GrademajorRequirementView grademajorRequirementView) { try { //查询数据库进行验证 var grademajorRequirementVerification = GrademajorRequirementDAL.GraduationRequirementRepository .GetList(x => x.GraduationRequirementID != grademajorRequirementView.GraduationRequirementID && x.GrademajorID == grademajorRequirementView.GrademajorID) .SingleOrDefault(); if (grademajorRequirementVerification == null) { //数据有误验证 if (grademajorRequirementView.GraduationRequirementID != Guid.Empty) { var grademajorRequirement = GrademajorRequirementDAL.GraduationRequirementRepository .GetList(x => x.GraduationRequirementID == grademajorRequirementView.GraduationRequirementID) .SingleOrDefault(); if (grademajorRequirement == null) { throw new Exception("数据有误,请核查"); } else { //表示修改 grademajorRequirement.GrademajorID = grademajorRequirementView.GrademajorID; grademajorRequirement.OptionalCourseCredit = grademajorRequirementView.OptionalCourseCredit; grademajorRequirement.RequiredCredit = grademajorRequirementView.RequiredCredit; grademajorRequirement.TotalCredit = grademajorRequirementView.TotalCredit; SetModifyStatus(grademajorRequirement); } } else { //表示新增 ER_GraduationRequirement grademajorRequirement = new ER_GraduationRequirement(); grademajorRequirement.GraduationRequirementID = Guid.NewGuid(); grademajorRequirement.GrademajorID = grademajorRequirementView.GrademajorID; grademajorRequirement.OptionalCourseCredit = grademajorRequirementView.OptionalCourseCredit; grademajorRequirement.RequiredCredit = grademajorRequirementView.RequiredCredit; grademajorRequirement.TotalCredit = grademajorRequirementView.TotalCredit; SetNewStatus(grademajorRequirement); UnitOfWork.Add(grademajorRequirement); } } else { throw new Exception("已存在相同的专业学分,请核查"); } //事务提交 UnitOfWork.Commit(); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 删除 /// /// /// public bool GradGrademajorRequirementDelete(IList graduationRequirementIDList) { try { UnitOfWork.Delete(x => graduationRequirementIDList.Contains(x.GraduationRequirementID)); UnitOfWork.Commit(); return true; } catch (Exception ex) { throw new Exception(ex.Message); } } } }