Dominique.freyd 16 年之前
父節點
當前提交
46b700661b

+ 44 - 2
CG67.FicheCollege.root/CG67.FicheCollege/Core/CG67.FicheCollege.Entrepot/EntrepotContact.cs

@@ -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;
+            }
+        }
     }
 }

+ 1 - 1
CG67.FicheCollege.root/CG67.FicheCollege/Core/CG67.FicheCollege.Entrepot/EntrepotEtablissement.cs

@@ -75,7 +75,7 @@ namespace CG67.FicheCollege.Entrepot
                                     EntrepotFactory.GetEntrepotATC().GetByCodeRNE,
                                     EntrepotFactory.GetEntrepotBilinguisme().GetByCodeRNEAndAnnee,
                                     EntrepotFactory.GetEntrepotCommentaires().GetByCodeRNEAndAnnee,
-                                    EntrepotFactory.GetEntrepotContact().GetByCodeRNE,
+                                    EntrepotFactory.GetEntrepotContact().GetAllContactByCodeRNE,
                                     EntrepotFactory.GetEntrepotDotation().GetByCodeRNEAndAnnee,
                                     EntrepotFactory.GetEntrepotEquipement().GetByCodeRNEAndAnnee,
                                     EntrepotFactory.GetEntrepotInvestissement().GetByCodeRNEAndAnnee,