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.CultureplanManage.PlanManagement; using EMIS.ViewModel.SelectCourse; using EMIS.ViewModel; using EMIS.Entities; using EMIS.ViewModel.CultureplanManage.PlanManagement; using EMIS.CommonLogic.CalendarManage; using EMIS.ViewModel.UniversityManage.SpecialtyClassManage; using Bowin.Common.DataTime; using Bowin.Common.Utility; using System.Text.RegularExpressions; using EMIS.ViewModel.CacheManage; using EMIS.DataLogic.UniversityManage.AdministrativeOrgan; using EMIS.DataLogic.Common.Cultureplan; using EMIS.DataLogic.Repositories; using EMIS.CommonLogic.UniversityManage.SpecialtyClassManage; namespace EMIS.CommonLogic.CultureplanManage.PlanManagement { public class OptionalCoursePlanServices : BaseServices, IOptionalCoursePlanServices { public OptionalCoursePlanDAL OptionalCoursePlanDAL { get; set; } public IGrademajorServices grademajorServices { get; set; } public IFacultymajorServices facultymajorServices { get; set; } public ISchoolYearServices schoolYearServices { get; set; } public ISpecialtyCourseServices specialtyCourseServices { get; set; } public DepartmentDAL departmentDAL { get; set; } public CoursematerialDAL coursematerialDAL { get; set; } public OptionalCoursePlanTeachingSettingRepository optionalCoursePlanTeachingSettingRepository { get; set; } /// /// 查询限选计划 /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetOptionalCourseSettingViewGrid(ConfiguretView configuretView, int? standardID, Guid? coursematerialID, int? schoolYearNumID, int? schoolCodeID, int? isEnable, int? isOpened, int? educationID, int? learningFormID, string LearnSystem, int pageIndex, int pageSize) { Expression> exp = (x => true); var query = OptionalCoursePlanDAL.GetOptionalCourseSettingViewQueryable(exp); if (standardID.HasValue) query = query.Where(x => x.StandardID == standardID); if (coursematerialID.HasValue) query = query.Where(x => x.CoursematerialID == coursematerialID); if (schoolYearNumID.HasValue) query = query.Where(x => x.SchoolyearNumID == schoolYearNumID); if (schoolCodeID.HasValue) query = query.Where(x => x.SchoolcodeID == schoolCodeID); if (isEnable.HasValue) query = query.Where(x => x.IsEnable == (isEnable == 1 ? true : false)); if (isOpened.HasValue) query = query.Where(x => x.IsOpened == (isOpened == 1 ? true : false)); 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); //var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x=>x.CollegeID).ToGridResultSet(pageIndex, pageSize); var result = query.OrderBy(x => x.IsEnable).ThenByDescending(x => x.StandardCode).ThenBy(x => x.SchoolyearNumID).ThenBy(x => x.SchoolcodeID).ThenBy(x => x.CourseCode).ToGridResultSet(pageIndex, pageSize); //return this.GetOptionalCourseSettingView(configuretView, exp, pageIndex, pageSize); return result; } public List GetOptionalCourseSettingViewList(ConfiguretView configuretView, int? standardID, Guid? coursematerialID, int? schoolYearNumID, int? schoolCodeID, int? isEnable, int? isOpened, int? educationID, int? learningFormID, string LearnSystem) { Expression> exp = (x => true); var query = OptionalCoursePlanDAL.GetOptionalCourseSettingViewQueryable(exp); if (standardID.HasValue) query = query.Where(x => x.StandardID == standardID); if (coursematerialID.HasValue) query = query.Where(x => x.CoursematerialID == coursematerialID); if (schoolYearNumID.HasValue) query = query.Where(x => x.SchoolyearNumID == schoolYearNumID); if (schoolCodeID.HasValue) query = query.Where(x => x.SchoolcodeID == schoolCodeID); if (isEnable.HasValue) query = query.Where(x => x.IsEnable == (isEnable == 1 ? true : false)); if (isOpened.HasValue) query = query.Where(x => x.IsOpened == (isOpened == 1 ? true : false)); 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); //var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x=>x.CollegeID).ToGridResultSet(pageIndex, pageSize); var result = query.OrderByDescending(x => x.StandardCode).ThenBy(x => x.SchoolyearNumID).ThenBy(x => x.SchoolcodeID).ThenBy(x => x.CourseCode).ToList(); //return this.GetOptionalCourseSettingView(configuretView, exp, pageIndex, pageSize); return result; } /// /// 获取选修计划视图 /// /// /// public OptionalCoursePlanView GetOptionalCourseSettingView(Guid? optionalCourseID) { return OptionalCoursePlanDAL.GetOptionalCourseSettingViewQueryable(x => x.OptionalCourseID == optionalCourseID).FirstOrDefault(); } /// /// 添加选修计划 /// /// /// public void OptionalCourseAdd(OptionalCoursePlanView optionalCourseSettingView) { try { var repeatOptionalCoursePlan = OptionalCoursePlanDAL.OptionalCoursePlanRepository.Entities.Where(x => x.CoursematerialID == optionalCourseSettingView.CoursematerialID && x.CourseTypeID == optionalCourseSettingView.CourseTypeID && x.SchoolcodeID == optionalCourseSettingView.SchoolcodeID && x.SchoolyearNumID == optionalCourseSettingView.SchoolyearNumID && x.SpecialtyID == optionalCourseSettingView.SpecialtyID).FirstOrDefault(); if (repeatOptionalCoursePlan != null) { //同专业同学期同课程类型同课程ID是否有重复 throw new Exception("已存在相同的限选计划,请核查。"); } EM_OptionalCoursePlan optionalCoursePlan = new EM_OptionalCoursePlan(); optionalCoursePlan.OptionalCourseID = Guid.NewGuid(); optionalCoursePlan.DepartmentID = optionalCourseSettingView.DepartmentID; optionalCoursePlan.SpecialtyID = optionalCourseSettingView.SpecialtyID; optionalCoursePlan.CoursematerialID = optionalCourseSettingView.CoursematerialID; optionalCoursePlan.CourseStructureID = optionalCourseSettingView.CourseStructureID; optionalCoursePlan.CourseCategoryID = optionalCourseSettingView.CourseCategoryID; optionalCoursePlan.CourseTypeID = optionalCourseSettingView.CourseTypeID; optionalCoursePlan.CourseQualityID = optionalCourseSettingView.CourseQualityID; optionalCoursePlan.PracticeTypeID = optionalCourseSettingView.PracticeTypeID; optionalCoursePlan.ExaminationModeID = optionalCourseSettingView.ExaminationModeID; optionalCoursePlan.TeachinglanguageID = optionalCourseSettingView.TeachinglanguageID; optionalCoursePlan.SchoolyearNumID = optionalCourseSettingView.SchoolyearNumID; optionalCoursePlan.SchoolcodeID = optionalCourseSettingView.SchoolcodeID; optionalCoursePlan.IsEnable = optionalCourseSettingView.IsEnable; optionalCoursePlan.PeopleNumlower = optionalCourseSettingView.PeopleNumlower; optionalCoursePlan.PeopleNumlimit = optionalCourseSettingView.PeopleNumlimit; optionalCoursePlan.IsOpened = optionalCourseSettingView.IsOpened; optionalCoursePlan.ResultTypeID = optionalCourseSettingView.ResultTypeID; optionalCoursePlan.Remarks = optionalCourseSettingView.Remarks; SetNewStatus(optionalCoursePlan); UnitOfWork.Add(optionalCoursePlan); EM_OptionalCoursePlanTeachingSetting optionalCourseTeachingSetting = new EM_OptionalCoursePlanTeachingSetting(); //教学设置表 optionalCourseTeachingSetting.OptionalCourseID = optionalCoursePlan.OptionalCourseID; optionalCourseTeachingSetting.Credit = optionalCourseSettingView.Credit; optionalCourseTeachingSetting.TheoryCourse = optionalCourseSettingView.TheoryCourse; optionalCourseTeachingSetting.Practicehours = optionalCourseSettingView.Practicehours; optionalCourseTeachingSetting.Trialhours = optionalCourseSettingView.Trialhours; optionalCourseTeachingSetting.WeeklyNum = optionalCourseSettingView.WeeklyNum; //if (optionalCourseSettingView.WeeklyNum == 0 || optionalCourseSettingView.WeeklyNum == null) //{ // var t = (optionalCourseSettingView.TheoryCourse.Value + optionalCourseSettingView.Practicehours.Value); // var w = (optionalCourseSettingView.TheoryWeeklyNum.Value + optionalCourseSettingView.PracticeWeeklyNum.Value); // if (w != 0 && t != 0) // optionalCourseTeachingSetting.WeeklyNum = t / w / 2; //} optionalCourseTeachingSetting.TheoryWeeklyNum = optionalCourseSettingView.TheoryWeeklyNum; optionalCourseTeachingSetting.PracticeWeeklyNum = optionalCourseSettingView.PracticeWeeklyNum; optionalCourseTeachingSetting.TrialWeeklyNum = optionalCourseSettingView.TrialWeeklyNum; optionalCourseTeachingSetting.StartWeeklyNum = optionalCourseSettingView.StartWeeklyNum; optionalCourseTeachingSetting.EndWeeklyNum = optionalCourseSettingView.EndWeeklyNum; optionalCourseTeachingSetting.WeeklyHours = optionalCourseSettingView.WeeklyHours; UnitOfWork.Add(optionalCourseTeachingSetting); //授课方式 if (optionalCourseSettingView.TeachingModeID != null) { //UnitOfWork.Delete(x => x.OptionalCourseID == optionalCourseSettingView.OptionalCourseID); foreach (var i in optionalCourseSettingView.TeachingModeID) { EM_OptionalCoursePlanTeachingMode optionalCourseTeachingMode = new EM_OptionalCoursePlanTeachingMode(); optionalCourseTeachingMode.OptionalCoursePlanTeachingModeID = Guid.NewGuid(); optionalCourseTeachingMode.OptionalCourseID = optionalCoursePlan.OptionalCourseID; optionalCourseTeachingMode.TeachingModeID = i; SetNewStatus(optionalCourseTeachingMode); UnitOfWork.Add(optionalCourseTeachingMode); } } UnitOfWork.Commit(); } catch (Exception) { throw; } } /// /// 更新 /// /// /// public void OptionalCourseUpdate(OptionalCoursePlanView optionalCourseSettingView) { try { var repeatOptionalCoursePlan = OptionalCoursePlanDAL.OptionalCoursePlanRepository.Entities.Where(x => x.CoursematerialID == optionalCourseSettingView.CoursematerialID && x.CourseTypeID == optionalCourseSettingView.CourseTypeID && x.SchoolcodeID == optionalCourseSettingView.SchoolcodeID && x.SchoolyearNumID == optionalCourseSettingView.SchoolyearNumID && x.SpecialtyID == optionalCourseSettingView.SpecialtyID).FirstOrDefault(); if (repeatOptionalCoursePlan != null && repeatOptionalCoursePlan.OptionalCourseID != optionalCourseSettingView.OptionalCourseID) { //同专业同学期同课程类型同课程ID是否有重复 throw new Exception("已存在相同的限选计划,请核查。"); } EM_OptionalCoursePlan optionalCoursePlan = GetOptionalCoursePlan(optionalCourseSettingView.OptionalCourseID); EM_OptionalCoursePlanTeachingSetting optionalCourseTeachingSetting = optionalCoursePlanTeachingSettingRepository.Entities.Where(x => x.OptionalCourseID == optionalCoursePlan.OptionalCourseID).SingleOrDefault(); if (optionalCoursePlan != null) { optionalCoursePlan.DepartmentID = optionalCourseSettingView.DepartmentID; optionalCoursePlan.SpecialtyID = optionalCourseSettingView.SpecialtyID; optionalCoursePlan.CoursematerialID = optionalCourseSettingView.CoursematerialID; optionalCoursePlan.CourseStructureID = optionalCourseSettingView.CourseStructureID; optionalCoursePlan.CourseCategoryID = optionalCourseSettingView.CourseCategoryID; optionalCoursePlan.CourseTypeID = optionalCourseSettingView.CourseTypeID; optionalCoursePlan.CourseQualityID = optionalCourseSettingView.CourseQualityID; optionalCoursePlan.PracticeTypeID = optionalCourseSettingView.PracticeTypeID; optionalCoursePlan.ExaminationModeID = optionalCourseSettingView.ExaminationModeID; optionalCoursePlan.TeachinglanguageID = optionalCourseSettingView.TeachinglanguageID; optionalCoursePlan.SchoolyearNumID = optionalCourseSettingView.SchoolyearNumID; optionalCoursePlan.SchoolcodeID = optionalCourseSettingView.SchoolcodeID; optionalCoursePlan.IsEnable = optionalCourseSettingView.IsEnable; //optionalCoursePlan.No = optionalCourseSettingView.No; //optionalCoursePlan.HandleModeID = optionalCourseSettingView.HandleModeID; //optionalCoursePlan.IsNeedMaterial = optionalCourseSettingView.IsNeedMaterial; optionalCoursePlan.PeopleNumlower = optionalCourseSettingView.PeopleNumlower; optionalCoursePlan.PeopleNumlimit = optionalCourseSettingView.PeopleNumlimit; optionalCoursePlan.IsOpened = optionalCourseSettingView.IsOpened; optionalCoursePlan.ResultTypeID = optionalCourseSettingView.ResultTypeID; optionalCoursePlan.Remarks = optionalCourseSettingView.Remarks; //教学设置表 if (optionalCourseTeachingSetting != null) { UnitOfWork.Update(optionalCourseTeachingSetting); } else { optionalCourseTeachingSetting = new EM_OptionalCoursePlanTeachingSetting(); optionalCourseTeachingSetting.OptionalCourseID = optionalCourseSettingView.OptionalCourseID; UnitOfWork.Add(optionalCourseTeachingSetting); } optionalCourseTeachingSetting.Credit = optionalCourseSettingView.Credit; optionalCourseTeachingSetting.TheoryCourse = optionalCourseSettingView.TheoryCourse; optionalCourseTeachingSetting.Practicehours = optionalCourseSettingView.Practicehours; optionalCourseTeachingSetting.Trialhours = optionalCourseSettingView.Trialhours; optionalCourseTeachingSetting.WeeklyNum = optionalCourseSettingView.WeeklyNum; if (optionalCourseSettingView.WeeklyNum == 0 || optionalCourseSettingView.WeeklyNum == null) { var t = (optionalCourseSettingView.TheoryCourse.Value + optionalCourseSettingView.Practicehours.Value); var w = (optionalCourseSettingView.TheoryWeeklyNum.Value + optionalCourseSettingView.PracticeWeeklyNum.Value); if (w != 0 && t != 0) optionalCourseTeachingSetting.WeeklyNum = t / w / 2; } optionalCourseTeachingSetting.TheoryWeeklyNum = optionalCourseSettingView.TheoryWeeklyNum; optionalCourseTeachingSetting.PracticeWeeklyNum = optionalCourseSettingView.PracticeWeeklyNum; optionalCourseTeachingSetting.TrialWeeklyNum = optionalCourseSettingView.TrialWeeklyNum; optionalCourseTeachingSetting.StartWeeklyNum = optionalCourseSettingView.StartWeeklyNum; optionalCourseTeachingSetting.EndWeeklyNum = optionalCourseSettingView.EndWeeklyNum; optionalCourseTeachingSetting.WeeklyHours = optionalCourseSettingView.WeeklyHours; //授课方式 if (optionalCourseSettingView.TeachingModeID != null) { UnitOfWork.Delete(x => x.OptionalCourseID == optionalCourseSettingView.OptionalCourseID); foreach (var i in optionalCourseSettingView.TeachingModeID) { EM_OptionalCoursePlanTeachingMode optionalCourseTeachingMode = new EM_OptionalCoursePlanTeachingMode(); optionalCourseTeachingMode.OptionalCoursePlanTeachingModeID = Guid.NewGuid(); optionalCourseTeachingMode.OptionalCourseID = optionalCoursePlan.OptionalCourseID; optionalCourseTeachingMode.TeachingModeID = i; SetNewStatus(optionalCourseTeachingMode); UnitOfWork.Add(optionalCourseTeachingMode); } } this.SetModifyStatus(optionalCoursePlan); UnitOfWork.Commit(); } } catch (Exception) { throw; } } public List GetTeachingModeType(Guid? OptionalCourseID) { return OptionalCoursePlanDAL.GetTeachingModeTypeQueryble(OptionalCourseID); } /// /// 删除 /// /// /// public bool OptionalCourseDelete(List optionalCourseIDs) { try { if (optionalCourseIDs.Count > 0) { UnitOfWork.Delete(x => optionalCourseIDs.Contains(x.OptionalCourseID)); return true; } return false; } catch (Exception) { throw; } } /// /// 获取选修计划实体 /// /// /// public EM_OptionalCoursePlan GetOptionalCoursePlan(Guid? optionalCourseID) { return OptionalCoursePlanDAL.OptionalCoursePlanRepository.GetSingle(x => x.OptionalCourseID == optionalCourseID); } //public void OptionalCoursePlanImport(Dictionary cellheader, out int OkCount, out List errdataList, out int ErrCount, string sourcePhysicalPath) //{ // StringBuilder errorMsg = new StringBuilder(); // 错误信息 // List errList = new List(); //错误数据行 // DataTimeHelper dth = new DataTimeHelper(); // Sys_DictionaryItem standardID = null; //专业 // Sys_DictionaryItem educationID = null; //所修学历 // Sys_DictionaryItem learningformID = null; //学习形式 // #region 1.1解析文件,存放到一个List集合里 // // 1.1解析文件,存放到一个List集合里 // cellheader.Remove("ErrorMessage");//去除异常列、导入操作不需要 // List enlist = // NpoiExcelHelper.ExcelToEntityList(cellheader, sourcePhysicalPath, out errorMsg, out errList); // cellheader.Add("ErrorMessage", "错误信息");//还原字典项 // #endregion // #region 1.2 将Excel数据写入数据库中 // #region 1.2.1 对List集合进行有效性校验 // if (enlist.Count() <= 0) // { // throw new Exception("请填写Excel模板信息数据。"); // } // #region 1.2.1.1数据逻辑验证 // for (int i = 0; i < enlist.Count; i++) // { // OptionalCoursePlanView en = enlist[i]; // string errorMsgStr = "第" + (i + 1) + "行数据检测异常:"; // bool isHaveNoInputValue = false; // 是否含有未输入项 // #region 检测必填项是否必填 // if (Guid.Empty == en.CoursematerialID) // { // errorMsgStr += "课程资料不能为空;"; // en.ErrorMessage = errorMsgStr; // isHaveNoInputValue = true; // } // #endregion // #region 验证数据格式 // // // Regex reg = new Regex(@"^[0-9]*$"); // if (!string.IsNullOrEmpty(en.PeopleNumlimit.ToString())) // { // if (!reg.IsMatch(en.PeopleNumlimit + "")) // { // errorMsgStr += "人数上限;"; // en.ErrorMessage = errorMsgStr; // isHaveNoInputValue = true; // } // } // if (!string.IsNullOrEmpty(en.PeopleNumlimit.ToString())) // { // if (!reg.IsMatch(en.PeopleNumlower + "")) // { // errorMsgStr += "人数下限;"; // en.ErrorMessage = errorMsgStr; // isHaveNoInputValue = true; // } // } // //实践类型名称 // Sys_DictionaryItem practiceType; // if (!string.IsNullOrEmpty(en.PracticeTypeName)) // { // practiceType = IdNameExt.GetDictionaryItem(DictionaryItem.EM_PracticeType.ToString()) // .Where(x => x.Name == en.PracticeTypeName.Trim()).FirstOrDefault(); // if (practiceType == null) // { // errorMsgStr += "实践类型名称不存在;"; // en.ErrorMessage = errorMsgStr; // isHaveNoInputValue = true; // } // else // en.PracticeTypeID = practiceType.Value.Value; // } // //考试方式名称 // Sys_DictionaryItem examinationMode; // if (!string.IsNullOrEmpty(en.ExaminationModeDesc)) // { // examinationMode = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ExaminationMode.ToString()) // .Where(x => x.Name == en.ExaminationModeDesc.Trim()).FirstOrDefault(); // if (examinationMode == null) // { // errorMsgStr += "考试方式名称不存在;"; // en.ErrorMessage = errorMsgStr; // isHaveNoInputValue = true; // } // else // en.PracticeTypeID = examinationMode.Value.Value; // } // //课程结构 // Sys_DictionaryItem courseStructure; // if (!string.IsNullOrEmpty(en.CourseStructureName)) // { // courseStructure = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseStructure.ToString()) // .Where(x => x.Name == en.CourseStructureName.Trim()).FirstOrDefault(); // if (courseStructure == null) // { // errorMsgStr += "课程结构不存在;"; // en.ErrorMessage = errorMsgStr; // isHaveNoInputValue = true; // } // else // en.PracticeTypeID = courseStructure.Value.Value; // } // //课程类型 // Sys_DictionaryItem courseType; // if (!string.IsNullOrEmpty(en.CourseTypeName)) // { // courseType = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseType.ToString()) // .Where(x => x.Name == en.CourseTypeName.Trim()).FirstOrDefault(); // if (courseType == null) // { // errorMsgStr += "课程类型不存在;"; // en.ErrorMessage = errorMsgStr; // isHaveNoInputValue = true; // } // else // en.PracticeTypeID = courseType.Value.Value; // } // //课程属性 // Sys_DictionaryItem courseCategory; // if (!string.IsNullOrEmpty(en.CourseCategoryName)) // { // courseCategory = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseCategory.ToString()) // .Where(x => x.Name == en.CourseCategoryName.Trim()).FirstOrDefault(); // if (courseCategory == null) // { // errorMsgStr += "课程属性不存在;"; // en.ErrorMessage = errorMsgStr; // isHaveNoInputValue = true; // } // else // en.PracticeTypeID = courseCategory.Value.Value; // } // //授课语言 // Sys_DictionaryItem teachinglanguage; // if (!string.IsNullOrEmpty(en.TeachinglanguageName)) // { // teachinglanguage = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Teachinglanguage.ToString()) // .Where(x => x.Name == en.TeachinglanguageName.Trim()).FirstOrDefault(); // if (teachinglanguage == null) // { // errorMsgStr += "授课语言不存在;"; // en.ErrorMessage = errorMsgStr; // isHaveNoInputValue = true; // } // else // en.PracticeTypeID = teachinglanguage.Value.Value; // } // //学年数 // Sys_DictionaryItem schoolyearNum; // if (!string.IsNullOrEmpty(en.SchoolyearNumName)) // { // schoolyearNum = IdNameExt.GetDictionaryItem(DictionaryItem.CF_SchoolyearNum.ToString()) // .Where(x => x.Name == en.SchoolyearNumName.Trim()).FirstOrDefault(); // if (schoolyearNum == null) // { // errorMsgStr += "学年数不存在;"; // en.ErrorMessage = errorMsgStr; // isHaveNoInputValue = true; // } // else // en.PracticeTypeID = schoolyearNum.Value.Value; // } // //学期 // Sys_DictionaryItem schoolcode; // if (!string.IsNullOrEmpty(en.SchoolcodeName)) // { // schoolcode = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Semester.ToString()) // .Where(x => x.Name == en.SchoolcodeName.Trim()).FirstOrDefault(); // if (schoolcode == null) // { // errorMsgStr += "学期不存在;"; // en.ErrorMessage = errorMsgStr; // isHaveNoInputValue = true; // } // else // en.PracticeTypeID = schoolcode.Value.Value; // } // //课程性质 // Sys_DictionaryItem courseQuality; // if (!string.IsNullOrEmpty(en.CourseQualityName)) // { // courseQuality = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CourseQuality.ToString()) // .Where(x => x.Name == en.CourseQualityName.Trim()).FirstOrDefault(); // if (courseQuality == null) // { // errorMsgStr += "课程性质不存在;"; // en.ErrorMessage = errorMsgStr; // isHaveNoInputValue = true; // } // else // en.PracticeTypeID = courseQuality.Value.Value; // } // #region 信息是否存在 // if (en.DepartmentID != Guid.Empty) // { // CF_Department department = departmentDAL.departmentRepository.GetSingle(x => x.DepartmentID == en.DepartmentID && x.RecordStatus > 0); // if (department == null) // { // errorMsgStr += "教研室不存在;"; // en.ErrorMessage = errorMsgStr; // isHaveNoInputValue = true; // } // else // en.DepartmentID = department.DepartmentID; // } // if (en.CoursematerialID != Guid.Empty) // { // EM_Coursematerial coursematerial = coursematerialDAL.coursematerialRepository.GetSingle(x => x.CoursematerialID == en.CoursematerialID && x.RecordStatus > 0); // if (coursematerial == null) // { // errorMsgStr += "课程资料不存在;"; // en.ErrorMessage = errorMsgStr; // isHaveNoInputValue = true; // } // else // en.CoursematerialID = coursematerial.CoursematerialID; // } // #endregion // if (isHaveNoInputValue) // 若必填项有值未填 // { // en.IsExcelVaildateOK = false; // en.ErrorMessage = errorMsgStr; // errList.Add(en); // errorMsg.AppendLine(errorMsgStr); // } // } // #endregion // // TODO:其他检测 // #region 1.2.1.3 循环写入验证成功的数据 // List newOptionalCoursePlanList = new List(); // for (int i = 0; i < enlist.Count; i++) // { // OptionalCoursePlanView enA = enlist[i]; // if (enA.IsExcelVaildateOK == false) // 上面验证不通过,不进行此步验证 // { // continue; // } // var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; // EM_OptionalCoursePlan optionalCoursePlan = new EM_OptionalCoursePlan(); // optionalCoursePlan.OptionalCourseID = Guid.NewGuid(); // optionalCoursePlan.DepartmentID = enA.DepartmentID; // optionalCoursePlan.SpecialtyID = enA.SpecialtyID; // optionalCoursePlan.CoursematerialID = enA.CoursematerialID; // optionalCoursePlan.CourseStructureID = enA.CourseStructureID; // optionalCoursePlan.CourseCategoryID = enA.CourseCategoryID; // optionalCoursePlan.CourseTypeID = enA.CourseTypeID; // optionalCoursePlan.CourseQualityID = enA.CourseQualityID; // optionalCoursePlan.PracticeTypeID = enA.PracticeTypeID; // optionalCoursePlan.ExaminationModeID = enA.ExaminationModeID; // optionalCoursePlan.TeachinglanguageID = enA.TeachinglanguageID; // optionalCoursePlan.SchoolyearNumID = enA.SchoolyearNumID; // optionalCoursePlan.SchoolcodeID = enA.SchoolcodeID; // optionalCoursePlan.IsEnable = enA.IsEnable; // optionalCoursePlan.PeopleNumlower = enA.PeopleNumlower; // optionalCoursePlan.PeopleNumlimit = enA.PeopleNumlimit; // optionalCoursePlan.IsOpened = enA.IsOpened; // optionalCoursePlan.Remarks = enA.Remarks; // SetNewStatus(optionalCoursePlan); // newOptionalCoursePlanList.Add(optionalCoursePlan); // } // #endregion // UnitOfWork.BulkInsert(newOptionalCoursePlanList);//统一写入 // #endregion // #endregion // #endregion // #region 1.3 返回各项数据值 // OkCount = enlist.Distinct().Count() - errList.Distinct().Count();//共条数减去失败条数 // errdataList = errList.Distinct().ToList(); // ErrCount = errList.Distinct().Count(); // #endregion //} } }