public static List <Objectifs> GetObjectifs(int IdEleves)
        {
            List <Objectifs> results = null;

            string connectionString = ConfigurationManager.ConnectionStrings["Database1"].ConnectionString;

            try
            {
                using (SqlConnection cn = new SqlConnection(connectionString))
                {
                    string     query = "Select * from Objectifs o, ElevesObjectifs eo where  @IdEleves=eo.IdEleves and o.id=eo.IdObjectifs";
                    SqlCommand cmd   = new SqlCommand(query, cn);
                    cmd.Parameters.AddWithValue("@IdEleves", IdEleves);

                    cn.Open();

                    using (SqlDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            if (results == null)
                            {
                                results = new List <Objectifs>();
                            }

                            Objectifs objectif = new Objectifs();

                            objectif.Id = (int)dr["Id"];

                            if (dr["Nom"] != null)
                            {
                                objectif.Nom = (String)dr["Nom"];
                            }

                            if (dr["Minima"] != null)
                            {
                                objectif.Minima = (Boolean)dr["Minima"];
                            }

                            if (dr["IdGroupe"] != null)
                            {
                                objectif.IdGroupe = (int)dr["IdGroupe"];
                            }

                            results.Add(objectif);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(results);
        }
示例#2
0
        public List <string> ObtenirLesRun()
        {
            var maListe = new List <string>();

            foreach (var item in Objectifs.Where(f => f.Value != 0).OrderByDescending(k => k.Value))
            {
                maListe.Add($"{item.Value} runs sur l'étage {item.Key.Numero} en {item.Key.Difficulte.ToString()} ({item.Key.NomZone})");
            }
            return(maListe);
        }