| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 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 EntrepotContact : EntrepotBase, IEntrepotContact
- {
- public IList<Contact> GetByCodeRNE(string codeRNE)
- {
- IList<Contact> resultat = new List<Contact>();
- using (SqlConnection connexion = new SqlConnection(this.ChaineDeConnexion))
- {
- try
- {
- connexion.Open();
- using (SqlCommand command = connexion.CreateCommand())
- {
- command.CommandText = "SELECT * FROM Contact WHERE CodeRNE = @RNE";
- command.Parameters.AddWithValue("@RNE", codeRNE);
- using (SqlDataReader dr = command.ExecuteReader())
- {
- while (dr.Read())
- {
- resultat.Add(new Contact(dr["Civilite"].ToString(), dr["Nom"].ToString(), dr["Prenom"].ToString(), dr["Fonction"].ToString(),dr["TypeContact"].ToString()));
- }
- }
- }
- }
- catch (Exception erreurInterne)
- {
- throw new Exception(" " + erreurInterne);
- }
- finally
- {
- if (connexion.State == ConnectionState.Open)
- connexion.Close();
- }
- }
- return resultat;
- }
- }
- }
|