Celine.meneu 16 rokov pred
rodič
commit
5f950f764a

+ 7 - 4
CG67.FicheCollege.root/CG67.FicheCollege/Core/CG67.FicheCollege.Entrepot/EntrepotContact.cs

@@ -28,13 +28,15 @@ namespace CG67.FicheCollege.Entrepot
                     connexion.Open();
                     using (SqlCommand command = connexion.CreateCommand())
                     {
-                        command.CommandText = "SELECT * FROM Contact WHERE CodeRNE = @RNE";
+
+//                        command.CommandText = "SELECT * FROM Contact WHERE CodeRNE = @RNE";
+                        command.CommandText = "SELECT * FROM Contact INNER JOIN  Fonction ON Contact.IdFonction = Fonction.Id  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()));
+                                resultat.Add(new Contact(dr["Civilite"].ToString(), dr["Nom"].ToString(), dr["Prenom"].ToString(), dr["Libelle"].ToString(),dr["TypeContact"].ToString()));
                             }
                         }
                     }
@@ -62,13 +64,14 @@ namespace CG67.FicheCollege.Entrepot
                     connexion.Open();
                     using (SqlCommand command = connexion.CreateCommand())
                     {
-                        command.CommandText = "SELECT * FROM Contact WHERE id = (select idConseillerGeneral from etablissement where codeRNE=@RNE)";
+                        //command.CommandText = "SELECT * FROM Contact WHERE id = (select idConseillerGeneral from etablissement where codeRNE=@RNE)";
+                        command.CommandText = "SELECT * FROM Contact, Fonction  WHERE (IdFonction = Fonction.Id) and Contact.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());
+                                resultat = new Contact(dr["Civilite"].ToString(), dr["Nom"].ToString(), dr["Prenom"].ToString(), dr["Libelle"].ToString(), dr["TypeContact"].ToString());
                             }
                         }
                     }

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

@@ -21,7 +21,7 @@ namespace CG67.FicheCollege.Entrepot
                     {
                         //command.CommandText = "Select Nom, Prenom, Ville FROM Etablissement INNER JOIN Mcg ON (Etablissement.IdMCG = Mcg.Id) INNER JOIN Contact ON (Mcg.IdContact = Contact.Id) WHERE Etablissement.CodeRNE = @RNE AND Fonction = 'Directeur MCG'";
                         //command.CommandText = "Select Nom, Prenom, Ville FROM Etablissement INNER JOIN Mcg ON (Etablissement.IdMCG = Mcg.Id) INNER JOIN Contact ON (Mcg.IdContact = Contact.Id) WHERE Etablissement.CodeRNE = @RNE AND Fonction = 'Directeur MCG'";
-                        command.CommandText = "SELECT Etablissement.CodeRNE, Ville, Civilite, Nom, Prenom FROM Etablissement INNER JOIN (Mcg INNER JOIN Contact ON Mcg.IdContact = Contact.Id) ON Etablissement.IdMCG = Mcg.Id WHERE Etablissement.CodeRNE = @RNE and Contact.Fonction='Directeur MCG';";
+                        command.CommandText = "SELECT Etablissement.CodeRNE, Ville, Civilite, Nom, Prenom FROM Etablissement INNER JOIN (Mcg INNER JOIN Contact ON Mcg.IdContact = Contact.Id) ON Etablissement.IdMCG = Mcg.Id INNER JOIN Fonction ON (Contact.IdFonction = Fonction.Id) WHERE Etablissement.CodeRNE = @RNE and Fonction.Libelle='Directeur MCG';";
                         
 
                         command.Parameters.AddWithValue("@RNE", codeRNE);