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)
            {
                //TODO - Button Clicked - Execute Code Here

                if (MessageBox.Show("Eliminare l'anagrafica di " + row.Cells["Cognome"].Value + " " + row.Cells["Nome"].Value + " ?",
                                    "Attenzione",
                                    MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    int idAtleta = (int)row.Cells["IdAtleta"].Value;

                    SqlDal_Fighters.EliminaAtleta(idAtleta);
                    SqlDal_Fighters.EliminaAtletaDaGironi(idAtleta);
                    SqlDal_Fighters.EliminaAtletaDaTorneo(idAtleta);
                    SqlDal_Fighters.EliminaAtletaDaRanking(idAtleta);

                    LoadListAtleti();
                }
            }
        }
Beispiel #2
0
        private void Search(String nome, String cognome)
        {
            List <AtletaEntity> atleti = SqlDal_Fighters.GetAtletiFromNameAndSurname(nome, cognome);

            if (atleti != null)
            {
                dataGridView1.DataSource = atleti.ToArray();
                dataGridView1.Columns["IdAtleta"].Visible = false;
                dataGridView1.Columns["IdAsd"].Visible    = false;
                //dataGridView1.Columns["Asd"].Visible = false;
                dataGridView1.Columns["Ranking"].Visible  = false;
                dataGridView1.Columns["FullNAme"].Visible = false;
                dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically;


                FullFillAssociationComboBox((int)dataGridView1.Rows[0].Cells["IdAtleta"].Value,
                                            (int)dataGridView1.Rows[0].Cells["IdAsd"].Value);

                textBoxNewName.Text    = (String)dataGridView1.Rows[0].Cells["Nome"].Value;
                textBoxNewSurname.Text = (String)dataGridView1.Rows[0].Cells["Cognome"].Value;

                radioButtonFemale.Checked = ((String)dataGridView1.Rows[0].Cells["Sesso"].Value).Remove(1) == "F" ? true : false;
                radioButtonMale.Checked   = ((String)dataGridView1.Rows[0].Cells["Sesso"].Value).Remove(1) == "M" ? true : false;

                EnableModificationControl();
                buttonSave.Enabled = true;
            }
        }
        private void LoadListAtleti()
        {
            List <AtletaEntity> atletiPresenti = SqlDal_Fighters.GetAllAnagraficaAtletiWithRanking();

            dataGridView1.DataSource = atletiPresenti.ToArray();

            dataGridView1.Columns["FullName"].Visible = false;
            dataGridView1.Columns["IdAtleta"].Visible = false;
            dataGridView1.Columns["IdAsd"].Visible    = false;

            dataGridView1.Columns["Asd"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

            dataGridView1.EditMode = DataGridViewEditMode.EditOnF2;

            if (dataGridView1.ColumnCount <= 8)
            {
                DataGridViewButtonColumn btn = new DataGridViewButtonColumn();

                dataGridView1.Columns.Add(btn);
                btn.HeaderText = "Elimina";
                btn.Text       = "Elimina";
                btn.Name       = "btn";
                btn.UseColumnTextForButtonValue = true;
            }

            lblNumber.Text = atletiPresenti.Count.ToString();
        }
Beispiel #4
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            String newName    = textBoxNewName.Text;
            String newSurname = textBoxNewSurname.Text;
            String sesso      = radioButtonMale.Checked ? "M" : "F";

            IdAsd = (int)comboBoxNewAssociation.SelectedValue;

            AtletaEntity a = new AtletaEntity()
            {
                IdAsd    = IdAsd,
                IdAtleta = IdAtleta,
                Nome     = newName,
                Cognome  = newSurname,
                Sesso    = sesso
            };

            if (SqlDal_Fighters.UpdateAngraficDataByAtleta(a))
            {
                MessageBox.Show("Anagrafica aggiornata correttamente", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Search(textBoxName.Text, textBoxSurname.Text);
            }
            else
            {
                MessageBox.Show("Anagrafica non aggiornata", "ERRORE", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #5
0
        private void LoadDataGrid()
        {
            List <AtletaEntity> atleti = SqlDal_Fighters.GetAllAnagraficaAtleti();

            dataGridView1.DataSource = atleti.ToArray();


            dataGridView1.Columns[6].Visible = false;
            dataGridView1.Columns[7].Visible = false;
        }
        public static Tuple <string, string> SaveFinalPool(int idTorneo, int idDisciplina, int pool, DataGrid dataGridPool)
        {
            List <AtletaEliminatorie> listAtleti = new List <AtletaEliminatorie>();

            int round = 1;

            int    vittorieRosso = 0;
            int    vittorieBlu   = 0;
            string winner        = "";
            string looser        = "";

            foreach (MatchEntity match in dataGridPool.Items)
            {
                if (match.PuntiRosso > match.PuntiBlu)
                {
                    vittorieRosso++;
                }
                else if (match.PuntiRosso < match.PuntiBlu)
                {
                    vittorieBlu++;
                }

                SqlDal_Pools.UpdateFinali(idTorneo, idDisciplina, pool, round, match.IdRosso, match.PuntiRosso, match.PuntiBlu);
                SqlDal_Pools.UpdateFinali(idTorneo, idDisciplina, pool, round, match.IdBlu, match.PuntiBlu, match.PuntiRosso);

                round++;
            }

            var m = ((MatchEntity)dataGridPool.Items[0]);

            if (vittorieRosso > vittorieBlu)
            {
                winner = SqlDal_Fighters.GetAtletaById(m.IdRosso).Asd + " - " + m.CognomeRosso + " " + m.NomeRosso;
                looser = SqlDal_Fighters.GetAtletaById(m.IdBlu).Asd + " - " + m.CognomeBlu + " " + m.NomeBlu;
            }
            else if (vittorieBlu > vittorieRosso)
            {
                looser = SqlDal_Fighters.GetAtletaById(m.IdRosso).Asd + " - " + m.CognomeRosso + " " + m.NomeRosso;
                winner = SqlDal_Fighters.GetAtletaById(m.IdBlu).Asd + " - " + m.CognomeBlu + " " + m.NomeBlu;
            }
            else
            {
                winner = "";
                looser = "";
            }

            return(new Tuple <string, string>(winner, looser));
        }
Beispiel #7
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            AtletaEntity newAtleta;

            if (comboBoxAssociation.SelectedIndex < 0)
            {
                MessageBox.Show("Selezionare un'ASD", "Attenzione", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (textBoxSurname.Text == "")
            {
                MessageBox.Show("Inserire il Cognome", "Attenzione", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (textBoxName.Text == "")
            {
                MessageBox.Show("Selezionare il Nome", "Attenzione", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                newAtleta = new AtletaEntity()
                {
                    IdAsd   = (int)comboBoxAssociation.SelectedValue,
                    Nome    = textBoxName.Text,
                    Cognome = textBoxSurname.Text,
                    Sesso   = radioButtonMale.Checked ? "M" : "F"
                };
                int idInserted = SqlDal_Fighters.InsertNewAtleta(newAtleta);

                if (idInserted > 0)
                {
                    MessageBox.Show("Atleta inserito correttamente [ID = " + idInserted + "]", "Messaggio", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Atleta NON inserito.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void LoadListAtleti()
        {
            atletiPresenti = SqlDal_Fighters.GetAllAnagraficaAtletiWithRanking();

            dataGridAthletes.ItemsSource = atletiPresenti;
        }