コード例 #1
0
        public int InsertModele(Qualite qualite, MouvementSynchronisation sens)
        {
            string sql = @"INSERT INTO Qualite (Nom,MiseAJour,Suppression,Creation)
                        VALUES(@1,@2,@3,@4)";
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@1", qualite.Nom },
                { "@2", DateTimeDbAdaptor.FormatDateTime(qualite.MiseAJour, Bdd) },
                { "@3", DateTimeDbAdaptor.FormatDateTime(qualite.Suppression, Bdd) },
                { "@4", DateTimeDbAdaptor.FormatDateTime(qualite.Creation, Bdd) }
            };
            int result = 0;

            try
            {
                result = Insert(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
                //Logger.WriteEx(e);
            }

            return(result);
        }
コード例 #2
0
        public int UpdateModele(Qualite qualiteLocal, Qualite qualiteDistant, MouvementSynchronisation sens)
        {
            //recopie des données du Qualite distant dans le Qualite local
            qualiteLocal.Copy(qualiteDistant);

            string sql = @"
                        UPDATE Qualite
                        SET Nom=@1,MiseAJour=@2
                        WHERE Id=@3
                      ";
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@1", qualiteLocal.Nom },
                { "@2", DateTimeDbAdaptor.FormatDateTime(qualiteLocal.MiseAJour, Bdd) },
                { "@3", qualiteLocal.Id }
            };
            int result = 0;

            try
            {
                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
                //Logger.WriteEx(e);
            }

            return(result);
        }
コード例 #3
0
        public int InsertModele(TypeModulePlacable modele, MouvementSynchronisation sens)
        {
            int result = 0;

            try
            {
                string sql = @"INSERT INTO TypeModulePlacable (Nom,Icone,MiseAJour,Creation,Suppression)
                        VALUES(@1,@2,@3,@4,@5)";
                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "@1", modele.Nom },
                    { "@2", modele.Icone },
                    { "@3", DateTimeDbAdaptor.FormatDateTime(modele.MiseAJour, Bdd) },
                    { "@4", DateTimeDbAdaptor.FormatDateTime(modele.Creation, Bdd) },
                    { "@5", DateTimeDbAdaptor.FormatDateTime(modele.Suppression, Bdd) },
                };

                result = Insert(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #4
0
ファイル: CommercialDAL.cs プロジェクト: Lowxorx/HouseMadera
        /// <summary>
        /// Methode implémentée de l'interface ICommercialDAL permettant l'insertion d'un Commercial en base
        /// </summary>
        /// <param name="comercial">Le modèle à insérer</param>
        /// <returns>Le nombre de lignes affectées</returns>
        public int InsertModele(Commercial commercial,MouvementSynchronisation sens)
        {
            string sql = @"INSERT INTO Commercial (Nom,Prenom,Login,Password,MiseAJour,Suppression,Creation)
                        VALUES(@1,@2,@3,@4,@5,@6,@7)";
            Dictionary<string, object> parameters = new Dictionary<string, object>() {
                {"@1",commercial.Nom },
                {"@2",commercial.Prenom },
                {"@3",commercial.Login },
                {"@4",commercial.Password },
                {"@5", DateTimeDbAdaptor.FormatDateTime( commercial.MiseAJour,Bdd) },
                {"@6", DateTimeDbAdaptor.FormatDateTime( commercial.Suppression,Bdd) },
                {"@7", DateTimeDbAdaptor.FormatDateTime( commercial.Creation,Bdd) }
            };
            int result = 0;
            try
            {
                result = Insert(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
                //Logger.WriteEx(e);
            }

            return result;
        }
コード例 #5
0
ファイル: FinitionDAL.cs プロジェクト: Lowxorx/HouseMadera
        public int UpdateModele(Finition finitionLocal, Finition finitionDistant, MouvementSynchronisation sens)
        {
            //Vérification des clés étrangères
            if (finitionDistant.TypeFinition == null)
            {
                throw new Exception("Tentative de mise a jour dans la table Isolant avec la clé étrangère TypeIsolant nulle");
            }

            int typeFinitionId = 0;

            if (sens == MouvementSynchronisation.Sortant)
            {
                Synchronisation <TypeFinitionDAL, TypeFinition> .CorrespondanceModeleId.TryGetValue(finitionDistant.TypeFinition.Id, out typeFinitionId);
            }
            else
            {
                typeFinitionId = Synchronisation <TypeFinitionDAL, TypeFinition> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == finitionDistant.TypeFinition.Id).Key;
            }


            ////Valeurs des clés étrangères est modifié avant update via la table de correspondance
            //if (!Synchronisation<TypeFinitionDAL, TypeFinition>.CorrespondanceModeleId.TryGetValue(finitionDistant.TypeFinition.Id, out int typeFinitionId))
            //{
            //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
            //    typeFinitionId = Synchronisation<TypeFinitionDAL, TypeFinition>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == finitionDistant.TypeFinition.Id).Key;
            //}

            //recopie des données de la Finition distante dans la Finition locale
            finitionLocal.Copy(finitionDistant);
            string sql = @"
                        UPDATE Finition
                        SET Nom=@1,TypeFinition_Id=@2,MiseAJour=@3
                        WHERE Id=@4
                      ";

            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@1", finitionLocal.Nom },
                { "@2", typeFinitionId },
                { "@3", DateTimeDbAdaptor.FormatDateTime(finitionLocal.MiseAJour, Bdd) },
                { "@4", finitionLocal.Id },
            };
            int result = 0;

            try
            {
                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #6
0
ファイル: DevisDAL.cs プロジェクト: Lowxorx/HouseMadera
        public int UpdateModele(Devis devisLocal, Devis devisDistant, MouvementSynchronisation sens)
        {
            //Vérification des clés étrangères
            if (devisDistant.StatutDevis == null)
            {
                throw new Exception("Tentative de mise a jour dans la table Devis avec la clé étrangère StatutDevis nulle");
            }
            int statutDevisId = 0;

            if (sens == MouvementSynchronisation.Sortant)
            {
                Synchronisation <StatutDevisDAL, StatutDevis> .CorrespondanceModeleId.TryGetValue(devisDistant.StatutDevis.Id, out statutDevisId);
            }
            else
            {
                statutDevisId = Synchronisation <StatutDevisDAL, StatutDevis> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == devisDistant.StatutDevis.Id).Key;
            }

            //recopie des données du Devis distant dans le Devis local
            if (devisDistant != null)
            {
                devisLocal.Copy(devisDistant);
            }

            string sql = @"
                        UPDATE Devis
                        SET Nom=@1,PrixHT=@2,PrixTTC=@3,StatutDevis_Id=@4,pdf=@5,MiseAJour=@6,DateCreation=@8
                        WHERE Id=@7
                      ";
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@1", devisLocal.Nom },
                { "@2", devisLocal.PrixHT },
                { "@3", devisLocal.PrixTTC },
                { "@4", statutDevisId },
                { "@5", devisLocal.Pdf },
                { "@6", devisLocal.DateCreation },
                //{"@6", DateTimeDbAdaptor.FormatDateTime( devisLocal.MiseAJour,Bdd)},
                { "@7", devisLocal.Id },
                { "@8", DateTimeDbAdaptor.FormatDateTime(devisLocal.DateCreation, Bdd) }
            };
            int result = 0;

            try
            {
                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #7
0
ファイル: SlotDAL.cs プロジェクト: Lowxorx/HouseMadera
        public int InsertModele(Slot modele, MouvementSynchronisation sens)
        {
            int result = 0;

            try
            {
                //Vérification des clés étrangères
                if (modele.TypeSlot == null)
                {
                    throw new Exception("Tentative d'insertion dans la base Finition avec la clé étrangère TypeFinition nulle");
                }

                int typeSlotId = 0;

                if (sens == MouvementSynchronisation.Sortant)
                {
                    Synchronisation <TypeSlotDAL, TypeSlot> .CorrespondanceModeleId.TryGetValue(modele.TypeSlot.Id, out typeSlotId);
                }
                else
                {
                    typeSlotId = Synchronisation <TypeSlotDAL, TypeSlot> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.TypeSlot.Id).Key;
                }


                ////Valeurs des clés étrangères est modifié avant insertion via la table de correspondance
                //if (!Synchronisation<TypeSlotDAL, TypeSlot>.CorrespondanceModeleId.TryGetValue(modele.TypeSlot.Id, out int typeSlotId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    typeSlotId = Synchronisation<TypeSlotDAL, TypeSlot>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.TypeSlot.Id).Key;
                //}

                string sql = @"INSERT INTO Slot (Nom,TypeSlot_Id,MiseAJour,Suppression,Creation)
                        VALUES(@1,@2,@3,@4,@5)";
                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "@1", modele.Nom },
                    { "@2", typeSlotId },
                    { "@3", DateTimeDbAdaptor.FormatDateTime(modele.MiseAJour, Bdd) },
                    { "@4", DateTimeDbAdaptor.FormatDateTime(modele.Suppression, Bdd) },
                    { "@5", DateTimeDbAdaptor.FormatDateTime(modele.Creation, Bdd) }
                };

                result = Insert(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);

                //Logger.WriteEx(e);
            }

            return(result);
        }
コード例 #8
0
        public int UpdateModele(Projet projetLocal, Projet projetDistant, MouvementSynchronisation sens)
        {
            int result = 0;

            try
            {
                int clientId     = 0;
                int commercialId = 0;
                if (sens == MouvementSynchronisation.Sortant)
                {
                    Synchronisation <ClientDAL, Client> .CorrespondanceModeleId.TryGetValue(projetDistant.Client.Id, out clientId);

                    Synchronisation <CommercialDAL, Commercial> .CorrespondanceModeleId.TryGetValue(projetDistant.Commercial.Id, out commercialId);
                }
                else
                {
                    clientId = Synchronisation <ClientDAL, Client> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == projetDistant.Client.Id).Key;

                    commercialId = Synchronisation <CommercialDAL, Commercial> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == projetDistant.Commercial.Id).Key;
                }


                //recopie des données du Projet distant dans le Projet local
                projetLocal.Copy(projetDistant);

                string sql = @"
                        UPDATE Projet
                        SET Nom=@1,Reference=@2,Client_Id=@3,Commercial_Id=@4,MiseAJour=@5
                        WHERE Id=@6
                      ";

                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "@1", projetLocal.Nom },
                    { "@2", projetLocal.Reference },
                    { "@3", projetLocal.Client.Id },
                    { "@4", projetLocal.Commercial.Id },
                    { "@5", DateTimeDbAdaptor.FormatDateTime(projetLocal.MiseAJour, Bdd) },
                    { "@6", projetLocal.Id },
                };

                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #9
0
        /// <summary>
        /// Methode implémentée de l'interface IClientDAL. Elle effectue une copie des valeurs du deuxième paramètre dans le premier
        /// et met à jour le client en base.
        /// </summary>
        /// <param name="clientLocal">Représente l'objet issue de la base locale </param>
        /// <param name="clientDistant">Représente l'objet issue de la base distante</param>
        /// <returns>Le nombre de lignes affectées</returns>
        public int UpdateModele(Client clientLocal, Client clientDistant, MouvementSynchronisation sens)
        {
            //recopie des données du client distant dans le client local
            if (clientDistant != null)
            {
                clientLocal.Copy(clientDistant);
            }

            //Vérifie la cohérence des données à mettre à jour
            if (!isDataCorrect(clientLocal))
            {
                throw new Exception(erreur);
            }

            string sql = @"
                        UPDATE Client
                        SET Nom=@1,Prenom=@2,Adresse1=@3,Adresse2=@4,Adresse3=@5,CodePostal=@6,Ville=@7,Email=@8,Telephone=@9,Mobile=@10,StatutClient_Id=@11,MiseAJour=@12
                        WHERE Id=@13
                      ";
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@1", clientLocal.Nom },
                { "@2", clientLocal.Prenom },
                { "@3", clientLocal.Adresse1 },
                { "@4", string.IsNullOrEmpty(clientLocal.Adresse2) ? NON_RENSEIGNE : clientLocal.Adresse2 },
                { "@5", string.IsNullOrEmpty(clientLocal.Adresse3) ? NON_RENSEIGNE : clientLocal.Adresse3 },
                { "@6", clientLocal.CodePostal },
                { "@7", clientLocal.Ville },
                { "@8", clientLocal.Email },
                { "@9", string.IsNullOrEmpty(clientLocal.Telephone) ? NON_RENSEIGNE : clientLocal.Telephone },
                { "@10", string.IsNullOrEmpty(clientLocal.Mobile) ? NON_RENSEIGNE : clientLocal.Mobile },
                { "@11", clientLocal.StatutClient },
                { "@12", DateTimeDbAdaptor.FormatDateTime(clientLocal.MiseAJour, Bdd) },
                { "@13", clientLocal.Id }
            };
            int result = 0;

            try
            {
                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #10
0
ファイル: DevisDAL.cs プロジェクト: Lowxorx/HouseMadera
        public int InsertModele(Devis devis, MouvementSynchronisation sens)
        {
            //Vérification des clés étrangères
            if (devis.StatutDevis == null)
            {
                throw new Exception("Tentative de mise a jour dans la table Devis avec la clé étrangère StatutDevis nulle");
            }
            int statutDevisId = 0;

            if (sens == MouvementSynchronisation.Sortant)
            {
                Synchronisation <StatutDevisDAL, StatutDevis> .CorrespondanceModeleId.TryGetValue(devis.StatutDevis.Id, out statutDevisId);
            }
            else
            {
                statutDevisId = Synchronisation <StatutDevisDAL, StatutDevis> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == devis.StatutDevis.Id).Key;
            }

            string sql = @"INSERT INTO Devis (Nom,PrixHT,PrixTTC,StatutDevis_Id,pdf,MiseAJour,Suppression,Creation,DateCreation)
                        VALUES(@1,@2,@3,@4,@5,@6,@7,@8,@9)";
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@1", devis.Nom },
                { "@2", devis.PrixHT },
                { "@3", devis.PrixTTC },
                { "@4", statutDevisId },
                { "@5", devis.Pdf },
                { "@6", DateTimeDbAdaptor.FormatDateTime(devis.MiseAJour, Bdd) },
                { "@7", DateTimeDbAdaptor.FormatDateTime(devis.Suppression, Bdd) },
                { "@8", DateTimeDbAdaptor.FormatDateTime(devis.Creation, Bdd) },
                { "@9", DateTimeDbAdaptor.FormatDateTime(devis.DateCreation, Bdd) },
            };
            int result = 0;

            try
            {
                result = Insert(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #11
0
        /// <summary>
        /// Methode implémentée de l'interface IClientDAL permettant l'insertion d'un Client en base
        /// </summary>
        /// <param name="client">Le modèle à insérer</param>
        /// <returns>Le nombre de lignes affectées</returns>
        public int InsertModele(Client client, MouvementSynchronisation sens)
        {
            if (!isDataCorrect(client))
            {
                throw new ValidationClientException(erreur);
            }
            if (IsClientExist(client))
            {
                throw new ClientException();
            }

            string sql = @"INSERT INTO Client (Nom,Prenom,Adresse1,Adresse2,Adresse3,CodePostal,Ville,Email,Telephone,Mobile,StatutClient_Id,MiseAJour,Suppression,Creation)
                        VALUES(@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11,@12,@13,@14)";
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@1", client.Nom },
                { "@2", client.Prenom },
                { "@3", client.Adresse1 },
                { "@4", client.Adresse2 },
                { "@5", client.Adresse3 },
                { "@6", client.CodePostal },
                { "@7", client.Ville },
                { "@8", client.Email },
                { "@9", client.Telephone },
                { "@10", client.Mobile },
                { "@11", client.StatutClient },
                { "@12", DateTimeDbAdaptor.FormatDateTime(client.MiseAJour, Bdd) },
                { "@13", DateTimeDbAdaptor.FormatDateTime(client.Suppression, Bdd) },
                { "@14", DateTimeDbAdaptor.FormatDateTime(client.Creation, Bdd) }
            };
            int result = 0;

            try
            {
                result = Insert(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #12
0
        public int InsertModele(Projet projet, MouvementSynchronisation sens)
        {
            int result = 0;

            try
            {
                //Vérification des clés étrangères
                if (projet.Client == null)
                {
                    throw new Exception("Tentative d'insertion dans la base Projet avec la clé étrangère Client nulle");
                }
                if (projet.Commercial == null)
                {
                    throw new Exception("Tentative d'insertion  dans la base Projet avec la clé étrangère Commercial nulle");
                }

                int clientId     = 0;
                int commercialId = 0;
                if (sens == MouvementSynchronisation.Sortant)
                {
                    Synchronisation <ClientDAL, Client> .CorrespondanceModeleId.TryGetValue(projet.Client.Id, out clientId);

                    Synchronisation <CommercialDAL, Commercial> .CorrespondanceModeleId.TryGetValue(projet.Commercial.Id, out commercialId);
                }
                else
                {
                    clientId = Synchronisation <ClientDAL, Client> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == projet.Client.Id).Key;

                    commercialId = Synchronisation <CommercialDAL, Commercial> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == projet.Commercial.Id).Key;
                }

                ////Valeurs des clés étrangères est modifié avant insertion via la table de correspondance
                //if (!Synchronisation<ClientDAL, Client>.CorrespondanceModeleId.TryGetValue(projet.Client.Id, out int clientId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    clientId = Synchronisation<ClientDAL, Client>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == projet.Client.Id).Key;

                //}

                //if (!Synchronisation<CommercialDAL, Commercial>.CorrespondanceModeleId.TryGetValue(projet.Commercial.Id, out int commercialId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    commercialId = Synchronisation<CommercialDAL, Commercial>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == projet.Commercial.Id).Key;
                //}

                string sql = @"INSERT INTO Projet (Nom,Reference,Client_Id,Commercial_Id,MiseAJour,Suppression,Creation)
                        VALUES(@1,@2,@3,@4,@5,@6,@7)";
                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "@1", projet.Nom },
                    { "@2", projet.Reference },
                    { "@3", clientId },
                    { "@4", commercialId },
                    { "@5", DateTimeDbAdaptor.FormatDateTime(projet.MiseAJour, Bdd) },
                    { "@6", DateTimeDbAdaptor.FormatDateTime(projet.Suppression, Bdd) },
                    { "@7", DateTimeDbAdaptor.FormatDateTime(projet.Creation, Bdd) }
                };

                result = Insert(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
                //Logger.WriteEx(e);
            }

            return(result);
        }
コード例 #13
0
ファイル: CommercialDAL.cs プロジェクト: Lowxorx/HouseMadera
        /// <summary>
        /// Methode implémentée de l'interface ICommercialDAL. Elle effectue une copie des valeurs du deuxième paramètre dans le premier
        /// et met à jour le commercial en base.
        /// </summary>
        /// <param name="commercialLocal">Représente l'objet issue de la base locale </param>
        /// <param name="commercialDistant">Représente l'objet issue de la base distante</param>
        /// <returns>Le nombre de lignes affectées</returns>
        public int UpdateModele(Commercial commercialLocal, Commercial commercialDistant, MouvementSynchronisation sens)
        {
            //recopie des données du Commercial distant dans le Commercial local
            commercialLocal.Copy(commercialDistant);

            string sql = @"
                        UPDATE Commercial
                        SET Nom=@1,Prenom=@2,Login=@3,Password=@4,MiseAJour=@5
                        WHERE Id=@6
                      ";
            Dictionary<string, object> parameters = new Dictionary<string, object>() {
                {"@1",commercialLocal.Nom},
                {"@2",commercialLocal.Prenom},
                {"@3",commercialLocal.Login},
                {"@4",commercialLocal.Password},
                {"@5", DateTimeDbAdaptor.FormatDateTime( commercialLocal.MiseAJour,Bdd)},
                {"@6",commercialLocal.Id }
            };
            int result = 0;
            try
            {
                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
                //Logger.WriteEx(e);
            }

            return result;
        }
コード例 #14
0
        public int UpdateModele(ModulePlacePlan modele1, ModulePlacePlan modele2, MouvementSynchronisation sens)
        {
            int result = 0;

            try
            {
                //Vérification des clés étrangères
                if (modele2.ModulePlace == null)
                {
                    throw new Exception("Tentative d'insertion dans la table ModulePlacePlan avec la clé étrangère ModulePlace nulle");
                }
                if (modele2.Plan == null)
                {
                    throw new Exception("Tentative d'insertion dans la table ModulePlacePlan avec la clé étrangère Plan nulle");
                }

                int modulePlaceId = 0;
                int planId        = 0;
                if (sens == MouvementSynchronisation.Sortant)
                {
                    Synchronisation <ModulePlaceDAL, ModulePlace> .CorrespondanceModeleId.TryGetValue(modele2.ModulePlace.Id, out modulePlaceId);

                    Synchronisation <PlanDAL, Plan> .CorrespondanceModeleId.TryGetValue(modele2.Plan.Id, out planId);
                }
                else
                {
                    modulePlaceId = Synchronisation <ModulePlaceDAL, ModulePlace> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele2.ModulePlace.Id).Key;

                    planId = Synchronisation <PlanDAL, Plan> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele2.Plan.Id).Key;
                }


                ////Valeurs des clés étrangères est modifié avant insertion via la table de correspondance
                //int modulePlaceId = 0;
                //if (!Synchronisation<ModulePlaceDAL, ModulePlace>.CorrespondanceModeleId.TryGetValue(modele2.ModulePlace.Id, out modulePlaceId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    modulePlaceId = Synchronisation<ModulePlaceDAL, ModulePlace>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele2.ModulePlace.Id).Key;
                //}
                //int planId = 0;
                //if (!Synchronisation<PlanDAL, Plan>.CorrespondanceModeleId.TryGetValue(modele2.Plan.Id, out planId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    planId = Synchronisation<PlanDAL, Plan>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele2.Plan.Id).Key;
                //}

                modele1.Copy(modele2);

                string sql = @"
                        UPDATE ModulePlacePlan
                        SET ModulePlace_Id=@1,Plan_Id=@2,MiseAJour=@3
                        WHERE ModulePlace_Id=@1 AND Plan_Id=@2";

                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "@1", modulePlaceId },
                    { "@2", planId },
                    { "@3", DateTimeDbAdaptor.FormatDateTime(modele1.MiseAJour, Bdd) },
                };

                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #15
0
        public int UpdateModele(TypeModulePlacable typeModulePlacableLocal, TypeModulePlacable typeModulePlacableDistant, MouvementSynchronisation sens)
        {
            int result = 0;

            try
            {
                if (typeModulePlacableDistant != null)
                {
                    typeModulePlacableLocal.Copy(typeModulePlacableDistant);
                }

                string sql = @"UPDATE Devis
                               SET Nom=@1,Icone=@2,MiseAJour=@3,DateCreation=@4
                               WHERE Id=@5";
                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "@1", typeModulePlacableLocal.Nom },
                    { "@2", typeModulePlacableLocal.Icone },
                    { "@3", DateTimeDbAdaptor.FormatDateTime(typeModulePlacableLocal.MiseAJour, Bdd) },
                    { "@4", DateTimeDbAdaptor.FormatDateTime(typeModulePlacableLocal.Creation, Bdd) },
                    { "@5", typeModulePlacableLocal.Id }
                };

                result = Insert(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #16
0
        public int InsertModele(ComposantModule modele, MouvementSynchronisation sens)
        {
            int result = 0;

            try
            {
                //Vérification des clés étrangères
                if (modele.Composant == null)
                {
                    throw new Exception("Tentative d'insertion dans la table ComposantModule avec la clé étrangère Composant nulle");
                }
                if (modele.Module == null)
                {
                    throw new Exception("Tentative d'insertion dans la table ComposantModule avec la clé étrangère Module nulle");
                }

                int composantId = 0;
                int moduleId    = 0;
                if (sens == MouvementSynchronisation.Sortant)
                {
                    Synchronisation <ComposantDAL, Composant> .CorrespondanceModeleId.TryGetValue(modele.Composant.Id, out composantId);

                    Synchronisation <ModuleDAL, Module> .CorrespondanceModeleId.TryGetValue(modele.Module.Id, out moduleId);
                }
                else
                {
                    composantId = Synchronisation <ComposantDAL, Composant> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Composant.Id).Key;

                    moduleId = Synchronisation <ModuleDAL, Module> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Module.Id).Key;
                }



                //if (!Synchronisation<ComposantDAL, Composant>.CorrespondanceModeleId.TryGetValue(modele.Composant.Id, out int composantId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    composantId = Synchronisation<ComposantDAL, Composant>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Composant.Id).Key;
                //}

                //if (!Synchronisation<ModuleDAL, Module>.CorrespondanceModeleId.TryGetValue(modele.Module.Id, out int moduleId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    moduleId = Synchronisation<ModuleDAL, Module>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Module.Id).Key;
                //}



                string sql = @"INSERT INTO ComposantModule (Nombre,Composant_Id,Module_Id,MiseAJour,Suppression,Creation)
                        VALUES(@1,@2,@3,@4,@5,@6)";
                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "@1", modele.Nombre },
                    { "@2", composantId },
                    { "@3", moduleId },
                    { "@4", DateTimeDbAdaptor.FormatDateTime(modele.MiseAJour, Bdd) },
                    { "@5", DateTimeDbAdaptor.FormatDateTime(modele.Suppression, Bdd) },
                    { "@6", DateTimeDbAdaptor.FormatDateTime(modele.Creation, Bdd) }
                };

                result = Insert(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);

                //Logger.WriteEx(e);
            }

            return(result);
        }
コード例 #17
0
ファイル: PlanDAL.cs プロジェクト: Lowxorx/HouseMadera
        public int InsertModele(Plan modele, MouvementSynchronisation sens)
        {
            int result = 0;

            try
            {
                //Vérification des clés étrangères
                if (modele.Gamme == null)
                {
                    throw new Exception("Tentative d'insertion dans la table Plan avec la clé étrangère Gamme nulle");
                }
                if (modele.CoupePrincipe == null)
                {
                    throw new Exception("Tentative d'insertion dans la table Plan avec la clé étrangère CoupePrincipe nulle");
                }

                int gammeId         = 0;
                int coupePrincipeId = 0;

                if (sens == MouvementSynchronisation.Entrant)
                {
                    Synchronisation <GammeDAL, Gamme> .CorrespondanceModeleId.TryGetValue(modele.Gamme.Id, out gammeId);

                    Synchronisation <CoupePrincipeDAL, CoupePrincipe> .CorrespondanceModeleId.TryGetValue(modele.CoupePrincipe.Id, out coupePrincipeId);
                }
                else
                {
                    gammeId = Synchronisation <GammeDAL, Gamme> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Gamme.Id).Key;

                    coupePrincipeId = Synchronisation <CoupePrincipeDAL, CoupePrincipe> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.CoupePrincipe.Id).Key;
                }

                ////Valeurs des clés étrangères est modifié avant insertion via la table de correspondance
                //if (!Synchronisation<GammeDAL, Gamme>.CorrespondanceModeleId.TryGetValue(modele.Gamme.Id, out int gammeId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    gammeId = Synchronisation<GammeDAL, Gamme>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Gamme.Id).Key;
                //}
                //if (!Synchronisation<CoupePrincipeDAL, CoupePrincipe>.CorrespondanceModeleId.TryGetValue(modele.CoupePrincipe.Id, out int coupePrincipeId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    coupePrincipeId = Synchronisation<CoupePrincipeDAL, CoupePrincipe>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.CoupePrincipe.Id).Key;
                //}


                string sql = @"INSERT INTO Plan (Nom,Gamme_Id,CoupePrincipe_Id,MiseAJour,Suppression,Creation)
                        VALUES(@1,@2,@3,@4,@5,@6)";
                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "@1", modele.Nom },
                    { "@2", gammeId },
                    { "@3", coupePrincipeId },
                    { "@4", DateTimeDbAdaptor.FormatDateTime(modele.MiseAJour, Bdd) },
                    { "@5", DateTimeDbAdaptor.FormatDateTime(modele.Suppression, Bdd) },
                    { "@6", DateTimeDbAdaptor.FormatDateTime(modele.Creation, Bdd) }
                };

                result = Insert(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);

                //Logger.WriteEx(e);
            }

            return(result);
        }
コード例 #18
0
        public int InsertModele(ModulePlace modele, MouvementSynchronisation sens)
        {
            int result = 0;

            try
            {
                //Vérification des clés étrangères
                if (modele.Module == null)
                {
                    throw new Exception("Tentative d'insertion dans la table ModulePlace avec la clé étrangère Module nulle");
                }
                if (modele.SlotPlace == null)
                {
                    throw new Exception("Tentative d'insertion dans la table ModulePlace avec la clé étrangère SlotPlace nulle");
                }
                if (modele.Produit == null)
                {
                    throw new Exception("Tentative d'insertion dans la table ModulePlace avec la clé étrangère Produit nulle");
                }


                int moduleId    = 0;
                int slotPlaceId = 0;
                int produitId   = 0;

                if (sens == MouvementSynchronisation.Sortant)
                {
                    Synchronisation <ModuleDAL, Module> .CorrespondanceModeleId.TryGetValue(modele.Module.Id, out moduleId);

                    Synchronisation <SlotPlaceDAL, SlotPlace> .CorrespondanceModeleId.TryGetValue(modele.SlotPlace.Id, out slotPlaceId);

                    Synchronisation <ProduitDAL, Produit> .CorrespondanceModeleId.TryGetValue(modele.Produit.Id, out produitId);
                }
                else
                {
                    moduleId = Synchronisation <ModuleDAL, Module> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Module.Id).Key;

                    slotPlaceId = Synchronisation <SlotPlaceDAL, SlotPlace> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.SlotPlace.Id).Key;

                    produitId = Synchronisation <ProduitDAL, Produit> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Produit.Id).Key;
                }

                ////Valeurs des clés étrangères est modifié avant insertion via la table de correspondance
                //if (!Synchronisation<ModuleDAL, Module>.CorrespondanceModeleId.TryGetValue(modele.Module.Id, out int moduleId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    moduleId = Synchronisation<ModuleDAL, Module>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Module.Id).Key;
                //}
                //if (!Synchronisation<SlotPlaceDAL, SlotPlace>.CorrespondanceModeleId.TryGetValue(modele.SlotPlace.Id, out int slotPlaceId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    slotPlaceId = Synchronisation<SlotPlaceDAL, SlotPlace>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.SlotPlace.Id).Key;
                //}
                //if (!Synchronisation<ProduitDAL, Produit>.CorrespondanceModeleId.TryGetValue(modele.Produit.Id, out int produitId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    produitId = Synchronisation<ProduitDAL, Produit>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Produit.Id).Key;
                //}


                string sql = @"INSERT INTO ModulePlace (Libelle,Horizontal,Vertical,Module_Id,SlotPlace_Id,Produit_Id,MiseAJour,Suppression,Creation)
                        VALUES(@1,@2,@3,@4,@5,@6,@7,@8,@9)";
                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "@1", modele.Libelle },
                    { "@2", modele.Horizontal },
                    { "@3", modele.Vertical },
                    { "@4", moduleId },
                    { "@5", slotPlaceId },
                    { "@6", produitId },
                    { "@7", DateTimeDbAdaptor.FormatDateTime(modele.MiseAJour, Bdd) },
                    { "@8", DateTimeDbAdaptor.FormatDateTime(modele.Suppression, Bdd) },
                    { "@9", DateTimeDbAdaptor.FormatDateTime(modele.Creation, Bdd) }
                };

                result = Insert(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);

                //Logger.WriteEx(e);
            }

            return(result);
        }
コード例 #19
0
        public int UpdateModele(TypeModuleTypeSlot modele1, TypeModuleTypeSlot modele2, MouvementSynchronisation sens)
        {
            int result = 0;

            try
            {
                //Vérification des clés étrangères
                if (modele2.TypeModule == null)
                {
                    throw new Exception("Tentative d'insertion dans la table TypeModuleTypeSlot avec la clé étrangère TypeModule nulle");
                }
                if (modele2.TypeSlot == null)
                {
                    throw new Exception("Tentative d'insertion dans la table TypeModuleTypeSlot avec la clé étrangère TypeSlot nulle");
                }

                int typeModuleId = 0;
                int typeSlotId   = 0;
                if (sens == MouvementSynchronisation.Sortant)
                {
                    Synchronisation <TypeModuleDAL, TypeModule> .CorrespondanceModeleId.TryGetValue(modele2.TypeModule.Id, out typeModuleId);

                    Synchronisation <TypeSlotDAL, TypeSlot> .CorrespondanceModeleId.TryGetValue(modele2.TypeSlot.Id, out typeSlotId);
                }
                else
                {
                    typeModuleId = Synchronisation <TypeModuleDAL, TypeModule> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele2.TypeModule.Id).Key;

                    typeSlotId = Synchronisation <TypeSlotDAL, TypeSlot> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele2.TypeSlot.Id).Key;
                }


                ////Valeurs des clés étrangères est modifié avant insertion via la table de correspondance
                //int typeModuleId = 0;
                //if (!Synchronisation<TypeModuleDAL, TypeModule>.CorrespondanceModeleId.TryGetValue(modele2.TypeModule.Id, out  typeModuleId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    typeModuleId = Synchronisation<TypeModuleDAL, TypeModule>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele2.TypeModule.Id).Key;
                //}
                //int typeSlotId = 0;
                //if (!Synchronisation<TypeSlotDAL, TypeSlot>.CorrespondanceModeleId.TryGetValue(modele2.TypeSlot.Id, out typeSlotId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    typeSlotId = Synchronisation<TypeSlotDAL, TypeSlot>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele2.TypeSlot.Id).Key;
                //}



                string sql = @"
                        UPDATE TypeModuleTypeSlot
                        SET TypeModule_Id=@1,TypeSlot_Id=@2,MiseAJour=@3
                        WHERE TypeModule_Id=@1 AND TypeSlot_Id=@2";
                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "@1", typeModuleId },
                    { "@2", typeSlotId },
                    { "@3", DateTimeDbAdaptor.FormatDateTime(modele2.MiseAJour, Bdd) },
                    { "@4", DateTimeDbAdaptor.FormatDateTime(modele2.Suppression, Bdd) },
                    { "@5", DateTimeDbAdaptor.FormatDateTime(modele2.Creation, Bdd) }
                };

                result = Insert(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);

                //Logger.WriteEx(e);
            }

            return(result);
        }
コード例 #20
0
ファイル: PlanDAL.cs プロジェクト: Lowxorx/HouseMadera
        public int UpdateModele(Plan planLocal, Plan planDistant, MouvementSynchronisation sens)
        {
            //Vérification des clés étrangères
            if (planDistant.Gamme == null)
            {
                throw new Exception("Tentative d'insertion dans la table Plan avec la clé étrangère Gamme nulle");
            }
            if (planDistant.CoupePrincipe == null)
            {
                throw new Exception("Tentative d'insertion dans la table Plan avec la clé étrangère CoupePrincipe nulle");
            }

            int gammeId         = 0;
            int coupePrincipeId = 0;

            if (sens == MouvementSynchronisation.Sortant)
            {
                Synchronisation <GammeDAL, Gamme> .CorrespondanceModeleId.TryGetValue(planDistant.Gamme.Id, out gammeId);

                Synchronisation <CoupePrincipeDAL, CoupePrincipe> .CorrespondanceModeleId.TryGetValue(planDistant.CoupePrincipe.Id, out coupePrincipeId);
            }
            else
            {
                gammeId = Synchronisation <GammeDAL, Gamme> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == planDistant.Gamme.Id).Key;

                coupePrincipeId = Synchronisation <CoupePrincipeDAL, CoupePrincipe> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == planDistant.CoupePrincipe.Id).Key;
            }

            ////Valeurs des clés étrangères est modifié avant insertion via la table de correspondance
            //if (!Synchronisation<GammeDAL, Gamme>.CorrespondanceModeleId.TryGetValue(planDistant.Gamme.Id, out int gammeId))
            //{
            //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
            //    gammeId = Synchronisation<GammeDAL, Gamme>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == planDistant.Gamme.Id).Key;
            //}
            //if (!Synchronisation<CoupePrincipeDAL, CoupePrincipe>.CorrespondanceModeleId.TryGetValue(planDistant.CoupePrincipe.Id, out int coupePrincipeId))
            //{
            //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
            //    coupePrincipeId = Synchronisation<CoupePrincipeDAL, CoupePrincipe>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == planDistant.CoupePrincipe.Id).Key;
            //}

            //recopie des données du Plan distant dans le Plan local
            planLocal.Copy(planDistant);
            string sql = @"
                        UPDATE Plan
                        SET Nom=@1,Gamme_Id=@2,CoupePrincipe_Id=@3,MiseAJour=@4
                        WHERE Id=@5
                      ";

            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@1", planLocal.Nom },
                { "@2", gammeId },
                { "@3", coupePrincipeId },
                { "@4", DateTimeDbAdaptor.FormatDateTime(planLocal.MiseAJour, Bdd) },
                { "@5", planLocal.Id },
            };
            int result = 0;

            try
            {
                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #21
0
ファイル: ProduitDAL.cs プロジェクト: Lowxorx/HouseMadera
        public int UpdateModele(Produit produitLocal, Produit produitDistant, MouvementSynchronisation sens)
        {
            //Vérification des clés étrangères
            if (produitDistant.Projet == null)
            {
                throw new Exception("Tentative d'insertion dans la table Produit avec la clé étrangère Projet nulle");
            }
            if (produitDistant.Devis == null)
            {
                throw new Exception("Tentative d'insertion dans la table Produit avec la clé étrangère Devis nulle");
            }
            if (produitDistant.Plan == null)
            {
                throw new Exception("Tentative d'insertion dans la table Produit avec la clé étrangère Plan nulle");
            }
            if (produitDistant.StatutProduit == null)
            {
                throw new Exception("Tentative d'insertion dans la table Produit avec la clé étrangère StatutProduit nulle");
            }

            int projetId        = 0;
            int devisId         = 0;
            int planId          = 0;
            int statutProduitId = 0;

            if (sens == MouvementSynchronisation.Sortant)
            {
                Synchronisation <ProjetDAL, Projet> .CorrespondanceModeleId.TryGetValue(produitDistant.Projet.Id, out projetId);

                Synchronisation <DevisDAL, Devis> .CorrespondanceModeleId.TryGetValue(produitDistant.Devis.Id, out devisId);

                Synchronisation <PlanDAL, Plan> .CorrespondanceModeleId.TryGetValue(produitDistant.Plan.Id, out planId);

                Synchronisation <StatutProduitDAL, StatutProduit> .CorrespondanceModeleId.TryGetValue(produitDistant.StatutProduit.Id, out statutProduitId);
            }
            else
            {
                projetId = Synchronisation <ProjetDAL, Projet> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == produitDistant.Projet.Id).Key;

                devisId = Synchronisation <DevisDAL, Devis> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == produitDistant.Devis.Id).Key;

                planId = Synchronisation <PlanDAL, Plan> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == produitDistant.Plan.Id).Key;

                statutProduitId = Synchronisation <StatutProduitDAL, StatutProduit> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == produitDistant.StatutProduit.Id).Key;
            }



            ////Valeurs des clés étrangères est modifié avant insertion via la table de correspondance
            //if (!Synchronisation<ProjetDAL, Projet>.CorrespondanceModeleId.TryGetValue(produitDistant.Projet.Id, out int projetId ))
            //{
            //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
            //    projetId = Synchronisation<ProjetDAL, Projet>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == produitDistant.Projet.Id).Key;
            //}
            //if (!Synchronisation<DevisDAL, Devis>.CorrespondanceModeleId.TryGetValue(produitDistant.Devis.Id, out int devisId))
            //{
            //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
            //    devisId = Synchronisation<DevisDAL, Devis>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == produitDistant.Devis.Id).Key;
            //}
            //if (!Synchronisation<PlanDAL, Plan>.CorrespondanceModeleId.TryGetValue(produitDistant.Plan.Id, out int planId))
            //{
            //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
            //    planId = Synchronisation<PlanDAL, Plan>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == produitDistant.Plan.Id).Key;
            //}
            //if (!Synchronisation<StatutProduitDAL, StatutProduit>.CorrespondanceModeleId.TryGetValue(produitDistant.StatutProduit.Id, out int statutProduitId))
            //{
            //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
            //    statutProduitId = Synchronisation<StatutProduitDAL, StatutProduit>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == produitDistant.StatutProduit.Id).Key;
            //}


            produitLocal.Copy(produitDistant);
            string sql = @"
                        UPDATE Produit
                        SET Nom=@1,Projet_Id=@2,Plan_Id=@3,Devis_Id=@3,StatutProduit_Id=@5,MiseAJour=@6
                        WHERE Id=@7
                      ";

            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@1", produitLocal.Nom },
                { "@2", projetId },
                { "@3", planId },
                { "@4", devisId == 0 ? string.Empty: Convert.ToString(devisId) },
                { "@5", statutProduitId },
                { "@6", DateTimeDbAdaptor.FormatDateTime(produitLocal.MiseAJour, Bdd) },
                { "@7", produitLocal.Id },
            };
            int result = 0;

            try
            {
                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #22
0
        public int UpdateModele(SlotPlace slotPlaceLocal, SlotPlace slotPlaceDistant, MouvementSynchronisation sens)
        {
            int result = 0;

            try
            {
                //Vérification des clés étrangères
                if (slotPlaceDistant.Module == null)
                {
                    throw new Exception("Tentative d'insertion dans la table SlotPlace avec la clé étrangère Module nulle");
                }
                if (slotPlaceDistant.Slot == null)
                {
                    throw new Exception("Tentative d'insertion dans la table SlotPlace avec la clé étrangère Slot nulle");
                }
                if (slotPlaceDistant.TypeModulePlacable == null)
                {
                    throw new Exception("Tentative d'insertion dans la table SlotPlace avec la clé étrangère TypeModulePlacable nulle");
                }

                int moduleId             = 0;
                int slotId               = 0;
                int typeModulePlacableId = 0;

                if (sens == MouvementSynchronisation.Sortant)
                {
                    Synchronisation <ModuleDAL, Module> .CorrespondanceModeleId.TryGetValue(slotPlaceDistant.Module.Id, out moduleId);

                    Synchronisation <SlotDAL, Slot> .CorrespondanceModeleId.TryGetValue(slotPlaceDistant.Slot.Id, out slotId);

                    Synchronisation <TypeModulePlacableDAL, TypeModulePlacable> .CorrespondanceModeleId.TryGetValue(slotPlaceDistant.TypeModulePlacable.Id, out typeModulePlacableId);
                }
                else
                {
                    moduleId = Synchronisation <ModuleDAL, Module> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == slotPlaceDistant.Module.Id).Key;

                    slotId = Synchronisation <SlotDAL, Slot> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == slotPlaceDistant.Slot.Id).Key;

                    typeModulePlacableId = Synchronisation <TypeModulePlacableDAL, TypeModulePlacable> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == slotPlaceDistant.TypeModulePlacable.Id).Key;
                }

                ////Valeurs des clés étrangères est modifié avant insertion via la table de correspondance
                //if (!Synchronisation<ModuleDAL, Module>.CorrespondanceModeleId.TryGetValue(slotPlaceDistant.Module.Id, out int moduleId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    moduleId = Synchronisation<ModuleDAL, Module>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == slotPlaceDistant.Module.Id).Key;
                //}
                //if (!Synchronisation<SlotDAL, Slot>.CorrespondanceModeleId.TryGetValue(slotPlaceDistant.Slot.Id, out int slotId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    slotId = Synchronisation<SlotDAL, Slot>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == slotPlaceDistant.Slot.Id).Key;
                //}
                //if (!Synchronisation<TypeModulePlacableDAL, TypeModulePlacable>.CorrespondanceModeleId.TryGetValue(slotPlaceDistant.TypeModulePlacable.Id, out int typeModulePlacableId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    typeModulePlacableId = Synchronisation<TypeModulePlacableDAL, TypeModulePlacable>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == slotPlaceDistant.TypeModulePlacable.Id).Key;
                //}

                slotPlaceLocal.Copy(slotPlaceDistant);
                string sql = @"
                        UPDATE SlotPlace
                        SET Libelle=@1,Module_Id=@2,Slot_Id=@3,TypeModulePlacable_Id=@4,MiseAJour=@5
                        WHERE Id=@6";

                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "@1", slotPlaceLocal.Libelle },
                    { "@2", moduleId },
                    { "@3", slotId },
                    { "@4", typeModulePlacableId },
                    { "@5", DateTimeDbAdaptor.FormatDateTime(slotPlaceLocal.MiseAJour, Bdd) },
                    { "@6", slotPlaceLocal.Id },
                };

                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #23
0
ファイル: GammeDAL.cs プロジェクト: Lowxorx/HouseMadera
        public int UpdateModele(Gamme gammeLocal, Gamme gammeDistant, MouvementSynchronisation sens)
        {
            //Vérification des clés étrangères
            if (gammeDistant.Finition == null)
            {
                throw new Exception("Tentative d'insertion dans la table Gamme avec la clé étrangère Finition nulle");
            }
            if (gammeDistant.Isolant == null)
            {
                throw new Exception("Tentative d'insertion dans la table Gamme avec la clé étrangère Isolant nulle");
            }

            int finitionId = 0;
            int isolantId  = 0;

            if (sens == MouvementSynchronisation.Sortant)
            {
                Synchronisation <FinitionDAL, Finition> .CorrespondanceModeleId.TryGetValue(gammeDistant.Finition.Id, out finitionId);

                Synchronisation <IsolantDAL, Isolant> .CorrespondanceModeleId.TryGetValue(gammeDistant.Isolant.Id, out isolantId);
            }
            else
            {
                finitionId = Synchronisation <FinitionDAL, Finition> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == gammeDistant.Finition.Id).Key;

                isolantId = Synchronisation <IsolantDAL, Isolant> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == gammeDistant.Isolant.Id).Key;
            }


            ////Valeurs des clés étrangères est modifié avant insertion via la table de correspondance
            //if (!Synchronisation<FinitionDAL, Finition>.CorrespondanceModeleId.TryGetValue(gammeDistant.Finition.Id, out int finitionId))
            //{
            //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
            //    finitionId = Synchronisation<FinitionDAL, Finition>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == gammeDistant.Finition.Id).Key;
            //}
            //if (!Synchronisation<IsolantDAL, Isolant>.CorrespondanceModeleId.TryGetValue(gammeDistant.Isolant.Id, out int isolantId))
            //{
            //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
            //    isolantId = Synchronisation<IsolantDAL, Isolant>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == gammeDistant.Isolant.Id).Key;
            //}
            //recopie des données de la Gamme distante dans la Gamme locale
            gammeLocal.Copy(gammeDistant);
            string sql = @"
                        UPDATE Gamme
                        SET Nom=@1,Finition_Id=@2,Isolant_Id=@3,MiseAJour=@4
                        WHERE Id=@5
                      ";

            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@1", gammeLocal.Nom },
                { "@2", finitionId },
                { "@3", isolantId },
                { "@4", DateTimeDbAdaptor.FormatDateTime(gammeLocal.MiseAJour, Bdd) },
                { "@5", gammeLocal.Id },
            };
            int result = 0;

            try
            {
                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #24
0
        public int UpdateModele(CoupePrincipe coupeLocale, CoupePrincipe coupeDistante, MouvementSynchronisation sens)
        {
            //recopie des données de CoupePrincipe distante dans CoupePrincipe locale
            if (coupeDistante != null)
            {
                coupeLocale.Copy(coupeDistante);
            }

            string sql = @"
                        UPDATE CoupePrincipe
                        SET Nom=@1,MiseAJour=@2
                        WHERE Id=@3
                      ";
            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@1", coupeLocale.Nom },
                { "@2", DateTimeDbAdaptor.FormatDateTime(coupeLocale.MiseAJour, Bdd) },
                { "@3", coupeLocale.Id }
            };
            int result = 0;

            try
            {
                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #25
0
        public int UpdateModele(Composant composantLocal, Composant composantDistant, MouvementSynchronisation sens)
        {
            //Vérification des clés étrangères
            if (composantDistant.TypeComposant == null)
            {
                throw new Exception("Tentative d'insertion dans la table Composant avec la clé étrangère TypeComposant nulle");
            }

            int typeComposantId = 0;

            if (sens == MouvementSynchronisation.Sortant)
            {
                Synchronisation <TypeComposantDAL, TypeComposant> .CorrespondanceModeleId.TryGetValue(composantDistant.TypeComposant.Id, out typeComposantId);
            }
            else
            {
                typeComposantId = Synchronisation <TypeComposantDAL, TypeComposant> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == composantDistant.TypeComposant.Id).Key;
            }

            ////Valeurs des clés étrangères est modifié avant insertion via la table de correspondance
            //if (!Synchronisation<TypeComposantDAL, TypeComposant>.CorrespondanceModeleId.TryGetValue(composantDistant.TypeComposant.Id, out int typeComposantId))
            //{
            //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
            //    typeComposantId = Synchronisation<TypeComposantDAL, TypeComposant>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == composantDistant.TypeComposant.Id).Key;
            //}

            //recopie des données du Composant distant dans le Composant local
            composantLocal.Copy(composantDistant);
            string sql = @"
                        UPDATE Composant
                        SET Nom=@1,Prix=@2,TypeComposant_Id=@3,MiseAJour=@4
                        WHERE Id=@5
                      ";

            Dictionary <string, object> parameters = new Dictionary <string, object>()
            {
                { "@1", composantLocal.Nom },
                { "@2", composantLocal.Prix },
                { "@3", typeComposantId },
                { "@4", DateTimeDbAdaptor.FormatDateTime(composantLocal.MiseAJour, Bdd) },
                { "@5", composantLocal.Id },
            };
            int result = 0;

            try
            {
                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
            }

            return(result);
        }
コード例 #26
0
        public int UpdateModele(Module moduleLocal, Module moduleDistant, MouvementSynchronisation sens)
        {
            int result = 0;

            try
            {
                //Vérification des clés étrangères
                if (moduleDistant.TypeModule == null)
                {
                    throw new Exception("Tentative d'insertion dans la table Module avec la clé étrangère TypeModule nulle");
                }
                if (moduleDistant.Gamme == null)
                {
                    throw new Exception("Tentative d'insertion dans la table Module avec la clé étrangère Gamme nulle");
                }

                int typeModuleId = 0;
                int gammeId      = 0;

                if (sens == MouvementSynchronisation.Sortant)
                {
                    Synchronisation <TypeModuleDAL, TypeModule> .CorrespondanceModeleId.TryGetValue(moduleDistant.TypeModule.Id, out typeModuleId);

                    Synchronisation <GammeDAL, Gamme> .CorrespondanceModeleId.TryGetValue(moduleDistant.Gamme.Id, out gammeId);
                }
                else
                {
                    typeModuleId = Synchronisation <TypeModuleDAL, TypeModule> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == moduleDistant.TypeModule.Id).Key;

                    gammeId = Synchronisation <GammeDAL, Gamme> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == moduleDistant.Gamme.Id).Key;
                }



                ////Valeurs des clés étrangères est modifié avant insertion via la table de correspondance
                //int typeModuleId = 0;
                //if (!Synchronisation<TypeModuleDAL, TypeModule>.CorrespondanceModeleId.TryGetValue(moduleDistant.TypeModule.Id, out typeModuleId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    typeModuleId = Synchronisation<TypeModuleDAL, TypeModule>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == moduleDistant.TypeModule.Id).Key;
                //}
                //int gammeId = 0;
                //if (!Synchronisation<GammeDAL, Gamme>.CorrespondanceModeleId.TryGetValue(moduleDistant.Gamme.Id, out gammeId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    gammeId = Synchronisation<GammeDAL, Gamme>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == moduleDistant.Gamme.Id).Key;
                //}
                moduleLocal.Copy(moduleDistant);
                string sql = @"
                        UPDATE Module
                        SET Nom=@1,Gamme_Id=@2,TypeModule_Id=@3,MiseAJour=@4
                        WHERE Id=@5";

                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "@1", moduleLocal.Nom },
                    { "@2", gammeId },
                    { "@3", typeModuleId },
                    { "@4", DateTimeDbAdaptor.FormatDateTime(moduleLocal.MiseAJour, Bdd) },
                    { "@5", moduleLocal.Id },
                };

                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Logger.WriteEx(e);
            }

            return(result);
        }
コード例 #27
0
        /// <summary>
        /// Compare chaque élément d'une liste avec une autre. Si l'élément est semblable
        /// détermine si il a été mis à jour ou supprimé.Si l'élément  comparable est
        /// absent de la liste distante celui-ci est inséré dans la base distante.
        /// </summary>
        /// <param name="liste1"> représente la liste principale (locale) à comparer</param>
        /// <param name="liste2">représente la liste secondaire(distante) à comparer</param>
        /// <param name="sens">indique le sens de comparaison local / distant ou distant / local</param>
        private void comparerDonnees(List <TMODELE> liste1, List <TMODELE> liste2, MouvementSynchronisation sens)
        {
            string bdd      = string.Empty;
            string locale   = string.Empty;
            string distante = string.Empty;


            if (sens == MouvementSynchronisation.Sortant)
            {
                //du local au distant
                bdd      = "locale";
                locale   = LOCALE;
                distante = DISTANTE;
            }
            else
            {
                if (sens == MouvementSynchronisation.Entrant)
                {
                    //du distant au local
                    bdd      = "distante";
                    locale   = DISTANTE;
                    distante = LOCALE;
                }
            }

            Console.WriteLine("validation  {0} : ", sens);

            if (liste1.Count == 0)
            {
                Console.WriteLine("La table ne comporte aucun enregistrement");
            }
            try
            {
                foreach (var modeleListe1 in liste1)
                {
                    bool isInDistant = false;
                    bool isUpToDate  = false;
                    bool isDeleted   = false;
                    foreach (var modeleListe2 in liste2)
                    {
                        isInDistant = modeleListe1.Equals(modeleListe2);
                        if (isInDistant)
                        {
                            //Est-ce que le modèle a été supprimé sur le serveur distant
                            isDeleted = modeleListe1.IsDeleted(modeleListe2);
                            if (isDeleted)
                            {
                                using (dalBddLocale = (TDAL)Activator.CreateInstance(typeof(TDAL), locale))
                                {
#if DEBUG
                                    Console.WriteLine("\nl'entité {0} avec l'ID {1} a été effacé sur la bdd  {2}\n", NomModele, modeleListe1.Id, bdd);
#endif
                                    dalBddLocale.DeleteModele(modeleListe1);
#if DEBUG
                                    Console.WriteLine("\nSuppression ----- OK");
#endif
                                }
                            }
                            else
                            {
                                //Est-ce que le modèle a été modifié sur le serveur distant
                                isUpToDate = modeleListe1.IsUpToDate(modeleListe2);

                                if (!isUpToDate)
                                {
                                    using (dalBddLocale = (TDAL)Activator.CreateInstance(typeof(TDAL), locale))
                                    {
#if DEBUG
                                        Console.WriteLine("\nL'entité {0} avec l'ID {1} a été modifié sur la bdd {2}\n", NomModele, modeleListe1.Id, bdd);
#endif
                                        dalBddLocale.UpdateModele(modeleListe1, modeleListe2, sens);
#if DEBUG
                                        Console.WriteLine("\nModification -------> OK");
#endif
                                    }
                                }
                            }
                            break;
                        }
                    }
                    if (!isInDistant)
                    {
                        //Console.WriteLine("L'entité {0} avec l'ID {1} n'existe pas sur dans la bdd {2}\n", NomModele, modeleListe1.Id, distante);
                        using (dalBddDistante = (TDAL)Activator.CreateInstance(typeof(TDAL), distante))
                        {
                            int nbLigneInseree = dalBddDistante.InsertModele(modeleListe1, sens);
                            if (nbLigneInseree > 0)
                            {
#if DEBUG
                                Console.WriteLine("Enregistrement dans {0} --------> OK\n", distante);
#endif
                                changements = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                NbErreurs++;

                string precision = (sens == MouvementSynchronisation.Sortant) ? LOCALE + " vers " + DISTANTE : DISTANTE + " vers " + LOCALE;
                string titre     = string.Format("Synchronisation de : {0}--> Comparaison des données {1}\n", NomModele, precision);
#if DEBUG
                Console.WriteLine(titre + ex.Message);
#endif
                Logger.WriteTrace(titre);
                Logger.WriteEx(ex);
            }
        }
コード例 #28
0
        public int UpdateModele(TypeIsolant typeIsolantLocal, TypeIsolant typeIsolantDistant, MouvementSynchronisation sens)
        {
            int result = 0;

            try
            {
                //Vérification des clés étrangères
                if (typeIsolantDistant.Qualite == null)
                {
                    throw new Exception("Tentative d'insertion dans la table TypeIsolant avec la clé étrangère Qualite nulle");
                }

                int qualiteId = 0;
                if (sens == MouvementSynchronisation.Sortant)
                {
                    Synchronisation <QualiteDAL, Qualite> .CorrespondanceModeleId.TryGetValue(typeIsolantDistant.Qualite.Id, out qualiteId);
                }
                else
                {
                    qualiteId = Synchronisation <QualiteDAL, Qualite> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == typeIsolantDistant.Qualite.Id).Key;
                }


                ////Valeurs des clés étrangères est modifié avant insertion via la table de correspondance
                //if (!Synchronisation<QualiteDAL, Qualite>.CorrespondanceModeleId.TryGetValue(typeIsolantDistant.Qualite.Id, out int qualiteId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    qualiteId = Synchronisation<QualiteDAL, Qualite>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == typeIsolantDistant.Qualite.Id).Key;

                //}

                // recopie des données du TypeIsolant distant dans le TypeIsolant local
                typeIsolantLocal.Copy <TypeIsolant>(typeIsolantDistant);

                string sql = @"
                        UPDATE TypeIsolant
                        SET Nom=@1,MiseAJour=@2,Qualite_Id=@3 
                        WHERE Id=@4
                      ";
                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "@1", typeIsolantLocal.Nom },
                    { "@2", DateTimeDbAdaptor.FormatDateTime(typeIsolantLocal.MiseAJour, Bdd) },
                    { "@3", qualiteId },
                    { "@4", typeIsolantLocal.Id }
                };


                result = Update(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);
                //Logger.WriteEx(e);
            }

            return(result);
        }
コード例 #29
0
ファイル: ProduitDAL.cs プロジェクト: Lowxorx/HouseMadera
        public int InsertModele(Produit modele, MouvementSynchronisation sens)
        {
            int result = 0;

            try
            {
                //Vérification des clés étrangères
                if (modele.Projet == null)
                {
                    throw new Exception("Tentative d'insertion dans la table Produit avec la clé étrangère Projet nulle");
                }
                if (modele.Devis == null)
                {
                    throw new Exception("Tentative d'insertion dans la table Produit avec la clé étrangère Devis nulle");
                }
                if (modele.Plan == null)
                {
                    throw new Exception("Tentative d'insertion dans la table Produit avec la clé étrangère Plan nulle");
                }
                if (modele.StatutProduit == null)
                {
                    throw new Exception("Tentative d'insertion dans la table Produit avec la clé étrangère StatutProduit nulle");
                }


                int projetId        = 0;
                int devisId         = 0;
                int planId          = 0;
                int statutProduitId = 0;

                if (sens == MouvementSynchronisation.Sortant)
                {
                    Synchronisation <ProjetDAL, Projet> .CorrespondanceModeleId.TryGetValue(modele.Projet.Id, out projetId);

                    Synchronisation <DevisDAL, Devis> .CorrespondanceModeleId.TryGetValue(modele.Devis.Id, out devisId);

                    Synchronisation <PlanDAL, Plan> .CorrespondanceModeleId.TryGetValue(modele.Plan.Id, out planId);

                    Synchronisation <StatutProduitDAL, StatutProduit> .CorrespondanceModeleId.TryGetValue(modele.StatutProduit.Id, out statutProduitId);
                }
                else
                {
                    projetId = Synchronisation <ProjetDAL, Projet> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Projet.Id).Key;

                    devisId = Synchronisation <DevisDAL, Devis> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Devis.Id).Key;

                    planId = Synchronisation <PlanDAL, Plan> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Plan.Id).Key;

                    statutProduitId = Synchronisation <StatutProduitDAL, StatutProduit> .CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.StatutProduit.Id).Key;
                }
                ////Valeurs des clés étrangères est modifié avant insertion via la table de correspondance
                //if (!Synchronisation<ProjetDAL, Projet>.CorrespondanceModeleId.TryGetValue(modele.Projet.Id, out int projetId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    projetId = Synchronisation<ProjetDAL, Projet>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Projet.Id).Key;
                //}
                //if (!Synchronisation<DevisDAL, Devis>.CorrespondanceModeleId.TryGetValue(modele.Devis.Id, out int devisId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    devisId = Synchronisation<DevisDAL, Devis>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Devis.Id).Key;
                //}
                //if (!Synchronisation<PlanDAL, Plan>.CorrespondanceModeleId.TryGetValue(modele.Plan.Id, out int planId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    planId = Synchronisation<PlanDAL, Plan>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.Plan.Id).Key;
                //}
                //if (!Synchronisation<StatutProduitDAL, StatutProduit>.CorrespondanceModeleId.TryGetValue(modele.StatutProduit.Id, out int statutProduitId))
                //{
                //    //si aucune clé existe avec l'id passé en paramètre alors on recherche par valeur
                //    statutProduitId = Synchronisation<StatutProduitDAL, StatutProduit>.CorrespondanceModeleId.FirstOrDefault(c => c.Value == modele.StatutProduit.Id).Key;
                //}

                string sql = @"INSERT INTO Produit (Nom,Projet_Id,Plan_Id,Devis_Id,StatutProduit_Id,MiseAJour,Suppression,Creation)
                        VALUES(@1,@2,@3,@4,@5,@6,@7,@8)";
                Dictionary <string, object> parameters = new Dictionary <string, object>()
                {
                    { "@1", modele.Nom },
                    { "@2", projetId },
                    { "@3", planId },
                    { "@4", devisId == 0 ? string.Empty: Convert.ToString(devisId) },
                    { "@5", statutProduitId },
                    { "@6", DateTimeDbAdaptor.FormatDateTime(modele.MiseAJour, Bdd) },
                    { "@7", DateTimeDbAdaptor.FormatDateTime(modele.Suppression, Bdd) },
                    { "@8", DateTimeDbAdaptor.FormatDateTime(modele.Creation, Bdd) }
                };

                result = Insert(sql, parameters);
            }
            catch (Exception e)
            {
                result = -1;
                Console.WriteLine(e.Message);

                //Logger.WriteEx(e);
            }

            return(result);
        }