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 = '" + codeAstre + "'";
  41. using (OracleDataReader dr1 = command1.ExecuteReader())
  42. {
  43. while (dr1.Read())
  44. {
  45. FicheDePoste = dr1["LIB_POSTE"].ToString();
  46. FicheDePoste = FicheDePoste.Replace("&", "et");
  47. 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()));
  48. }
  49. }
  50. }
  51. }
  52. catch
  53. {
  54. throw;
  55. }
  56. finally
  57. {
  58. if (connexion1.State == ConnectionState.Open)
  59. connexion1.Close();
  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. }