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); }
public List <TypeModulePlacable> GetAllModeles() { List <TypeModulePlacable> listeTypeModulePlacable = new List <TypeModulePlacable>(); try { string sql = string.Format("SELECT * FROM TypeModulePlacable"); using (DbDataReader reader = Get(sql, null)) { while (reader.Read()) { TypeModulePlacable t = new TypeModulePlacable() { Id = Convert.ToInt32(reader["Id"]), Nom = Convert.ToString(reader["Nom"]), Icone = string.IsNullOrEmpty(reader["Icone"].ToString()) ? null :(byte[])reader["Icone"], MiseAJour = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["MiseAJour"])), Suppression = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Suppression"])), Creation = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Creation"])), }; listeTypeModulePlacable.Add(t); } } } catch (Exception ex) { Console.WriteLine(ex); //Logger.WriteEx(ex); } return(listeTypeModulePlacable); }
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); }
public List <CoupePrincipe> GetAllModeles() { string sql = @" SELECT * FROM CoupePrincipe ORDER BY Nom DESC"; List <CoupePrincipe> coupes = new List <CoupePrincipe>(); using (DbDataReader reader = Get(sql, null)) { while (reader.Read()) { CoupePrincipe coupe = new CoupePrincipe(); coupe.Id = Convert.ToInt32(reader["Id"]); coupe.Nom = Convert.ToString(reader["Nom"]); coupe.MiseAJour = DateTimeDbAdaptor.InitialiserDate(reader["MiseAJour"].ToString()); coupe.Suppression = DateTimeDbAdaptor.InitialiserDate(reader["Suppression"].ToString()); coupe.Creation = DateTimeDbAdaptor.InitialiserDate(reader["Creation"].ToString()); if (coupe != null) { coupes.Add(coupe); } } } return(coupes); }
public List <Qualite> GetAllModeles() { List <Qualite> listeQualites = new List <Qualite>(); try { string sql = @"SELECT * FROM Qualite"; using (DbDataReader reader = Get(sql, null)) { while (reader.Read()) { Qualite q = new Qualite() { Id = Convert.ToInt32(reader["Id"]), Nom = Convert.ToString(reader["Nom"]), MiseAJour = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["MiseAJour"])), Suppression = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Suppression"])), Creation = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Creation"])), }; listeQualites.Add(q); } } } catch (Exception ex) { Console.WriteLine(ex); //Logger.WriteEx(ex); } return(listeQualites); }
public int DeleteModele(TypeIsolant modele) { string sql = @" UPDATE TypeIsolant SET Suppression= @2 WHERE Id=@1 "; Dictionary <string, object> parameters = new Dictionary <string, object>() { { "@1", modele.Id }, { "@2", DateTimeDbAdaptor.FormatDateTime(modele.Suppression, Bdd) } }; int result = 0; try { result = Update(sql, parameters); } catch (Exception e) { result = -1; Console.WriteLine(e.Message); //Logger.WriteEx(e); } return(result); }
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); }
/// <summary> /// Met à jour en base la date de suppression du client (suppression logique) /// </summary> /// <param name="client">Représente le client à effacer</param> /// <returns>Le nombre de lignes affectées</returns> public int DeleteModele(Client client) { if (!isDataCorrect(client)) { throw new Exception(erreur); } string sql = @" UPDATE Client SET Suppression= @2 WHERE Id=@1 "; Dictionary <string, object> parameters = new Dictionary <string, object>() { { "@1", client.Id }, { "@2", DateTimeDbAdaptor.FormatDateTime(client.Suppression, Bdd) } }; int result = 0; try { result = Update(sql, parameters); } catch (Exception e) { result = -1; Console.WriteLine(e.Message); } return(result); }
/// <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; }
public int UpdateDevis(Devis devis) { var sql = @"UPDATE Devis SET Nom=@1, DateCreation=@2 ,PrixHT=@3 ,PrixTTC=@4 ,StatutDevis_Id=@5 , Pdf=@6, MiseAJour=@7"; var parameters = new Dictionary <string, object>() { { "@1", devis.Nom }, { "@2", devis.DateCreation }, { "@3", devis.PrixHT }, { "@4", devis.PrixTTC }, { "@5", devis.StatutDevis.Id }, { "@6", devis.Pdf }, { "@7", DateTimeDbAdaptor.FormatDateTime(devis.MiseAJour, Bdd) } }; var result = 0; try { result = Update(sql, parameters); } catch (Exception e) { result = -1; Logger.WriteEx(e); Console.WriteLine(e.Message); } return(result); }
/// <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; }
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); }
/// <summary> /// Réalise des test sur les propriétés de l'objet Devis /// avant insertion en base. /// </summary> /// <param name="devis"></param> /// <returns>Le nombre de ligne affecté en base. -1 si aucune ligne insérée</returns> public int InsertDevis(Devis devis) { if (IsDevisExist(devis)) { return(UpdateDevis(devis)); } var sql = @"INSERT INTO Devis (Nom,DateCreation,PrixHT,PrixTTC,StatutDevis_Id,Pdf,MiseAJour,Suppression,Creation) VALUES(@1,@2,@3,@4,@5,@6,@7,@8,@9)"; var parameters = new Dictionary <string, object>() { { "@1", devis.Nom }, { "@2", devis.DateCreation }, { "@3", devis.PrixHT }, { "@4", devis.PrixTTC }, { "@5", devis.StatutDevis.Id }, { "@6", devis.Pdf }, { "@7", DateTimeDbAdaptor.FormatDateTime(devis.MiseAJour, Bdd) }, { "@8", DateTimeDbAdaptor.FormatDateTime(devis.Suppression, Bdd) }, { "@9", DateTimeDbAdaptor.FormatDateTime(devis.Creation, Bdd) } }; var result = 0; try { result = Insert(sql, parameters); } catch (Exception e) { result = -1; Logger.WriteEx(e); Console.WriteLine(e.Message); } return(result); }
/// <summary> /// Réalise des test sur les propriétés de l'objet Projet /// avant insertion en base. /// </summary> /// <param name="projet"></param> /// <returns>Le nombre de ligne affecté en base. -1 si aucune ligne insérée</returns> public int CreerProjet(Projet p) { string sql = @"INSERT INTO Projet (Nom,Reference,UpdateDate,CreateDate,Client_Id,Commercial_Id,MiseAJour,Suppression,Creation) VALUES(@1,@2,@3,@4,@5,@6,@7,@8,@9)"; Dictionary <string, object> parameters = new Dictionary <string, object>() { { "@1", p.Nom }, { "@2", p.Reference }, { "@3", DateTimeDbAdaptor.FormatDateTime(p.UpdateDate, Bdd) }, { "@4", DateTimeDbAdaptor.FormatDateTime(p.CreateDate, Bdd) }, { "@5", p.Client.Id }, { "@6", p.Commercial.Id }, { "@7", DateTimeDbAdaptor.FormatDateTime(p.MiseAJour, Bdd) }, { "@8", DateTimeDbAdaptor.FormatDateTime(p.Suppression, Bdd) }, { "@9", DateTimeDbAdaptor.FormatDateTime(p.Creation, Bdd) } }; int result = 0; try { result = Insert(sql, parameters); } catch (Exception e) { result = -1; Console.WriteLine(e.Message); } return(result); }
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); }
public List <StatutProduit> GetAllModeles() { List <StatutProduit> statutsProduit = new List <StatutProduit>(); try { string sql = @"SELECT * FROM StatutProduit"; using (DbDataReader reader = Get(sql, null)) { while (reader.Read()) { StatutProduit s = new StatutProduit() { Id = Convert.ToInt32(reader["Id"]), Nom = Convert.ToString(reader["Nom"]), MiseAJour = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["MiseAJour"])), Suppression = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Suppression"])), Creation = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Creation"])), }; statutsProduit.Add(s); } } } catch (Exception ex) { Console.WriteLine(ex); //Logger.WriteEx(ex); } return(statutsProduit); }
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); }
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); }
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); }
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); }
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); }
public List <ModulePlace> GetAllModeles() { List <ModulePlace> listeModulesPlaces = new List <ModulePlace>(); try { string sql = @"SELECT mp.*,m.Id AS module_Id , m.Nom AS module_Nom , s.Id AS slotPlace_Id ,s.Libelle AS slotPlace_Libelle,p.Id AS produit_Id,p.Nom AS produit_Nom FROM ModulePlace mp LEFT JOIN Module m ON mp.Module_Id = m.Id LEFT JOIN SlotPlace s ON mp.SlotPlace_Id = s.Id LEFT JOIN Produit p ON mp.Produit_Id = p.Id"; using (DbDataReader reader = Get(sql, null)) { while (reader.Read()) { ModulePlace m = new ModulePlace() { Id = Convert.ToInt32(reader["Id"]), Horizontal = string.IsNullOrEmpty(reader["Horizontal"].ToString()) ? false : Convert.ToBoolean(reader["Horizontal"]), Vertical = string.IsNullOrEmpty(reader["Vertical"].ToString()) ? false : Convert.ToBoolean(reader["Vertical"]), MiseAJour = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["MiseAJour"])), Suppression = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Suppression"])), Creation = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Creation"])), Module = new Module() { Id = Convert.ToInt32(reader["module_Id"]), Nom = Convert.ToString(reader["module_Nom"]), }, SlotPlace = new SlotPlace() { Id = Convert.ToInt32(reader["slotPlace_Id"]), Libelle = Convert.ToString(reader["slotPlace_Libelle"]) }, Produit = new Produit() { Id = Convert.ToInt32(reader["produit_Id"]), Nom = Convert.ToString(reader["produit_Nom"]), } }; listeModulesPlaces.Add(m); } } } catch (Exception ex) { Console.WriteLine(ex); //Logger.WriteEx(ex); } return(listeModulesPlaces); }
public List <SlotPlace> GetAllModeles() { List <SlotPlace> listeSlotsPlaces = new List <SlotPlace>(); try { string sql = @"SELECT sp.*,m.Id AS module_Id , m.Nom AS module_Nom , s.Id AS slot_Id ,s.Nom AS slot_Nom,tmp.Id AS typeModulePlacable_Id,tmp.Nom AS typeModulePlacable_Nom FROM SlotPlace sp LEFT JOIN Module m ON sp.Module_Id = m.Id LEFT JOIN Slot s ON sp.Slot_Id = s.Id LEFT JOIN TypeModulePlacable tmp ON sp.TypeModulePlacable_Id = tmp.Id"; using (DbDataReader reader = Get(sql, null)) { while (reader.Read()) { SlotPlace sp = new SlotPlace() { Id = Convert.ToInt32(reader["Id"]), Libelle = Convert.ToString(reader["Libelle"]), MiseAJour = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["MiseAJour"])), Suppression = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Suppression"])), Creation = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Creation"])), Module = new Module() { Id = Convert.ToInt32(reader["module_Id"]), Nom = Convert.ToString(reader["module_Nom"]), }, Slot = new Slot() { Id = Convert.ToInt32(reader["slot_Id"]), Nom = Convert.ToString(reader["slot_Nom"]) }, TypeModulePlacable = new TypeModulePlacable() { Id = reader["typeModulePlacable_Id"] == null ? 0 : Convert.ToInt32(reader["module_Id"]), Nom = Convert.ToString(reader["typeModulePlacable_Nom"]), } }; listeSlotsPlaces.Add(sp); } } } catch (Exception ex) { Console.WriteLine(ex); //Logger.WriteEx(ex); } return(listeSlotsPlaces); }
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); }
/// <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); }
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); }
public List <ComposantModule> GetAllModeles() { List <ComposantModule> listeComposantModule = new List <ComposantModule>(); try { string sql = @"SELECT cm.*,c.Id AS composant_Id , c.Nom AS composant_Nom, m.Id AS module_Id , m.Nom AS module_Nom FROM ComposantModule cm LEFT JOIN Composant c ON cm.Composant_Id = c.Id LEFT JOIN Module m ON cm.Module_Id = m.Id"; using (DbDataReader reader = Get(sql, null)) { while (reader.Read()) { ComposantModule c = new ComposantModule() { Id = 0, //La table de liaison ne contient pas d'ID Nombre = Convert.ToInt32(reader["Nombre"]), MiseAJour = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["MiseAJour"])), Suppression = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Suppression"])), Creation = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Creation"])), Composant = new Composant() { Id = Convert.ToInt32(reader["composant_Id"]), Nom = Convert.ToString(reader["composant_Nom"]), }, Module = new Module() { Id = Convert.ToInt32(reader["module_Id"]), Nom = Convert.ToString(reader["module_Nom"]), } }; listeComposantModule.Add(c); } } } catch (Exception ex) { Console.WriteLine(ex); //Logger.WriteEx(ex); } return(listeComposantModule); }
public List <Gamme> GetAllModeles() { List <Gamme> listeGammes = new List <Gamme>(); try { string sql = @"SELECT g.*,f.Id AS Finition_Id , f.Nom AS Finition_Nom, i.Id AS Isolant_Id ,i.Nom AS Isolant_Nom FROM Gamme g LEFT JOIN Finition f ON g.Finition_Id = f.Id LEFT JOIN Isolant i ON g.Isolant_Id = i.Id"; using (DbDataReader reader = Get(sql, null)) { while (reader.Read()) { Gamme g = new Gamme() { Id = Convert.ToInt32(reader["Id"]), Nom = Convert.ToString(reader["Nom"]), MiseAJour = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["MiseAJour"])), Suppression = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Suppression"])), Creation = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Creation"])), Finition = new Finition() { Id = Convert.ToInt32(reader["Finition_Id"]), Nom = Convert.ToString(reader["Finition_Nom"]) }, Isolant = new Isolant() { Id = Convert.ToInt32(reader["Isolant_Id"]), Nom = Convert.ToString(reader["Isolant_Nom"]) } }; listeGammes.Add(g); } } } catch (Exception ex) { Console.WriteLine(ex); //Logger.WriteEx(ex); } return(listeGammes); }
public List <Plan> GetAllModeles() { List <Plan> listePlans = new List <Plan>(); try { string sql = @"SELECT p.*,g.Id AS gamme_Id , g.Nom AS gamme_Nom, c.Id AS coupePrincipe_Id ,c.Nom AS coupePrincipe_Nom FROM Plan p LEFT JOIN Gamme g ON p.Gamme_Id = g.Id LEFT JOIN CoupePrincipe c ON p.CoupePrincipe_Id = c.Id"; using (DbDataReader reader = Get(sql, null)) { while (reader.Read()) { Plan p = new Plan() { Id = Convert.ToInt32(reader["Id"]), Nom = Convert.ToString(reader["Nom"]), MiseAJour = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["MiseAJour"])), Suppression = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Suppression"])), Creation = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Creation"])), Gamme = new Gamme() { Id = Convert.ToInt32(reader["gamme_Id"]), Nom = Convert.ToString(reader["gamme_Nom"]) }, CoupePrincipe = new CoupePrincipe() { Id = Convert.ToInt32(reader["coupePrincipe_Id"]), Nom = Convert.ToString(reader["coupePrincipe_Nom"]) } }; listePlans.Add(p); } } } catch (Exception ex) { Console.WriteLine(ex); //Logger.WriteEx(ex); } return(listePlans); }
public List <Module> GetAllModeles() { List <Module> listeModules = new List <Module>(); try { string sql = @"SELECT m.*,g.Id AS gamme_Id , g.Nom AS gamme_Nom , t.Id AS typeModule_Id , t.Nom AS typeModule_Nom FROM Module m LEFT JOIN Gamme g ON m.Gamme_Id = g.Id LEFT JOIN TypeModule t ON m.TypeModule_Id = t.Id"; using (DbDataReader reader = Get(sql, null)) { while (reader.Read()) { Module m = new Module() { Id = Convert.ToInt32(reader["Id"]), Nom = Convert.ToString(reader["Nom"]), MiseAJour = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["MiseAJour"])), Suppression = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Suppression"])), Creation = DateTimeDbAdaptor.InitialiserDate(Convert.ToString(reader["Creation"])), Gamme = new Gamme() { Id = Convert.ToInt32(reader["gamme_Id"]), Nom = Convert.ToString(reader["gamme_Nom"]), }, TypeModule = new TypeModule() { Id = Convert.ToInt32(reader["typeModule_Id"]), Nom = Convert.ToString(reader["typeModule_Nom"]), } }; listeModules.Add(m); } } } catch (Exception ex) { Logger.WriteEx(ex); } return(listeModules); }