コード例 #1
0
        private void Top5Cdr_recette()
        {
            MySqlCommand top_cdr = mySql_cooking.CreateCommand();

            top_cdr.CommandText = "select r.nom_recette from recette as r  join est_composee as c on c.nom_recette=r.nom_recette where r.id_createur = (select  r.id_createur from commande , est_composee as c , recette as r where commande.id_commande=c.id_commande and c.nom_recette=r.nom_recette  group  by  id_createur  order by sum(c.quantite) desc limit 1) group by nom_recette  order by sum(c.quantite) desc limit 5;";

            MySqlDataReader dr;

            dr = top_cdr.ExecuteReader();
            while (dr.Read())
            {
                var data = new top5week {
                    nom_recette = Convert.ToString(dr["nom_recette"])
                };
                best_recette.Items.Add(data);
            }

            dr.Close();
        }
コード例 #2
0
        private void Top5Week_Grid()
        {
            MySqlCommand top_week = mySql_cooking.CreateCommand();

            top_week.CommandText = "select  c.nom_recette,r.type,r.id_createur,sum(c.quantite) as 'nb_fois' from commande, est_composee as c , recette as r where commande.id_commande = c.id_commande " +
                                   "and c.nom_recette = r.nom_recette  and(adddate(commande.date, 7) >= @datenow) group by  c.nom_recette order by sum(c.quantite) desc limit 5";
            top_week.Parameters.AddWithValue("@datenow", DateTime.Now);
            MySqlDataReader dr;

            dr = top_week.ExecuteReader();
            while (dr.Read())
            {
                var data = new top5week {
                    nom_recette = Convert.ToString(dr["nom_recette"]), type = Convert.ToString(dr["type"]), id_createur = Convert.ToString(dr["id_createur"]), nb_fois = Convert.ToString(dr["nb_fois"])
                };

                topDataGrid.Items.Add(data);
            }

            dr.Close();
        }