EntrepotATC.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 distinct NOM_USUEL, NOM_PRENOM, LIB_POSTE, LIB_CATAGT 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. if (FicheDePoste == "")
  49. FicheDePoste = "Agent polyvalent d'entretien et d'accueil";
  50. resultat.Add(new ATC(dr1["NOM_USUEL"].ToString(), dr1["NOM_PRENOM"].ToString(), FicheDePoste, dr1["LIB_CATAGT"].ToString()));
  51. }
  52. }
  53. }
  54. }
  55. catch
  56. {
  57. throw;
  58. }
  59. finally
  60. {
  61. if (connexion1.State == ConnectionState.Open)
  62. connexion1.Close();
  63. }
  64. }
  65. }
  66. catch
  67. {
  68. throw;
  69. }
  70. finally
  71. {
  72. if (connexion.State == ConnectionState.Open)
  73. connexion.Close();
  74. }
  75. }
  76. return resultat;
  77. }
  78. }
  79. }