Example #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            DataGridView    dgv = sender as DataGridView;
            DataGridViewRow row = dataGridView1.Rows[e.RowIndex];

            if (e.ColumnIndex >= 0 && senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
            {
                if (MessageBox.Show("Eliminare dal Torneo " + row.Cells["Cognome"].Value + " " + row.Cells["Nome"].Value + " ?",
                                    "Attenzione",
                                    MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    Int32 idTorneo     = (int)comboBox1.SelectedValue;
                    Int32 idDisciplina = (int)comboBox2.SelectedValue;

                    if (SqlDal_Tournaments.EliminaPartecipanteDaTorneo(idTorneo, idDisciplina, (int)row.Cells["IdAtleta"].Value))
                    {
                        LoadPartecipantFromTournament(idTorneo, idDisciplina, Categoria);
                        LoadPartecipantOffTournament(idTorneo, idDisciplina, Categoria);
                        MessageBox.Show("Atleta rimosso correttamente.", "Messaggio", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Atleta NON rimosso.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }