예제 #1
0
        public static ObservableCollection <Inscrit> selectInscritsDeUnTorneigIGrup(Int32 idTorneig, Grup g)
        {
            DateTime data;
            ObservableCollection <Inscrit> inscrits = new ObservableCollection <Inscrit>();

            //---------------------------------
            using (MySqlConnection connexio = MySQL.GetConnexio())
            {
                connexio.Open();
                using (MySqlCommand consulta = connexio.CreateCommand())
                {
                    consulta.CommandText = @"select inscrit.* from inscrit where inscrit.torneig_id = @idTorneig and inscrit.grup_num = @numGrup";
                    UtilsDB.AddParameter(consulta, "idTorneig", idTorneig, MySqlDbType.Int32);
                    UtilsDB.AddParameter(consulta, "numGrup", g.Num, MySqlDbType.Int32);

                    MySqlDataReader reader = consulta.ExecuteReader();
                    while (reader.Read())
                    {
                        Inscrit i;

                        Int32 idS  = reader.GetInt32(reader.GetOrdinal("soci_id"));
                        Int32 idT  = reader.GetInt32(reader.GetOrdinal("torneig_id"));
                        Int32 numG = -1;
                        try
                        {
                            numG = reader.GetInt32(reader.GetOrdinal("grup_num"));
                        }
                        catch (Exception e)
                        {
                        }
                        data = reader.GetDateTime(reader.GetOrdinal("data"));

                        Soci    s = TorneigBD.selectSociPerId(idS);
                        Torneig t = TorneigBD.selectTorneigPerId(idT);
                        if (numG != -1)
                        {
                            Grup gr = TorneigBD.selectGrupDeUnTorneigIUnGrup(idT, numG);
                            i = new Inscrit(s, t, gr, data);
                            inscrits.Add(i);
                        }
                        else
                        {
                            i = new Inscrit(s, t, null, data);
                            inscrits.Add(i);
                        }
                    }
                }
            }
            return(inscrits);
        }
예제 #2
0
        public static ObservableCollection <Inscrit> selectInscritsDeUnTorneig(Int32 idTorneig)
        {
            DateTime data;
            ObservableCollection <Inscrit> inscrits = new ObservableCollection <Inscrit>();

            //---------------------------------
            using (MySqlConnection connexio = MySQL.GetConnexio())
            {
                connexio.Open();
                using (MySqlCommand consulta = connexio.CreateCommand())
                {
                    consulta.CommandText = @"select inscrit.* from inscrit inner join soci on inscrit.soci_id = soci.id left join estadistica_modalitat on estadistica_modalitat.soci_id = soci.id where inscrit.torneig_id = @idTorneig and inscrit.grup_num is NULL and estadistica_modalitat.modalitat_id = 1 order by estadistica_modalitat.coeficient_base desc";
                    UtilsDB.AddParameter(consulta, "idTorneig", idTorneig, MySqlDbType.Int32);

                    MySqlDataReader reader = consulta.ExecuteReader();
                    while (reader.Read())
                    {
                        Inscrit i;

                        Int32 idS  = reader.GetInt32(reader.GetOrdinal("soci_id"));
                        Int32 idT  = reader.GetInt32(reader.GetOrdinal("torneig_id"));
                        Int32 numG = -1;
                        try
                        {
                            numG = reader.GetInt32(reader.GetOrdinal("grup_num"));
                        }
                        catch (Exception e)
                        {
                        }
                        data = reader.GetDateTime(reader.GetOrdinal("data"));

                        Soci    s = TorneigBD.selectSociPerId(idS);
                        Torneig t = TorneigBD.selectTorneigPerId(idT);
                        if (numG != -1)
                        {
                            Grup g = TorneigBD.selectGrupDeUnTorneigIUnGrup(idT, numG);
                            i = new Inscrit(s, t, g, data);
                            inscrits.Add(i);
                        }
                        else
                        {
                            i = new Inscrit(s, t, null, data);
                            inscrits.Add(i);
                        }
                    }
                }
            }
            return(inscrits);
        }