summaryrefslogtreecommitdiff
path: root/Aktywator/ChooseTournament.cs
blob: 734b191572982f8753b07db415c2f9121cbfc67b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Aktywator
{
    public partial class ChooseTournament : Form
    {
        private MySQLTournament[] turns;
        public MySQLTournament chosenTournament;

        public ChooseTournament()
        {
            InitializeComponent();
        }

        private void ChooseTournament_Load(object sender, EventArgs e)
        {
            List<MySQLTournament> list = MySQLTournament.getTournaments();
            turns = new MySQLTournament[list.Count];
            int c = 0;
            foreach (MySQLTournament t in list)
            {
                turns[c++] = t;
                listBox.Items.Add(t.ToString());
            }
        }

        private void bChoose_Click(object sender, EventArgs e)
        {
            if (listBox.SelectedIndex >= 0)
            {
                switch (turns[listBox.SelectedIndex].type)
                {
                    case Tournament.TYPE_PARY:
                        chosenTournament = new ParyTournament(turns[listBox.SelectedIndex].name);
                        break;
                    case Tournament.TYPE_TEAMY:
                        chosenTournament = new TeamyTournament(turns[listBox.SelectedIndex].name);
                        break;
                }
                Close();
            }
        }

        private void listBox_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            bChoose_Click(sender, e);
        }
    }
}