void cancel(object obj) { ChooseClassHourWindow window = obj as ChooseClassHourWindow; if (this.CourseLevels.Count(c => c.IsChecked) > 0) { if (window.CourseLevels == null) { window.CourseLevels = new List <UICourseLevelTree>(); } foreach (var cl in this.CourseLevels) { if (cl.IsChecked) { if (window.CourseLevels.Any(ccl => ccl.LevelID == cl.LevelID && ccl.CourseID == cl.CourseID)) { window.CourseLevels.Remove(window.CourseLevels.Find(cc => cc.LevelID == cl.LevelID && cc.CourseID == cl.CourseID)); } window.CourseLevels.Add(cl); } } } if (window.CourseLevels != null && window.CourseLevels.Count > 0) { window.CourseLevels.ForEach(cl => cl.IsChecked = true); } window.DialogResult = window.IsSave; }
void save(object obj) { ChooseClassHourWindow window = obj as ChooseClassHourWindow; //window.CourseLevels = this.CourseLevels; //window.IsSave = true; foreach (var cl in this.CourseLevels) { if (cl.IsChecked) { if (window.CourseLevels == null) { window.CourseLevels = new List <UICourseLevelTree>(); } if (window.CourseLevels.Any(ccl => ccl.LevelID == cl.LevelID && ccl.CourseID == cl.CourseID)) { window.CourseLevels.Remove(window.CourseLevels.Find(cc => cc.LevelID == cl.LevelID && cc.CourseID == cl.CourseID)); } window.CourseLevels.Add(cl); } } window.IsSave = true; // 清除选中状态 this.CourseLevels.ForEach(c => c.IsChecked = false); this.ShowDialog("提示信息", "保存成功", CustomControl.Enums.DialogSettingType.NoButton, CustomControl.Enums.DialogType.None); }