EntrepotClasseDecouverte.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. { // modif le 14/04/2010 - modification pour l'année en cours => année civile
  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. 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 = :COD_ASTRE GROUP BY ZONE, ANNEE ORDER BY ZONE ";
  52. command.Parameters.AddWithValue(":ANNEE", annee);
  53. command.Parameters.AddWithValue(":COD_ASTRE", codeAstre);
  54. using (OracleDataReader ds = command.ExecuteReader())
  55. {
  56. while (ds.Read())
  57. {
  58. resultat.Add(new ClasseDecouverte(ds["annee"].ToString(), ds["ZONE"].ToString(), ds["NBELEVES"].ToString(), Convert.ToDouble(ds["SUBVENTION"].ToString())));
  59. }
  60. }
  61. }
  62. }
  63. catch
  64. {
  65. throw;
  66. }
  67. finally
  68. {
  69. if (connexion.State == ConnectionState.Open)
  70. connexion.Close();
  71. }
  72. }
  73. return resultat;
  74. }
  75. }
  76. }
  77. }