| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Data;
- using System.Data.SqlClient;
- using CG67.FicheCollege.Domaine;
- using CG67.FicheCollege.Interface;
- namespace CG67.FicheCollege.Entrepot
- {
- public class EntrepotBilinguisme : EntrepotBase, IEntrepotBilinguisme
- {
- public IList<Bilinguisme> GetByCodeRNEAndAnnee(string codeRNE, int annee)
- {
- IList<Bilinguisme> resultat = new List<Bilinguisme>();
- using (SqlConnection connexion = new SqlConnection(this.ChaineDeConnexion))
- {
- try
- {
- connexion.Open();
- using (SqlCommand command = connexion.CreateCommand())
- {
- command.CommandText = "SELECT Niveau, NbEleve FROM Bilinguisme WHERE CodeRne = @RNE AND Annee = @Annee";
- command.Parameters.AddWithValue("@RNE", codeRNE);
- command.Parameters.AddWithValue("@Annee", annee);
- using (SqlDataReader dr = command.ExecuteReader())
- {
- // List<int> lstNiveaux = new List<int>();
- while (dr.Read())
- {
- //lstNiveaux.Add(Convert.ToInt16(dr["Niveau"].ToString()));
- //Céline, on peut pas faire tenir "3ème" dans un int!
- // lstNiveaux.Add(Convert.ToInt16(dr["Niveau"].ToString().Substring(0,1)));
- // nombreTotalEleves += Convert.ToInt16(dr["NbEleve"].ToString());
- resultat.Add(new Bilinguisme(dr["Niveau"].ToString(), Convert.ToInt16(dr["NbEleve"].ToString())));
- //resultat = new Bilinguisme(lstNiveaux, nombreTotalEleves);
- }
- // resultat.Add(new Bilinguisme(dr["Niveau"].ToString(), Convert.ToInt16(dr["NbEleve"].ToString());
- }
- }
- }
- catch (Exception erreurInterne)
- {
- throw new Exception(" " + erreurInterne);
- }
- finally
- {
- if (connexion.State == ConnectionState.Open)
- connexion.Close();
- }
- }
- return resultat;
- }
- }
- }
|