EntrepotClasseDecouverte.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. string An = annee.ToString();
  18. using (SqlConnection connexion1 = new SqlConnection(this.ChaineDeConnexion))
  19. {
  20. try
  21. {
  22. connexion1.Open();
  23. using (SqlCommand command1 = connexion1.CreateCommand())
  24. {
  25. command1.CommandText = "Select NumeroTiersAstreGF from Etablissement WHERE CodeRNE = @RNE";
  26. command1.Parameters.AddWithValue("@RNE", codeRNE);
  27. using (SqlDataReader dr = command1.ExecuteReader())
  28. {
  29. if (dr.Read())
  30. codeAstre = dr["NumeroTiersAstreGF"].ToString();
  31. }
  32. }
  33. }
  34. catch
  35. {
  36. throw;
  37. }
  38. finally
  39. {
  40. if (connexion1.State == ConnectionState.Open)
  41. connexion1.Close();
  42. }
  43. using (OracleConnection connexion = new OracleConnection(this.ChaineDeConnexionSubvention))
  44. {
  45. try
  46. {
  47. connexion.Open();
  48. using (OracleCommand command = connexion.CreateCommand())
  49. {
  50. command.CommandText = "Select ANNEE, ZONE, Sum(TO_NUMBER(NB_ELEVE)) as NBELEVES, Sum(MT_VOTE) AS SUBVENTION from ASTRE.W67_SIC_FICHE_ELU WHERE ANNEE = '" + annee + "' AND COD_TIERS = '" + codeAstre + "' GROUP BY ZONE, ANNEE ORDER BY ZONE ";
  51. using (OracleDataReader ds = command.ExecuteReader())
  52. {
  53. while (ds.Read())
  54. {
  55. resultat.Add(new ClasseDecouverte(ds["annee"].ToString(), ds["ZONE"].ToString(), ds["NBELEVES"].ToString(), Convert.ToDouble(ds["SUBVENTION"].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. }