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