private void UnosAdr(object sender, RoutedEventArgs e) { if (dgOsobe.SelectedItem == null) { MessageBox.Show("Izaberite osobu!"); return; } Baza db = new Baza(); BindingGroup.CommitEdit(); db.Adresas.Add(a); a.Osobe.Add(db.Osobas.Where(oDB => oDB.ID == o.ID).First()); db.SaveChanges(); o = new Osoba(); a = new Adresa(); }
private void Unos(object sender, RoutedEventArgs e) { Baza db = new Baza(); BindingGroup.CommitEdit(); try { db.Osobas.Add(o); o = new Osoba(); db.SaveChanges(); dgOsobe.ItemsSource = db.Osobas.ToList(); } catch (Exception ee) { MessageBox.Show("Proverite podatke!"); MessageBox.Show(ee.Message); } }