void uj_FormClosing(object sender, FormClosingEventArgs e) { if (((UjAuto)sender).DialogResult == DialogResult.OK) { select = ((UjAuto)sender).car; if (Duplicate(select.Rendszam)) { MessageBox.Show("A rendszám már szerepel a listán!", "Hibás érték", MessageBoxButtons.OK, MessageBoxIcon.Error); e.Cancel = true; return; } select.Index = Auto.AutoIndex++; cars.Add(select); dao.InsertCar(select); AppLogger.WriteEvent("Új autó:"); AppLogger.WriteAuto(select); if (BeforeRowAdd != null) { BeforeRowAdd(); } DoCarUpdate(); } }