public void RemoveClassHour(UIClassHour classHour) { if (this.TargetHours.Any(t => t.ID == classHour.ID)) { this.TargetHours.Remove(classHour); } }
/// <summary> /// 生成课时 /// </summary> /// <param name="classCourse"></param> void createClassHours(UIClassCourse classCourse) { // 清除 classCourse.ClassHours.Clear(); // 课时 var lessons = classCourse.Lessons; for (int i = 1; i <= lessons; i++) { // 课时 UIClassHour classHour = new UIClassHour() { // 生成的时候当做序号使用 ID = i, ClassID = classCourse.ClassID, Class = classCourse.ClassName, CourseID = classCourse.CourseID, Course = classCourse.Course, Teachers = classCourse.Teachers, Active = true, }; classCourse.ClassHours.Add(classHour); } }
/// <summary> /// 获取课时根据课程ID /// </summary> /// <param name="cp"></param> /// <param name="courseID"></param> /// <param name="classID"></param> /// <returns></returns> public static List <UIClassHour> GetClassHours(this CPCase cp, string courseID, string classID) { List <UIClassHour> results = new List <UIClassHour>(); var teachers = cp.Teachers; var classes = cp.Classes; var courses = cp.Courses; var classHours = cp.ClassHours.Where(c => c.CourseID.Equals(courseID) && c.ClassID.Equals(classID)); foreach (var ch in classHours) { UIClassHour uiClassHour = new UIClassHour(); uiClassHour.ClassID = ch.ClassID; uiClassHour.CourseID = ch.CourseID; uiClassHour.ID = ch.ID; if (ch.TeacherIDs == null) { uiClassHour.Teachers = new List <TeacherModel>(); } else { uiClassHour.Teachers = (from id in ch.TeacherIDs from t in teachers where t.ID == id select t)?.ToList(); } uiClassHour.Class = classes.FirstOrDefault(c => c.ID.Equals(ch.ClassID))?.Name; uiClassHour.Course = courses.FirstOrDefault(c => c.ID.Equals(ch.CourseID))?.Name; results.Add(uiClassHour); } return(results); }
public void AddClassHour(UIClassHour classHour) { if (this.TargetHours.Any(t => t.ID == classHour.ID)) { return; } else { this.TargetHours.Add(classHour); } }
void setTeacherCommand(object obj) { UIClassHour classHour = obj as UIClassHour; var cpCase = CommonDataManager.GetCPCase(base.LocalID); var currentTeachers = classHour.Teachers.Select(s => { return(new UITeacher { ID = s.ID, Name = s.Name }); })?.ToList(); var allTeachers = cpCase.Teachers.Select(s => { return(new UITeacher { ID = s.ID, Name = s.Name }); })?.ToList(); ChooseTeacherWindow window = new ChooseTeacherWindow(currentTeachers, allTeachers); window.Closed += (s, arg) => { if (window.DialogResult.Value) { // 清空教师 //classHour.Teachers.Clear(); if (window.Teachers.Count > 0) { var selectedTeachers = window.Teachers.Select(st => { return(new XYKernel.OS.Common.Models.Administrative.TeacherModel() { ID = st.ID, Name = st.Name }); })?.ToList(); classHour.Teachers = selectedTeachers; } else { classHour.Teachers.Clear(); classHour.TeacherString = string.Empty; } classHour.RaiseChanged(); } }; window.ShowDialog(); }
/// <summary> /// 获取课时 /// </summary> /// <param name="cl"></param> /// <param name="ids"></param> /// <returns></returns> public static List <UIClassHour> GetClassHours(this CLCase cl, int[] ids) { List <UIClassHour> results = new List <UIClassHour>(); if (cl == null || ids == null) { return(results); } var teachers = cl.Teachers; var classes = cl.Classes; var courses = cl.Courses; var classHours = (from i in ids from ch in cl.ClassHours where i == ch.ID select ch); foreach (var ch in classHours) { UIClassHour uiClassHour = new UIClassHour(); uiClassHour.ClassID = ch.ClassID; uiClassHour.CourseID = ch.CourseID; uiClassHour.ID = ch.ID; uiClassHour.LevelID = ch.LevelID; uiClassHour.Tags = ch.TagIDs; if (ch.TeacherIDs == null) { uiClassHour.Teachers = new List <TeacherModel>(); } else { uiClassHour.Teachers = (from id in ch.TeacherIDs from t in teachers where t.ID == id select t)?.ToList(); } uiClassHour.Class = classes.FirstOrDefault(c => c.ID.Equals(ch.ClassID))?.Name; var course = courses.FirstOrDefault(c => c.ID.Equals(ch.CourseID)); if (course != null) { var defaultLevel = course.Levels.FirstOrDefault(l => l.ID.Equals(ch.LevelID)); uiClassHour.Course = course.Name; uiClassHour.Level = defaultLevel?.Name; } results.Add(uiClassHour); } return(results); }
void chooseClassHour(object obj) { UIClassHour classHour = obj as UIClassHour; }