EntrepotContratAide.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Data;
  3. using System.Data.SqlClient;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. using CG67.FicheCollege.Domaine;
  7. using CG67.FicheCollege.Interface;
  8. namespace CG67.FicheCollege.Entrepot
  9. {
  10. public class EntrepotContratAide : EntrepotBase, IEntrepotContratAide
  11. {
  12. public IList<ContratAide> GetByCodeRNE(string codeRNE)
  13. {
  14. IList<ContratAide> resultat = new List<ContratAide>();
  15. using (SqlConnection connexion = new SqlConnection(this.ChaineDeConnexion))
  16. {
  17. try
  18. {
  19. // int nbJourFormation;
  20. // double valeurETP;
  21. connexion.Open();
  22. using (SqlCommand command = connexion.CreateCommand())
  23. {
  24. //on récupère les ATC en contrat aidés.
  25. command.CommandText = "Select Nom, Prenom, TypeContrat, Quotite from ContratAide WHERE CodeRNE = @RNE ";
  26. command.Parameters.AddWithValue("@RNE", codeRNE);
  27. using (SqlDataReader dr = command.ExecuteReader())
  28. {
  29. while (dr.Read())
  30. {
  31. // nbJourFormation = dr["NbJoursFormation"] == DBNull.Value ? 0 : Convert.ToInt32(dr["NbJoursFormation"].ToString());
  32. // valeurETP = dr["ValeurETP"] == DBNull.Value ? 0 : Convert.ToDouble(dr["ValeurETP"].ToString());
  33. resultat.Add(new ContratAide(dr["Nom"].ToString(), dr["Prenom"].ToString(), dr["Quotite"].ToString(), dr["TypeContrat"].ToString()));
  34. }
  35. }
  36. }
  37. }
  38. catch
  39. {
  40. throw;
  41. }
  42. finally
  43. {
  44. if (connexion.State == ConnectionState.Open)
  45. connexion.Close();
  46. }
  47. }
  48. return resultat;
  49. }
  50. }
  51. }