| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Data;
- using System.Data.SqlClient;
- using CG67.FicheCollege.Domaine;
- using CG67.FicheCollege.Interface;
- namespace CG67.FicheCollege.Entrepot
- {
- public class EntrepotATC : EntrepotBase, IEntrepotATC
- {
- public IList<ATC> GetByCodeRNE(string codeRNE)
- {
- IList<ATC> resultat = new List<ATC>();
- using (SqlConnection connexion = new SqlConnection(this.ChaineDeConnexion))
- {
- try
- {
- connexion.Open();
- using (SqlCommand command = connexion.CreateCommand())
- {
- //on récupère les ATC.
- command.CommandText = "Select ValeurETP, TypeContact, Nom, Prenom, Fonction, Fonction, Catégorie, Grade, Sum(NbJours) as NbJoursFormation from ATC INNER JOIN Contact ON (ATC.Id = Contact.Id) LEFT JOIN Formation_ATC ON (ATC.Id = Formation_ATC.IdATC) WHERE CodeRNE = @RNE GROUP BY ValeurETP, TypeContact, Nom, Prenom, Fonction, Fonction, Catégorie, Grade";
- command.Parameters.AddWithValue("@RNE", codeRNE);
- using (SqlDataReader dr = command.ExecuteReader())
- {
- while (dr.Read())
- {
- resultat.Add(new ATC(Convert.ToDouble(dr["ValeurETP"].ToString()), dr["Nom"].ToString(), dr["Prenom"].ToString(), dr["Fonction"].ToString(), dr["TypeContact"].ToString(), dr["Catégorie"].ToString(), dr["Grade"].ToString(), Convert.ToInt32(dr["NbJoursFormation"].ToString())));
- }
- }
- }
- }
- catch (Exception erreurInterne)
- {
- throw new Exception(" " + erreurInterne);
- }
- finally
- {
- if (connexion.State == ConnectionState.Open)
- connexion.Close();
- }
- }
- return resultat;
- }
- }
- }
|