Initial commit
This commit is contained in:
commit
c0e2623315
Binary file not shown.
|
@ -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
|
|
@ -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();
|
||||
}*/
|
||||
}
|
||||
}
|
|
@ -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<Article> ListArticles()
|
||||
{
|
||||
CommandSQL.Parameters.Clear();
|
||||
List<Article> lstArt = new List<Article>();
|
||||
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<Article> VerifStock(int alerteStock)
|
||||
{
|
||||
CommandSQL.Parameters.Clear();
|
||||
List<Article> lstArt = new List<Article>();
|
||||
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<Article> 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<Article> 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<Article> articles, bool definitivement)
|
||||
{
|
||||
foreach (Article article in articles)
|
||||
SuprimerArticle(article.ID, definitivement);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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<Panier.LSTArticle> listeArticlePanier(int panierId)
|
||||
{
|
||||
CommandSQL.Parameters.Clear();
|
||||
List<Panier.LSTArticle> lstARt = new List<Panier.LSTArticle>();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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<Utilisateur> ListUtilisateurs(Utilisateur.Tri_E tri)
|
||||
{
|
||||
CommandSQL.Parameters.Clear();
|
||||
List<Utilisateur> lstArt = new List<Utilisateur>();
|
||||
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<Utilisateur> 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<Utilisateur> 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<Utilisateur> utilisateurs, bool definitivement)
|
||||
{
|
||||
foreach (Utilisateur utilisateur in utilisateurs)
|
||||
SuprimerUtilisateur(utilisateur.ID, definitivement);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{E6602180-4F8E-437A-867B-75B90834D712}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>GestionDeCommerceInfoClasseBDDNCouches</RootNamespace>
|
||||
<AssemblyName>GestionDeCommerceInfoClasseBDDNCouches</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Article.cs" />
|
||||
<Compile Include="DataLayer\BDDAccesArticle.cs" />
|
||||
<Compile Include="DataLayer\BDDAccesBase.cs" />
|
||||
<Compile Include="DataLayer\BDDAccesPanier.cs" />
|
||||
<Compile Include="DataLayer\BDDAccesUtilisateur.cs" />
|
||||
<Compile Include="Panier.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utilisateur.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="BusinessLayer\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -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<LSTArticle> 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<LSTArticle>();
|
||||
}
|
||||
public Panier(int id, Utilisateur user, string nomPanier, Type_E type, Status_E status, DateTime dateAchat, List<LSTArticle> 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<LSTArticle>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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")]
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
6f6b11a48c5084ee50ef613076f253a8a59cdfcf
|
|
@ -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
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
730ef345d5b5f3a770b9fba2bbb6ce6a91c6fa1c
|
|
@ -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
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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)
|
||||
/// <summary>
|
||||
/// Constructeur par défaut
|
||||
/// </summary>
|
||||
/// <remarks>La chaîne de connexion est récupérée en argument</remarks>
|
||||
public ADBase(string sChaineConnexion)
|
||||
{
|
||||
_commande = new SqlCommand();
|
||||
_commande.Connection = new SqlConnection(sChaineConnexion);
|
||||
}
|
||||
/// <summary>
|
||||
/// Méthode assignant une procédure stockée
|
||||
/// </summary>
|
||||
/// <param name="sCommande">Nom de la procédure stockée</param>
|
||||
public void CreerCommande(string sCommande)
|
||||
{
|
||||
_commande.CommandType = CommandType.StoredProcedure;
|
||||
_commande.CommandText = sCommande;
|
||||
}
|
||||
/// <summary>
|
||||
/// Méthode assignant une procédure stockée ET une chaîne de connexion
|
||||
/// </summary>
|
||||
/// <param name="sCommande">Nom de la procédure stockée</param>
|
||||
/// <param name="sConnexion">Chaîne de connexion à utiliser</param>
|
||||
public void CreerCommande(string sCommande, string sConnexion)
|
||||
{
|
||||
_commande.Connection = new SqlConnection(sConnexion);
|
||||
_commande.CommandType = CommandType.StoredProcedure;
|
||||
_commande.CommandText = sCommande;
|
||||
}
|
||||
/// <summary>
|
||||
/// Méthode assignant une procédure stockée et le type de requête
|
||||
/// </summary>
|
||||
/// <param name="sCommande">Nom de la procédure stockée</param>
|
||||
/// <param name="bTypeProcedures">Type de requête (Vrai=stockée, Faux=Texte)</param>
|
||||
public void CreerCommande(string sCommande, bool bTypeRequete)
|
||||
{
|
||||
if (bTypeRequete) _commande.CommandType = CommandType.StoredProcedure;
|
||||
else _commande.CommandType = CommandType.Text;
|
||||
_commande.CommandText = sCommande;
|
||||
}
|
||||
/// <summary>
|
||||
/// Méthode assignant une procédure stockée, une chaîne de connexion et le type de requête
|
||||
/// </summary>
|
||||
/// <param name="sCommande">Nom de la procédure stockée</param>
|
||||
/// <param name="sConnexion">Chaîne de connexion à utiliser</param>
|
||||
/// <param name="bTypeProcedures">Type de requête (Vrai=stockée, Faux=Texte)</param>
|
||||
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
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Couche d'accès aux données (Data Access Layer)
|
||||
/// </summary>
|
||||
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<C_Personne> Lire(string Index)
|
||||
{
|
||||
CreerCommande("SelectionnerPersonne");
|
||||
Commande.Parameters.AddWithValue("@Index", Index);
|
||||
Commande.Connection.Open();
|
||||
SqlDataReader dr = Commande.ExecuteReader();
|
||||
List<C_Personne> res = new List<C_Personne>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
#region Ressources extérieures
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
#endregion
|
||||
|
||||
namespace Projet_BD_EXEMPLE.Classes
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe de définition des données
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Couche intermédiaire de gestion (Business Layer)
|
||||
/// </summary>
|
||||
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<C_Personne> 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); }
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Couche d'accès aux données (Data Access Layer)
|
||||
/// </summary>
|
||||
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<C_Article> Lire(string Index)
|
||||
{
|
||||
CreerCommande("SelectionnerArticle");
|
||||
Commande.Parameters.AddWithValue("@Index", Index);
|
||||
Commande.Connection.Open();
|
||||
SqlDataReader dr = Commande.ExecuteReader();
|
||||
List<C_Article> res = new List<C_Article>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
/// <summary>
|
||||
/// Constructeur par défaut
|
||||
/// </summary>
|
||||
/// <remarks>La chaîne de connexion est récupérée en argument</remarks>
|
||||
public ADBase(string sChaineConnexion)
|
||||
{
|
||||
_commande = new SqlCommand();
|
||||
_commande.Connection = new SqlConnection(sChaineConnexion);
|
||||
}
|
||||
/// <summary>
|
||||
/// Méthode assignant une procédure stockée
|
||||
/// </summary>
|
||||
/// <param name="sCommande">Nom de la procédure stockée</param>
|
||||
public void CreerCommande(string sCommande)
|
||||
{
|
||||
_commande.CommandType = CommandType.StoredProcedure;
|
||||
_commande.CommandText = sCommande;
|
||||
}
|
||||
/// <summary>
|
||||
/// Méthode assignant une procédure stockée ET une chaîne de connexion
|
||||
/// </summary>
|
||||
/// <param name="sCommande">Nom de la procédure stockée</param>
|
||||
/// <param name="sConnexion">Chaîne de connexion à utiliser</param>
|
||||
public void CreerCommande(string sCommande, string sConnexion)
|
||||
{
|
||||
_commande.Connection = new SqlConnection(sConnexion);
|
||||
_commande.CommandType = CommandType.StoredProcedure;
|
||||
_commande.CommandText = sCommande;
|
||||
}
|
||||
/// <summary>
|
||||
/// Méthode assignant une procédure stockée et le type de requête
|
||||
/// </summary>
|
||||
/// <param name="sCommande">Nom de la procédure stockée</param>
|
||||
/// <param name="bTypeProcedures">Type de requête (Vrai=stockée, Faux=Texte)</param>
|
||||
public void CreerCommande(string sCommande, bool bTypeRequete)
|
||||
{
|
||||
if (bTypeRequete) _commande.CommandType = CommandType.StoredProcedure;
|
||||
else _commande.CommandType = CommandType.Text;
|
||||
_commande.CommandText = sCommande;
|
||||
}
|
||||
/// <summary>
|
||||
/// Méthode assignant une procédure stockée, une chaîne de connexion et le type de requête
|
||||
/// </summary>
|
||||
/// <param name="sCommande">Nom de la procédure stockée</param>
|
||||
/// <param name="sConnexion">Chaîne de connexion à utiliser</param>
|
||||
/// <param name="bTypeProcedures">Type de requête (Vrai=stockée, Faux=Texte)</param>
|
||||
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
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Couche d'accès aux données (Data Access Layer)
|
||||
/// </summary>
|
||||
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<C_LSTArticle> Lire(string Index)
|
||||
{
|
||||
CreerCommande("SelectionnerLSTArticle");
|
||||
Commande.Parameters.AddWithValue("@Index", Index);
|
||||
Commande.Connection.Open();
|
||||
SqlDataReader dr = Commande.ExecuteReader();
|
||||
List<C_LSTArticle> res = new List<C_LSTArticle>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Couche d'accès aux données (Data Access Layer)
|
||||
/// </summary>
|
||||
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<C_Panier> Lire(string Index)
|
||||
{
|
||||
CreerCommande("SelectionnerPanier");
|
||||
Commande.Parameters.AddWithValue("@Index", Index);
|
||||
Commande.Connection.Open();
|
||||
SqlDataReader dr = Commande.ExecuteReader();
|
||||
List<C_Panier> res = new List<C_Panier>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Couche d'accès aux données (Data Access Layer)
|
||||
/// </summary>
|
||||
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<C_Utilisateur> Lire(string Index)
|
||||
{
|
||||
CreerCommande("SelectionnerUtilisateur");
|
||||
Commande.Parameters.AddWithValue("@Index", Index);
|
||||
Commande.Connection.Open();
|
||||
SqlDataReader dr = Commande.ExecuteReader();
|
||||
List<C_Utilisateur> res = new List<C_Utilisateur>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
#region Ressources extérieures
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
#endregion
|
||||
|
||||
namespace Projet_GestionCommerceInfo.Classes
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe de définition des données
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
#region Ressources extérieures
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
#endregion
|
||||
|
||||
namespace Projet_GestionCommerceInfo.Classes
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe de définition des données
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
#region Ressources extérieures
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
#endregion
|
||||
|
||||
namespace Projet_GestionCommerceInfo.Classes
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe de définition des données
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
#region Ressources extérieures
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
#endregion
|
||||
|
||||
namespace Projet_GestionCommerceInfo.Classes
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe de définition des données
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Couche intermédiaire de gestion (Business Layer)
|
||||
/// </summary>
|
||||
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<C_Article> 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); }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Couche intermédiaire de gestion (Business Layer)
|
||||
/// </summary>
|
||||
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<C_LSTArticle> 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); }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Couche intermédiaire de gestion (Business Layer)
|
||||
/// </summary>
|
||||
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<C_Panier> 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); }
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Couche intermédiaire de gestion (Business Layer)
|
||||
/// </summary>
|
||||
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<C_Utilisateur> 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); }
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue