private void btnSave_Click(object sender, RoutedEventArgs e) { var x = this.DataContext as Training; if (x.IsValidate()) { if (x.ID == null) { if (Training.InsertData(x)) { foreach (var t in x.Trainees) { Trained.InsertData(t); } MyMessage.InsertMessage(); } } else { foreach (var t in x.Trainees) { if (t.ID.HasValue) { Trained.UpdateData(t); } else { Trained.InsertData(t); } } if (Training.UpdateData(x)) { MyMessage.UpdateMessage(); } } } }
public TrainingControl(Training t) { InitializeComponent(); this.DataContext = t; }
public SelectTraineesControl(Training t) { InitializeComponent(); this.DataContext = t; dgTrained.ItemsSource = t.Trainees.ToList(); }