Beispiel #1
0
        public ManageTournament()
        {
            InitializeComponent();

            this.StartPosition = FormStartPosition.CenterScreen;

            List <TorneoEntity> tornei = SqlDal_Tournaments.GetTorneiAttivi(false);

            this.comboBox1.DataSource            = tornei.ToArray();
            this.comboBox1.ValueMember           = "Id";
            this.comboBox1.DisplayMember         = "Name";
            this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.ComboBox1_SelectedIndexChanged);
            this.comboBox1.SelectedItem          = 0;

            //La inizializzo a 0
            List <DisciplinaEntity> discipline = SqlDal_Tournaments.GetDisciplineByIdTorneo(0);

            this.comboBox2.DataSource    = discipline.ToArray();
            this.comboBox2.ValueMember   = "IdDisciplina";
            this.comboBox2.DisplayMember = "Nome";
            this.comboBox2.SelectedItem  = 0;

            buttonLoadIscritti.DialogResult = DialogResult.OK;
            buttonClose.DialogResult        = DialogResult.Abort;

            buttonPrintList.Enabled = false;
        }
Beispiel #2
0
        private void btnAddAtleta_Click(object sender, EventArgs e)
        {
            Int32 idTorneo     = (int)comboBox1.SelectedValue;
            Int32 idDisciplina = (int)comboBox2.SelectedValue;
            Int32 idAtleta     = (int)comboBoxAtletaToAdd.SelectedValue;

            if (idAtleta > 0)
            {
                if (SqlDal_Tournaments.InsertAtletaOnTournament(idTorneo, idDisciplina, idAtleta))
                {
                    LoadPartecipantFromTournament(idTorneo, idDisciplina, Categoria);
                    LoadPartecipantOffTournament(idTorneo, idDisciplina, Categoria);
                    MessageBox.Show("Atleta inserito correttamente.", "Messaggio", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Atleta NON inserito nel torneo.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Selezionare un Atleta da inserire nel Torneo '" + comboBox1.Text + "' per la disciplina '" + comboBox2.Text + "'",
                                "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        public CaricaGironiDaDisciplina(bool export)
        {
            InitializeComponent();
            var dbType = Helper.GetDbType();

            this.StartPosition = FormStartPosition.CenterScreen;

            if (export)
            {
                this.buttonOk.Text = "Carica Risultati";
            }

            List <TorneoEntity> tornei = !export?SqlDal_Tournaments.GetTorneiAttivi(false) : SqlDal_Tournaments.GetTorneiConclusi(false);

            this.comboBox1.DataSource            = tornei.ToArray();
            this.comboBox1.ValueMember           = "Id";
            this.comboBox1.DisplayMember         = "Name";
            this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.ComboBox1_SelectedIndexChanged);

            //La inizializzo a 0
            List <DisciplinaEntity> discipline = SqlDal_Tournaments.GetDisciplineByIdTorneo(0);

            this.comboBox2.DataSource    = discipline.ToArray();
            this.comboBox2.ValueMember   = "IdDisciplina";
            this.comboBox2.DisplayMember = "Nome";



            buttonOk.DialogResult     = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Abort;
        }
Beispiel #4
0
        private void LoadPartecipantFromTournament(Int32 idTorneo, Int32 idDisciplina, string categoria)
        {
            List <AtletaEntity> atleti = SqlDal_Tournaments.GetAtletiIscrittiTorneoVsDisciplina(idTorneo, idDisciplina);


            if ((atleti != null) && (atleti.Count > 0))
            {
                atleti = atleti.OrderByDescending(x => x.Ranking).ThenBy(x => x.Asd).ThenBy(x => x.Cognome).ToList();

                dataGridView1.DataSource = atleti.ToArray();
                dataGridView1.Visible    = true;

                InitializegridView();

                lblCount.Text = atleti.Count.ToString();
            }
            else
            {
                dataGridView1.DataSource = null;
                MessageBox.Show("Nessun Atelta trovato per il Torneo e la Disciplina Selezionati", "Attenzione", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            btnAddAtleta.Enabled    = true;
            buttonPrintList.Enabled = true;
        }
Beispiel #5
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);
                    }
                }
            }
        }
        private void BtnPrintResult_Click(object sender, RoutedEventArgs e)
        {
            TorneoEntity tournament     = SqlDal_Tournaments.GetTorneoById(_idTorneo);
            String       nomeDisciplina = SqlDal_Tournaments.GetDisciplinaById(_idDisciplina);

            pdf.FineTorneo(goldMedal, silverMedal, bronzeMedal, woodMedal, tournament.Name, nomeDisciplina);
        }
Beispiel #7
0
        private void LoadPartecipantOffTournament(Int32 idTorneo, Int32 idDisciplina, string categoria)
        {
            List <AtletaEntity> atletiOffTournament = SqlDal_Tournaments.GetAtletiOffTournament(idTorneo, idDisciplina, categoria);

            comboBoxAtletaToAdd.DataSource         = atletiOffTournament.OrderBy(x => x.Cognome).ToArray();
            this.comboBoxAtletaToAdd.ValueMember   = "IdAtleta";
            this.comboBoxAtletaToAdd.DisplayMember = "FullName";// + " " + "Nome";
            this.comboBoxAtletaToAdd.SelectedItem  = 0;
        }
Beispiel #8
0
        private void BtnPrintResult_Click(object sender, RoutedEventArgs e)
        {
            PdfManager pdf = new PdfManager();

            pdf.StampaRisultatiGironi(
                dataGridResult,
                SqlDal_Tournaments.GetTorneoById(this.idTorneo).Name,
                SqlDal_Tournaments.GetDisciplinaById(this.idDisciplina));
        }
        private void btnStampa_Click(object sender, EventArgs e)
        {
            PdfManager pdf = new PdfManager();

            pdf.StampaRisultatiGironi(
                dataGridView1,
                SqlDal_Tournaments.GetTorneoById(this.idTorneo).Name,
                SqlDal_Tournaments.GetDisciplinaById(this.idDisciplina));
        }
Beispiel #10
0
        private void buttonPrintList_Click(object sender, EventArgs e)
        {
            PdfManager pdf = new PdfManager();

            Int32 idTorneo     = (int)comboBox1.SelectedValue;
            Int32 idDisciplina = (int)comboBox2.SelectedValue;

            pdf.StampaAtletiTorneo(SqlDal_Tournaments.GetAtletiTorneoVsDisciplina(idTorneo, idDisciplina), comboBox1.Text, comboBox2.Text);
        }
        private void LoadTornei()
        {
            List <TorneoEntity> tornei = SqlDal_Tournaments.GetTorneiAttivi(true);

            this.comboBoxTornei.DataSource    = tornei.ToArray();
            this.comboBoxTornei.ValueMember   = "TournamentId";
            this.comboBoxTornei.DisplayMember = "TournamentName";
            this.comboBoxTornei.SelectedItem  = 0;
        }
        private void ComboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if ((int)comboBox1.SelectedValue > 0)
            {
                ComboBox comboBox = (ComboBox)sender;

                List <DisciplinaEntity> discipline = SqlDal_Tournaments.GetDisciplineByIdTorneo((int)comboBox1.SelectedValue);

                this.comboBox2.DataSource    = discipline.ToArray();
                this.comboBox2.ValueMember   = "IdDisciplina";
                this.comboBox2.DisplayMember = "Nome";
            }
        }
        private void LoadAllTornei()
        {
            dataGridViewTornei.DataSource = SqlDal_Tournaments.GetAllTornei().ToArray();

            dataGridViewTornei.Columns["TournamentId"].Visible        = false;
            dataGridViewTornei.Columns["TournamentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

            if (dataGridViewTornei.ColumnCount <= 5)
            {
                DataGridViewButtonColumn btn = new DataGridViewButtonColumn();
                dataGridViewTornei.Columns.Add(btn);
                btn.HeaderText = "Elimina";
                btn.Text       = "Elimina";
                btn.Name       = "btn";
                btn.UseColumnTextForButtonValue = true;
            }
        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (textBoxNomeTorneo.Text != "")
            {
                DateTime datainizioTorneo = dateTimePickerDataInizioTorneo.Value;
                DateTime dataFineTorneo   = dateTimePickerDataFineTorneo.Value;
                String   nomeTorneo       = textBoxNomeTorneo.Text;
                String   luogoTorneo      = textBoxLuogo.Text;

                bool swordAndDagger  = checkBoxSpagaPugnale.Checked;
                bool swordAndBuckler = checkBoxSpadaBrocchiero.Checked;
                bool swordAndShield  = checkBoxSpadaRotella.Checked;
                bool twoHandSword    = checkBoxSpadaDueMani.Checked;
                bool singleSword     = checkBoxSpadaSola.Checked;

                TorneoEntity t = new TorneoEntity()
                {
                    Name      = nomeTorneo,
                    Place     = luogoTorneo,
                    StartDate = datainizioTorneo,
                    EndDate   = dataFineTorneo
                                //mancano i commenti
                };

                Int32 newTournamentId = SqlDal_Tournaments.InserNewTorneo(t);

                if (newTournamentId > 0)
                {
                    String categoria = radioButtonMale.Checked ? "M" : radioButtonMale.Checked ? "F" : "O";
                    SqlDal_Tournaments.AddDisciplineToTorneo(newTournamentId, singleSword, swordAndDagger, swordAndBuckler, swordAndShield, twoHandSword, categoria);
                }
                else
                {
                    MessageBox.Show("Errore durante il salvataggio del nuovo torneo", "ERRORE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Inserire un nome per il nuovo Torneo", "Attenzione", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #15
0
        private void LoadAllResults()
        {
            var disciplines = SqlDal_Tournaments.GetDisciplineByIdTorneo(_idTorneo);

            foreach (var d in disciplines)
            {
                if (d.IdDisciplina == 0)
                {
                    continue;   //skip the empy record
                }
                TabItem item = new TabItem();

                item.Header = d.Nome;

                item.Content = new TournamentReportByDiscipline(_idTorneo, d.IdDisciplina, d.Nome);

                tabControlResults.Items.Add(item);
            }

            tabControlResults.SelectedIndex = 0;
        }
Beispiel #16
0
        public CreaGironiDaDisciplina()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;

            List <TorneoEntity> tornei = SqlDal_Tournaments.GetTorneiAttivi(false);

            this.comboBox1.DataSource            = tornei.ToArray();
            this.comboBox1.ValueMember           = "Id";
            this.comboBox1.DisplayMember         = "Name";
            this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.Tornei_SelectedIndexChanged);

            //La inizializzo a 0
            List <DisciplinaEntity> discipline = SqlDal_Tournaments.GetDisciplineByIdTorneo(0);

            this.comboBox2.DataSource    = discipline.ToArray();
            this.comboBox2.ValueMember   = "IdDisciplina";
            this.comboBox2.DisplayMember = "Nome";

            buttonOk.DialogResult     = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Abort;
        }
        private void dataGridViewTornei_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

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

            if (e.ColumnIndex >= 0 && senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
            {
                if (MessageBox.Show("Eliminare il Torneo " + row.Cells["TournamentName"].Value + " ? (verranno cancellate anche tutte le iscrizioni al torneo stesso)",
                                    "Attenzione",
                                    MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    Int32 idTorneo = (int)row.Cells["tournamentId"].Value;

                    if (SqlDal_Tournaments.EliminaTorneo(idTorneo))
                    {
                        if (SqlDal_Tournaments.EliminaAtletiVsTorneoVsDiscipline(idTorneo))
                        {
                            if (SqlDal_Tournaments.EliminaTorneoVsDiscipline(idTorneo))
                            {
                                MessageBox.Show("Torneo ELIMINATO correttamente", "Messaggio", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                LoadAllTornei();
                            }
                            else
                            {
                                MessageBox.Show("Errore durante la cancellazione delle Discipline del Torneo", "Eroore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Errore durante la cancellazione degli Atleti associati al Torneo", "Eroore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    MessageBox.Show("Errore durante la cancellazione del Torneo", "Eroore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void creaGironiAndLoad(int idTorneo, int idDisciplina)
        {
            _dicFighter = new Dictionary <string, int>();

            //loadToolStripMenuItem.Enabled = false;      //Non permetto più di caricare i dati (in teoria va fatto meglio)

            //partecipantiTorneo = CaricaAtleti();

            // i dati in lettura vanno fatti caricando la disciplina dal DB (divisione per disciplina)
            //se sono in presenza degli assoluti, per ora, carico i dati ordinati solo per ranking e senza random dei nomi all'interno delle ASD
            //partecipantiTorneo = assoluti == false ?
            //                                    Helper.GetAtletiTorneoVsDisciplina(idTorneo, idDisciplina, categoria) :
            //                                    Helper.GetAtletiTorneoVsDisciplinaAssoluti(idTorneo, idDisciplina, categoria);

            SqlDal_Pools.DeletePoolsAndMatches(idTorneo, idDisciplina);

            var partecipantiTorneo = SqlDal_Tournaments.GetAtletiTorneoVsDisciplinaAssoluti(idTorneo, idDisciplina);

            //TODO: da parametrizzare

            bool rankingEnabled = partecipantiTorneo.Sum(x => x.Ranking) != 0;

            numeroGironi = SqlDal_Pools.GetNumeroGironiByTorneoDisciplina(idTorneo, idDisciplina);


            if (numeroGironi > 0)
            {
                gironi = new List <List <AtletaEntity> >();

                //Setting delle strutture dati
                for (int i = 0; i < numeroGironi; i++)
                {
                    //Per ogni girone creo la lista, vuota al momento, dei partecipanti al girone stesso
                    gironi.Add(new List <AtletaEntity>());
                }

                //Inserisco ogni partecipante del torneo dentro la struttura dati dei gironi
                //e dell'albero nella posizione corrispondente
                //(l'abero deve essere visualizzato via WEB : quando ci clicchi ti deve far vedere la lista e lo stato degli incontri al suo interno
                int count = 0;

                if (!rankingEnabled)
                {
                    foreach (AtletaEntity a in partecipantiTorneo)    //ciclo sui gironi, e sulla lista atleti partecipanti al torneo, inserendo ogni atleta in un girone diverso, e poi rifacendo il giro
                    {
                        gironi[count].Add(a);

                        if (count == numeroGironi - 1)
                        {
                            count = 0;
                        }
                        else
                        {
                            count++;
                        }
                    }
                }
                else
                {
                    //qui ci va il codice per il calcolo dei gironi con gli assoluti
                    int fasceAssoluti   = 4;
                    int atletiPerfascia = partecipantiTorneo.Count / fasceAssoluti;

                    #region inizializziani 4 fasce
                    List <AtletaEntity> primaFascia   = new List <AtletaEntity>();
                    List <AtletaEntity> secondaFascia = new List <AtletaEntity>();
                    List <AtletaEntity> terzaFascia   = new List <AtletaEntity>();
                    List <AtletaEntity> quartaFascia  = new List <AtletaEntity>();
                    #endregion

                    //primo quarto
                    primaFascia.AddRange(partecipantiTorneo.GetRange(0, atletiPerfascia));
                    //secondo quarto
                    secondaFascia.AddRange(partecipantiTorneo.GetRange(atletiPerfascia, atletiPerfascia));
                    //terzo quarto
                    terzaFascia.AddRange(partecipantiTorneo.GetRange(2 * atletiPerfascia, atletiPerfascia));
                    //tutti i restanti
                    quartaFascia.AddRange(partecipantiTorneo.GetRange(3 * atletiPerfascia, atletiPerfascia + (partecipantiTorneo.Count - (4 * atletiPerfascia))));

                    foreach (List <AtletaEntity> g in gironi)
                    {
                        //inserisco il primo atleta di ogni fascia nel girone i-esimo
                        if (primaFascia.Count > 0)
                        {
                            g.Add(primaFascia.ElementAt(0));
                        }
                        if (secondaFascia.Count > 0)
                        {
                            g.Add(secondaFascia.ElementAt(0));
                        }
                        if (terzaFascia.Count > 0)
                        {
                            g.Add(terzaFascia.ElementAt(0));
                        }
                        if (quartaFascia.Count > 0)
                        {
                            g.Add(quartaFascia.ElementAt(0));
                        }

                        //elimino quell'atleta dalla lista dei papabili
                        if (primaFascia.Count > 0)
                        {
                            primaFascia.RemoveAt(0);
                        }
                        if (secondaFascia.Count > 0)
                        {
                            secondaFascia.RemoveAt(0);
                        }
                        if (terzaFascia.Count > 0)
                        {
                            terzaFascia.RemoveAt(0);
                        }
                        if (quartaFascia.Count > 0)
                        {
                            quartaFascia.RemoveAt(0);
                        }
                    }

                    //gestisco eventuali orfani : GIRONI da 5
                    //per sicurezza controllo tutte le fasce ma sarà solo la quarta ad avere degli orfani
                    //che andaranno inseriti nei gironi già popolati a partire dal primo
                    if (primaFascia.Count > 0 || secondaFascia.Count > 0 || terzaFascia.Count > 0 || quartaFascia.Count > 0)
                    {
                        foreach (List <AtletaEntity> g in gironi)
                        {
                            if (primaFascia.Count > 0)
                            {
                                g.Add(primaFascia.ElementAt(0));
                                primaFascia.RemoveAt(0);
                            }
                            else if (secondaFascia.Count > 0)
                            {
                                g.Add(secondaFascia.ElementAt(0));
                                secondaFascia.RemoveAt(0);
                            }
                            else if (terzaFascia.Count > 0)
                            {
                                g.Add(terzaFascia.ElementAt(0));
                                terzaFascia.RemoveAt(0);
                            }
                            else if (quartaFascia.Count > 0)
                            {
                                g.Add(quartaFascia.ElementAt(0));
                                quartaFascia.RemoveAt(0);
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }

                ///TODO
                ///per ogni girone devo creare la lsita corrispondente degli scontri
                ///- nuova struttura dati dei gironi/scontri che ogni posizione contiene una lista di incontri
                ///- tali incontri vanno salvati sul DB
                ///- tali incontri dovranno, in futuro, essere anche visualizzati via WEB
                ///
                gironiIncontri = new List <List <MatchEntity> >();

                tabControlPool.Items.Clear();

                Int32 idGirone = 1;

                foreach (List <AtletaEntity> g in gironi)
                {
                    List <MatchEntity> matchList = null;

                    if (g.Count == 4)
                    {
                        matchList = Helper.ElaborateT4(g);
                    }
                    else if (g.Count == 5)
                    {
                        matchList = Helper.ElaborateT5(g);
                    }
                    else if (g.Count == 6)
                    {
                        matchList = Helper.ElaborateT6(g);
                    }

                    gironiIncontri.Add(matchList);
                    string title = "Girone " + (tabControlPool.Items.Count + 1).ToString();
                    tabControlPool.Items.Add(ElaboraTab(idTorneo, idDisciplina, title, g, matchList, tabControlPool.Items.Count + 1));

                    //TODO l'inserimento va fatto solo se già non è stato fatto, altrimenti vanno eliminati TUTTI i dati
                    SqlDal_Pools.InserisciGironiIncontri(idTorneo, idDisciplina, matchList, idGirone);

                    foreach (AtletaEntity a in g)
                    {
                        SqlDal_Pools.InsertAtletaInGirone(creaGironi.IdTorneo, creaGironi.IdDisciplina, idGirone, a.IdAtleta);
                    }

                    idGirone++;
                }

                EnablePageControls();
            }
            else
            {
                MessageBox.Show("Si è verificato un errore durante il recupero delle informazioni sul numero dei gironi \r\nContattare un amministratore",
                                "ERRORE Applicazione", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 private void LoadClosedTournaments()
 {
     closedTournamentList = SqlDal_Tournaments.GetTorneiConclusi(true);
     dataGridClosedTournament.ItemsSource = closedTournamentList;
 }
 private void LoadActiveTournaments()
 {
     activeTournamentList = SqlDal_Tournaments.GetTorneiAttivi(true);
     dataGridActiveTournament.ItemsSource = activeTournamentList;
 }
 private void LoadNewTournaments()
 {
     newTournamentList = SqlDal_Tournaments.GetTorneiToActivate(true);
     dataGridNewTournament.ItemsSource = newTournamentList;
 }