EntrepotClasseDecouverte.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 EntrepotClasseDecouverte : EntrepotBase, IEntrepotClasseDecouverte
  11. {
  12. public ClasseDecouverte GetByCodeRNEAndAnnee(string codeRNE, int annee)
  13. {
  14. ClasseDecouverte resultat = new ClasseDecouverte();
  15. string codeAstre = "";
  16. using (SqlConnection connexion1 = new SqlConnection(this.ChaineDeConnexion))
  17. {
  18. try
  19. {
  20. connexion1.Open();
  21. using (SqlCommand command = connexion1.CreateCommand())
  22. {
  23. command.CommandText = "Select NumeroTiersAstreGF from Etablissement WHERE CodeRNE = @RNE";
  24. command.Parameters.AddWithValue("@RNE", codeRNE);
  25. using (SqlDataReader dr = command.ExecuteReader())
  26. {
  27. if (dr.Read())
  28. codeAstre = dr["NumeroTiersAstreGF"].ToString();
  29. }
  30. }
  31. }
  32. catch
  33. {
  34. throw;
  35. }
  36. finally
  37. {
  38. if (connexion1.State == ConnectionState.Open)
  39. connexion1.Close();
  40. }
  41. using (SqlConnection connexion = new SqlConnection(this.ChaineDeConnexionSubvention))
  42. {
  43. try
  44. {
  45. connexion.Open();
  46. using (SqlCommand command = connexion.CreateCommand())
  47. {
  48. command.CommandText = "Select * from ASTRE_W67_SIC_FICHE_ELU WHERE CodeRNE = @RNE";
  49. command.Parameters.AddWithValue("@RNE", codeAstre);
  50. using (SqlDataReader dr = command.ExecuteReader())
  51. {
  52. while (dr.Read())
  53. {
  54. resultat= new ClasseDecouverte(dr["annee"].ToString(), dr["ZONE"].ToString(), dr["NB_ELEVE"].ToString(), Convert.ToDouble(dr["MT_VOTE"].ToString()));
  55. }
  56. }
  57. }
  58. }
  59. catch
  60. {
  61. throw;
  62. }
  63. finally
  64. {
  65. if (connexion.State == ConnectionState.Open)
  66. connexion.Close();
  67. }
  68. }
  69. return resultat;
  70. }
  71. }
  72. #region IEntrepotClasseDecouverte Membres
  73. ClasseDecouverte IEntrepotClasseDecouverte.GetByCodeRNEAndAnnee(string codeRNE, int annee)
  74. {
  75. throw new Exception("The method or operation is not implemented.");
  76. }
  77. #endregion
  78. }
  79. }