using System; using System.Collections.Generic; using System.Linq; using System.Text; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.CommonLogic.SystemServices; using EMIS.Entities; using EMIS.DataLogic.RetakeManage; using EMIS.CommonLogic.EducationSchedule; using System.Linq.Expressions; using EMIS.ViewModel; using EMIS.ViewModel.RetakeManage; using EMIS.ViewModel.EducationManage; using EMIS.Utility.FormValidate; using EMIS.DataLogic.ChargeManage.ArrearsSituation; namespace EMIS.CommonLogic.RetakeManage { public class RetakePlanStudentServices : BaseWorkflowServices, IRetakePlanStudentServices { public RetakeConditionDAL RetakeConditionDAL { get; set; } public RetakeOpenControlDAL RetakeOpenControlDAL { get; set; } public RetakePlanDAL RetakePlanDAL { get; set; } public ChargeControlDAL ChargeControlDAL { get; set; } public Lazy EducationMissionClassScheduleAdultServices { get; set; } public Lazy ParameterServices { get; set; } public Bowin.Common.Linq.Entity.IGridResultSet GetRetakeStudentListViewList( ViewModel.ConfiguretView retakePlanConditionView, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID, bool? isNoArrear, int? learningformID, int? education, string LearnSystem, int pageIndex, int pageSize) { Expression> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> studentExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { planExp = planExp.And(x => x.SchoolyearID == schoolyearID); } if (collegeID.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID); } if (year.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year); } if (standardID.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID); } if (classmajorID != null) { studentExp = studentExp.And(x => x.CF_Student.ClassmajorID == classmajorID); } if (learningformID.HasValue) studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID); if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1") { var LearnSystems = Convert.ToDecimal(LearnSystem); studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems); } if (education.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value); } var query = this.RetakePlanDAL.GetRetakeStudentListViewQuery(planExp, studentExp); if (!string.IsNullOrEmpty(retakePlanConditionView.ConditionValue) && !string.IsNullOrEmpty(retakePlanConditionView.Attribute)) query = query.DynamicWhere(retakePlanConditionView.Attribute, retakePlanConditionView.Condition, retakePlanConditionView.ConditionValue); if (isNoArrear==false) { query = query.Where(x => x.AmountSum == 0 || x.AmountSum == null); } if (isNoArrear == true) { query = query.Where(x => x.AmountSum>0); } query = this.GetQueryByDataRangeByCollege(query); query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID); return query.ToGridResultSet(pageIndex, pageSize); } //Excel导出 public List GetRetakeExcelList(ViewModel.ConfiguretView retakePlanConditionView, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID,bool? isNoArrear,int? learningformID,int? education,string LearnSystem) { Expression> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> studentExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { planExp = planExp.And(x => x.SchoolyearID == schoolyearID); } if (collegeID.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID); } if (year.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year); } if (standardID.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID); } if (classmajorID != null) { studentExp = studentExp.And(x => x.CF_Student.ClassmajorID == classmajorID); } if (learningformID.HasValue) studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID); if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1") { var LearnSystems = Convert.ToDecimal(LearnSystem); studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems); } if (education.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value); } var query = this.RetakePlanDAL.GetRetakeStudentListViewQuery(planExp, studentExp); if (!string.IsNullOrEmpty(retakePlanConditionView.ConditionValue) && !string.IsNullOrEmpty(retakePlanConditionView.Attribute)) query = query.DynamicWhere(retakePlanConditionView.Attribute, retakePlanConditionView.Condition, retakePlanConditionView.ConditionValue); if (isNoArrear == false) { query = query.Where(x => x.AmountSum == 0 || x.AmountSum == null); } if (isNoArrear == true) { query = query.Where(x => x.AmountSum > 0); } query = this.GetQueryByDataRangeByCollege(query); query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID); return query.ToList(); } public Bowin.Common.Linq.Entity.IGridResultSet GetRetakeStudentDetailListView( Guid? userID, Guid? schoolyearID, int pageIndex, int pageSize) { Expression> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> studentExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { planExp = planExp.And(x => x.SchoolyearID == schoolyearID); } var query = this.RetakePlanDAL.GetRetakeStudentDetailListViewQuery(planExp, studentExp); if (userID.HasValue) { query = query.Where(x => x.UserID == userID); } query = this.GetQueryByDataRangeByCollege(query); query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID); return query.ToGridResultSet(pageIndex, pageSize); } public List GetRetakeStudentListViewList(ViewModel.ConfiguretView retakePlanConditionView, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID, bool? isNoArrear) { Expression> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> studentExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { planExp = planExp.And(x => x.SchoolyearID == schoolyearID); } if (collegeID.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID); } if (year.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year); } if (standardID.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID); } if (classmajorID != null) { studentExp = studentExp.And(x => x.CF_Student.ClassmajorID == classmajorID); } var query = this.RetakePlanDAL.GetRetakeStudentListViewQuery(planExp, studentExp); if (!string.IsNullOrEmpty(retakePlanConditionView.ConditionValue) && !string.IsNullOrEmpty(retakePlanConditionView.Attribute)) query = query.DynamicWhere(retakePlanConditionView.Attribute, retakePlanConditionView.Condition, retakePlanConditionView.ConditionValue); if (isNoArrear.HasValue) { query = query.Where(x => x.IsNoArrears == isNoArrear); } query = this.GetQueryByDataRangeByCollege(query); query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID); return query.ToList(); } public void ChargePush(IList userIDList) { var startStatusID = this.GetStartStatus(); Expression> studentExp = (x => x.RecordStatus == startStatusID); if (userIDList.Count > 0) { studentExp = studentExp.And(x => userIDList.Contains(x.UserID)); } var chargeInsertList = this.RetakePlanDAL.GetStudentChargeQueryable(x => true, studentExp).ToList() .Select(x => new EC_StudentCharge { StudentChargeID = x.StudentChargeID, UserID = x.UserID, ChargeProjectID = x.ChargeProjectID, ChargeYear = x.ChargeYear, Amount = 0, ActualAmount = 0, ChargeTag = (int)EC_ChargeTag.Retake, Remark = "" }).ToList(); chargeInsertList.ForEach(x => this.SetNewStatus(x)); UnitOfWork.BulkInsert(chargeInsertList); } public void DeleteStudent(IList userIDList) { var startStatusID = this.GetStartStatus(); var retakeStudentList = this.RetakePlanDAL.RetakePlanStudentRepository.GetList(x => userIDList.Contains(x.UserID), (x => x.ER_RetakePlan)).ToList(); if (retakeStudentList.Any(x => x.RecordStatus != startStatusID)) { throw new Exception("部分学生的重修记录已提交,不能删除,请检查所选记录的状态。"); } var retakePlanIDList = retakeStudentList.Select(x => x.RetakePlanID).Distinct().ToList(); UnitOfWork.RemoveRange(new HashSet(retakeStudentList)); UnitOfWork.Remove(x => retakePlanIDList.Contains(x.RetakePlanID) && x.ER_RetakePlanStudent.Count() == 0); UnitOfWork.Commit(); } public void AddStudent(Guid userID) { var startStatusID = this.GetStartStatus(); var schoolyearID = ParameterServices.Value.GetParameterValue(CF_ParameterType.RetakeSchoolyearID); var retakeStudentViewQueryable = this.RetakeConditionDAL.GetRetakeStudentView().Where(x => x.UserID == userID); var retakeStudentViewList = retakeStudentViewQueryable.ToList(); var retakePlanGroup = retakeStudentViewList .GroupBy(x => new { x.CoursematerialID, x.Abbreviation, x.CourseName, x.CourseTypeID, x.CourseTypeDesc, x.Credit }); var existRetakePlanList = this.RetakePlanDAL.GetRetakePlanByStudentQueryable(retakeStudentViewQueryable, startStatusID).ToList(); var planInsertList = new List(); var planStudentInsertList = new List(); foreach (var retakePlan in retakePlanGroup) { bool isNewPlan = false; var plan = existRetakePlanList.FirstOrDefault(x => x.CoursematerialID == retakePlan.Key.CoursematerialID && x.CourseTypeID == retakePlan.Key.CourseTypeID && x.Credit == retakePlan.Key.Credit); if (plan == null) { isNewPlan = true; plan = new ER_RetakePlan { RetakePlanID = Guid.NewGuid(), CoursematerialID = retakePlan.Key.CoursematerialID, ClassName = (retakePlan.Key.Abbreviation ?? retakePlan.Key.CourseName) + "-重修(" + retakePlan.Key.CourseTypeDesc + string.Format("{0:#.00}", retakePlan.Key.Credit) + "学分)", SchoolyearID = schoolyearID, CourseTypeID = retakePlan.Key.CourseTypeID, Credit = retakePlan.Key.Credit }; this.SetNewStatus(plan); } foreach (var retakePlanStudent in retakePlan.Select(w => w).ToList()) { var planStudent = new ER_RetakePlanStudent { RetakePlanStudentID = Guid.NewGuid(), RetakePlanID = plan.RetakePlanID, UserID = retakePlanStudent.UserID.Value, SchoolyearNumID = retakePlanStudent.SchoolyearNumID, StarttermID = retakePlanStudent.StarttermID }; this.SetNewStatus(planStudent); planStudent.RecordStatus = startStatusID; planStudentInsertList.Add(planStudent); } if (isNewPlan) { planInsertList.Add(plan); } } UnitOfWork.BulkInsert(planInsertList); UnitOfWork.BulkInsert(planStudentInsertList); } public List GetRetakeStudentApplyViewStudentList(Guid userID) { Expression> exp = (x => x.UserID == userID); var startStatusID = this.GetStartStatus(); var statusList = this.GetStatusViewList(); var backpointList = this.GetBackpointStatus(); var nowDate = DateTime.Today; var openControl = this.RetakeOpenControlDAL.GetRetakeOpenControlViewQuery(x => x.CF_Schoolyear.IsCurrent == true && x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList(); var studentApplyViewQueryable = this.RetakePlanDAL.GetRetakeStudentApplyViewQueryable(exp); var teacherViewQueryable = this.RetakePlanDAL.GetRetakePlanStudentTeacherViewQueryable(exp); var studentApplyViewList = studentApplyViewQueryable.ToList(); var teacherViewList = teacherViewQueryable.ToList(); studentApplyViewList.ForEach(x => { x.RetakePlanStudentTeacherView = teacherViewList.Where(w => w.RetakePlanStudentID == x.RetakePlanStudentID).ToList(); x.RecordStatusDesc = statusList.Where(w => w.ID == x.RecordStatus).Select(w => w.Name).FirstOrDefault(); x.IsCanApply = (x.RecordStatus == startStatusID || backpointList.Contains(x.RecordStatus)) && openControl.Any(w => x.SchoolyearID == w.SchoolyearID && (w.StartDate ?? DateTime.MinValue).Date <= nowDate && (w.EndDate ?? DateTime.MaxValue).Date >= nowDate); }); return studentApplyViewList; } public List GetEducationMissionImportClassViewList(Guid? coursematerialID) { var schoolyearID = ParameterServices.Value.GetParameterValue(CF_ParameterType.RetakeSchoolyearID); var educationMissionList = EducationMissionClassScheduleAdultServices.Value.GetEducationMissionClassScheduleViewGridExcel(new ConfiguretView(), null, null, schoolyearID, null, coursematerialID, (int)EM_EducationMissionClassStatus.Scheduled, null, null, null, null,null,null,null,null,null); return educationMissionList; } public void Submit(Guid retakePlanStudentID, Guid? educationMissionID) { this.CheckCanSubmit(retakePlanStudentID); var startStatusID = this.GetStartStatus(); var retakePlanStudent = this.RetakePlanDAL.RetakePlanStudentRepository.GetSingle(x => x.RetakePlanStudentID == retakePlanStudentID); if (educationMissionID.HasValue) { retakePlanStudent.EducationMissionID = educationMissionID; } else { throw new Exception("请选择教学任务。"); } if (retakePlanStudent.RecordStatus == startStatusID) { this.StartUp(new List { retakePlanStudentID }, CustomPrincipal.Current.UserID); } else { var actionList = this.GetActionView(retakePlanStudentID, CustomPrincipal.Current.UserID); if (actionList.Count == 0) { throw new Exception("该用户没有审核下一步环节的权限。"); } this.Approve(new List { retakePlanStudentID }, CustomPrincipal.Current.UserID, actionList[0].ActionID); } } public void CheckCanSubmit(Guid retakePlanStudentID) { var startStatusID = this.GetStartStatus(); var backPointIDList = this.GetBackpointStatus(); var retakePlanStudent = this.RetakePlanDAL.RetakePlanStudentRepository.GetSingle(x => x.RetakePlanStudentID == retakePlanStudentID, (x => x.ER_RetakePlan.CF_Schoolyear)); if (retakePlanStudent == null) { throw new Exception("重修记录不存在。"); } if (retakePlanStudent.RecordStatus != startStatusID && !backPointIDList.Contains(retakePlanStudent.RecordStatus)) { throw new Exception("该重修课程已经提交,请不要重复提交。"); } var duplicatePlan = this.RetakePlanDAL.RetakePlanStudentRepository.GetSingle(x => x.ER_RetakePlan.CoursematerialID == retakePlanStudent.ER_RetakePlan.CoursematerialID && x.ER_RetakePlan.SchoolyearID == retakePlanStudent.ER_RetakePlan.SchoolyearID && x.RecordStatus != startStatusID && !backPointIDList.Contains(x.RecordStatus)); if (duplicatePlan != null) { throw new Exception("你已经在这个学期申请过同一课程的重修,不能重复申请。"); } if (ChargeControlDAL.GetRetakeArrearsAmountView(x => x.UserID == retakePlanStudent.UserID, retakePlanStudent.ER_RetakePlan.CF_Schoolyear.Years).Count() > 0) { throw new Exception("你的重修费用还没有缴,不能申请重修,请先缴清重修费用再进行申请。"); } } public IGridResultSet GetRetakeStudentApproveViewList(ConfiguretView retakePlanConditionView, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID,int? learningformID, int? education,string LearnSystem, int pageIndex, int pageSize) { var statusList = this.GetStatusViewList(); var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList(); Expression> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> studentExp = (x => approveStatusIDList.Contains(x.RecordStatus)); if (schoolyearID.HasValue) { planExp = planExp.And(x => x.SchoolyearID == schoolyearID); } if (collegeID.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID); } if (year.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year); } if (standardID.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID); } if (classmajorID != null) { studentExp = studentExp.And(x => x.CF_Student.ClassmajorID == classmajorID); } if (learningformID.HasValue) studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID); if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1") { var LearnSystems = Convert.ToDecimal(LearnSystem); studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems); } if (education.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value); } var query = this.RetakePlanDAL.GetRetakeStudentApproveViewQueryable(planExp, studentExp); if (!string.IsNullOrEmpty(retakePlanConditionView.ConditionValue) && !string.IsNullOrEmpty(retakePlanConditionView.Attribute)) query = query.DynamicWhere(retakePlanConditionView.Attribute, retakePlanConditionView.Condition, retakePlanConditionView.ConditionValue); query = this.GetQueryByDataRangeByCollege(query); query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID); var result = query.ToGridResultSet(pageIndex, pageSize); result.rows.ForEach(x => { x.RecordStatusDesc = statusList.Where(w => w.ID == x.RecordStatus).Select(w => w.Name).FirstOrDefault(); }); return result; } public List GetRetakeStudentApproveViewList(ConfiguretView retakePlanConditionView, IList retakePlanStudentIDList, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID) { var statusList = this.GetStatusViewList(); var approveStatusIDList = this.GetApproveStatusViewList().Select(x => x.ID).ToList(); Expression> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> studentExp = (x => approveStatusIDList.Contains(x.RecordStatus)); if (retakePlanStudentIDList.Count > 0) { studentExp = studentExp.And(x => retakePlanStudentIDList.Contains(x.RetakePlanStudentID)); } else { if (schoolyearID.HasValue) { planExp = planExp.And(x => x.SchoolyearID == schoolyearID); } if (collegeID.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID); } if (year.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year); } if (standardID.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID); } if (classmajorID != null) { studentExp = studentExp.And(x => x.CF_Student.ClassmajorID == classmajorID); } } var query = this.RetakePlanDAL.GetRetakeStudentApproveViewQueryable(planExp, studentExp); if (!string.IsNullOrEmpty(retakePlanConditionView.ConditionValue) && !string.IsNullOrEmpty(retakePlanConditionView.Attribute)) query = query.DynamicWhere(retakePlanConditionView.Attribute, retakePlanConditionView.Condition, retakePlanConditionView.ConditionValue); query = this.GetQueryByDataRangeByCollege(query); query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID); var result = query.ToList(); result.ForEach(x => { x.RecordStatusDesc = statusList.Where(w => w.ID == x.RecordStatus).Select(w => w.Name).FirstOrDefault(); }); return result; } public void OnApproveEnd(Guid? retakePlanStudentID, Guid? userID) { var retakePlanStudent = this.RetakePlanDAL.RetakePlanStudentRepository.GetSingle(x => x.RetakePlanStudentID == retakePlanStudentID, (x => x.CF_Student)); if (retakePlanStudent == null) { throw new Exception("重修记录不存在。"); } var educationSchedulingClassList = this.RetakePlanDAL.EducationSchedulingClassRepository.GetList(x => x.EM_EducationMissionClass.EducationMissionID == retakePlanStudent.EducationMissionID, (x => x.CF_Student)).ToList(); educationSchedulingClassList.ForEach(x => x.CF_Student.Add(retakePlanStudent.CF_Student)); this.UnitOfWork.Commit(); } public IGridResultSet GetFinalRetakeStudentApproveViewList(ConfiguretView retakePlanConditionView, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID,int? learningformID, int? education,string LearnSystem, int pageIndex, int pageSize) { var statusList = this.GetStatusViewList(); var endStatus = this.GetCorrectEndStatus(); Expression> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> studentExp = (x => x.RecordStatus == endStatus); if (schoolyearID.HasValue) { planExp = planExp.And(x => x.SchoolyearID == schoolyearID); } if (collegeID.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID); } if (year.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year); } if (standardID.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID); } if (classmajorID != null) { studentExp = studentExp.And(x => x.CF_Student.ClassmajorID == classmajorID); } if (learningformID.HasValue) studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID); if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1") { var LearnSystems = Convert.ToDecimal(LearnSystem); studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems); } if (education.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value); } var query = this.RetakePlanDAL.GetRetakeStudentApproveViewQueryable(planExp, studentExp); if (!string.IsNullOrEmpty(retakePlanConditionView.ConditionValue) && !string.IsNullOrEmpty(retakePlanConditionView.Attribute)) query = query.DynamicWhere(retakePlanConditionView.Attribute, retakePlanConditionView.Condition, retakePlanConditionView.ConditionValue); query = this.GetQueryByDataRangeByCollege(query); query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID); var result = query.ToGridResultSet(pageIndex, pageSize); result.rows.ForEach(x => { x.RecordStatusDesc = statusList.Where(w => w.ID == x.RecordStatus).Select(w => w.Name).FirstOrDefault(); }); return result; } public List GetFinalRetakeStudentApproveViewList(ConfiguretView retakePlanConditionView, IList retakePlanStudentIDList, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID, int? learningformID, int? education, string LearnSystem) { var statusList = this.GetStatusViewList(); var endStatus = this.GetCorrectEndStatus(); Expression> planExp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); Expression> studentExp = (x => x.RecordStatus == endStatus); if (retakePlanStudentIDList.Count > 0) { studentExp = studentExp.And(x => retakePlanStudentIDList.Contains(x.RetakePlanStudentID)); } else { if (schoolyearID.HasValue) { planExp = planExp.And(x => x.SchoolyearID == schoolyearID); } if (collegeID.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID); } if (year.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == year); } if (standardID.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID); } if (classmajorID != null) { studentExp = studentExp.And(x => x.CF_Student.ClassmajorID == classmajorID); } if (learningformID.HasValue) studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID); if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1") { var LearnSystems = Convert.ToDecimal(LearnSystem); studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems); } if (education.HasValue) { studentExp = studentExp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value); } } var query = this.RetakePlanDAL.GetRetakeStudentApproveViewQueryable(planExp, studentExp); if (!string.IsNullOrEmpty(retakePlanConditionView.ConditionValue) && !string.IsNullOrEmpty(retakePlanConditionView.Attribute)) query = query.DynamicWhere(retakePlanConditionView.Attribute, retakePlanConditionView.Condition, retakePlanConditionView.ConditionValue); query = this.GetQueryByDataRangeByCollege(query); query = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.ClassName).ThenBy(x => x.LoginID); var result = query.ToList(); result.ForEach(x => { x.RecordStatusDesc = statusList.Where(w => w.ID == x.RecordStatus).Select(w => w.Name).FirstOrDefault(); }); return result; } } }