private void btnPersonAdd_Click(object sender, EventArgs e) { using (PersonEditForm frmEditPerson = new PersonEditForm() { p = new Person() }) { if (frmEditPerson.ShowDialog() == System.Windows.Forms.DialogResult.OK) { db.InsertPerson(frmEditPerson.p); personBindingSource.DataSource = db.GetPeople(); personBindingSource.MoveLast(); } } }
private void btnPersonEdit_Click(object sender, EventArgs e) { Person obj = personBindingSource.Current as Person; if (obj != null) { using (PersonEditForm editForm = new PersonEditForm() { p = obj }) { if (editForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) { personBindingSource.EndEdit(); DataAccess db = new DataAccess(); db.UpdatePerson(obj); personBindingSource.ResetBindings(false); btnEdit.Focus(); } } } }