EntrepotInvestissementDCE.cs 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 EntrepotInvestissementDCE : EntrepotBase, IEntrepotInvestissementDCE
  12. {
  13. public IList<InvestissementDCE> GetByCodeRNEAndAnnee(string codeRNE, int annee)
  14. {
  15. IList<InvestissementDCE> resultat = new List<InvestissementDCE>();
  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 NumeroAnaAstreGF 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["NumeroAnaAstreGF"].ToString();
  31. }
  32. }
  33. }
  34. catch
  35. {
  36. throw;
  37. }
  38. finally
  39. {
  40. if (connexion1.State == ConnectionState.Open)
  41. connexion1.Close();
  42. }
  43. }
  44. // using (SqlConnection connexion = new SqlConnection(this.ChaineDeConnexion))
  45. using (OracleConnection connexion = new OracleConnection(this.ChaineDeConnexionAstreGF))
  46. {
  47. try
  48. {
  49. connexion.Open();
  50. // using (SqlCommand command = connexion.CreateCommand())
  51. using (OracleCommand command = connexion.CreateCommand())
  52. {
  53. // command.CommandText = "Select Annee, Libelle, Montant from Investissement INNER JOIN TypeDotation ON Investissement.IdDotation = TypeDotation.id WHERE CodeRNE = @RNE AND Annee = @Annee ORDER BY Libelle ASC";
  54. // command.Parameters.AddWithValue("@RNE", codeRNE);
  55. // command.Parameters.AddWithValue("@Annee", annee);
  56. // using (SqlDataReader dr = command.ExecuteReader())
  57. // command.CommandText = "Select NCOD_EXEBUD, LIB_C_COUT, MNT_VENT from SO.W67_ANA_MDT_VUE8_COLLEGE3800 INNER JOIN Etablissement ON Etablissement.NumeroAnaAstreGF = SO_W67_ANA_MDT_VUE8_COLLEGE3800.LIB_SIGLE WHERE CodeRNE = :RNE AND NCOD_EXEBUD = :Annee ORDER BY LIB_C_COUT ASC";
  58. command.CommandText = "Select NCOD_EXEBUD, LIB_C_COUT, Sum(TO_NUMBER(Round(MNT_VENT))) As SUBVENTION from SO.W67_ANA_MDT_VUE8_COLLEGE3800 WHERE SO.W67_ANA_MDT_VUE8_COLLEGE3800.LIB_SIGLE= :COD_ASTRE AND NCOD_EXEBUD >= :ANNEE GROUP BY NCOD_EXEBUD, LIB_C_COUT ORDER BY NCOD_EXEBUD, LIB_C_COUT ASC";
  59. command.Parameters.AddWithValue(":ANNEE", annee);
  60. command.Parameters.AddWithValue(":COD_ASTRE", codeAstre);
  61. // command.Parameters.AddWithValue(":RNE", codeRNE);
  62. // command.Parameters.AddWithValue(":Annee", annee);
  63. using (OracleDataReader ds = command.ExecuteReader())
  64. {
  65. while (ds.Read())
  66. {
  67. // resultat.Add(new InvestissementDCE(Convert.ToInt16(dr["Annee"].ToString()), dr["Libelle"].ToString(), Convert.ToDouble(dr["Montant"].ToString())));
  68. resultat.Add(new InvestissementDCE(Convert.ToInt16(ds["NCOD_EXEBUD"].ToString()), ds["LIB_C_COUT"].ToString(), Convert.ToDouble(ds["SUBVENTION"].ToString())));
  69. }
  70. }
  71. }
  72. }
  73. catch
  74. {
  75. throw;
  76. }
  77. finally
  78. {
  79. if (connexion.State == ConnectionState.Open)
  80. connexion.Close();
  81. }
  82. }
  83. return resultat;
  84. }
  85. }
  86. }