EntrepotProjetPilote.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using CG67.FicheCollege.Domaine;
  7. using CG67.FicheCollege.Interface;
  8. namespace CG67.FicheCollege.Entrepot
  9. {
  10. public class EntrepotProjetPilote : EntrepotBase, IEntrepotProjetPilote
  11. {
  12. public IList<ProjetPilote> GetByCodeRNEAndAnnee(string codeRNE, int annee)
  13. {
  14. IList<ProjetPilote> resultat = new List<ProjetPilote>();
  15. using (SqlConnection connexion = new SqlConnection(this.ChaineDeConnexion))
  16. {
  17. try
  18. {
  19. connexion.Open();
  20. using (SqlCommand command = connexion.CreateCommand())
  21. {
  22. command.CommandText = "SELECT Libelle,participer, Initiateur from ProjetPilote INNER JOIN Etablissement_ProjetPilote ON (ProjetPilote.Id = Etablissement_ProjetPilote.IdProjetPilote) WHERE CodeRNE = @RNE AND Annee = @Annee";
  23. // command.CommandText = "SELECT Libelle from ProjetPilote INNER JOIN Etablissement_ProjetPilote ON (ProjetPilote.Id = Etablissement_ProjetPilote.IdProjetPilote) WHERE CodeRNE = @RNE AND Annee = @Annee";
  24. command.Parameters.AddWithValue("@RNE", codeRNE);
  25. command.Parameters.AddWithValue("@Annee", annee);
  26. using (SqlDataReader dr = command.ExecuteReader())
  27. {
  28. while (dr.Read())
  29. {
  30. resultat.Add(new ProjetPilote(dr["Libelle"].ToString(), dr.GetBoolean(dr.GetOrdinal("participer")), dr["Initiateur"].ToString()));
  31. }
  32. }
  33. }
  34. }
  35. catch (Exception erreurInterne)
  36. {
  37. throw new Exception(" " + erreurInterne);
  38. }
  39. finally
  40. {
  41. if (connexion.State == ConnectionState.Open)
  42. connexion.Close();
  43. }
  44. }
  45. return resultat;
  46. }
  47. }
  48. }