EntrepotClasseDecouverte.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Data.OracleClient;
  7. using CG67.FicheCollege.Domaine;
  8. using CG67.FicheCollege.Interface;
  9. namespace CG67.FicheCollege.Entrepot
  10. {
  11. public class EntrepotClasseDecouverte : EntrepotBase, IEntrepotClasseDecouverte
  12. {
  13. public IList<ClasseDecouverte> GetByCodeRNEAndAnnee(string codeRNE, int annee)
  14. {
  15. IList<ClasseDecouverte> resultat = new List<ClasseDecouverte>();
  16. string codeAstre = "";
  17. using (SqlConnection connexion1 = new SqlConnection(this.ChaineDeConnexion))
  18. {
  19. try
  20. {
  21. connexion1.Open();
  22. using (SqlCommand command1 = connexion1.CreateCommand())
  23. {
  24. command1.CommandText = "Select NumeroTiersAstreGF from Etablissement WHERE CodeRNE = @RNE";
  25. command1.Parameters.AddWithValue("@RNE", codeRNE);
  26. using (SqlDataReader dr = command1.ExecuteReader())
  27. {
  28. if (dr.Read())
  29. codeAstre = dr["NumeroTiersAstreGF"].ToString();
  30. }
  31. }
  32. }
  33. catch
  34. {
  35. throw;
  36. }
  37. finally
  38. {
  39. if (connexion1.State == ConnectionState.Open)
  40. connexion1.Close();
  41. }
  42. using (OracleConnection connexion = new OracleConnection(this.ChaineDeConnexionSubvention))
  43. {
  44. try
  45. {
  46. connexion.Open();
  47. using (OracleCommand command = connexion.CreateCommand())
  48. {
  49. command.CommandText = "Select * from ASTRE.W67_SIC_FICHE_ELU WHERE CodeRNE = @RNE AND ANNEE = @ANNEE";
  50. command.Parameters.AddWithValue("@RNE", codeAstre);
  51. using (OracleDataReader dr = command.ExecuteReader())
  52. {
  53. while (dr.Read())
  54. {
  55. resultat.Add(new ClasseDecouverte(dr["annee"].ToString(), dr["ZONE"].ToString(), dr["NB_ELEVE"].ToString(), Convert.ToDouble(dr["MT_VOTE"].ToString())));
  56. }
  57. }
  58. }
  59. }
  60. catch
  61. {
  62. throw;
  63. }
  64. finally
  65. {
  66. if (connexion.State == ConnectionState.Open)
  67. connexion.Close();
  68. }
  69. }
  70. return resultat;
  71. }
  72. }
  73. }
  74. }