private void bNewOwner_Click(object sender, EventArgs e) { //подготовить форму для новой записи таблицы "Владельцы" FormOwner formOwner = new FormOwner(); formOwner.txtOwner.Text = txtFindOwner.Text; formOwner.IdOwner = 0; if (formOwner.ShowDialog() == DialogResult.OK) { //новую запись в таблицу владельцев автотранспорта dbContext.NewOwner(formOwner.txtOwner.Text); UpdateListOwners(txtFindOwner.Text); } }
private void listBoxOwner_DoubleClick(object sender, EventArgs e) { Owner owner = (Owner)listBoxOwner.SelectedItem; FormOwner formOwner = new FormOwner(); formOwner.IdOwner = owner.OwnerId; formOwner.txtOwner.Text = owner.OwnerName; if (formOwner.ShowDialog() == DialogResult.OK) { owner.OwnerName = formOwner.txtOwner.Text; dbContext.UpdateOwner(owner.OwnerId, owner.OwnerName); listBoxOwner.Items[listBoxOwner.SelectedIndex] = owner; } UpdateListOwners(txtFindOwner.Text); }