void type_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { ContactpersonType type = sender as ContactpersonType; if (type.IsValid()) { if (type.ID != null) { try { if (!type.Update()) { throw new Exception("Could not update contacttype"); } } catch (Exception ex) { Console.WriteLine(ex.Message); MessageBox.Show("Kon contacttype niet updaten naar de database"); } } else { try { if (!type.Insert()) { throw new Exception("Could not insert contacttype"); } } catch (Exception ex) { Console.WriteLine(ex.Message); MessageBox.Show("Kon contacttype niet in de database steken"); } } } }