private void btnAdd_Click(object sender, RoutedEventArgs e) { Model.mCMGPerson person = new Model.mCMGPerson(new CMGPerson()); person.RecordCreatedUser = "******"; person.RecordCreatedDate = DateTime.Now; dlgCMGPerson dialog = new dlgCMGPerson(person); bool? result = dialog.ShowDialog(); if (result.HasValue && result.Value) { entities.CMGPersons.Add(person.m_Person); try { entities.SaveChanges(); personList.Add(person); person.AllChanged(); } catch (Exception exc) { MessageBox.Show(exc.Message, "Exception"); } } else { } }
private void cMGPersonDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { Model.mCMGPerson person = cMGPersonDataGrid.SelectedItem as Model.mCMGPerson; if (person != null) { dlgCMGPerson dialog = new dlgCMGPerson(person); bool? result = dialog.ShowDialog(); if (result.HasValue && result.Value) { entities.SaveChanges(); } else { entities.Entry(person.m_Person).Reload(); } person.AllChanged(); } }
public dlgCMGPerson(Model.mCMGPerson person) { DataContext = person; InitializeComponent(); }