EntrepotATC.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. // command1.CommandText = "Select * from V_ATC WHERE COD_STRUC = '38401024'"
  42. //command1.Parameters.AddWithValue("@C_STRUC", codeAstre);
  43. using (OracleDataReader dr1 = command1.ExecuteReader())
  44. {
  45. while (dr1.Read())
  46. {
  47. FicheDePoste = dr1["LIB_POSTE"].ToString();
  48. FicheDePoste = FicheDePoste.Replace("&", "et");
  49. 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()));
  50. }
  51. }
  52. }
  53. }
  54. catch
  55. {
  56. throw;
  57. }
  58. finally
  59. {
  60. if (connexion1.State == ConnectionState.Open)
  61. connexion1.Close();
  62. }
  63. }
  64. }
  65. catch
  66. {
  67. throw;
  68. }
  69. finally
  70. {
  71. if (connexion.State == ConnectionState.Open)
  72. connexion.Close();
  73. }
  74. }
  75. return resultat;
  76. }
  77. }
  78. }