private void bNewCar_Click(object sender, EventArgs e) { FormCar formCar = new FormCar(); formCar.txtCarname.Text = ""; formCar.txtCaryear.Text = ""; formCar.IdCar = 0; if (formCar.ShowDialog() == DialogResult.OK) { dbContext.NewCar(formCar.txtCarname.Text, formCar.txtCaryear.Text); UpdateListCars(txtFindCar.Text); } }
private void listBoxCar_DoubleClick(object sender, EventArgs e) { Car car = (Car)listBoxCar.SelectedItem; FormCar formCar = new FormCar(); formCar.txtCarname.Text = car.Carname; formCar.txtCaryear.Text = car.Caryear; formCar.IdCar = car.IdCar; if (formCar.ShowDialog() == DialogResult.OK) { car.Carname = formCar.txtCarname.Text; car.Caryear = formCar.txtCaryear.Text; dbContext.UpdateCar(car); listBoxCar.Items[listBoxCar.SelectedIndex] = car; } UpdateListCars(txtFindCar.Text); }