Пример #1
0
        // Procède à l'importation du barème des points ATP.
        private void LoadPointsAtpScale()
        {
            foreach (object level in Enum.GetValues(typeof(Level)))
            {
                string query = string.Format("select * from points where level_ID = {0}", (int)level);
                using (DataTableReader reader = SqlTools.ExecuteReader(query))
                {
                    while (reader.Read())
                    {
                        new PointsAtpScale((Level)level,
                                           (Round)reader.GetByte("round_ID"),
                                           reader.GetUint32("points_w"),
                                           reader.GetUint32("points_l"),
                                           reader.GetUint32("points_l_ex"),
                                           reader.GetBoolean("is_cumuled"));

                        _dataLoadingProgressEventHandler?.Invoke(new DataLoadingProgressEvent(100 * ++_currentDataCount / _totalDataCount));
                    }
                }
            }
        }
Пример #2
0
        private void buttonArtikellesen_Click(object sender, EventArgs e)
        {
            adapterArtikel.FillSchema(ds, SchemaType.Source, "Artikel");
            ds.Tables["Artikel"].Columns[0].AutoIncrement = true;
            adapterArtikel.Fill(ds, "Artikel");
            dataGridViewAusgabe.DataSource = ds;
            dataGridViewAusgabe.DataMember = "Artikel";
            DataTableReader reader = ds.Tables["Artikel"].CreateDataReader();

            while (reader.Read())
            {
                DisplayArtikel ds = new DisplayArtikel();
                ds.ArtikelOid   = reader.GetInt32(0);
                ds.ArtNr        = reader.GetString(1);
                ds.Bezeichnung  = reader.GetString(3);
                ds.Meldebestand = reader.GetInt16(5);
                ds.ArtGruppe    = GetArtGruppe(reader.GetInt32(2));
                ds.Bestand      = reader.GetByte(4);
                lsArt.Add(ds);
            }
            dataGridViewAusgabe.DataSource = lsArt;
        }
Пример #3
0
 // <Snippet1>
 private static void PrintColumn(DataTableReader reader)
 {
     // Loop through all the rows in the DataTableReader
     while (reader.Read())
     {
         if (reader.IsDBNull(2))
         {
             Console.Write("<NULL>");
         }
         else
         {
             try
             {
                 Console.Write(reader.GetByte(2));
             }
             catch (InvalidCastException)
             {
                 Console.Write("Invalid data type.");
             }
         }
         Console.WriteLine();
     }
 }
Пример #4
0
        /// <summary>
        /// Crée les éditions des tournois disputés dans une année.
        /// L'intégration manuelle des nouveaux tournois (ou ceux mis à jour) doit être réalisée au préalable.
        /// Les données relatives à la coupe Davis sont ignorées.
        /// </summary>
        public void IntegrateEditionOfTournaments()
        {
            string insertEditionQuery = SqlTools.BuildInsertQuery("editions", new Dictionary <string, string>()
            {
                { "tournament_ID", "@id" },
                { "year", "@year" },
                { "draw_size", "@drawsize" },
                { "date_begin", "@bdate" },
                { "date_end", "@edate" },
                { "surface_ID", "@surface" },
                { "slot_order", "@slot" },
                { "is_indoor", "@indoor" },
                { "level_ID", "@level" },
                { "substitute_ID", "@substitute" },
                { "name", "@name" },
                { "city", "@city" }
            });

            List <string> uniqueTournamentList = new List <string>();

            foreach (Dictionary <string, string> match in _matchs)
            {
                if (!uniqueTournamentList.Contains(match["tourney_id"]))
                {
                    uniqueTournamentList.Add(match["tourney_id"]);

                    string baseCode = match["tourney_id"].Substring(5);

                    using (DataTableReader reader = SqlTools.ExecuteReader("select * from tournaments where original_code in (@code2, @code1)",
                                                                           new SqlParam("@code1", DbType.String, baseCode), new SqlParam("@code2", DbType.String, GetGenericTournamentCode(baseCode))))
                    {
                        if (reader.Read())
                        {
                            DateTime dateBegin = Tools.FormatCsvDateTime(match["tourney_date"]);
                            // Pas le vrai type SQL, mais san importance
                            int drawSize = Convert.ToInt32(match["draw_size"]);

                            // TODO : système de préparation de la requête SQL
                            SqlTools.ExecuteNonQuery(insertEditionQuery,
                                                     new SqlParam("@id", DbType.UInt32, reader.GetUint64("ID")),
                                                     new SqlParam("@year", DbType.UInt32, _year),
                                                     new SqlParam("@drawsize", DbType.UInt16, drawSize),
                                                     new SqlParam("@bdate", DbType.DateTime, dateBegin.ToString("yyyy-MM-dd")),
                                                     new SqlParam("@edate", DbType.DateTime, ComputeEditionEndDate(dateBegin, drawSize).ToString("yyyy-MM-dd")),
                                                     new SqlParam("@surface", DbType.Byte, reader.GetByte("surface_ID")),
                                                     new SqlParam("@slot", DbType.Byte, reader.GetByteNull("slot_order")),
                                                     new SqlParam("@indoor", DbType.Boolean, reader.GetByte("is_indoor") == 1),
                                                     new SqlParam("@level", DbType.Byte, reader.GetByte("level_ID")),
                                                     new SqlParam("@substitute", DbType.UInt32, reader.GetUint64Null("substitute_ID")),
                                                     new SqlParam("@name", DbType.String, reader.GetString("name")),
                                                     new SqlParam("@city", DbType.String, reader.GetString("city")));
                        }
                        else
                        {
                            Tools.WriteLog(string.Format("Le tournoi {0} a été ignoré. C'est une erreur s'il ne s'agit pas d'un match de coupe Davis.", match["tourney_id"]));
                        }
                    }
                }
            }
        }
Пример #5
0
 public byte GetByte(int i)
 {
     return(_reader.GetByte(i));
 }
Пример #6
0
        /// <summary>
        /// Importe des matchs depuis la base de données selon des paramètres optionnels.
        /// </summary>
        /// <param name="editionId">Identifiant d'édition de tournoi.</param>
        /// <param name="playerId">Identifiant de joueur.</param>
        /// <returns>Les matchs importés.</returns>
        public IEnumerable <Match> LoadMatches(uint?editionId, ulong?playerId)
        {
            List <Match> matchs = new List <Match>();

            Match.SetBatchMode(true);

            string          query     = "select * from matches where 1 = 1";
            List <SqlParam> sqlParams = new List <SqlParam>();

            if (editionId.HasValue)
            {
                query += " and edition_ID = @edition";
                sqlParams.Add(new SqlParam("@edition", DbType.UInt32, editionId.Value));
            }
            if (playerId.HasValue)
            {
                query += " and (winner_ID = @player or loser_ID = @player)";
                sqlParams.Add(new SqlParam("@player", DbType.UInt32, playerId.Value));
            }

            using (DataTableReader reader = SqlTools.ExecuteReader(query, sqlParams.ToArray()))
            {
                while (reader.Read())
                {
                    Match match = new Match(reader.GetUint64("ID"),
                                            reader.GetUint32("edition_ID"),
                                            reader.GetUint16("match_num"),
                                            (Round)reader.GetByte("round_ID"),
                                            reader.GetByte("best_of"),
                                            reader.GetUint32Null("minutes"),
                                            reader.GetBoolean("unfinished"),
                                            reader.GetBoolean("retirement"),
                                            reader.GetBoolean("walkover"),
                                            reader.GetUint32("winner_ID"),
                                            reader.GetUint32Null("winner_seed"),
                                            reader.GetString("winner_entry"),
                                            reader.GetUint32Null("winner_rank"),
                                            reader.GetUint32Null("winner_rank_points"),
                                            reader.GetUint32("loser_ID"),
                                            reader.GetUint32Null("loser_seed"),
                                            reader.GetString("loser_entry"),
                                            reader.GetUint32Null("loser_rank"),
                                            reader.GetUint32Null("loser_rank_points"));
                    match.DefineStatistics(reader.ToDynamicDictionnary <uint?>(true), reader.ToDynamicDictionnary <uint?>(true));
                    for (byte i = 1; i <= 5; i++)
                    {
                        match.AddSetByNumber(i, reader.GetByteNull("w_set_" + i.ToString()), reader.GetByteNull("l_set_" + i.ToString()), reader.GetUint16Null("tb_set_" + i.ToString()));
                    }
                    matchs.Add(match);

                    if (Config.GetBool(AppKey.ComputeMatchesWhileLoading))
                    {
                        _dataLoadingProgressEventHandler?.Invoke(new DataLoadingProgressEvent(100 * ++_currentDataCount / _totalDataCount));
                    }
                }
            }

            Match.SetBatchMode(false);

            return(matchs);
        }
 public byte GetByte(int _index)
 {
     return(dataReader.GetByte(_index));
 }