void createCommand() { CreateTeacherNoAvaliable createWin = new CreateTeacherNoAvaliable(Models.Enums.OperatorEnum.Add, Models.Enums.AdministrativeAlgoRuleEnum.TeacherNotAvailableTimes); createWin.Closed += (s, arg) => { if (createWin.DialogResult.Value) { var has = this.Rules.Any(r => r.TeacherID.Equals(createWin.Add.TeacherID)); if (has) { this.ShowDialog("提示信息", "该教师存在规则", CustomControl.Enums.DialogSettingType.OnlyOkButton, CustomControl.Enums.DialogType.Warning); return; } // 1.向UI中插入 var last = this.Rules.LastOrDefault(); var index = last == null ? 0 : Convert.ToInt32(last.NO); // 2.创建对象 createWin.Add.NO = index + 1; // 3.更新界面 this.Rules.Add(createWin.Add); } }; createWin.ShowDialog(); }
void modifyCommand(object obj) { UITeacherRule rule = obj as UITeacherRule; CreateTeacherNoAvaliable createWin = new CreateTeacherNoAvaliable(Models.Enums.OperatorEnum.Modify, Models.Enums.AdministrativeAlgoRuleEnum.TeacherNotAvailableTimes, rule); createWin.Closed += (s, arg) => { var modify = createWin.Modify; if (createWin.DialogResult.Value) { rule.IsActive = modify.IsActive; rule.Value = modify.Value; rule.Weight = modify.Weight; rule.ForbidTimes = modify.ForbidTimes; } }; createWin.ShowDialog(); }