private void btnConferma_Click(object sender, EventArgs e) { if (MessageBox.Show("Confermi la cancellazione dell'evento del " + dataEvento[listaEventi.SelectedIndex].ToShortDateString() + "?", "Conferma cancellazione", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { OdbcConnection conn = new OdbcConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString); conn.Open(); OdbcCommand cm = new OdbcCommand(); cm.CommandText = "DELETE FROM SerataDanzante WHERE IDSerata=" + idEvento[listaEventi.SelectedIndex]; cm.Connection = conn; if (cm.ExecuteNonQuery() > 0) { MessageBox.Show("Evento cancellato"); } conn.Close(); CaricaEventi.RunWorkerAsync(); } }
public CancellaEvento() { InitializeComponent(); CaricaEventi.RunWorkerAsync(); }