Initial commit
This commit is contained in:
59
GestionDeCommerceInfoClasseBDDNCouches/Article.cs
Normal file
59
GestionDeCommerceInfoClasseBDDNCouches/Article.cs
Normal file
@@ -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>
|
||||
150
GestionDeCommerceInfoClasseBDDNCouches/Panier.cs
Normal file
150
GestionDeCommerceInfoClasseBDDNCouches/Panier.cs
Normal file
@@ -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")]
|
||||
60
GestionDeCommerceInfoClasseBDDNCouches/Utilisateur.cs
Normal file
60
GestionDeCommerceInfoClasseBDDNCouches/Utilisateur.cs
Normal file
@@ -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.
Reference in New Issue
Block a user