commit c0e26233159131bdd341d4ac52afe017fcd72c1f Author: adri Date: Thu Jun 7 17:40:51 2018 +0200 Initial commit diff --git a/GestionCommerceInfo.mdf b/GestionCommerceInfo.mdf new file mode 100644 index 0000000..c553ec6 Binary files /dev/null and b/GestionCommerceInfo.mdf differ diff --git a/GestionDeCommerceInfoClasseBDDNCouches.sln b/GestionDeCommerceInfoClasseBDDNCouches.sln new file mode 100644 index 0000000..bf27a7d --- /dev/null +++ b/GestionDeCommerceInfoClasseBDDNCouches.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2020 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GestionDeCommerceInfoClasseBDDNCouches", "GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches.csproj", "{E6602180-4F8E-437A-867B-75B90834D712}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E6602180-4F8E-437A-867B-75B90834D712}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E6602180-4F8E-437A-867B-75B90834D712}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E6602180-4F8E-437A-867B-75B90834D712}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E6602180-4F8E-437A-867B-75B90834D712}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9A74BA61-758E-4E9A-A947-0086E1C68108} + EndGlobalSection +EndGlobal diff --git a/GestionDeCommerceInfoClasseBDDNCouches/Article.cs b/GestionDeCommerceInfoClasseBDDNCouches/Article.cs new file mode 100644 index 0000000..10ae132 --- /dev/null +++ b/GestionDeCommerceInfoClasseBDDNCouches/Article.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GestionDeCommerceInfoClasseBDDNCouches +{ + public class Article + { + private int? id; + public int ID + { + get + { + if (id != null) + return id.Value; + else + return -1; + } + set + { + if (id == null) + id = value; + } + } + public double PrixHTVA; + public int Stock; + public bool Visible, Actif; + public string Designation; + public Article() + { + + } + public Article(int id, string designation, double prixHTVA, int stock, bool visible, bool actif) + { + this.id = id; Designation = designation; + PrixHTVA = prixHTVA; Stock = stock; Visible = visible; Actif = actif; + } + public Article(string designation, double prixHTVA, int stock, bool visible, bool actif) + { + this.id = null; Designation = designation; + PrixHTVA = prixHTVA; Stock = stock; Visible = visible; Actif = actif; + } + + public override string ToString() + { + return Designation; + } + public static implicit operator string(Article lSTArticle) + { + return lSTArticle.ToString(); + } + /*public static explicit operator string(Article lSTArticle) + { + return lSTArticle.ToString(); + }*/ + } +} diff --git a/GestionDeCommerceInfoClasseBDDNCouches/DataLayer/BDDAccesArticle.cs b/GestionDeCommerceInfoClasseBDDNCouches/DataLayer/BDDAccesArticle.cs new file mode 100644 index 0000000..573ac99 --- /dev/null +++ b/GestionDeCommerceInfoClasseBDDNCouches/DataLayer/BDDAccesArticle.cs @@ -0,0 +1,158 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +namespace GestionDeCommerceInfoClasseBDDNCouches.DataLayer +{ + public class BDDAccesArticle : BDDAccesBase + { + //private string sCHConnBDD; + //public string SCHConnBDD { get => sCHConnBDD; set => sCHConnBDD = value; } + + //private SqlCommand CommandSQL = new SqlCommand(); + + public BDDAccesArticle(string schConn) : base(schConn) + { + //SCHConnBDD = schConn; + //CommandSQL.Connection = new SqlConnection(schConn); + } + public List
ListArticles() + { + CommandSQL.Parameters.Clear(); + List
lstArt = new List
(); + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "ListArticle"; + CommandSQL.Parameters.AddWithValue("@ID", Convert.DBNull); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + while (data.Read()) + { + //Console.WriteLine(data.ToString()+"\n"+ (data["ID"].ToString()) +"__"+ (data["PrixHTVA"].ToString())+"__"+(data["Stock"].ToString())+"__"+ ((data["Visible"].ToString()))+"__"+ ((data["Actif"].ToString()))); + lstArt.Add(new Article(int.Parse(data["ID"].ToString()), data["Designation"].ToString(), + float.Parse(data["PrixHTVA"].ToString()), + int.Parse(data["Stock"].ToString()), + (bool.Parse(data["Visible"].ToString())), + (bool.Parse(data["Actif"].ToString())))); + } + CommandSQL.Connection.Close(); + return lstArt; + } + public List
VerifStock(int alerteStock) + { + CommandSQL.Parameters.Clear(); + List
lstArt = new List
(); + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "StockUnder"; + CommandSQL.Parameters.AddWithValue("@Stock", alerteStock); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + while (data.Read()) + { + //Console.WriteLine(data.ToString()+"\n"+ (data["ID"].ToString()) +"__"+ (data["PrixHTVA"].ToString())+"__"+(data["Stock"].ToString())+"__"+ ((data["Visible"].ToString()))+"__"+ ((data["Actif"].ToString()))); + lstArt.Add(new Article(int.Parse(data["ID"].ToString()), data["Designation"].ToString(), + float.Parse(data["PrixHTVA"].ToString()), + int.Parse(data["Stock"].ToString()), + (bool.Parse(data["Visible"].ToString())), + (bool.Parse(data["Actif"].ToString())))); + } + CommandSQL.Connection.Close(); + return lstArt; + } + public Article LireArticle(int id) + { + CommandSQL.Parameters.Clear(); + Article lstArt; + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "ListArticle"; + CommandSQL.Parameters.AddWithValue("@ID", id); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + + if (data.Read()) + { + //Console.WriteLine(data.ToString()+"\n"+ (data["ID"].ToString()) +"__"+ (data["PrixHTVA"].ToString())+"__"+(data["Stock"].ToString())+"__"+ ((data["Visible"].ToString()))+"__"+ ((data["Actif"].ToString()))); + lstArt = new Article(int.Parse(data["ID"].ToString()), data["Designation"].ToString(), + float.Parse(data["PrixHTVA"].ToString()), + int.Parse(data["Stock"].ToString()), + (bool.Parse(data["Visible"].ToString())), + (bool.Parse(data["Actif"].ToString()))); + CommandSQL.Connection.Close(); + return lstArt; + } + else + { + CommandSQL.Connection.Close(); + return null; + } + } + public int AjouterArticle(Article article) + { + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "AjoutArticle"; + CommandSQL.Parameters.Clear(); + CommandSQL.Parameters.Add("ID", SqlDbType.Int); + Direction("ID", ParameterDirection.Output); + CommandSQL.Parameters.AddWithValue("@Designation",article.Designation); + CommandSQL.Parameters.AddWithValue("@PrixHTVA",article.PrixHTVA); + CommandSQL.Parameters.AddWithValue("@Stock",article.Stock); + CommandSQL.Parameters.AddWithValue("@Visible",article.Visible); + CommandSQL.Parameters.AddWithValue("@Actif",article.Actif); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + int a = int.Parse(CommandSQL.Parameters["ID"].Value.ToString()); + article.ID = a; + CommandSQL.Connection.Close(); + return a; + } + public void AjouterArticles(List
articles) + { + foreach (Article article in articles) + article.ID = AjouterArticle(article); + } + public void ModifArticle(Article article) + { + CommandSQL.Parameters.Clear(); + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "ModifArticle"; + CommandSQL.Parameters.AddWithValue("@ID", article.ID); + CommandSQL.Parameters.AddWithValue("@Designation", article.Designation); + CommandSQL.Parameters.AddWithValue("@PrixHTVA", article.PrixHTVA); + CommandSQL.Parameters.AddWithValue("@Stock", article.Stock); + CommandSQL.Parameters.AddWithValue("@Visible", article.Visible); + CommandSQL.Parameters.AddWithValue("@Actif", article.Actif); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + CommandSQL.Connection.Close(); + } + public void ModifArticles(List
articles) + { + foreach (Article article in articles) + ModifArticle(article); + } + public void SuprimerArticle(int id, bool definitivement) + { + CommandSQL.Parameters.Clear(); + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "SuprimerArticle"; + CommandSQL.Parameters.AddWithValue("@ID", id); + CommandSQL.Parameters.AddWithValue("@definitivement", definitivement); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + CommandSQL.Connection.Close(); + } + public void SuprimerArticle(Article article, bool definitivement) + { + SuprimerArticle(article.ID, definitivement); + } + public void SuprimerArticle(List
articles, bool definitivement) + { + foreach (Article article in articles) + SuprimerArticle(article.ID, definitivement); + } + } +} diff --git a/GestionDeCommerceInfoClasseBDDNCouches/DataLayer/BDDAccesBase.cs b/GestionDeCommerceInfoClasseBDDNCouches/DataLayer/BDDAccesBase.cs new file mode 100644 index 0000000..d5d9148 --- /dev/null +++ b/GestionDeCommerceInfoClasseBDDNCouches/DataLayer/BDDAccesBase.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GestionDeCommerceInfoClasseBDDNCouches.DataLayer +{ + public class BDDAccesBase + { + private string sCHConnBDD; + public string SCHConnBDD { get => sCHConnBDD; set => sCHConnBDD = value; } + public SqlCommand CommandSQL { get => commandSQL; set { } } + + private SqlCommand commandSQL = new SqlCommand(); + public BDDAccesBase(string schConn) + { + SCHConnBDD = schConn; + CommandSQL.Connection = new SqlConnection(schConn); + } + #region Utilitaires + public void Direction(string sParam, ParameterDirection dParam) + { CommandSQL.Parameters[sParam].Direction = dParam; } + public string LireParametre(string sParam) + { return CommandSQL.Parameters[sParam].Value.ToString(); } + #endregion + } +} diff --git a/GestionDeCommerceInfoClasseBDDNCouches/DataLayer/BDDAccesPanier.cs b/GestionDeCommerceInfoClasseBDDNCouches/DataLayer/BDDAccesPanier.cs new file mode 100644 index 0000000..bc7ccc4 --- /dev/null +++ b/GestionDeCommerceInfoClasseBDDNCouches/DataLayer/BDDAccesPanier.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using GestionDeCommerceInfoClasseBDDNCouches; + +namespace GestionDeCommerceInfoClasseBDDNCouches.DataLayer +{ + public class BDDAccesPanier : BDDAccesBase + { + public BDDAccesPanier(string schConn) : base(schConn) + { + } + public List listeArticlePanier(int panierId) + { + CommandSQL.Parameters.Clear(); + List lstARt = new List(); + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "ListArticlePanier"; + CommandSQL.Parameters.AddWithValue("@ID", panierId); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + while (data.Read()) + { + lstARt.Add(new Panier.LSTArticle(new BDDAccesArticle(base.SCHConnBDD).LireArticle(int.Parse(data["ArticleID"].ToString())), + int.Parse(data["ID"].ToString()), + int.Parse(data["Quantite"].ToString()), + float.Parse(data["PrixHTVA"].ToString()))); + + + } + CommandSQL.Connection.Close(); + + return lstARt; + } + public Panier LirePanier(int id) + { + Panier pret; + + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "LirePanier"; + CommandSQL.Parameters.AddWithValue("@ID", id); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + + if (data.Read()) + { + pret = new Panier(int.Parse(data["ID"].ToString()), + new BDDAccesUtilisateur(base.SCHConnBDD).LireUtilisateur(int.Parse(data["UserId"].ToString())), + data["Nom"].ToString(), + (Panier.Type_E)int.Parse(data["Type"].ToString()), + (Panier.Status_E)int.Parse(data["Status"].ToString()), + DateTime.Parse(data["DateAchat"].ToString()), + listeArticlePanier(id)); + CommandSQL.Connection.Close(); + return pret; + } + else + { + CommandSQL.Connection.Close(); + return null; + } + } + public void SuprimerArticlePanier(int id) + { + CommandSQL.Parameters.Clear(); + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "SuprimerArticlePanier"; + CommandSQL.Parameters.AddWithValue("@ID", id); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + CommandSQL.Connection.Close(); + } + public int AjouterArticlePanier(Panier.LSTArticle lstart, int idPanier) + { + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "AjoutArticleDansPanier"; + CommandSQL.Parameters.Clear(); + CommandSQL.Parameters.Add("ID", SqlDbType.Int); + Direction("ID", ParameterDirection.Output); + CommandSQL.Parameters.AddWithValue("@IDArt", lstart.article.Designation); + CommandSQL.Parameters.AddWithValue("@IDPanier", idPanier); + CommandSQL.Parameters.AddWithValue("@Quantite", lstart.quantitee); + CommandSQL.Parameters.AddWithValue("@PrixHTVA", lstart.prixHTVAPC); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + int a = int.Parse(CommandSQL.Parameters["ID"].Value.ToString()); + lstart.id = a; + CommandSQL.Connection.Close(); + return a; + } + public int CreerPanier(Panier panier) + { + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "AjoutArticleDansPanier"; + CommandSQL.Parameters.Clear(); + CommandSQL.Parameters.Add("ID", SqlDbType.Int); + Direction("ID", ParameterDirection.Output); + CommandSQL.Parameters.AddWithValue("@UserID", panier.user.ID); + CommandSQL.Parameters.AddWithValue("@Nom", panier.nomPanier); + CommandSQL.Parameters.AddWithValue("@type", (int)panier.type); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + int a = int.Parse(CommandSQL.Parameters["ID"].Value.ToString()); + panier.idPanier = a; + CommandSQL.Connection.Close(); + return a; + } + + } +} diff --git a/GestionDeCommerceInfoClasseBDDNCouches/DataLayer/BDDAccesUtilisateur.cs b/GestionDeCommerceInfoClasseBDDNCouches/DataLayer/BDDAccesUtilisateur.cs new file mode 100644 index 0000000..43fdc34 --- /dev/null +++ b/GestionDeCommerceInfoClasseBDDNCouches/DataLayer/BDDAccesUtilisateur.cs @@ -0,0 +1,152 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +namespace GestionDeCommerceInfoClasseBDDNCouches.DataLayer +{ + public class BDDAccesUtilisateur : BDDAccesBase + { + //private string sCHConnBDD; + //public string SCHConnBDD { get => sCHConnBDD; set => sCHConnBDD = value; } + + //private SqlCommand CommandSQL = new SqlCommand(); + + public BDDAccesUtilisateur(string schConn) : base(schConn) + { + //SCHConnBDD = schConn; + //CommandSQL.Connection = new SqlConnection(schConn); + } + public List ListUtilisateurs(Utilisateur.Tri_E tri) + { + CommandSQL.Parameters.Clear(); + List lstArt = new List(); + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "ListUtilisateurs"; + CommandSQL.Parameters.AddWithValue("@ID", Convert.DBNull); + if(tri == Utilisateur.Tri_E.NONE) + CommandSQL.Parameters.AddWithValue("@TRI", Convert.DBNull); + else + CommandSQL.Parameters.AddWithValue("@TRI", tri.ToString()); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + while (data.Read()) + { + //Console.WriteLine(data.ToString()+"\n"+ (data["ID"].ToString()) +"__"+ (data["PrixHTVA"].ToString())+"__"+(data["Stock"].ToString())+"__"+ ((data["Visible"].ToString()))+"__"+ ((data["Actif"].ToString()))); + //public Utilisateur(int id, string nom, string pre, string addr, string nCompte, string email, Type_E type) + + lstArt.Add(new Utilisateur(int.Parse(data["ID"].ToString()), data["Nom"].ToString(), + (data["Prenom"].ToString()), + (data["Adresse"].ToString()), + (data["NCompte"].ToString()), + (data["email"].ToString()), + (Utilisateur.Type_E)Enum.Parse(typeof(Utilisateur.Type_E), data["type"].ToString()))); + } + CommandSQL.Connection.Close(); + return lstArt; + } + public Utilisateur LireUtilisateur(int id) + { + CommandSQL.Parameters.Clear(); + Utilisateur lstArt; + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "ListUtilisateurs"; + CommandSQL.Parameters.AddWithValue("@ID", id); + CommandSQL.Parameters.AddWithValue("@TRI", Convert.DBNull); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + + if (data.Read()) + { + //Console.WriteLine(data.ToString()+"\n"+ (data["ID"].ToString()) +"__"+ (data["PrixHTVA"].ToString())+"__"+(data["Stock"].ToString())+"__"+ ((data["Visible"].ToString()))+"__"+ ((data["Actif"].ToString()))); + lstArt = new Utilisateur(int.Parse(data["ID"].ToString()), data["Nom"].ToString(), + (data["Prenom"].ToString()), + (data["Adresse"].ToString()), + (data["NCompte"].ToString()), + (data["email"].ToString()), + (Utilisateur.Type_E)Enum.Parse(typeof(Utilisateur.Type_E), data["type"].ToString())); + CommandSQL.Connection.Close(); + return lstArt; + } + else + { + CommandSQL.Connection.Close(); + return null; + } + } + public int AjouterUtilisateur(Utilisateur utilisateur) + { + CommandSQL.Parameters.Clear(); + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "AjoutUtilisateur"; + CommandSQL.Parameters.Clear(); + CommandSQL.Parameters.Add("ID", SqlDbType.Int); + Direction("ID", ParameterDirection.Output); + CommandSQL.Parameters.AddWithValue("@Nom", utilisateur.Nom); + CommandSQL.Parameters.AddWithValue("@Prenom", utilisateur.Prenom); + CommandSQL.Parameters.AddWithValue("@Adresse", utilisateur.Adresse); + CommandSQL.Parameters.AddWithValue("@NCompte", utilisateur.NCompte); + CommandSQL.Parameters.AddWithValue("@DateDeNaisance", (utilisateur.DateDeNaisance == null)? Convert.DBNull : utilisateur.DateDeNaisance.Value); + CommandSQL.Parameters.AddWithValue("@email", utilisateur.Email); + CommandSQL.Parameters.AddWithValue("@Type", (int)utilisateur.TypeUtilisateur); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + int a = int.Parse(CommandSQL.Parameters["ID"].Value.ToString()); + utilisateur.ID = a; + CommandSQL.Connection.Close(); + return a; + } + public void AjouterUtilisateurs(List utilisateurs) + { + foreach (Utilisateur utilisateur in utilisateurs) + AjouterUtilisateur(utilisateur); + } + public void ModifUtilisateur(Utilisateur utilisateur) + { + CommandSQL.Parameters.Clear(); + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "ModifUtilisateur"; + CommandSQL.Parameters.AddWithValue("@ID", utilisateur.ID); + CommandSQL.Parameters.AddWithValue("@Nom", utilisateur.Nom); + CommandSQL.Parameters.AddWithValue("@Prenom", utilisateur.Prenom); + CommandSQL.Parameters.AddWithValue("@Adresse", utilisateur.Adresse); + CommandSQL.Parameters.AddWithValue("@NCompte", utilisateur.NCompte); + CommandSQL.Parameters.AddWithValue("@DateDeNaisance", (utilisateur.DateDeNaisance == null) ? Convert.DBNull : utilisateur.DateDeNaisance.Value); + CommandSQL.Parameters.AddWithValue("@email", utilisateur.Email); + CommandSQL.Parameters.AddWithValue("@Type", ((int)utilisateur.TypeUtilisateur)); + CommandSQL.Parameters.AddWithValue("@Actif", true); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + CommandSQL.Connection.Close(); + } + public void ModifUtilisateurs(List utilisateurs) + { + foreach (Utilisateur utilisateur in utilisateurs) + ModifUtilisateur(utilisateur); + } + public void SuprimerUtilisateur(int id, bool definitivement) + { + CommandSQL.Parameters.Clear(); + CommandSQL.CommandType = System.Data.CommandType.StoredProcedure; + CommandSQL.CommandText = "SuprimerUtilisateur"; + CommandSQL.Parameters.AddWithValue("@ID", id); + CommandSQL.Parameters.AddWithValue("@definitivement", definitivement); + CommandSQL.Connection.Open(); + SqlDataReader data = CommandSQL.ExecuteReader(); + CommandSQL.Connection.Close(); + } + public void SuprimerUtilisateur(Utilisateur utilisateur, bool definitivement) + { + SuprimerUtilisateur(utilisateur.ID, definitivement); + } + public void SuprimerUtilisateur(List utilisateurs, bool definitivement) + { + foreach (Utilisateur utilisateur in utilisateurs) + SuprimerUtilisateur(utilisateur.ID, definitivement); + } + } +} diff --git a/GestionDeCommerceInfoClasseBDDNCouches/GestionDeCommerceInfoClasseBDDNCouches.csproj b/GestionDeCommerceInfoClasseBDDNCouches/GestionDeCommerceInfoClasseBDDNCouches.csproj new file mode 100644 index 0000000..252fd1c --- /dev/null +++ b/GestionDeCommerceInfoClasseBDDNCouches/GestionDeCommerceInfoClasseBDDNCouches.csproj @@ -0,0 +1,56 @@ + + + + + Debug + AnyCPU + {E6602180-4F8E-437A-867B-75B90834D712} + Library + Properties + GestionDeCommerceInfoClasseBDDNCouches + GestionDeCommerceInfoClasseBDDNCouches + v4.6.1 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GestionDeCommerceInfoClasseBDDNCouches/Panier.cs b/GestionDeCommerceInfoClasseBDDNCouches/Panier.cs new file mode 100644 index 0000000..9a1bf5f --- /dev/null +++ b/GestionDeCommerceInfoClasseBDDNCouches/Panier.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using GestionDeCommerceInfoClasseBDDNCouches.DataLayer; + +namespace GestionDeCommerceInfoClasseBDDNCouches +{ + public class Panier + { + public int idPanier; + public Utilisateur user; + public string nomPanier; + public Type_E type; + public Status_E status; + public DateTime dateAchat; + public List ArticleDansPanier; + + + + public enum Type_E {Vente, Achat}; + public enum Status_E + { + NULL = 0x00, + Commander = 0x01, + Envoyer = 0x02, + Recu = 0x03 + }; + + public struct LSTArticle + { + public Article article; + public int quantitee; + public int id; + public float prixHTVAPC; + public float prixHTVATot + { + get + { + return prixHTVATot * quantitee; + } + } + public LSTArticle(Article art,int id, int quantitee) + { + this.article = art; + this.quantitee = quantitee; + prixHTVAPC = (float)article.PrixHTVA; + // prixHTVATot = prixHTVAPC * quantitee; + this.id = id; + } + public LSTArticle(Article article, int quantitee) + { + this.article = article; + this.quantitee = quantitee; + prixHTVAPC = (float)article.PrixHTVA; + //prixHTVATot = prixHTVAPC * quantitee; + this.id = -1; + } + public LSTArticle(Article article, int id, int quantitee, float prix) + { + this.article = article; + this.quantitee = quantitee; + prixHTVAPC = (float)article.PrixHTVA; + //prixHTVATot = prixHTVAPC * quantitee; + this.id = id; + } + + + public override string ToString() + { + return article.Designation; + } + + public static implicit operator string(LSTArticle lSTArticle) + { + return lSTArticle.ToString(); + } + } + + + public Panier() + { + ArticleDansPanier = new List(); + } + public Panier(int id, Utilisateur user, string nomPanier, Type_E type, Status_E status, DateTime dateAchat, List lstart) + { + idPanier = id; + this.user = user; + this.nomPanier = nomPanier; + this.type = type; + this.status = status; + this.dateAchat = dateAchat; + ArticleDansPanier = lstart; + } + public Panier(Utilisateur user, string nomPanier, Type_E type, Status_E status, DateTime dateAchat) + { + this.user = user; + this.nomPanier = nomPanier; + this.type = type; + this.status = status; + this.dateAchat = dateAchat; + ArticleDansPanier = new List(); + idPanier = -1; + + } + public bool SuprimerArticlePanier(BDDAccesPanier bdd, LSTArticle article) + { + for(int i=0;ArticleDansPanier.Count()>i;i++) + { + if(ArticleDansPanier[i].id == article.id) + { + ArticleDansPanier.RemoveAt(i); + return true; + } + } + return false; + } + public LSTArticle ajoutArticle(BDDAccesPanier bdd, Article artcle, int quant) + { + LSTArticle lstart = new LSTArticle(artcle, quant); + bdd.AjouterArticlePanier(lstart, this.idPanier); + ArticleDansPanier.Add(lstart); + return lstart; + } + public LSTArticle? ajoutArticle(Article artcle, int quant) + { + if (idPanier < 0) + { + LSTArticle lstart = new LSTArticle(artcle, quant); + ArticleDansPanier.Add(lstart); + return lstart; + } + else + return null; + } + public void EnvoyerPanierBDD(BDDAccesPanier bdd) + { + if(idPanier < 0) + { + bdd.CreerPanier(this); + foreach(LSTArticle lstart in ArticleDansPanier) + { + bdd.AjouterArticlePanier(lstart, this.idPanier); + } + } + } + + } +} diff --git a/GestionDeCommerceInfoClasseBDDNCouches/Properties/AssemblyInfo.cs b/GestionDeCommerceInfoClasseBDDNCouches/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c61b739 --- /dev/null +++ b/GestionDeCommerceInfoClasseBDDNCouches/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Les informations générales relatives à un assembly dépendent de +// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations +// associées à un assembly. +[assembly: AssemblyTitle("GestionDeCommerceInfoClasseBDDNCouches")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("GestionDeCommerceInfoClasseBDDNCouches")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly +// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de +// COM, affectez la valeur true à l'attribut ComVisible sur ce type. +[assembly: ComVisible(false)] + +// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM +[assembly: Guid("e6602180-4f8e-437a-867b-75b90834d712")] + +// Les informations de version pour un assembly se composent des quatre valeurs suivantes : +// +// Version principale +// Version secondaire +// Numéro de build +// Révision +// +// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut +// en utilisant '*', comme indiqué ci-dessous : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.1")] +[assembly: AssemblyFileVersion("1.0.0.1")] diff --git a/GestionDeCommerceInfoClasseBDDNCouches/Utilisateur.cs b/GestionDeCommerceInfoClasseBDDNCouches/Utilisateur.cs new file mode 100644 index 0000000..778db4b --- /dev/null +++ b/GestionDeCommerceInfoClasseBDDNCouches/Utilisateur.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GestionDeCommerceInfoClasseBDDNCouches +{ + public class Utilisateur + { + public enum Type_E { Commercant, Client, Fournisseur }; + public enum Tri_E { NONE, NOM, PRENOM }; + public string Nom, Prenom, Adresse, NCompte, Email; + public DateTime? DateDeNaisance; + public bool Actif; + public Type_E TypeUtilisateur; + private int? id; + + public int ID { + get + { + if (id != null) + return id.Value; + else + return -1; + } + set + { + if (id == null) + id = value; + } + } + + public Utilisateur() + { + + } + public Utilisateur(string nom, string pre, string addr, string nCompte, string email, Type_E type) + { + Nom = nom; Prenom = pre; Adresse = addr; NCompte = nCompte; Email = email; TypeUtilisateur = type; + Actif = true; + id = null; + } + public Utilisateur(int id, string nom, string pre, string addr, string nCompte, string email, Type_E type) + { + this.id = id; + Nom = nom; Prenom = pre; Adresse = addr; NCompte = nCompte; Email = email; TypeUtilisateur = type; + Actif = true; + } + public override string ToString() + { + return $"{Nom} {Prenom}"; + } + public static implicit operator string(Utilisateur lSTArticle) + { + return lSTArticle.ToString(); + } + + } +} diff --git a/GestionDeCommerceInfoClasseBDDNCouches/bin/Debug/GestionDeCommerceInfoClasseBDDNCouches.dll b/GestionDeCommerceInfoClasseBDDNCouches/bin/Debug/GestionDeCommerceInfoClasseBDDNCouches.dll new file mode 100644 index 0000000..8520dab Binary files /dev/null and b/GestionDeCommerceInfoClasseBDDNCouches/bin/Debug/GestionDeCommerceInfoClasseBDDNCouches.dll differ diff --git a/GestionDeCommerceInfoClasseBDDNCouches/bin/Debug/GestionDeCommerceInfoClasseBDDNCouches.pdb b/GestionDeCommerceInfoClasseBDDNCouches/bin/Debug/GestionDeCommerceInfoClasseBDDNCouches.pdb new file mode 100644 index 0000000..7ae2e47 Binary files /dev/null and b/GestionDeCommerceInfoClasseBDDNCouches/bin/Debug/GestionDeCommerceInfoClasseBDDNCouches.pdb differ diff --git a/GestionDeCommerceInfoClasseBDDNCouches/bin/Release/GestionDeCommerceInfoClasseBDDNCouches.dll b/GestionDeCommerceInfoClasseBDDNCouches/bin/Release/GestionDeCommerceInfoClasseBDDNCouches.dll new file mode 100644 index 0000000..2208ba4 Binary files /dev/null and b/GestionDeCommerceInfoClasseBDDNCouches/bin/Release/GestionDeCommerceInfoClasseBDDNCouches.dll differ diff --git a/GestionDeCommerceInfoClasseBDDNCouches/bin/Release/GestionDeCommerceInfoClasseBDDNCouches.pdb b/GestionDeCommerceInfoClasseBDDNCouches/bin/Release/GestionDeCommerceInfoClasseBDDNCouches.pdb new file mode 100644 index 0000000..bf2ad6b Binary files /dev/null and b/GestionDeCommerceInfoClasseBDDNCouches/bin/Release/GestionDeCommerceInfoClasseBDDNCouches.pdb differ diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/DesignTimeResolveAssemblyReferences.cache new file mode 100644 index 0000000..ec47fcf Binary files /dev/null and b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..7f5da49 Binary files /dev/null and b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.csproj.CoreCompileInputs.cache b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..3dd1805 --- /dev/null +++ b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +6f6b11a48c5084ee50ef613076f253a8a59cdfcf diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.csproj.FileListAbsolute.txt b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..d613475 --- /dev/null +++ b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.csproj.FileListAbsolute.txt @@ -0,0 +1,11 @@ +G:\users\adrien\nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\obj\Debug\GestionDeCommerceInfoClasseBDDNCouches.csproj.CoreCompileInputs.cache +G:\users\adrien\nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\bin\Debug\GestionDeCommerceInfoClasseBDDNCouches.dll +G:\users\adrien\nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\bin\Debug\GestionDeCommerceInfoClasseBDDNCouches.pdb +G:\users\adrien\nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\obj\Debug\GestionDeCommerceInfoClasseBDDNCouches.dll +G:\users\adrien\nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\obj\Debug\GestionDeCommerceInfoClasseBDDNCouches.pdb +G:\users\adrien\nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\obj\Debug\GestionDeCommerceInfoClasseBDDNCouches.csprojResolveAssemblyReference.cache +C:\Users\adrie\Nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\bin\Debug\GestionDeCommerceInfoClasseBDDNCouches.dll +C:\Users\adrie\Nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\bin\Debug\GestionDeCommerceInfoClasseBDDNCouches.pdb +C:\Users\adrie\Nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\obj\Debug\GestionDeCommerceInfoClasseBDDNCouches.csproj.CoreCompileInputs.cache +C:\Users\adrie\Nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\obj\Debug\GestionDeCommerceInfoClasseBDDNCouches.dll +C:\Users\adrie\Nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\obj\Debug\GestionDeCommerceInfoClasseBDDNCouches.pdb diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.csprojResolveAssemblyReference.cache b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..da0177c Binary files /dev/null and b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.csprojResolveAssemblyReference.cache differ diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.dll b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.dll new file mode 100644 index 0000000..8520dab Binary files /dev/null and b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.dll differ diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.pdb b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.pdb new file mode 100644 index 0000000..7ae2e47 Binary files /dev/null and b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/GestionDeCommerceInfoClasseBDDNCouches.pdb differ diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs new file mode 100644 index 0000000..e69de29 diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/GestionDeCommerceInfoClasseBDDNCouches/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.csproj.CoreCompileInputs.cache b/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..9aa1bdc --- /dev/null +++ b/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +730ef345d5b5f3a770b9fba2bbb6ce6a91c6fa1c diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.csproj.FileListAbsolute.txt b/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..e94f289 --- /dev/null +++ b/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.csproj.FileListAbsolute.txt @@ -0,0 +1,6 @@ +G:\users\adrien\nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\bin\Release\GestionDeCommerceInfoClasseBDDNCouches.dll +G:\users\adrien\nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\bin\Release\GestionDeCommerceInfoClasseBDDNCouches.pdb +G:\users\adrien\nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\obj\Release\GestionDeCommerceInfoClasseBDDNCouches.csproj.CoreCompileInputs.cache +G:\users\adrien\nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\obj\Release\GestionDeCommerceInfoClasseBDDNCouches.dll +G:\users\adrien\nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\obj\Release\GestionDeCommerceInfoClasseBDDNCouches.pdb +G:\users\adrien\nextcloud\iset\2IS\2IS\POO\GestionDeCommerceInfoClasseBDDNCouches\GestionDeCommerceInfoClasseBDDNCouches\obj\Release\GestionDeCommerceInfoClasseBDDNCouches.csprojResolveAssemblyReference.cache diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.csprojResolveAssemblyReference.cache b/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..da0177c Binary files /dev/null and b/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.csprojResolveAssemblyReference.cache differ diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.dll b/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.dll new file mode 100644 index 0000000..2208ba4 Binary files /dev/null and b/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.dll differ diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.pdb b/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.pdb new file mode 100644 index 0000000..bf2ad6b Binary files /dev/null and b/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/GestionDeCommerceInfoClasseBDDNCouches.pdb differ diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs b/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs new file mode 100644 index 0000000..e69de29 diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs b/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs new file mode 100644 index 0000000..e69de29 diff --git a/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs b/GestionDeCommerceInfoClasseBDDNCouches/obj/Release/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs new file mode 100644 index 0000000..e69de29 diff --git a/Nouveau dossier/A_Base.cs b/Nouveau dossier/A_Base.cs new file mode 100644 index 0000000..2fce1d0 --- /dev/null +++ b/Nouveau dossier/A_Base.cs @@ -0,0 +1,86 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +using System.Data; +using System.Data.SqlClient; +using System.Configuration; +#endregion + +namespace Projet_BD_EXEMPLE.Acces +{ + public class ADBase + { + #region Données membres + protected SqlCommand _commande; + #endregion + #region Constructeurs (étendus) + /// + /// Constructeur par défaut + /// + /// La chaîne de connexion est récupérée en argument + public ADBase(string sChaineConnexion) + { + _commande = new SqlCommand(); + _commande.Connection = new SqlConnection(sChaineConnexion); + } + /// + /// Méthode assignant une procédure stockée + /// + /// Nom de la procédure stockée + public void CreerCommande(string sCommande) + { + _commande.CommandType = CommandType.StoredProcedure; + _commande.CommandText = sCommande; + } + /// + /// Méthode assignant une procédure stockée ET une chaîne de connexion + /// + /// Nom de la procédure stockée + /// Chaîne de connexion à utiliser + public void CreerCommande(string sCommande, string sConnexion) + { + _commande.Connection = new SqlConnection(sConnexion); + _commande.CommandType = CommandType.StoredProcedure; + _commande.CommandText = sCommande; + } + /// + /// Méthode assignant une procédure stockée et le type de requête + /// + /// Nom de la procédure stockée + /// Type de requête (Vrai=stockée, Faux=Texte) + public void CreerCommande(string sCommande, bool bTypeRequete) + { + if (bTypeRequete) _commande.CommandType = CommandType.StoredProcedure; + else _commande.CommandType = CommandType.Text; + _commande.CommandText = sCommande; + } + /// + /// Méthode assignant une procédure stockée, une chaîne de connexion et le type de requête + /// + /// Nom de la procédure stockée + /// Chaîne de connexion à utiliser + /// Type de requête (Vrai=stockée, Faux=Texte) + public void CreerCommande(string sCommande, bool bTypeRequete, string sConnexion) + { + _commande.Connection = new SqlConnection(sConnexion); + if (bTypeRequete) _commande.CommandType = CommandType.StoredProcedure; + else _commande.CommandType = CommandType.Text; + _commande.CommandText = sCommande; + } + #endregion + #region Accesseurs + public SqlCommand Commande + { + get { return _commande; } + set { _commande = value; } + } + #endregion + #region Utilitaires + public void Direction(string sParam, ParameterDirection dParam) + { Commande.Parameters[sParam].Direction = dParam; } + public string LireParametre(string sParam) + { return Commande.Parameters[sParam].Value.ToString(); } + #endregion + } +} diff --git a/Nouveau dossier/A_Personne.cs b/Nouveau dossier/A_Personne.cs new file mode 100644 index 0000000..e38a663 --- /dev/null +++ b/Nouveau dossier/A_Personne.cs @@ -0,0 +1,104 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +using System.Data; +using System.Data.SqlClient; +using System.Data.SqlTypes; +using Projet_BD_EXEMPLE.Classes; +#endregion + +namespace Projet_BD_EXEMPLE.Acces +{ + /// + /// Couche d'accès aux données (Data Access Layer) + /// + public class A_Personne : ADBase + { + #region Constructeurs + public A_Personne(string sChaineConnexion) + : base(sChaineConnexion) + { } + #endregion + public int Ajouter(string NOM, string PRE, DateTime? NAI) + { + CreerCommande("AjouterPersonne"); + int res = 0; + Commande.Parameters.Add("ID", SqlDbType.Int); + Direction("ID", ParameterDirection.Output); + Commande.Parameters.AddWithValue("@NOM", NOM); + if(PRE == null) Commande.Parameters.AddWithValue("@PRE", Convert.DBNull); + else Commande.Parameters.AddWithValue("@PRE", PRE); + if(NAI == null) Commande.Parameters.AddWithValue("@NAI", Convert.DBNull); + else Commande.Parameters.AddWithValue("@NAI", NAI); + Commande.Connection.Open(); + Commande.ExecuteNonQuery(); + res = int.Parse(LireParametre("ID")); + Commande.Connection.Close(); + return res; + } + public int Modifier(int ID, string NOM, string PRE, DateTime? NAI) + { + CreerCommande("ModifierPersonne"); + int res = 0; + Commande.Parameters.AddWithValue("ID", SqlDbType.Int); + Commande.Parameters.AddWithValue("@NOM", NOM); + if(PRE == null) Commande.Parameters.AddWithValue("@PRE", Convert.DBNull); + else Commande.Parameters.AddWithValue("@PRE", PRE); + if(NAI == null) Commande.Parameters.AddWithValue("@NAI", Convert.DBNull); + else Commande.Parameters.AddWithValue("@NAI", NAI); + Commande.Connection.Open(); + Commande.ExecuteNonQuery(); + Commande.Connection.Close(); + return res; + } + public List Lire(string Index) + { + CreerCommande("SelectionnerPersonne"); + Commande.Parameters.AddWithValue("@Index", Index); + Commande.Connection.Open(); + SqlDataReader dr = Commande.ExecuteReader(); + List res = new List(); + while (dr.Read()) + { + C_Personne tmp = new C_Personne(); + tmp.ID = int.Parse(dr["ID"].ToString()); + tmp.NOM = dr["NOM"].ToString(); + tmp.PRE = dr["PRE"].ToString(); + if(dr["NAI"] != DBNull.Value) tmp.NAI = DateTime.Parse(dr["NAI"].ToString()); + res.Add(tmp); + } + dr.Close(); + Commande.Connection.Close(); + return res; + } + public C_Personne Lire_ID(int ID) + { + CreerCommande("SelectionnerPersonne_ID"); + Commande.Parameters.AddWithValue("@ID", ID); + Commande.Connection.Open(); + SqlDataReader dr = Commande.ExecuteReader(); + C_Personne res = new C_Personne(); + while (dr.Read()) + { + res.ID = int.Parse(dr["ID"].ToString()); + res.NOM = dr["NOM"].ToString(); + res.PRE = dr["PRE"].ToString(); + if(dr["NAI"] != DBNull.Value) res.NAI = DateTime.Parse(dr["NAI"].ToString()); + } + dr.Close(); + Commande.Connection.Close(); + return res; + } + public int Supprimer(int ID) + { + CreerCommande("SupprimerPersonne"); + int res = 0; + Commande.Parameters.AddWithValue("@ID", ID); + Commande.Connection.Open(); + res = Commande.ExecuteNonQuery(); + Commande.Connection.Close(); + return res; + } + } +} diff --git a/Nouveau dossier/C_Personne.cs b/Nouveau dossier/C_Personne.cs new file mode 100644 index 0000000..9297a7e --- /dev/null +++ b/Nouveau dossier/C_Personne.cs @@ -0,0 +1,58 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +#endregion + +namespace Projet_BD_EXEMPLE.Classes +{ + /// + /// Classe de définition des données + /// + public class C_Personne + { + #region Données membres + private int _ID; + private string _NOM; + private string _PRE; + private DateTime? _NAI; + #endregion + #region Constructeurs + public C_Personne() + { } + public C_Personne(string NOM_, string PRE_, DateTime? NAI_) + { + NOM = NOM_; + PRE = PRE_; + NAI = NAI_; + } + public C_Personne(int ID_, string NOM_, string PRE_, DateTime? NAI_) + : this(NOM_, PRE_, NAI_) + { + ID = ID_; + } + #endregion + #region Accesseurs + public int ID + { + get { return _ID; } + set { _ID = value; } + } + public string NOM + { + get { return _NOM; } + set { _NOM = value; } + } + public string PRE + { + get { return _PRE; } + set { _PRE = value; } + } + public DateTime? NAI + { + get { return _NAI; } + set { _NAI = value; } + } + #endregion + } +} diff --git a/Nouveau dossier/G_Base.cs b/Nouveau dossier/G_Base.cs new file mode 100644 index 0000000..1bdaf6f --- /dev/null +++ b/Nouveau dossier/G_Base.cs @@ -0,0 +1,28 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +#endregion + +namespace Projet_BD_EXEMPLE.Gestion +{ + public class G_Base + { + #region Données membres + string _ChaineConnexion; + #endregion + #region Constructeurs + public G_Base() + { ChaineConnexion = ""; } + public G_Base(string sChaineConnexion) + { ChaineConnexion = sChaineConnexion; } + #endregion + #region Accesseur + public string ChaineConnexion + { + get { return _ChaineConnexion; } + set { _ChaineConnexion = value; } + } + #endregion + } +} diff --git a/Nouveau dossier/G_Personne.cs b/Nouveau dossier/G_Personne.cs new file mode 100644 index 0000000..c7fb996 --- /dev/null +++ b/Nouveau dossier/G_Personne.cs @@ -0,0 +1,35 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +using Projet_BD_EXEMPLE.Classes; +using Projet_BD_EXEMPLE.Acces; +#endregion + +namespace Projet_BD_EXEMPLE.Gestion +{ + /// + /// Couche intermédiaire de gestion (Business Layer) + /// + public class G_Personne : G_Base + { + #region Constructeurs + public G_Personne() + : base() + { } + public G_Personne(string sChaineConnexion) + : base(sChaineConnexion) + { } + #endregion + public int Ajouter(string NOM, string PRE, DateTime? NAI) + { return new A_Personne(ChaineConnexion).Ajouter(NOM, PRE, NAI); } + public int Modifier(int ID, string NOM, string PRE, DateTime? NAI) + { return new A_Personne(ChaineConnexion).Modifier(ID, NOM, PRE, NAI); } + public List Lire(string Index) + { return new A_Personne(ChaineConnexion).Lire(Index); } + public C_Personne Lire_ID(int ID) + { return new A_Personne(ChaineConnexion).Lire_ID(ID); } + public int Supprimer(int ID) + { return new A_Personne(ChaineConnexion).Supprimer(ID); } + } +} diff --git a/Nouveau dossier/P_Personne.sql b/Nouveau dossier/P_Personne.sql new file mode 100644 index 0000000..b65d5a9 --- /dev/null +++ b/Nouveau dossier/P_Personne.sql @@ -0,0 +1,55 @@ +use [G:\USERS\ADRIEN\NEXTCLOUD\ISET\2IS\2IS\POO\BD_PERSO.MDF] +go +CREATE PROCEDURE AjouterPersonne + @ID int OUTPUT, + @NOM varchar(25), + @PRE varchar(25), + @NAI datetime +AS + INSERT INTO Personne(NOM,PRE,NAI) + VALUES(@NOM,@PRE,@NAI) + SET @ID=@@IDENTITY +RETURN +GO +CREATE PROCEDURE ModifierPersonne + @ID int, + @NOM varchar(25), + @PRE varchar(25), + @NAI datetime +AS + IF(@ID IS NULL OR @ID=0) + RAISERROR('Identifiant requis !',16,1) + ELSE UPDATE Personne + SET NOM=@NOM,PRE=@PRE,NAI=@NAI + WHERE ID=@ID +RETURN +GO +CREATE PROCEDURE SelectionnerPersonne + @Index VARCHAR(10) +AS + IF(@Index='NOM') SELECT * FROM Personne ORDER BY NOM + ELSE IF(@Index='PRE') SELECT * FROM Personne ORDER BY PRE + ELSE IF(@Index='NAI') SELECT * FROM Personne ORDER BY NAI + ELSE SELECT * FROM Personne ORDER BY ID +RETURN +GO +CREATE PROCEDURE SelectionnerPersonne_ID + @ID int +AS + IF(@ID IS NULL) + RAISERROR('Identifiant requis !',16,1) + ELSE + SELECT ID,NOM,PRE,NAI + FROM Personne + WHERE @ID=ID +RETURN +GO +CREATE PROCEDURE SupprimerPersonne + @ID int +AS + IF(@ID IS NULL) + RAISERROR('Identifiant requis !',16,1) + ELSE + DELETE FROM Personne WHERE @ID=ID +RETURN +GO diff --git a/bdd.sql b/bdd.sql new file mode 100644 index 0000000..ac135a9 Binary files /dev/null and b/bdd.sql differ diff --git a/bdd2.sql b/bdd2.sql new file mode 100644 index 0000000..caf0bc7 Binary files /dev/null and b/bdd2.sql differ diff --git a/bdd3.sql b/bdd3.sql new file mode 100644 index 0000000..8dadd5b Binary files /dev/null and b/bdd3.sql differ diff --git a/fivhier pata/A_Article.cs b/fivhier pata/A_Article.cs new file mode 100644 index 0000000..d44a2f2 --- /dev/null +++ b/fivhier pata/A_Article.cs @@ -0,0 +1,110 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +using System.Data; +using System.Data.SqlClient; +using System.Data.SqlTypes; +using Projet_GestionCommerceInfo.Classes; +#endregion + +namespace Projet_GestionCommerceInfo.Acces +{ + /// + /// Couche d'accès aux données (Data Access Layer) + /// + public class A_Article : ADBase + { + #region Constructeurs + public A_Article(string sChaineConnexion) + : base(sChaineConnexion) + { } + #endregion + public int Ajouter(string Designation, int Stock, bool Visible, bool Actif, decimal? PrixHTVA) + { + CreerCommande("AjouterArticle"); + int res = 0; + Commande.Parameters.Add("ID", SqlDbType.Int); + Direction("ID", ParameterDirection.Output); + Commande.Parameters.AddWithValue("@Designation", Designation); + Commande.Parameters.AddWithValue("@Stock", Stock); + Commande.Parameters.AddWithValue("@Visible", Visible); + Commande.Parameters.AddWithValue("@Actif", Actif); + if(PrixHTVA == null) Commande.Parameters.AddWithValue("@PrixHTVA", Convert.DBNull); + else Commande.Parameters.AddWithValue("@PrixHTVA", PrixHTVA); + Commande.Connection.Open(); + Commande.ExecuteNonQuery(); + res = int.Parse(LireParametre("ID")); + Commande.Connection.Close(); + return res; + } + public int Modifier(int ID, string Designation, int Stock, bool Visible, bool Actif, decimal? PrixHTVA) + { + CreerCommande("ModifierArticle"); + int res = 0; + Commande.Parameters.AddWithValue("@ID", ID); + Commande.Parameters.AddWithValue("@Designation", Designation); + Commande.Parameters.AddWithValue("@Stock", Stock); + Commande.Parameters.AddWithValue("@Visible", Visible); + Commande.Parameters.AddWithValue("@Actif", Actif); + if(PrixHTVA == null) Commande.Parameters.AddWithValue("@PrixHTVA", Convert.DBNull); + else Commande.Parameters.AddWithValue("@PrixHTVA", PrixHTVA); + Commande.Connection.Open(); + Commande.ExecuteNonQuery(); + Commande.Connection.Close(); + return res; + } + public List Lire(string Index) + { + CreerCommande("SelectionnerArticle"); + Commande.Parameters.AddWithValue("@Index", Index); + Commande.Connection.Open(); + SqlDataReader dr = Commande.ExecuteReader(); + List res = new List(); + while (dr.Read()) + { + C_Article tmp = new C_Article(); + tmp.ID = int.Parse(dr["ID"].ToString()); + tmp.Designation = dr["Designation"].ToString(); + tmp.Stock = int.Parse(dr["Stock"].ToString()); + tmp.Visible = bool.Parse(dr["Visible"].ToString()); + tmp.Actif = bool.Parse(dr["Actif"].ToString()); + if(dr["PrixHTVA"] != DBNull.Value) tmp.PrixHTVA = decimal.Parse(dr["PrixHTVA"].ToString()); + res.Add(tmp); + } + dr.Close(); + Commande.Connection.Close(); + return res; + } + public C_Article Lire_ID(int ID) + { + CreerCommande("SelectionnerArticle_ID"); + Commande.Parameters.AddWithValue("@ID", ID); + Commande.Connection.Open(); + SqlDataReader dr = Commande.ExecuteReader(); + C_Article res = new C_Article(); + while (dr.Read()) + { + res.ID = int.Parse(dr["ID"].ToString()); + res.Designation = dr["Designation"].ToString(); + res.Stock = int.Parse(dr["Stock"].ToString()); + res.Visible = bool.Parse(dr["Visible"].ToString()); + res.Actif = bool.Parse(dr["Actif"].ToString()); + if(dr["PrixHTVA"] != DBNull.Value) res.PrixHTVA = decimal.Parse(dr["PrixHTVA"].ToString()); + } + dr.Close(); + Commande.Connection.Close(); + return res; + } + public int Supprimer(int ID) + { + CreerCommande("SupprimerArticle"); + int res = 0; + Commande.Parameters.AddWithValue("@ID", ID); + Commande.Connection.Open(); + res = Commande.ExecuteNonQuery(); + Commande.Connection.Close(); + return res; + } + } +} diff --git a/fivhier pata/A_Base.cs b/fivhier pata/A_Base.cs new file mode 100644 index 0000000..cf43fe9 --- /dev/null +++ b/fivhier pata/A_Base.cs @@ -0,0 +1,86 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +using System.Data; +using System.Data.SqlClient; +using System.Configuration; +#endregion + +namespace Projet_GestionCommerceInfo.Acces +{ + public class ADBase + { + #region Données membres + protected SqlCommand _commande; + #endregion + #region Constructeurs (étendus) + /// + /// Constructeur par défaut + /// + /// La chaîne de connexion est récupérée en argument + public ADBase(string sChaineConnexion) + { + _commande = new SqlCommand(); + _commande.Connection = new SqlConnection(sChaineConnexion); + } + /// + /// Méthode assignant une procédure stockée + /// + /// Nom de la procédure stockée + public void CreerCommande(string sCommande) + { + _commande.CommandType = CommandType.StoredProcedure; + _commande.CommandText = sCommande; + } + /// + /// Méthode assignant une procédure stockée ET une chaîne de connexion + /// + /// Nom de la procédure stockée + /// Chaîne de connexion à utiliser + public void CreerCommande(string sCommande, string sConnexion) + { + _commande.Connection = new SqlConnection(sConnexion); + _commande.CommandType = CommandType.StoredProcedure; + _commande.CommandText = sCommande; + } + /// + /// Méthode assignant une procédure stockée et le type de requête + /// + /// Nom de la procédure stockée + /// Type de requête (Vrai=stockée, Faux=Texte) + public void CreerCommande(string sCommande, bool bTypeRequete) + { + if (bTypeRequete) _commande.CommandType = CommandType.StoredProcedure; + else _commande.CommandType = CommandType.Text; + _commande.CommandText = sCommande; + } + /// + /// Méthode assignant une procédure stockée, une chaîne de connexion et le type de requête + /// + /// Nom de la procédure stockée + /// Chaîne de connexion à utiliser + /// Type de requête (Vrai=stockée, Faux=Texte) + public void CreerCommande(string sCommande, bool bTypeRequete, string sConnexion) + { + _commande.Connection = new SqlConnection(sConnexion); + if (bTypeRequete) _commande.CommandType = CommandType.StoredProcedure; + else _commande.CommandType = CommandType.Text; + _commande.CommandText = sCommande; + } + #endregion + #region Accesseurs + public SqlCommand Commande + { + get { return _commande; } + set { _commande = value; } + } + #endregion + #region Utilitaires + public void Direction(string sParam, ParameterDirection dParam) + { Commande.Parameters[sParam].Direction = dParam; } + public string LireParametre(string sParam) + { return Commande.Parameters[sParam].Value.ToString(); } + #endregion + } +} diff --git a/fivhier pata/A_LSTArticle.cs b/fivhier pata/A_LSTArticle.cs new file mode 100644 index 0000000..dbf0fe7 --- /dev/null +++ b/fivhier pata/A_LSTArticle.cs @@ -0,0 +1,112 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +using System.Data; +using System.Data.SqlClient; +using System.Data.SqlTypes; +using Projet_GestionCommerceInfo.Classes; +#endregion + +namespace Projet_GestionCommerceInfo.Acces +{ + /// + /// Couche d'accès aux données (Data Access Layer) + /// + public class A_LSTArticle : ADBase + { + #region Constructeurs + public A_LSTArticle(string sChaineConnexion) + : base(sChaineConnexion) + { } + #endregion + public int Ajouter(int PanierID, int ArticleID, int Quantite, decimal? PrixHTVA, int? TVA) + { + CreerCommande("AjouterLSTArticle"); + int res = 0; + Commande.Parameters.Add("ID", SqlDbType.Int); + Direction("ID", ParameterDirection.Output); + Commande.Parameters.AddWithValue("@PanierID", PanierID); + Commande.Parameters.AddWithValue("@ArticleID", ArticleID); + Commande.Parameters.AddWithValue("@Quantite", Quantite); + if(PrixHTVA == null) Commande.Parameters.AddWithValue("@PrixHTVA", Convert.DBNull); + else Commande.Parameters.AddWithValue("@PrixHTVA", PrixHTVA); + if(TVA == null) Commande.Parameters.AddWithValue("@TVA", Convert.DBNull); + else Commande.Parameters.AddWithValue("@TVA", TVA); + Commande.Connection.Open(); + Commande.ExecuteNonQuery(); + res = int.Parse(LireParametre("ID")); + Commande.Connection.Close(); + return res; + } + public int Modifier(int ID, int PanierID, int ArticleID, int Quantite, decimal? PrixHTVA, int? TVA) + { + CreerCommande("ModifierLSTArticle"); + int res = 0; + Commande.Parameters.AddWithValue("@ID", ID); + Commande.Parameters.AddWithValue("@PanierID", PanierID); + Commande.Parameters.AddWithValue("@ArticleID", ArticleID); + Commande.Parameters.AddWithValue("@Quantite", Quantite); + if(PrixHTVA == null) Commande.Parameters.AddWithValue("@PrixHTVA", Convert.DBNull); + else Commande.Parameters.AddWithValue("@PrixHTVA", PrixHTVA); + if(TVA == null) Commande.Parameters.AddWithValue("@TVA", Convert.DBNull); + else Commande.Parameters.AddWithValue("@TVA", TVA); + Commande.Connection.Open(); + Commande.ExecuteNonQuery(); + Commande.Connection.Close(); + return res; + } + public List Lire(string Index) + { + CreerCommande("SelectionnerLSTArticle"); + Commande.Parameters.AddWithValue("@Index", Index); + Commande.Connection.Open(); + SqlDataReader dr = Commande.ExecuteReader(); + List res = new List(); + while (dr.Read()) + { + C_LSTArticle tmp = new C_LSTArticle(); + tmp.ID = int.Parse(dr["ID"].ToString()); + tmp.PanierID = int.Parse(dr["PanierID"].ToString()); + tmp.ArticleID = int.Parse(dr["ArticleID"].ToString()); + tmp.Quantite = int.Parse(dr["Quantite"].ToString()); + if(dr["PrixHTVA"] != DBNull.Value) tmp.PrixHTVA = decimal.Parse(dr["PrixHTVA"].ToString()); + if(dr["TVA"] != DBNull.Value) tmp.TVA = int.Parse(dr["TVA"].ToString()); + res.Add(tmp); + } + dr.Close(); + Commande.Connection.Close(); + return res; + } + public C_LSTArticle Lire_ID(int ID) + { + CreerCommande("SelectionnerLSTArticle_ID"); + Commande.Parameters.AddWithValue("@ID", ID); + Commande.Connection.Open(); + SqlDataReader dr = Commande.ExecuteReader(); + C_LSTArticle res = new C_LSTArticle(); + while (dr.Read()) + { + res.ID = int.Parse(dr["ID"].ToString()); + res.PanierID = int.Parse(dr["PanierID"].ToString()); + res.ArticleID = int.Parse(dr["ArticleID"].ToString()); + res.Quantite = int.Parse(dr["Quantite"].ToString()); + if(dr["PrixHTVA"] != DBNull.Value) res.PrixHTVA = decimal.Parse(dr["PrixHTVA"].ToString()); + if(dr["TVA"] != DBNull.Value) res.TVA = int.Parse(dr["TVA"].ToString()); + } + dr.Close(); + Commande.Connection.Close(); + return res; + } + public int Supprimer(int ID) + { + CreerCommande("SupprimerLSTArticle"); + int res = 0; + Commande.Parameters.AddWithValue("@ID", ID); + Commande.Connection.Open(); + res = Commande.ExecuteNonQuery(); + Commande.Connection.Close(); + return res; + } + } +} diff --git a/fivhier pata/A_Panier.cs b/fivhier pata/A_Panier.cs new file mode 100644 index 0000000..04ba9f6 --- /dev/null +++ b/fivhier pata/A_Panier.cs @@ -0,0 +1,114 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +using System.Data; +using System.Data.SqlClient; +using System.Data.SqlTypes; +using Projet_GestionCommerceInfo.Classes; +#endregion + +namespace Projet_GestionCommerceInfo.Acces +{ + /// + /// Couche d'accès aux données (Data Access Layer) + /// + public class A_Panier : ADBase + { + #region Constructeurs + public A_Panier(string sChaineConnexion) + : base(sChaineConnexion) + { } + #endregion + public int Ajouter(int UserId, string Nom, int? Status, DateTime? DateAchat, int Type) + { + CreerCommande("AjouterPanier"); + int res = 0; + Commande.Parameters.Add("ID", SqlDbType.Int); + Direction("ID", ParameterDirection.Output); + Commande.Parameters.AddWithValue("@UserId", UserId); + if(Nom == null) Commande.Parameters.AddWithValue("@Nom", Convert.DBNull); + else Commande.Parameters.AddWithValue("@Nom", Nom); + if(Status == null) Commande.Parameters.AddWithValue("@Status", Convert.DBNull); + else Commande.Parameters.AddWithValue("@Status", Status); + if(DateAchat == null) Commande.Parameters.AddWithValue("@DateAchat", Convert.DBNull); + else Commande.Parameters.AddWithValue("@DateAchat", DateAchat); + Commande.Parameters.AddWithValue("@Type", Type); + Commande.Connection.Open(); + Commande.ExecuteNonQuery(); + res = int.Parse(LireParametre("ID")); + Commande.Connection.Close(); + return res; + } + public int Modifier(int ID, int UserId, string Nom, int? Status, DateTime? DateAchat, int Type) + { + CreerCommande("ModifierPanier"); + int res = 0; + Commande.Parameters.AddWithValue("@ID", ID); + Commande.Parameters.AddWithValue("@UserId", UserId); + if(Nom == null) Commande.Parameters.AddWithValue("@Nom", Convert.DBNull); + else Commande.Parameters.AddWithValue("@Nom", Nom); + if(Status == null) Commande.Parameters.AddWithValue("@Status", Convert.DBNull); + else Commande.Parameters.AddWithValue("@Status", Status); + if(DateAchat == null) Commande.Parameters.AddWithValue("@DateAchat", Convert.DBNull); + else Commande.Parameters.AddWithValue("@DateAchat", DateAchat); + Commande.Parameters.AddWithValue("@Type", Type); + Commande.Connection.Open(); + Commande.ExecuteNonQuery(); + Commande.Connection.Close(); + return res; + } + public List Lire(string Index) + { + CreerCommande("SelectionnerPanier"); + Commande.Parameters.AddWithValue("@Index", Index); + Commande.Connection.Open(); + SqlDataReader dr = Commande.ExecuteReader(); + List res = new List(); + while (dr.Read()) + { + C_Panier tmp = new C_Panier(); + tmp.ID = int.Parse(dr["ID"].ToString()); + tmp.UserId = int.Parse(dr["UserId"].ToString()); + tmp.Nom = dr["Nom"].ToString(); + if(dr["Status"] != DBNull.Value) tmp.Status = int.Parse(dr["Status"].ToString()); + if(dr["DateAchat"] != DBNull.Value) tmp.DateAchat = DateTime.Parse(dr["DateAchat"].ToString()); + tmp.Type = int.Parse(dr["Type"].ToString()); + res.Add(tmp); + } + dr.Close(); + Commande.Connection.Close(); + return res; + } + public C_Panier Lire_ID(int ID) + { + CreerCommande("SelectionnerPanier_ID"); + Commande.Parameters.AddWithValue("@ID", ID); + Commande.Connection.Open(); + SqlDataReader dr = Commande.ExecuteReader(); + C_Panier res = new C_Panier(); + while (dr.Read()) + { + res.ID = int.Parse(dr["ID"].ToString()); + res.UserId = int.Parse(dr["UserId"].ToString()); + res.Nom = dr["Nom"].ToString(); + if(dr["Status"] != DBNull.Value) res.Status = int.Parse(dr["Status"].ToString()); + if(dr["DateAchat"] != DBNull.Value) res.DateAchat = DateTime.Parse(dr["DateAchat"].ToString()); + res.Type = int.Parse(dr["Type"].ToString()); + } + dr.Close(); + Commande.Connection.Close(); + return res; + } + public int Supprimer(int ID) + { + CreerCommande("SupprimerPanier"); + int res = 0; + Commande.Parameters.AddWithValue("@ID", ID); + Commande.Connection.Open(); + res = Commande.ExecuteNonQuery(); + Commande.Connection.Close(); + return res; + } + } +} diff --git a/fivhier pata/A_Utilisateur.cs b/fivhier pata/A_Utilisateur.cs new file mode 100644 index 0000000..8bd2ad3 --- /dev/null +++ b/fivhier pata/A_Utilisateur.cs @@ -0,0 +1,130 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +using System.Data; +using System.Data.SqlClient; +using System.Data.SqlTypes; +using Projet_GestionCommerceInfo.Classes; +#endregion + +namespace Projet_GestionCommerceInfo.Acces +{ + /// + /// Couche d'accès aux données (Data Access Layer) + /// + public class A_Utilisateur : ADBase + { + #region Constructeurs + public A_Utilisateur(string sChaineConnexion) + : base(sChaineConnexion) + { } + #endregion + public int Ajouter(string Nom, string Prenom, string Adresse, string NCompte, DateTime? DateDeNaisance, int type, bool Actif, string email) + { + CreerCommande("AjouterUtilisateur"); + int res = 0; + Commande.Parameters.Add("ID", SqlDbType.Int); + Direction("ID", ParameterDirection.Output); + if(Nom == null) Commande.Parameters.AddWithValue("@Nom", Convert.DBNull); + else Commande.Parameters.AddWithValue("@Nom", Nom); + if(Prenom == null) Commande.Parameters.AddWithValue("@Prenom", Convert.DBNull); + else Commande.Parameters.AddWithValue("@Prenom", Prenom); + if(Adresse == null) Commande.Parameters.AddWithValue("@Adresse", Convert.DBNull); + else Commande.Parameters.AddWithValue("@Adresse", Adresse); + if(NCompte == null) Commande.Parameters.AddWithValue("@NCompte", Convert.DBNull); + else Commande.Parameters.AddWithValue("@NCompte", NCompte); + if(DateDeNaisance == null) Commande.Parameters.AddWithValue("@DateDeNaisance", Convert.DBNull); + else Commande.Parameters.AddWithValue("@DateDeNaisance", DateDeNaisance); + Commande.Parameters.AddWithValue("@type", type); + Commande.Parameters.AddWithValue("@Actif", Actif); + Commande.Parameters.AddWithValue("@email", email); + Commande.Connection.Open(); + Commande.ExecuteNonQuery(); + res = int.Parse(LireParametre("ID")); + Commande.Connection.Close(); + return res; + } + public int Modifier(int ID, string Nom, string Prenom, string Adresse, string NCompte, DateTime? DateDeNaisance, int type, bool Actif, string email) + { + CreerCommande("ModifierUtilisateur"); + int res = 0; + Commande.Parameters.AddWithValue("@ID", ID); + if(Nom == null) Commande.Parameters.AddWithValue("@Nom", Convert.DBNull); + else Commande.Parameters.AddWithValue("@Nom", Nom); + if(Prenom == null) Commande.Parameters.AddWithValue("@Prenom", Convert.DBNull); + else Commande.Parameters.AddWithValue("@Prenom", Prenom); + if(Adresse == null) Commande.Parameters.AddWithValue("@Adresse", Convert.DBNull); + else Commande.Parameters.AddWithValue("@Adresse", Adresse); + if(NCompte == null) Commande.Parameters.AddWithValue("@NCompte", Convert.DBNull); + else Commande.Parameters.AddWithValue("@NCompte", NCompte); + if(DateDeNaisance == null) Commande.Parameters.AddWithValue("@DateDeNaisance", Convert.DBNull); + else Commande.Parameters.AddWithValue("@DateDeNaisance", DateDeNaisance); + Commande.Parameters.AddWithValue("@type", type); + Commande.Parameters.AddWithValue("@Actif", Actif); + Commande.Parameters.AddWithValue("@email", email); + Commande.Connection.Open(); + Commande.ExecuteNonQuery(); + Commande.Connection.Close(); + return res; + } + public List Lire(string Index) + { + CreerCommande("SelectionnerUtilisateur"); + Commande.Parameters.AddWithValue("@Index", Index); + Commande.Connection.Open(); + SqlDataReader dr = Commande.ExecuteReader(); + List res = new List(); + while (dr.Read()) + { + C_Utilisateur tmp = new C_Utilisateur(); + tmp.ID = int.Parse(dr["ID"].ToString()); + tmp.Nom = dr["Nom"].ToString(); + tmp.Prenom = dr["Prenom"].ToString(); + tmp.Adresse = dr["Adresse"].ToString(); + tmp.NCompte = dr["NCompte"].ToString(); + if(dr["DateDeNaisance"] != DBNull.Value) tmp.DateDeNaisance = DateTime.Parse(dr["DateDeNaisance"].ToString()); + tmp.type = int.Parse(dr["type"].ToString()); + tmp.Actif = bool.Parse(dr["Actif"].ToString()); + tmp.email = dr["email"].ToString(); + res.Add(tmp); + } + dr.Close(); + Commande.Connection.Close(); + return res; + } + public C_Utilisateur Lire_ID(int ID) + { + CreerCommande("SelectionnerUtilisateur_ID"); + Commande.Parameters.AddWithValue("@ID", ID); + Commande.Connection.Open(); + SqlDataReader dr = Commande.ExecuteReader(); + C_Utilisateur res = new C_Utilisateur(); + while (dr.Read()) + { + res.ID = int.Parse(dr["ID"].ToString()); + res.Nom = dr["Nom"].ToString(); + res.Prenom = dr["Prenom"].ToString(); + res.Adresse = dr["Adresse"].ToString(); + res.NCompte = dr["NCompte"].ToString(); + if(dr["DateDeNaisance"] != DBNull.Value) res.DateDeNaisance = DateTime.Parse(dr["DateDeNaisance"].ToString()); + res.type = int.Parse(dr["type"].ToString()); + res.Actif = bool.Parse(dr["Actif"].ToString()); + res.email = dr["email"].ToString(); + } + dr.Close(); + Commande.Connection.Close(); + return res; + } + public int Supprimer(int ID) + { + CreerCommande("SupprimerUtilisateur"); + int res = 0; + Commande.Parameters.AddWithValue("@ID", ID); + Commande.Connection.Open(); + res = Commande.ExecuteNonQuery(); + Commande.Connection.Close(); + return res; + } + } +} diff --git a/fivhier pata/C_Article.cs b/fivhier pata/C_Article.cs new file mode 100644 index 0000000..c972e6b --- /dev/null +++ b/fivhier pata/C_Article.cs @@ -0,0 +1,72 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +#endregion + +namespace Projet_GestionCommerceInfo.Classes +{ + /// + /// Classe de définition des données + /// + public class C_Article + { + #region Données membres + private int _ID; + private string _Designation; + private int _Stock; + private bool _Visible; + private bool _Actif; + private decimal? _PrixHTVA; + #endregion + #region Constructeurs + public C_Article() + { } + public C_Article(string Designation_, int Stock_, bool Visible_, bool Actif_, decimal? PrixHTVA_) + { + Designation = Designation_; + Stock = Stock_; + Visible = Visible_; + Actif = Actif_; + PrixHTVA = PrixHTVA_; + } + public C_Article(int ID_, string Designation_, int Stock_, bool Visible_, bool Actif_, decimal? PrixHTVA_) + : this(Designation_, Stock_, Visible_, Actif_, PrixHTVA_) + { + ID = ID_; + } + #endregion + #region Accesseurs + public int ID + { + get { return _ID; } + set { _ID = value; } + } + public string Designation + { + get { return _Designation; } + set { _Designation = value; } + } + public int Stock + { + get { return _Stock; } + set { _Stock = value; } + } + public bool Visible + { + get { return _Visible; } + set { _Visible = value; } + } + public bool Actif + { + get { return _Actif; } + set { _Actif = value; } + } + public decimal? PrixHTVA + { + get { return _PrixHTVA; } + set { _PrixHTVA = value; } + } + #endregion + } +} diff --git a/fivhier pata/C_LSTArticle.cs b/fivhier pata/C_LSTArticle.cs new file mode 100644 index 0000000..6446299 --- /dev/null +++ b/fivhier pata/C_LSTArticle.cs @@ -0,0 +1,72 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +#endregion + +namespace Projet_GestionCommerceInfo.Classes +{ + /// + /// Classe de définition des données + /// + public class C_LSTArticle + { + #region Données membres + private int _ID; + private int _PanierID; + private int _ArticleID; + private int _Quantite; + private decimal? _PrixHTVA; + private int? _TVA; + #endregion + #region Constructeurs + public C_LSTArticle() + { } + public C_LSTArticle(int PanierID_, int ArticleID_, int Quantite_, decimal? PrixHTVA_, int? TVA_) + { + PanierID = PanierID_; + ArticleID = ArticleID_; + Quantite = Quantite_; + PrixHTVA = PrixHTVA_; + TVA = TVA_; + } + public C_LSTArticle(int ID_, int PanierID_, int ArticleID_, int Quantite_, decimal? PrixHTVA_, int? TVA_) + : this(PanierID_, ArticleID_, Quantite_, PrixHTVA_, TVA_) + { + ID = ID_; + } + #endregion + #region Accesseurs + public int ID + { + get { return _ID; } + set { _ID = value; } + } + public int PanierID + { + get { return _PanierID; } + set { _PanierID = value; } + } + public int ArticleID + { + get { return _ArticleID; } + set { _ArticleID = value; } + } + public int Quantite + { + get { return _Quantite; } + set { _Quantite = value; } + } + public decimal? PrixHTVA + { + get { return _PrixHTVA; } + set { _PrixHTVA = value; } + } + public int? TVA + { + get { return _TVA; } + set { _TVA = value; } + } + #endregion + } +} diff --git a/fivhier pata/C_Panier.cs b/fivhier pata/C_Panier.cs new file mode 100644 index 0000000..1f02167 --- /dev/null +++ b/fivhier pata/C_Panier.cs @@ -0,0 +1,72 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +#endregion + +namespace Projet_GestionCommerceInfo.Classes +{ + /// + /// Classe de définition des données + /// + public class C_Panier + { + #region Données membres + private int _ID; + private int _UserId; + private string _Nom; + private int? _Status; + private DateTime? _DateAchat; + private int _Type; + #endregion + #region Constructeurs + public C_Panier() + { } + public C_Panier(int UserId_, string Nom_, int? Status_, DateTime? DateAchat_, int Type_) + { + UserId = UserId_; + Nom = Nom_; + Status = Status_; + DateAchat = DateAchat_; + Type = Type_; + } + public C_Panier(int ID_, int UserId_, string Nom_, int? Status_, DateTime? DateAchat_, int Type_) + : this(UserId_, Nom_, Status_, DateAchat_, Type_) + { + ID = ID_; + } + #endregion + #region Accesseurs + public int ID + { + get { return _ID; } + set { _ID = value; } + } + public int UserId + { + get { return _UserId; } + set { _UserId = value; } + } + public string Nom + { + get { return _Nom; } + set { _Nom = value; } + } + public int? Status + { + get { return _Status; } + set { _Status = value; } + } + public DateTime? DateAchat + { + get { return _DateAchat; } + set { _DateAchat = value; } + } + public int Type + { + get { return _Type; } + set { _Type = value; } + } + #endregion + } +} diff --git a/fivhier pata/C_Utilisateur.cs b/fivhier pata/C_Utilisateur.cs new file mode 100644 index 0000000..22e1f03 --- /dev/null +++ b/fivhier pata/C_Utilisateur.cs @@ -0,0 +1,93 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +#endregion + +namespace Projet_GestionCommerceInfo.Classes +{ + /// + /// Classe de définition des données + /// + public class C_Utilisateur + { + #region Données membres + private int _ID; + private string _Nom; + private string _Prenom; + private string _Adresse; + private string _NCompte; + private DateTime? _DateDeNaisance; + private int _type; + private bool _Actif; + private string _email; + #endregion + #region Constructeurs + public C_Utilisateur() + { } + public C_Utilisateur(string Nom_, string Prenom_, string Adresse_, string NCompte_, DateTime? DateDeNaisance_, int type_, bool Actif_, string email_) + { + Nom = Nom_; + Prenom = Prenom_; + Adresse = Adresse_; + NCompte = NCompte_; + DateDeNaisance = DateDeNaisance_; + type = type_; + Actif = Actif_; + email = email_; + } + public C_Utilisateur(int ID_, string Nom_, string Prenom_, string Adresse_, string NCompte_, DateTime? DateDeNaisance_, int type_, bool Actif_, string email_) + : this(Nom_, Prenom_, Adresse_, NCompte_, DateDeNaisance_, type_, Actif_, email_) + { + ID = ID_; + } + #endregion + #region Accesseurs + public int ID + { + get { return _ID; } + set { _ID = value; } + } + public string Nom + { + get { return _Nom; } + set { _Nom = value; } + } + public string Prenom + { + get { return _Prenom; } + set { _Prenom = value; } + } + public string Adresse + { + get { return _Adresse; } + set { _Adresse = value; } + } + public string NCompte + { + get { return _NCompte; } + set { _NCompte = value; } + } + public DateTime? DateDeNaisance + { + get { return _DateDeNaisance; } + set { _DateDeNaisance = value; } + } + public int type + { + get { return _type; } + set { _type = value; } + } + public bool Actif + { + get { return _Actif; } + set { _Actif = value; } + } + public string email + { + get { return _email; } + set { _email = value; } + } + #endregion + } +} diff --git a/fivhier pata/G_Article.cs b/fivhier pata/G_Article.cs new file mode 100644 index 0000000..3f7f5fc --- /dev/null +++ b/fivhier pata/G_Article.cs @@ -0,0 +1,35 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +using Projet_GestionCommerceInfo.Classes; +using Projet_GestionCommerceInfo.Acces; +#endregion + +namespace Projet_GestionCommerceInfo.Gestion +{ + /// + /// Couche intermédiaire de gestion (Business Layer) + /// + public class G_Article : G_Base + { + #region Constructeurs + public G_Article() + : base() + { } + public G_Article(string sChaineConnexion) + : base(sChaineConnexion) + { } + #endregion + public int Ajouter(string Designation, int Stock, bool Visible, bool Actif, decimal? PrixHTVA) + { return new A_Article(ChaineConnexion).Ajouter(Designation, Stock, Visible, Actif, PrixHTVA); } + public int Modifier(int ID, string Designation, int Stock, bool Visible, bool Actif, decimal? PrixHTVA) + { return new A_Article(ChaineConnexion).Modifier(ID, Designation, Stock, Visible, Actif, PrixHTVA); } + public List Lire(string Index) + { return new A_Article(ChaineConnexion).Lire(Index); } + public C_Article Lire_ID(int ID) + { return new A_Article(ChaineConnexion).Lire_ID(ID); } + public int Supprimer(int ID) + { return new A_Article(ChaineConnexion).Supprimer(ID); } + } +} diff --git a/fivhier pata/G_Base.cs b/fivhier pata/G_Base.cs new file mode 100644 index 0000000..4d505e4 --- /dev/null +++ b/fivhier pata/G_Base.cs @@ -0,0 +1,28 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +#endregion + +namespace Projet_GestionCommerceInfo.Gestion +{ + public class G_Base + { + #region Données membres + string _ChaineConnexion; + #endregion + #region Constructeurs + public G_Base() + { ChaineConnexion = ""; } + public G_Base(string sChaineConnexion) + { ChaineConnexion = sChaineConnexion; } + #endregion + #region Accesseur + public string ChaineConnexion + { + get { return _ChaineConnexion; } + set { _ChaineConnexion = value; } + } + #endregion + } +} diff --git a/fivhier pata/G_LSTArticle.cs b/fivhier pata/G_LSTArticle.cs new file mode 100644 index 0000000..37d6bc2 --- /dev/null +++ b/fivhier pata/G_LSTArticle.cs @@ -0,0 +1,35 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +using Projet_GestionCommerceInfo.Classes; +using Projet_GestionCommerceInfo.Acces; +#endregion + +namespace Projet_GestionCommerceInfo.Gestion +{ + /// + /// Couche intermédiaire de gestion (Business Layer) + /// + public class G_LSTArticle : G_Base + { + #region Constructeurs + public G_LSTArticle() + : base() + { } + public G_LSTArticle(string sChaineConnexion) + : base(sChaineConnexion) + { } + #endregion + public int Ajouter(int PanierID, int ArticleID, int Quantite, decimal? PrixHTVA, int? TVA) + { return new A_LSTArticle(ChaineConnexion).Ajouter(PanierID, ArticleID, Quantite, PrixHTVA, TVA); } + public int Modifier(int ID, int PanierID, int ArticleID, int Quantite, decimal? PrixHTVA, int? TVA) + { return new A_LSTArticle(ChaineConnexion).Modifier(ID, PanierID, ArticleID, Quantite, PrixHTVA, TVA); } + public List Lire(string Index) + { return new A_LSTArticle(ChaineConnexion).Lire(Index); } + public C_LSTArticle Lire_ID(int ID) + { return new A_LSTArticle(ChaineConnexion).Lire_ID(ID); } + public int Supprimer(int ID) + { return new A_LSTArticle(ChaineConnexion).Supprimer(ID); } + } +} diff --git a/fivhier pata/G_Panier.cs b/fivhier pata/G_Panier.cs new file mode 100644 index 0000000..95e337d --- /dev/null +++ b/fivhier pata/G_Panier.cs @@ -0,0 +1,35 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +using Projet_GestionCommerceInfo.Classes; +using Projet_GestionCommerceInfo.Acces; +#endregion + +namespace Projet_GestionCommerceInfo.Gestion +{ + /// + /// Couche intermédiaire de gestion (Business Layer) + /// + public class G_Panier : G_Base + { + #region Constructeurs + public G_Panier() + : base() + { } + public G_Panier(string sChaineConnexion) + : base(sChaineConnexion) + { } + #endregion + public int Ajouter(int UserId, string Nom, int? Status, DateTime? DateAchat, int Type) + { return new A_Panier(ChaineConnexion).Ajouter(UserId, Nom, Status, DateAchat, Type); } + public int Modifier(int ID, int UserId, string Nom, int? Status, DateTime? DateAchat, int Type) + { return new A_Panier(ChaineConnexion).Modifier(ID, UserId, Nom, Status, DateAchat, Type); } + public List Lire(string Index) + { return new A_Panier(ChaineConnexion).Lire(Index); } + public C_Panier Lire_ID(int ID) + { return new A_Panier(ChaineConnexion).Lire_ID(ID); } + public int Supprimer(int ID) + { return new A_Panier(ChaineConnexion).Supprimer(ID); } + } +} diff --git a/fivhier pata/G_Utilisateur.cs b/fivhier pata/G_Utilisateur.cs new file mode 100644 index 0000000..88e5875 --- /dev/null +++ b/fivhier pata/G_Utilisateur.cs @@ -0,0 +1,35 @@ +#region Ressources extérieures +using System; +using System.Collections.Generic; +using System.Text; +using Projet_GestionCommerceInfo.Classes; +using Projet_GestionCommerceInfo.Acces; +#endregion + +namespace Projet_GestionCommerceInfo.Gestion +{ + /// + /// Couche intermédiaire de gestion (Business Layer) + /// + public class G_Utilisateur : G_Base + { + #region Constructeurs + public G_Utilisateur() + : base() + { } + public G_Utilisateur(string sChaineConnexion) + : base(sChaineConnexion) + { } + #endregion + public int Ajouter(string Nom, string Prenom, string Adresse, string NCompte, DateTime? DateDeNaisance, int type, bool Actif, string email) + { return new A_Utilisateur(ChaineConnexion).Ajouter(Nom, Prenom, Adresse, NCompte, DateDeNaisance, type, Actif, email); } + public int Modifier(int ID, string Nom, string Prenom, string Adresse, string NCompte, DateTime? DateDeNaisance, int type, bool Actif, string email) + { return new A_Utilisateur(ChaineConnexion).Modifier(ID, Nom, Prenom, Adresse, NCompte, DateDeNaisance, type, Actif, email); } + public List Lire(string Index) + { return new A_Utilisateur(ChaineConnexion).Lire(Index); } + public C_Utilisateur Lire_ID(int ID) + { return new A_Utilisateur(ChaineConnexion).Lire_ID(ID); } + public int Supprimer(int ID) + { return new A_Utilisateur(ChaineConnexion).Supprimer(ID); } + } +} diff --git a/fivhier pata/P_Article.sql b/fivhier pata/P_Article.sql new file mode 100644 index 0000000..a078ff4 --- /dev/null +++ b/fivhier pata/P_Article.sql @@ -0,0 +1,59 @@ +CREATE PROCEDURE AjouterArticle + @ID int OUTPUT, + @Designation varchar(50), + @Stock int, + @Visible bit, + @Actif bit, + @PrixHTVA money +AS + INSERT INTO Article(Designation,Stock,Visible,Actif,PrixHTVA) + VALUES(@Designation,@Stock,@Visible,@Actif,@PrixHTVA) + SET @ID=@@IDENTITY +RETURN +GO +CREATE PROCEDURE ModifierArticle + @ID int, + @Designation varchar(50), + @Stock int, + @Visible bit, + @Actif bit, + @PrixHTVA money +AS + IF(@ID IS NULL OR @ID=0) + RAISERROR('Identifiant requis !',16,1) + ELSE UPDATE Article + SET Designation=@Designation,Stock=@Stock,Visible=@Visible,Actif=@Actif,PrixHTVA=@PrixHTVA + WHERE ID=@ID +RETURN +GO +CREATE PROCEDURE SelectionnerArticle + @Index VARCHAR(10) +AS + IF(@Index='Designation') SELECT * FROM Article ORDER BY Designation + ELSE IF(@Index='Stock') SELECT * FROM Article ORDER BY Stock + ELSE IF(@Index='Visible') SELECT * FROM Article ORDER BY Visible + ELSE IF(@Index='Actif') SELECT * FROM Article ORDER BY Actif + ELSE IF(@Index='PrixHTVA') SELECT * FROM Article ORDER BY PrixHTVA + ELSE SELECT * FROM Article ORDER BY ID +RETURN +GO +CREATE PROCEDURE SelectionnerArticle_ID + @ID int +AS + IF(@ID IS NULL) + RAISERROR('Identifiant requis !',16,1) + ELSE + SELECT ID,Designation,Stock,Visible,Actif,PrixHTVA + FROM Article + WHERE @ID=ID +RETURN +GO +CREATE PROCEDURE SupprimerArticle + @ID int +AS + IF(@ID IS NULL) + RAISERROR('Identifiant requis !',16,1) + ELSE + DELETE FROM Article WHERE @ID=ID +RETURN +GO diff --git a/fivhier pata/P_LSTArticle.sql b/fivhier pata/P_LSTArticle.sql new file mode 100644 index 0000000..3883071 --- /dev/null +++ b/fivhier pata/P_LSTArticle.sql @@ -0,0 +1,59 @@ +CREATE PROCEDURE AjouterLSTArticle + @ID int OUTPUT, + @PanierID int, + @ArticleID int, + @Quantite int, + @PrixHTVA money, + @TVA int +AS + INSERT INTO LSTArticle(PanierID,ArticleID,Quantite,PrixHTVA,TVA) + VALUES(@PanierID,@ArticleID,@Quantite,@PrixHTVA,@TVA) + SET @ID=@@IDENTITY +RETURN +GO +CREATE PROCEDURE ModifierLSTArticle + @ID int, + @PanierID int, + @ArticleID int, + @Quantite int, + @PrixHTVA money, + @TVA int +AS + IF(@ID IS NULL OR @ID=0) + RAISERROR('Identifiant requis !',16,1) + ELSE UPDATE LSTArticle + SET PanierID=@PanierID,ArticleID=@ArticleID,Quantite=@Quantite,PrixHTVA=@PrixHTVA,TVA=@TVA + WHERE ID=@ID +RETURN +GO +CREATE PROCEDURE SelectionnerLSTArticle + @Index VARCHAR(10) +AS + IF(@Index='PanierID') SELECT * FROM LSTArticle ORDER BY PanierID + ELSE IF(@Index='ArticleID') SELECT * FROM LSTArticle ORDER BY ArticleID + ELSE IF(@Index='Quantite') SELECT * FROM LSTArticle ORDER BY Quantite + ELSE IF(@Index='PrixHTVA') SELECT * FROM LSTArticle ORDER BY PrixHTVA + ELSE IF(@Index='TVA') SELECT * FROM LSTArticle ORDER BY TVA + ELSE SELECT * FROM LSTArticle ORDER BY ID +RETURN +GO +CREATE PROCEDURE SelectionnerLSTArticle_ID + @ID int +AS + IF(@ID IS NULL) + RAISERROR('Identifiant requis !',16,1) + ELSE + SELECT ID,PanierID,ArticleID,Quantite,PrixHTVA,TVA + FROM LSTArticle + WHERE @ID=ID +RETURN +GO +CREATE PROCEDURE SupprimerLSTArticle + @ID int +AS + IF(@ID IS NULL) + RAISERROR('Identifiant requis !',16,1) + ELSE + DELETE FROM LSTArticle WHERE @ID=ID +RETURN +GO diff --git a/fivhier pata/P_Panier.sql b/fivhier pata/P_Panier.sql new file mode 100644 index 0000000..4581682 --- /dev/null +++ b/fivhier pata/P_Panier.sql @@ -0,0 +1,59 @@ +CREATE PROCEDURE AjouterPanier + @ID int OUTPUT, + @UserId int, + @Nom varchar(50), + @Status int, + @DateAchat datetime, + @Type int +AS + INSERT INTO Panier(UserId,Nom,Status,DateAchat,Type) + VALUES(@UserId,@Nom,@Status,@DateAchat,@Type) + SET @ID=@@IDENTITY +RETURN +GO +CREATE PROCEDURE ModifierPanier + @ID int, + @UserId int, + @Nom varchar(50), + @Status int, + @DateAchat datetime, + @Type int +AS + IF(@ID IS NULL OR @ID=0) + RAISERROR('Identifiant requis !',16,1) + ELSE UPDATE Panier + SET UserId=@UserId,Nom=@Nom,Status=@Status,DateAchat=@DateAchat,Type=@Type + WHERE ID=@ID +RETURN +GO +CREATE PROCEDURE SelectionnerPanier + @Index VARCHAR(10) +AS + IF(@Index='UserId') SELECT * FROM Panier ORDER BY UserId + ELSE IF(@Index='Nom') SELECT * FROM Panier ORDER BY Nom + ELSE IF(@Index='Status') SELECT * FROM Panier ORDER BY Status + ELSE IF(@Index='DateAchat') SELECT * FROM Panier ORDER BY DateAchat + ELSE IF(@Index='Type') SELECT * FROM Panier ORDER BY Type + ELSE SELECT * FROM Panier ORDER BY ID +RETURN +GO +CREATE PROCEDURE SelectionnerPanier_ID + @ID int +AS + IF(@ID IS NULL) + RAISERROR('Identifiant requis !',16,1) + ELSE + SELECT ID,UserId,Nom,Status,DateAchat,Type + FROM Panier + WHERE @ID=ID +RETURN +GO +CREATE PROCEDURE SupprimerPanier + @ID int +AS + IF(@ID IS NULL) + RAISERROR('Identifiant requis !',16,1) + ELSE + DELETE FROM Panier WHERE @ID=ID +RETURN +GO diff --git a/fivhier pata/P_Utilisateur.sql b/fivhier pata/P_Utilisateur.sql new file mode 100644 index 0000000..5297b0a --- /dev/null +++ b/fivhier pata/P_Utilisateur.sql @@ -0,0 +1,68 @@ +CREATE PROCEDURE AjouterUtilisateur + @ID int OUTPUT, + @Nom varchar(50), + @Prenom varchar(50), + @Adresse varchar(50), + @NCompte varchar(50), + @DateDeNaisance datetime, + @type int, + @Actif bit, + @email varchar(50) +AS + INSERT INTO Utilisateur(Nom,Prenom,Adresse,NCompte,DateDeNaisance,type,Actif,email) + VALUES(@Nom,@Prenom,@Adresse,@NCompte,@DateDeNaisance,@type,@Actif,@email) + SET @ID=@@IDENTITY +RETURN +GO +CREATE PROCEDURE ModifierUtilisateur + @ID int, + @Nom varchar(50), + @Prenom varchar(50), + @Adresse varchar(50), + @NCompte varchar(50), + @DateDeNaisance datetime, + @type int, + @Actif bit, + @email varchar(50) +AS + IF(@ID IS NULL OR @ID=0) + RAISERROR('Identifiant requis !',16,1) + ELSE UPDATE Utilisateur + SET Nom=@Nom,Prenom=@Prenom,Adresse=@Adresse,NCompte=@NCompte,DateDeNaisance=@DateDeNaisance,type=@type,Actif=@Actif,email=@email + WHERE ID=@ID +RETURN +GO +CREATE PROCEDURE SelectionnerUtilisateur + @Index VARCHAR(10) +AS + IF(@Index='Nom') SELECT * FROM Utilisateur ORDER BY Nom + ELSE IF(@Index='Prenom') SELECT * FROM Utilisateur ORDER BY Prenom + ELSE IF(@Index='Adresse') SELECT * FROM Utilisateur ORDER BY Adresse + ELSE IF(@Index='NCompte') SELECT * FROM Utilisateur ORDER BY NCompte + ELSE IF(@Index='DateDeNaisance') SELECT * FROM Utilisateur ORDER BY DateDeNaisance + ELSE IF(@Index='type') SELECT * FROM Utilisateur ORDER BY type + ELSE IF(@Index='Actif') SELECT * FROM Utilisateur ORDER BY Actif + ELSE IF(@Index='email') SELECT * FROM Utilisateur ORDER BY email + ELSE SELECT * FROM Utilisateur ORDER BY ID +RETURN +GO +CREATE PROCEDURE SelectionnerUtilisateur_ID + @ID int +AS + IF(@ID IS NULL) + RAISERROR('Identifiant requis !',16,1) + ELSE + SELECT ID,Nom,Prenom,Adresse,NCompte,DateDeNaisance,type,Actif,email + FROM Utilisateur + WHERE @ID=ID +RETURN +GO +CREATE PROCEDURE SupprimerUtilisateur + @ID int +AS + IF(@ID IS NULL) + RAISERROR('Identifiant requis !',16,1) + ELSE + DELETE FROM Utilisateur WHERE @ID=ID +RETURN +GO diff --git a/procedure.sql b/procedure.sql new file mode 100644 index 0000000..22ab7ca --- /dev/null +++ b/procedure.sql @@ -0,0 +1,361 @@ +use [GestionCommerceInfo] +-- ================================================ +-- Template generated from Template Explorer using: +-- Create Procedure (New Menu).SQL +-- +-- Use the Specify Values for Template Parameters +-- command (Ctrl-Shift-M) to fill in the parameter +-- values below. +-- +-- This block of comments will not be included in +-- the definition of the procedure. +-- ================================================ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +-- ============================================= +-- Author: VAN DAMME Adrien +-- Create date: +-- Description: +-- ============================================= + +/*========================================================================================================== + * + * GESTION UTILISATEUR + * + *==========================================================================================================*/ +IF OBJECT_ID ( 'AjoutUtilisateur', 'P' ) IS NOT NULL + DROP PROCEDURE AjoutUtilisateur; +GO +CREATE PROCEDURE AjoutUtilisateur + -- Add the parameters for the stored procedure here + @ID int OUTPUT, + @Nom varchar(50), + @Prenom varchar(50), + @Adresse varchar(50), + @NCompte varchar(50), + @DateDeNaisance datetime, + @email varchar(50), + @type int +AS +BEGIN +IF(@type IS NULL OR @email IS NULL) + RAISERROR('Type de compte et email requis !', 16,1); +ELSE + INSERT INTO Utilisateur(Nom,Prenom,Adresse,NCompte,DateDeNaisance,type,Actif,email) + VALUES(@Nom,@Prenom,@Adresse,@NCompte,@DateDeNaisance,@type,1,@email); + SET @ID=@@IDENTITY; + RETURN; +END +GO +IF OBJECT_ID ( 'ModifUtilisateur', 'P' ) IS NOT NULL + DROP PROCEDURE ModifUtilisateur; +GO +CREATE PROCEDURE ModifUtilisateur + -- Add the parameters for the stored procedure here + @ID int, + @Nom varchar(50), + @Prenom varchar(50), + @Adresse varchar(50), + @NCompte varchar(50), + @DateDeNaisance datetime, + @email varchar(50), + @type int, + @actif bit +AS +BEGIN +IF(@ID IS NULL) + RAISERROR('Identifiant requis !', 16,1); +ELSE IF(@type IS NULL OR @email IS NULL OR @actif IS NULL) + RAISERROR('Type de compte, email et actif requis !', 16,1); +ELSE + UPDATE Utilisateur SET Nom=@Nom,Prenom=@Prenom,Adresse=@Adresse,NCompte=@NCompte,DateDeNaisance=@DateDeNaisance,type=@type,Actif=@actif,email=@email + WHERE ID=@ID; + RETURN; +END +GO +IF OBJECT_ID ( 'SuprimerUtilisateur', 'P' ) IS NOT NULL + DROP PROCEDURE SuprimerUtilisateur; +GO +CREATE PROCEDURE SuprimerUtilisateur + -- Add the parameters for the stored procedure here + @ID int, + @definitivement bit +AS +BEGIN +IF(@ID IS NULL) + RAISERROR('Identifiant requis !', 16,1) +ELSE IF(@definitivement IS NULL OR @definitivement = 0) + BEGIN + UPDATE Utilisateur SET Actif=0 WHERE ID=@ID; + RETURN; + END +ELSE + DELETE FROM Utilisateur WHERE ID=@ID; + RETURN; +END +GO +IF OBJECT_ID ( 'ListUtilisateurs', 'P' ) IS NOT NULL + DROP PROCEDURE ListUtilisateurs; +GO +CREATE PROCEDURE ListUtilisateurs + -- Add the parameters for the stored procedure here + @ID int, + @TRI varchar(15) +AS +BEGIN + IF(@ID IS NULL OR @ID<=0) + BEGIN + IF(@TRI='NOM') + SELECT * FROM Utilisateur ORDER BY Nom + ELSE IF(@TRI='PRENOM') + SELECT * FROM Utilisateur ORDER BY Prenom + ELSE + SELECT * FROM Utilisateur + END + ELSE + SELECT * FROM Utilisateur WHERE ID=@ID; +END +GO +/*========================================================================================================== + * + * GESTION ARTICLE + * + *==========================================================================================================*/ +IF OBJECT_ID ( 'AjoutArticle', 'P' ) IS NOT NULL + DROP PROCEDURE AjoutArticle; +GO +CREATE PROCEDURE AjoutArticle + -- Add the parameters for the stored procedure here + @ID int OUTPUT, + @Designation varchar(50), + @PrixHTVA money, + @Stock int, + @Visible bit, + @Actif bit +AS +BEGIN +IF(@Designation IS NULL OR @PrixHTVA IS NULL OR @Stock IS NULL OR @Visible IS NULL OR @Actif IS NULL) + RAISERROR('Tous les parametre sont requis !', 16,1) +ELSE + INSERT INTO Article(Designation,PrixHTVA,Stock,Visible,Actif) + VALUES(@Designation,@PrixHTVA,@Stock,@Visible,@Actif) + SET @ID=@@IDENTITY + RETURN +END +GO +IF OBJECT_ID ( 'ModifArticle', 'P' ) IS NOT NULL + DROP PROCEDURE ModifArticle; +GO +CREATE PROCEDURE ModifArticle + -- Add the parameters for the stored procedure here + @ID int, + @Designation varchar(50), + @PrixHTVA money, + @Stock int, + @Visible bit, + @Actif bit +AS +BEGIN +IF(@ID IS NULL) + RAISERROR('Identifiant requis !', 16,1) +ELSE IF(@Designation IS NULL OR @PrixHTVA IS NULL OR @Stock IS NULL OR @Visible IS NULL OR @Actif IS NULL) + RAISERROR('Tous les parametre sont requis !', 16,1) +ELSE + UPDATE Article SET Designation=@Designation,PrixHTVA=@PrixHTVA,Stock=@Stock,Visible=@Visible,Actif=@Actif WHERE ID=@ID + RETURN +END +GO +IF OBJECT_ID ( 'SuprimerArticle', 'P' ) IS NOT NULL + DROP PROCEDURE SuprimerArticle; +GO +CREATE PROCEDURE SuprimerArticle + -- Add the parameters for the stored procedure here + @ID int, + @definitivement bit +AS +BEGIN +IF(@ID IS NULL) + RAISERROR('Identifiant requis !', 16,1) +ELSE IF(@definitivement IS NULL OR @definitivement = 0) + BEGIN + UPDATE Article SET Actif=0 WHERE ID=@ID; + RETURN; + END +ELSE + DELETE FROM Article WHERE ID=@ID; + RETURN; +END +GO +IF OBJECT_ID ( 'ListArticle', 'P' ) IS NOT NULL + DROP PROCEDURE ListArticle; +GO +CREATE PROCEDURE ListArticle + -- Add the parameters for the stored procedure here + @ID int +AS +BEGIN + IF(@ID IS NULL OR @ID<=0) + BEGIN + SELECT * FROM Article + END + ELSE + SELECT * FROM Article WHERE ID=@ID; +END +GO +IF OBJECT_ID ( 'StockUnder', 'P' ) IS NOT NULL + DROP PROCEDURE StockUnder; +GO +CREATE PROCEDURE StockUnder + -- Add the parameters for the stored procedure here + @Stock int +AS +BEGIN + IF(@Stock IS NULL OR @Stock<0) + BEGIN + RAISERROR('Stock non nul ou non négatif !', 16,1) + END + ELSE + SELECT * FROM Article WHERE Stock<=@Stock; +END +GO + +/*========================================================================================================== + * + * GESTION PANIER + * + *==========================================================================================================*/ + +IF OBJECT_ID ( 'CreerPanier', 'P' ) IS NOT NULL + DROP PROCEDURE CreerPanier; +GO +CREATE PROCEDURE CreerPanier + -- Add the parameters for the stored procedure here + @ID int OUTPUT, + @UserID int, + @Nom varchar(50), + @type int +AS +BEGIN +IF(@type IS NULL OR @UserID IS NULL) + RAISERROR('Type de compte et UserId requis !', 16,1); +ELSE + INSERT INTO Panier(UserId, Nom, Status, Type) + VALUES(@UserID, @Nom, 0, @type); + SET @ID=@@IDENTITY; + RETURN; +END +GO +IF OBJECT_ID ( 'ListArticlePanier', 'P' ) IS NOT NULL + DROP PROCEDURE ListArticlePanier; +GO +CREATE PROCEDURE ListArticlePanier + -- Add the parameters for the stored procedure here + @ID int +AS +BEGIN +IF(@ID is NULL) + RAISERROR('ID Requis !', 16,1); +ELSE +BEGIN + SELECT * FROM LSTArticle AS art JOIN Article ON ( art.ArticleID = Article.ID) WHERE art.PanierID = @ID; +END +END +GO + +IF OBJECT_ID ( 'ListPanierUser', 'P' ) IS NOT NULL + DROP PROCEDURE ListPanierUser; +GO +CREATE PROCEDURE ListPanierUser + -- Add the parameters for the stored procedure here + @UserID int +AS +BEGIN +IF(@UserID IS NULL) + SELECT * FROM Panier ORDER BY ID DESC; +ELSE +BEGIN + SELECT * FROM Panier WHERE UserID = @UserID ORDER BY ID DESC; +END +END +GO + + +IF OBJECT_ID ( 'LirePanier', 'P' ) IS NOT NULL + DROP PROCEDURE LirePanier; +GO +CREATE PROCEDURE LirePanier + -- Add the parameters for the stored procedure here + @ID int +AS +BEGIN +IF(@ID IS NULL) + RAISERROR('ID Requis !', 16,1); +ELSE +BEGIN + SELECT * FROM Panier WHERE ID = @ID; +END +END +GO + + +IF OBJECT_ID ( 'AjoutArticleDansPanier', 'P' ) IS NOT NULL + DROP PROCEDURE AjoutArticleDansPanier; +GO +CREATE PROCEDURE AjoutArticleDansPanier + -- Add the parameters for the stored procedure here + @ID int OUTPUT, + @IDArt int, + @IDPanier int, + @Quantite int, + @PrixHTVA money +AS +BEGIN +IF(@IDArt IS NULL OR @IDPanier IS NULL OR @Quantite IS NULL) + RAISERROR('Tout les parametre sont requis !', 16,1); +ELSE + INSERT INTO LSTArticle(PanierID, ArticleID, Quantite, PrixHTVA, TVA) + VALUES(@IDPanier, @IDArt, @Quantite, @PrixHTVA, 0); + SET @ID=@@IDENTITY; + RETURN; +END +GO + + +IF OBJECT_ID ( 'SuprimerArticlePanier', 'P' ) IS NOT NULL + DROP PROCEDURE SuprimerArticlePanier; +GO +CREATE PROCEDURE SuprimerArticlePanier + -- Add the parameters for the stored procedure here + @ID int +AS +BEGIN +IF(@ID is NULL) + RAISERROR('Tout les parametre sont requis !', 16,1); +ELSE + DELETE FROM LSTArticle WHERE ID=@ID; +END +GO + +IF OBJECT_ID ( 'ModifPanier', 'P' ) IS NOT NULL + DROP PROCEDURE ModifPanier; +GO +CREATE PROCEDURE ModifPanier + -- Add the parameters for the stored procedure here + @ID int, + @userID int, + @nom varchar(50), + @Status int, + @type bit +AS +BEGIN +IF(@ID IS NULL) + RAISERROR('Identifiant requis !', 16,1) +ELSE IF(@userID IS NULL OR @nom IS NULL OR @Status IS NULL OR @type IS NULL) + RAISERROR('Tous les parametre sont requis !', 16,1) +ELSE + UPDATE Panier SET UserId=@UserID,Nom=@nom,Status=@Status,Type=@type WHERE ID=@ID + RETURN +END +GO