private void btnEdit_Click(object sender, EventArgs e) { if (CurrentDirector == null) return; Person directorCopy = new Person(CurrentDirector); using (EditDirectorDialog dlg = new EditDirectorDialog(directorCopy)) { dlg.StartPosition = FormStartPosition.CenterParent; if (dlg.ShowDialog() != DialogResult.OK) return; CurrentDirector.Update(directorCopy); } }
private void btnAdd_Click(object sender, EventArgs e) { Person director = new Person(); using (EditDirectorDialog dlg = new EditDirectorDialog(director)) { dlg.StartPosition = FormStartPosition.CenterParent; if (dlg.ShowDialog() != DialogResult.OK) return; _movieRepository.Add(director); lstDirectors.SelectedItem = director; UpdateButtons(); } }
public void Update(Person person) { FirstName = person.FirstName; LastName = person.LastName; }
public Person(Person person) { Update(person); }
public EditDirectorDialog(Person owner) : this() { txtFirst.DataBindings.Add("Text", owner, "FirstName", true, DataSourceUpdateMode.OnPropertyChanged); txtLast.DataBindings.Add("Text", owner, "LastName", true, DataSourceUpdateMode.OnPropertyChanged); }