|
|
@@ -10,6 +10,14 @@ namespace CG67.FicheCollege.Entrepot
|
|
|
{
|
|
|
public class EntrepotContact : EntrepotBase, IEntrepotContact
|
|
|
{
|
|
|
+ public IList<Contact> GetAllContactByCodeRNE(string codeRNE)
|
|
|
+ {
|
|
|
+ IList<Contact> resultat = GetByCodeRNE(codeRNE);
|
|
|
+ Contact cg = GetConseillerGeneralByRNE(codeRNE);
|
|
|
+ if (cg != null)
|
|
|
+ resultat.Add(cg);
|
|
|
+ return resultat;
|
|
|
+ }
|
|
|
public IList<Contact> GetByCodeRNE(string codeRNE)
|
|
|
{
|
|
|
IList<Contact> resultat = new List<Contact>();
|
|
|
@@ -31,9 +39,9 @@ namespace CG67.FicheCollege.Entrepot
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- catch (Exception erreurInterne)
|
|
|
+ catch
|
|
|
{
|
|
|
- throw new Exception(" " + erreurInterne);
|
|
|
+ throw;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
@@ -43,5 +51,39 @@ namespace CG67.FicheCollege.Entrepot
|
|
|
}
|
|
|
return resultat;
|
|
|
}
|
|
|
+
|
|
|
+ public Contact GetConseillerGeneralByRNE(string codeRNE)
|
|
|
+ {
|
|
|
+ Contact resultat = null;
|
|
|
+ using (SqlConnection connexion = new SqlConnection(this.ChaineDeConnexion))
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ connexion.Open();
|
|
|
+ using (SqlCommand command = connexion.CreateCommand())
|
|
|
+ {
|
|
|
+ command.CommandText = "SELECT * FROM Contact WHERE id = (select idConseillerGeneral from etablissement where codeRNE=@RNE)";
|
|
|
+ command.Parameters.AddWithValue("@RNE", codeRNE);
|
|
|
+ using (SqlDataReader dr = command.ExecuteReader())
|
|
|
+ {
|
|
|
+ if (dr.Read())
|
|
|
+ {
|
|
|
+ resultat = new Contact(dr["Civilite"].ToString(), dr["Nom"].ToString(), dr["Prenom"].ToString(), dr["Fonction"].ToString(), dr["TypeContact"].ToString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ if (connexion.State == ConnectionState.Open)
|
|
|
+ connexion.Close();
|
|
|
+ }
|
|
|
+ return resultat;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|