summaryrefslogtreecommitdiff
path: root/Aktywator/ParyTournament.cs
blob: 4950c3d2e11debc14e29c4b3279ba8d3c1e5b606 (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
56
using System;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;

namespace Aktywator
{
    class ParyTournament: MySQLTournament
    {
        public ParyTournament(string name)
            : base(name)
        {
            this._type = Tournament.TYPE_PARY;
        }

        override internal string getTypeLabel()
        {
            return "Pary";
        }

        override public string getSectionsNum()
        {
            return this.mysql.selectOne("SELECT COUNT(DISTINCT seknum) FROM sektory;");
        }

        override public string getTablesNum()
        {
            return this.mysql.selectOne("SELECT COUNT(*) FROM sektory;");
        }

        override internal Dictionary<int, List<string>> getNameList()
        {
            Dictionary<int, List<String>> pairs = new Dictionary<int, List<string>>();
            MySqlDataReader dbData = this.mysql.select("SELECT idp, CONCAT(imie, ' ', nazw) name FROM zawodnicy");
            while (dbData.Read())
            {
                int pairNo = dbData.GetInt32(0);
                if (!pairs.ContainsKey(pairNo))
                {
                    pairs.Add(pairNo, new List<string>());
                }
                pairs[pairNo].Add(dbData.IsDBNull(1) ? " " : dbData.GetString(1));
            }
            foreach (KeyValuePair<int, List<string>> pair in pairs)
            {
                while (pair.Value.Count < 2)
                {
                    pair.Value.Add(" ");
                }
            }
            dbData.Close();
            return pairs;
        }

    }
}