Ejemplo n.º 1
0
        private void listBoxTorneio_SelectedIndexChanged(object sender, EventArgs e)
        {
            //torneios.GetType();
            if (listBoxTorneio.SelectedItem.GetType() == typeof(TeamTournament))
            {
                TeamTournament team = (TeamTournament)listBoxTorneio.SelectedItem;

                if (team != null)
                {
                    labelNome.Text = team.Nome;
                    labelDesc.Text = team.Desc;
                    labelData.Text = Convert.ToString(team.Data);
                }
            }
            else if (listBoxTorneio.SelectedItem.GetType() == typeof(StandardTournament))
            {
                StandardTournament solo = (StandardTournament)listBoxTorneio.SelectedItem;
                if (solo != null)
                {
                    labelNome.Text = solo.Nome;
                    labelDesc.Text = solo.Desc;
                    labelData.Text = Convert.ToString(solo.Data);
                }
            }
        }
Ejemplo n.º 2
0
        private void buttonCriarTorneio_Click(object sender, EventArgs e)
        {
            if (textBoxNome.Text.Length == 0 || textBoxDesc.Text.Length == 0)
            {
                MessageBox.Show("Preencha as caixas de texto, Por Favor.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (radioButtonStandard.Checked == true)
            {
                string   nome = textBoxNome.Text.Trim();
                string   desc = textBoxDesc.Text.Trim();
                DateTime date = dateTimePicker.Value;

                NovoTorneioStandard = new StandardTournament()
                {
                    Nome = nome,
                    Data = date,
                    Desc = desc,
                };
                DialogResult = DialogResult.OK;
                Close();
            }
            else if (radioButtonEquipas.Checked == true)
            {
                string   nome = textBoxNome.Text.Trim();
                string   desc = textBoxDesc.Text.Trim();
                DateTime date = dateTimePicker.Value;

                NovoTorneioTeam = new TeamTournament()
                {
                    Nome = nome,
                    Data = date,
                    Desc = desc,
                };
                DialogResult = DialogResult.Yes;
                Close();
            }
            else
            {
                MessageBox.Show("Nenhum tipo de torneio selecionado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 3
0
        private void listBoxTorneio_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBoxTorneio.SelectedItem.GetType() == typeof(TeamTournament))
            {
                TeamTournament team = (TeamTournament)listBoxTorneio.SelectedItem;

                if (team != null)
                {
                    textBoxNome.Text     = team.Nome;
                    textBoxDesc.Text     = team.Desc;
                    dateTimePicker.Value = team.Data;
                }
            }
            else
            {
                StandardTournament solo = (StandardTournament)listBoxTorneio.SelectedItem;
                if (solo != null)
                {
                    textBoxNome.Text     = solo.Nome;
                    textBoxDesc.Text     = solo.Desc;
                    dateTimePicker.Value = solo.Data;
                }
            }
        }
        /// <summary>
        /// Ao selecionar 1 torneio, carrega os jogos
        /// associados ao árbitro atual para a tabela lvStandardJ
        /// </summary>
        private void lbxStandardT_SelectedIndexChanged(object sender, EventArgs e)
        {
            lvStandardJ.Items.Clear();

            if (lbxStandardT.SelectedItems.Count > 0)
            {
                //Obter torneio selecionado
                StandardTournament torneioSelecionado = (StandardTournament)lbxStandardT.SelectedItem;

                //Percorrer todos os jogos desse torneio
                foreach (StandardGame jogo in torneioSelecionado.Games)
                {
                    if (jogo.RefereeId == idArbitro) //Verificar se o jogo está associado ao árbitro
                    {
                        ListViewItem item = new ListViewItem(jogo.Description);
                        item.SubItems.Add(jogo.Date.ToShortDateString());
                        item.SubItems.Add(jogo.Player1.Nickname);
                        item.SubItems.Add(jogo.Player2.Nickname);

                        lvStandardJ.Items.Add(item);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void buttonGuardar_Click(object sender, EventArgs e)
        {
            if (listBoxTorneio.SelectedItem == null)
            {
                MessageBox.Show("Nenhum torneio selecionado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                if (listBoxTorneio.SelectedItem.GetType() == typeof(TeamTournament))
                {
                    TeamTournament team = (TeamTournament)listBoxTorneio.SelectedItem;

                    if (team != null)
                    {
                        DialogResult result = MessageBox.Show("Tem a certeza que deseja guardar as alterações ? ", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                        if (result == DialogResult.Yes)
                        {
                            if (textBoxDesc.Text == null || textBoxNome.Text == null)
                            {
                                MessageBox.Show("Preencha as caixas de texto, Por favor", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else
                            {
                                string   nome = textBoxNome.Text.Trim();
                                string   desc = textBoxDesc.Text.Trim();
                                DateTime date = dateTimePicker.Value;

                                team.Nome = nome;
                                team.Data = date;
                                team.Desc = desc;

                                container.SaveChanges();
                            }
                        }
                    }
                }
                else //if(listBoxTorneio.SelectedItem.GetType() == typeof(StandardTournament))
                {
                    StandardTournament standard = (StandardTournament)listBoxTorneio.SelectedItem;

                    if (standard != null)
                    {
                        DialogResult result = MessageBox.Show("Tem a certeza que deseja guardar as alterações ? ", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);


                        if (result == DialogResult.Yes)
                        {
                            if (textBoxDesc.Text == null || textBoxNome.Text == null)
                            {
                                MessageBox.Show("Preencha as caixas de texto, Por favor", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else
                            {
                                string   nome = textBoxNome.Text.Trim();
                                string   desc = textBoxDesc.Text.Trim();
                                DateTime date = dateTimePicker.Value;

                                standard.Nome = nome;
                                standard.Data = date;
                                standard.Desc = desc;

                                container.SaveChanges();
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
 private void AdicionarTorneioStandard(StandardTournament torneio)
 {
     container.Tournament.Add(torneio);
     container.SaveChanges();
 }