EntrepotATC.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 EntrepotATC : EntrepotBase, IEntrepotATC
  12. {
  13. public IList<ATC> GetByCodeRNE(string codeRNE)
  14. {
  15. IList<ATC> resultat = new List<ATC>();
  16. using (SqlConnection connexion = new SqlConnection(this.ChaineDeConnexion))
  17. {
  18. try
  19. {
  20. string FicheDePoste = "";
  21. string codeAstre = "";
  22. connexion.Open();
  23. using (SqlCommand command = connexion.CreateCommand())
  24. {
  25. command.CommandText = "Select CodeAstreRH from Etablissement WHERE CodeRNE = @RNE";
  26. command.Parameters.AddWithValue("@RNE", codeRNE);
  27. using (SqlDataReader dr = command.ExecuteReader())
  28. {
  29. if (dr.Read())
  30. codeAstre = dr["CodeAstreRH"].ToString();
  31. }
  32. }
  33. using (OracleConnection connexion1 = new OracleConnection(this.ChaineDeConnexionRH))
  34. {
  35. try
  36. {
  37. connexion1.Open();
  38. using (OracleCommand command1 = connexion1.CreateCommand())
  39. {
  40. command1.CommandText = "Select * from V_ATC WHERE COD_STRUC = :CODE_STR";
  41. command1.Parameters.AddWithValue(":CODE_STR", codeAstre);
  42. using (OracleDataReader dr1 = command1.ExecuteReader())
  43. {
  44. while (dr1.Read())
  45. {
  46. FicheDePoste = dr1["LIB_POSTE"].ToString();
  47. FicheDePoste = FicheDePoste.Replace("&", "et");
  48. resultat.Add(new ATC(dr1["TAU_LIB"].ToString(), dr1["NOM_USUEL"].ToString(), dr1["NOM_PRENOM"].ToString(), FicheDePoste, dr1["LIB_GRADE"].ToString(), dr1["LIB_CATAGT"].ToString()));
  49. }
  50. }
  51. }
  52. }
  53. catch
  54. {
  55. throw;
  56. }
  57. finally
  58. {
  59. if (connexion1.State == ConnectionState.Open)
  60. connexion1.Close();
  61. }
  62. }
  63. }
  64. catch
  65. {
  66. throw;
  67. }
  68. finally
  69. {
  70. if (connexion.State == ConnectionState.Open)
  71. connexion.Close();
  72. }
  73. }
  74. return resultat;
  75. }
  76. }
  77. }