Esempio n. 1
0
    protected void afficherLesDonnees()
    {
        PPGestionnaires gestionnaires = new PPGestionnaires();

        lblgestionnaires.Text = gestionnaires.Values.Count.ToString() + " donnée(s)";
        PPDetailsCommandes detailsCommandes = new PPDetailsCommandes();

        lbldetailscommandes.Text = detailsCommandes.Values.Count.ToString() + " donnée(s)";
        PPCommandes commandes = new PPCommandes();

        lblcommandes.Text = commandes.Values.Count.ToString() + " donnée(s)";
        PPPoidsLivraisons poidLivraison = new PPPoidsLivraisons();

        lblpoidslivraisons.Text = poidLivraison.Values.Count.ToString() + " donnée(s)";
        PPTypesLivraison typeLivraison = new PPTypesLivraison();

        lbltypeslivraison.Text = typeLivraison.Values.Count.ToString() + " donnée(s)";
        PPTypesPoids typePoids = new PPTypesPoids();

        lbltypespoids.Text = typePoids.Values.Count.ToString() + " donnée(s)";
        PPVendeursClients vendeursClients = new PPVendeursClients();

        lblvendeursclients.Text = vendeursClients.Values.Count.ToString() + " donnée(s)";
        PPArticlesEnPanier articlesEnPanier = new PPArticlesEnPanier();

        lblarticlesenpanier.Text = articlesEnPanier.Values.Count.ToString() + " donnée(s)";
        PPClients clients = new PPClients();

        lblclients.Text = clients.Values.Count.ToString() + " donnée(s)";
        PPProduits produits = new PPProduits();

        lblproduits.Text = produits.Values.Count.ToString() + " donnée(s)";
        PPVendeurs vendeurs = new PPVendeurs();

        lblvendeurs.Text = vendeurs.Values.Count.ToString() + " donnée(s)";
        PPCategories categories = new PPCategories();

        lblcategories.Text = categories.Values.Count.ToString() + " donnée(s)";
        PPHistoriquePaiements historique = new PPHistoriquePaiements();

        lblhistoriquepaiements.Text = historique.Values.Count.ToString() + " donnée(s)";
        PPTaxeFederale taxeFed = new PPTaxeFederale();

        lbltaxefederale.Text = taxeFed.Values.Count.ToString() + " donnée(s)";
        PPTaxeProvinciale taxeProv = new PPTaxeProvinciale();

        lbltaxeprovinciale.Text = taxeProv.Values.Count.ToString() + " donnée(s)";
        if ((gestionnaires.Values.Count > 0) || (detailsCommandes.Values.Count > 0) || (commandes.Values.Count > 0) || (poidLivraison.Values.Count > 0) || (typeLivraison.Values.Count > 0) ||
            (typePoids.Values.Count > 0) || (vendeursClients.Values.Count > 0) || (articlesEnPanier.Values.Count > 0) || (clients.Values.Count > 0) || (produits.Values.Count > 0) ||
            (vendeurs.Values.Count > 0) || (categories.Values.Count > 0) || (historique.Values.Count > 0) || (taxeFed.Values.Count > 0) || (taxeProv.Values.Count > 0))
        {
            idCreerDatabase.Enabled = false;
            idViderDatabase.Enabled = true;
        }
        else
        {
            idCreerDatabase.Enabled = true;
            idViderDatabase.Enabled = false;
        }
    }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Session.IsClient())
        {
            Response.Redirect(SessionManager.RedirectConnexionLink);
        }

        Client client = Session.GetClient();

        PPCommandes        commandes        = new PPCommandes();
        PPDetailsCommandes detailsCommandes = new PPDetailsCommandes();
        PPVendeurs         vendeurs         = new PPVendeurs();
        PPTypesLivraison   typesLivraison   = new PPTypesLivraison();

        var listeCommandes = from commande in commandes.Values
                             join vendeur in vendeurs.Values on commande.NoVendeur equals vendeur.NoVendeur
                             join typeLivraison in typesLivraison.Values on commande.TypeLivraison equals typeLivraison.CodeLivraison
                             where commande.NoClient == client.NoClient
                             let listeDetails = detailsCommandes.Values.Where(x => x.NoCommande == commande.NoCommande)
                                                select new { Commande = commande, TypeLivraison = typeLivraison, Vendeur = vendeur, Details = listeDetails };

        pnlContent.CardDyn(
            "", "mb-3",
            lbl => lbl.Text = "Historique des commandes",
            body =>
        {
            Table table         = body.TableDyn("", "table table-padding");
            TableHeaderRow hrow = table.ThrDyn();
            hrow.ThdDyn("No Commande");
            hrow.ThdDyn("Nom du vendeur");
            hrow.ThdDyn("Date de la commande");
            hrow.ThdDyn("Prix total avant taxes");

            foreach (var commande in listeCommandes)
            {
                TableRow row = table.TrDyn();

                TableCell cellBtnCommande = row.TdDyn();
                string path = $"Factures/{commande.Commande.NoCommande}.pdf";
                if (File.Exists(Server.MapPath($"~/{path}")))
                {
                    cellBtnCommande.BtnClientDyn("", commande.Commande.NoCommande.ToString(), $"window.open('/{path}'); return false;", "btn btn-outline-secondary btn-block");
                }
                else
                {
                    cellBtnCommande.BtnClientDyn("", commande.Commande.NoCommande.ToString(), $"window.open('/Factures/defaut.pdf'); return false", "btn btn-outline-secondary btn-block");
                }

                TableCell cellLinkVendeur = row.TdDyn();
                cellLinkVendeur.HlinkDYN("", $"~/Pages/Client/Catalogue.aspx?NoVendeur={commande.Vendeur.NoVendeur}", commande.Vendeur.NomAffaires);

                row.TdDyn(commande.Commande.DateCommande.ToString());
                row.TdDyn(commande.Commande.MontantTotAvantTaxes.Value.ToString("N2") + "$");
            }
        });
    }
Esempio n. 3
0
    protected void ViderBD()
    {
        PPGestionnaires gestionnaires = new PPGestionnaires();

        gestionnaires.RemoveAll();
        PPDetailsCommandes detailsCommandes = new PPDetailsCommandes();

        detailsCommandes.RemoveAll();
        PPCommandes commandes = new PPCommandes();

        commandes.RemoveAll();
        PPPoidsLivraisons poidLivraison = new PPPoidsLivraisons();

        poidLivraison.RemoveAll();
        PPTypesLivraison typeLivraison = new PPTypesLivraison();

        typeLivraison.RemoveAll();
        PPTypesPoids typePoids = new PPTypesPoids();

        typePoids.RemoveAll();
        PPVendeursClients vendeursClients = new PPVendeursClients();

        vendeursClients.RemoveAll();
        PPArticlesEnPanier articlesEnPanier = new PPArticlesEnPanier();

        articlesEnPanier.RemoveAll();
        PPClients clients = new PPClients();

        clients.RemoveAll();
        PPProduits produits = new PPProduits();

        produits.RemoveAll();
        PPVendeurs vendeurs = new PPVendeurs();

        vendeurs.RemoveAll();
        PPCategories categories = new PPCategories();

        categories.RemoveAll();
        PPHistoriquePaiements historique = new PPHistoriquePaiements();

        historique.RemoveAll();
        PPTaxeFederale taxeFed = new PPTaxeFederale();

        taxeFed.RemoveAll();
        PPTaxeProvinciale taxeProv = new PPTaxeProvinciale();

        taxeProv.RemoveAll();
        afficherLesDonnees();
    }
Esempio n. 4
0
    protected void remplirDetailsCommandes(XNamespace ss, XElement worksheet)
    {
        PPDetailsCommandes detailsCommandes = new PPDetailsCommandes();

        foreach (XElement row in worksheet.Descendants(ss + "Row"))
        {
            List <String> arrayStr = new List <string>();
            foreach (XElement cell in row.Descendants(ss + "Data"))
            {
                arrayStr.Add(cell.Value);
            }
            if (arrayStr.Count() == 5)
            {
                detailsCommandes.Add(new DetailsCommandes(null)
                {
                    NoDetailCommandes = Convert.ToInt64(arrayStr[0]),
                    NoCommande        = Convert.ToInt64(arrayStr[1]),
                    NoProduit         = Convert.ToInt32(arrayStr[2]),
                    PrixVente         = Convert.ToDecimal(arrayStr[3]),
                    Quantité          = Convert.ToInt16(arrayStr[4])
                });
            }
        }
    }
Esempio n. 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Session.IsVendeur())
        {
            Response.Redirect(SessionManager.RedirectConnexionLink);
        }

        Vendeur vendeur = Session.GetVendeur();

        //Requetes pour commandes non traitées
        PPCommandes        commandes = new PPCommandes();
        PPDetailsCommandes details   = new PPDetailsCommandes();
        PPClients          clients   = new PPClients();

        var commandesVendeur = from commande in commandes.Values
                               join monClient in clients.Values on commande.NoClient equals monClient.NoClient
                               where commande.NoVendeur == vendeur.NoVendeur && commande.Statut == "0"
                               orderby commande.DateCommande ascending
                               let lstDetails = details.Values.Where(x => x.NoCommande == commande.NoCommande).ToList()
                                                select new { Commande = commande, Client = monClient, Details = lstDetails };

        //Commandes
        int indexCom = 0;

        //commandes non-traitées

        if (commandesVendeur.Count() > 0)
        {
            foreach (var com in commandesVendeur)
            {
                TableRow row          = new TableRow();
                long?    noCommande   = com.Commande.NoCommande;
                string   nomClient    = com.Client.Prenom + " " + com.Client.Nom;
                DateTime dateCommande = com.Commande.DateCommande.Value;

                decimal poidsCommande = com.Commande.PoidsTotal.Value;

                PPHistoriquePaiements historique = new PPHistoriquePaiements();
                //requete pour aller cherche le montant dans l'historique
                var montant = from montantHisto in historique.Values
                              where montantHisto.NoCommande == com.Commande.NoCommande
                              select montantHisto.MontantVenteAvantLivraison;

                decimal montantCom = montant.First().Value;

                TableCell cellNom = new TableCell();

                /* cellNom.Text = "Marcel Leboeuf";
                 * cellNom.Attributes.Add("OnClick", "window.location.assign('http://www.google.com');");*/

                string nomPDF = "";

                if (File.Exists(Server.MapPath("~/Factures/" + noCommande.ToString() + ".pdf")))
                {
                    nomPDF = noCommande.ToString() + ".pdf";
                }
                else
                {
                    nomPDF = "defaut.pdf";
                }

                cellNom.Text = nomClient;
                cellNom.Attributes.Add("OnClick", "ouvrirPDF('" + nomPDF + "');");
                row.Cells.Add(cellNom);


                TableCell cellDate = new TableCell();
                cellDate.Text = dateCommande.ToString("yyyy/MM/dd");
                cellDate.Attributes.Add("OnClick", "ouvrirPDF('" + nomPDF + "');");
                row.Cells.Add(cellDate);

                TableCell cellPrix = new TableCell();
                cellPrix.Text = montantCom.ToString("N2") + " $";
                cellPrix.Attributes.Add("OnClick", "ouvrirPDF('" + nomPDF + "');");
                row.Cells.Add(cellPrix);

                TableCell cellStatut = new TableCell();
                cellStatut.Text = poidsCommande.ToString("N2") + " Lbs";
                cellStatut.Attributes.Add("OnClick", "ouvrirPDF('" + nomPDF + "');");
                row.Cells.Add(cellStatut);


                //modal (il faut faire référence à la div à cet effet dans le front-hand.
                modal(panelAvecModal, "myModal" + indexCom.ToString(), noCommande.ToString(), "btnAnnulerLiv" + indexCom.ToString(), "Livraison", "Voulez-vous vraiment confirmer la livraison de cette commande? (" + noCommande.ToString() + ")", true);

                TableCell cellBtn   = row.TdDyn();
                Button    btnLivrer = cellBtn.BtnDyn("", "Prêt à livrer", null, "btn btn-secondary btn-block btn-sm");

                btnLivrer.OnClientClick = "return false;";
                btnLivrer.Attributes.Add("data-toggle", "modal");
                btnLivrer.Attributes.Add("data-target", "#Contenu_ContenuPrincipal_myModal" + indexCom.ToString());

                row.Cells.Add(cellBtn);

                tableCommandesNonTraitee.Rows.Add(row);
                indexCom++;
            }
        }
        else
        {
            tableCommandesNonTraitee.Visible = false;
            divBTN.Visible = false;
            pnCommandesClient.LblDyn("", "Vous n'avez aucune commande non traité", "h4 text-info ml-3");
        }

        //historique commandes
        var commandesVendeurH = from commande in commandes.Values
                                join monClient in clients.Values on commande.NoClient equals monClient.NoClient
                                where commande.NoVendeur == vendeur.NoVendeur && commande.Statut == "1"
                                orderby commande.DateCommande descending
                                let lstDetails = details.Values.Where(x => x.NoCommande == commande.NoCommande).ToList()
                                                 select new { Commande = commande, Client = monClient, Details = lstDetails };

        int index = 0;

        if (commandesVendeurH.Count() > 0)
        {
            foreach (var com in commandesVendeurH)
            {
                string nomPDF     = "";
                long?  noCommande = com.Commande.NoCommande.Value;

                if (File.Exists(Server.MapPath("~/Factures/" + noCommande.ToString() + ".pdf")))
                {
                    nomPDF = noCommande.ToString() + ".pdf";
                }
                else
                {
                    nomPDF = "defaut.pdf";
                }
                TableRow row = new TableRow();
                row.Attributes.Add("OnClick", "ouvrirPDF('" + nomPDF + "');");

                string   nomClient    = com.Client.Prenom + " " + com.Client.Nom;
                DateTime dateCommande = com.Commande.DateCommande.Value;

                decimal poidsCommande = com.Commande.PoidsTotal.Value;

                PPHistoriquePaiements historique = new PPHistoriquePaiements();
                //requete pour aller cherche le montant dans l'historique
                var montant = from montantHisto in historique.Values
                              where montantHisto.NoCommande == com.Commande.NoCommande
                              select montantHisto.MontantVenteAvantLivraison;

                decimal montantCom = montant.First().Value;

                TableCell cellNom = new TableCell();

                /* cellNom.Text = "Marcel Leboeuf";
                 * cellNom.Attributes.Add("OnClick", "window.location.assign('http://www.google.com');");*/
                cellNom.Text = nomClient;
                row.Cells.Add(cellNom);


                TableCell cellDate = new TableCell();
                cellDate.Text = dateCommande.ToString("yyyy/MM/dd");
                row.Cells.Add(cellDate);

                TableCell cellPrix = new TableCell();
                cellPrix.Text = montantCom.ToString("N2") + " $";
                row.Cells.Add(cellPrix);

                TableCell cellStatut = new TableCell();
                cellStatut.Text = poidsCommande.ToString("N2") + " Lbs";
                row.Cells.Add(cellStatut);


                //modal (il faut faire référence à la div à cet effet dans le front-hand.
                modal(panelAvecModal, "myModalH" + index.ToString(), "btnOkLivH" + index.ToString(), "btnAnnulerLivH" + index.ToString(), "Livraison", "Voulez-vous vraiment confirmer la livraison de cette commande? (" + nomClient + ")", true);
                tableHistorique.Rows.Add(row);
                index++;
            }
        }
        else
        {
            tableHistorique.Visible = false;
            divBTN2.Visible         = false;
            pnCommandesTraitees.LblDyn("", "Vous n'avez aucune commande dans l'historique", "h4 text-info ml-3");
        }
    }
    protected void btnImporterDonnees_Click(object sender, EventArgs e)
    {
        bool binOK = true;

        using (var transaction = dbContext.Database.BeginTransaction())
        {
            try
            {
                XDocument document = XDocument.Load(Server.MapPath("\\static\\xml\\PPVendeurs.xml"));
                XElement  racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPVendeurs"))
                {
                    PPVendeurs vendeur = new PPVendeurs();
                    vendeur.NoVendeur         = long.Parse(element.Descendants("NoVendeur").Single().Value);
                    vendeur.NomAffaires       = element.Descendants("NomAffaires").Single().Value;
                    vendeur.Nom               = element.Descendants("Nom").Single().Value;
                    vendeur.Prenom            = element.Descendants("Prenom").Single().Value;
                    vendeur.Rue               = element.Descendants("Rue").Single().Value;
                    vendeur.Ville             = element.Descendants("Ville").Single().Value;
                    vendeur.Province          = element.Descendants("Province").Single().Value;
                    vendeur.CodePostal        = element.Descendants("CodePostal").Single().Value;
                    vendeur.Pays              = element.Descendants("Pays").Single().Value;
                    vendeur.Tel1              = element.Descendants("Tel1").Single().Value;
                    vendeur.Tel2              = element.Descendants("Tel2").Single().Value == "NULL" ? null : element.Descendants("Tel2").Single().Value;
                    vendeur.AdresseEmail      = element.Descendants("AdresseEmail").Single().Value;
                    vendeur.MotDePasse        = element.Descendants("MotDePasse").Single().Value;
                    vendeur.PoidsMaxLivraison = int.Parse(element.Descendants("PoidsMaxLivraison").Single().Value);
                    vendeur.LivraisonGratuite = decimal.Parse(element.Descendants("LivraisonGratuite").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    vendeur.Taxes             = element.Descendants("Taxes").Single().Value == "1" ? true : false;
                    if (element.Descendants("Pourcentage").Single().Value == "NULL")
                    {
                        vendeur.Pourcentage = null;
                    }
                    else
                    {
                        vendeur.Pourcentage = decimal.Parse(element.Descendants("Pourcentage").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    }
                    vendeur.Configuration = element.Descendants("Configuration").Single().Value;
                    if (element.Descendants("DateCreation").Single().Value == "NULL")
                    {
                        vendeur.DateCreation = null;
                    }
                    else
                    {
                        vendeur.DateCreation = DateTime.Parse(element.Descendants("DateCreation").Single().Value);
                    }
                    if (element.Descendants("DateMAJ").Single().Value == "NULL")
                    {
                        vendeur.DateMAJ = null;
                    }
                    else
                    {
                        vendeur.DateMAJ = DateTime.Parse(element.Descendants("DateMAJ").Single().Value);
                    }

                    if (element.Descendants("Statut").Single().Value == "NULL")
                    {
                        vendeur.Statut = null;
                    }
                    else
                    {
                        vendeur.Statut = short.Parse(element.Descendants("Statut").Single().Value);
                    }

                    dbContext.PPVendeurs.Add(vendeur);

                    XDocument configuration = new XDocument();
                    XElement  urlImage      = new XElement("urlImage");
                    urlImage.Value = "image_magasin.jpg";
                    XElement couleurFond = new XElement("couleurFond");
                    couleurFond.Value = "#ffffff";
                    XElement couleurTexte = new XElement("couleurTexte");
                    couleurTexte.Value = "#000000";
                    configuration.Add(new XElement("configuration", urlImage, couleurFond, couleurTexte));
                    configuration.Save(Server.MapPath("\\static\\xml\\" + vendeur.Configuration));
                }

                document = XDocument.Load(Server.MapPath("\\static\\xml\\PPClients.xml"));
                racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPClients"))
                {
                    PPClients client = new PPClients();
                    client.NoClient     = long.Parse(element.Descendants("NoClient").Single().Value);
                    client.AdresseEmail = element.Descendants("AdresseEmail").Single().Value;
                    client.MotDePasse   = element.Descendants("MotDePasse").Single().Value;
                    client.Nom          = element.Descendants("Nom").Single().Value == "NULL" ? null : element.Descendants("Nom").Single().Value;
                    client.Prenom       = element.Descendants("Prenom").Single().Value == "NULL" ? null : element.Descendants("Prenom").Single().Value;
                    client.Rue          = element.Descendants("Rue").Single().Value == "NULL" ? null : element.Descendants("Rue").Single().Value;
                    client.Ville        = element.Descendants("Ville").Single().Value == "NULL" ? null : element.Descendants("Ville").Single().Value;
                    client.Province     = element.Descendants("Province").Single().Value == "NULL" ? null : element.Descendants("Province").Single().Value;
                    client.CodePostal   = element.Descendants("CodePostal").Single().Value == "NULL" ? null : element.Descendants("CodePostal").Single().Value;
                    client.Pays         = element.Descendants("Pays").Single().Value == "NULL" ? null : element.Descendants("Pays").Single().Value;
                    client.Tel1         = element.Descendants("Tel1").Single().Value == "NULL" ? null : element.Descendants("Tel1").Single().Value;
                    client.Tel2         = element.Descendants("Tel2").Single().Value == "NULL" ? null : element.Descendants("Tel2").Single().Value;
                    client.DateCreation = DateTime.Parse(element.Descendants("DateCreation").Single().Value);
                    if (element.Descendants("DateMAJ").Single().Value == "NULL")
                    {
                        client.DateMAJ = null;
                    }
                    else
                    {
                        client.DateMAJ = DateTime.Parse(element.Descendants("DateMAJ").Single().Value);
                    }
                    client.NbConnexions = short.Parse(element.Descendants("NbConnexions").Single().Value);
                    if (element.Descendants("DateDerniereConnexion").Single().Value == "NULL")
                    {
                        client.DateDerniereConnexion = null;
                    }
                    else
                    {
                        client.DateDerniereConnexion = DateTime.Parse(element.Descendants("DateDerniereConnexion").Single().Value);
                    }
                    client.Statut = short.Parse(element.Descendants("Statut").Single().Value);

                    dbContext.PPClients.Add(client);
                }

                document = XDocument.Load(Server.MapPath("\\static\\xml\\PPCategories.xml"));
                racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPCategories"))
                {
                    PPCategories categorie = new PPCategories();
                    categorie.NoCategorie = int.Parse(element.Descendants("NoCategorie").Single().Value);
                    categorie.Description = element.Descendants("Description").Single().Value;
                    categorie.Details     = element.Descendants("Details").Single().Value;

                    dbContext.PPCategories.Add(categorie);
                }

                document = XDocument.Load(Server.MapPath("\\static\\xml\\PPProduits.xml"));
                racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPProduits"))
                {
                    PPProduits produit = new PPProduits();
                    produit.NoProduit     = long.Parse(element.Descendants("NoProduit").Single().Value);
                    produit.NoVendeur     = long.Parse(element.Descendants("NoVendeur").Single().Value);
                    produit.NoCategorie   = int.Parse(element.Descendants("NoCategorie").Single().Value);
                    produit.Nom           = element.Descendants("Nom").Single().Value;
                    produit.Description   = element.Descendants("Description").Single().Value;
                    produit.Photo         = element.Descendants("Photo").Single().Value;
                    produit.PrixDemande   = decimal.Parse(element.Descendants("PrixDemande").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    produit.NombreItems   = short.Parse(element.Descendants("NombreItems").Single().Value);
                    produit.Disponibilité = element.Descendants("Disponibilit_").Single().Value == "1" ? true : false;
                    if (element.Descendants("DateVente").Single().Value == "NULL")
                    {
                        produit.DateVente = null;
                    }
                    else
                    {
                        produit.DateVente = DateTime.Parse(element.Descendants("DateVente").Single().Value);
                    }
                    if (element.Descendants("PrixVente").Single().Value == "NULL")
                    {
                        produit.PrixVente = null;
                    }
                    else
                    {
                        produit.PrixVente = decimal.Parse(element.Descendants("PrixVente").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    }
                    produit.Poids        = decimal.Parse(element.Descendants("Poids").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    produit.DateCreation = DateTime.Parse(element.Descendants("DateCreation").Single().Value);
                    if (element.Descendants("DateMAJ").Single().Value == "NULL")
                    {
                        produit.DateMAJ = null;
                    }
                    else
                    {
                        produit.DateMAJ = DateTime.Parse(element.Descendants("DateMAJ").Single().Value);
                    }

                    dbContext.PPProduits.Add(produit);
                }

                document = XDocument.Load(Server.MapPath("\\static\\xml\\PPArticlesEnPanier.xml"));
                racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPArticlesEnPanier"))
                {
                    PPArticlesEnPanier articleEnPanier = new PPArticlesEnPanier();
                    articleEnPanier.NoPanier     = long.Parse(element.Descendants("NoPanier").Single().Value);
                    articleEnPanier.NoClient     = long.Parse(element.Descendants("NoClient").Single().Value);
                    articleEnPanier.NoVendeur    = long.Parse(element.Descendants("NoVendeur").Single().Value);
                    articleEnPanier.NoProduit    = long.Parse(element.Descendants("NoProduit").Single().Value);
                    articleEnPanier.DateCreation = DateTime.Parse(element.Descendants("DateCreation").Single().Value);
                    articleEnPanier.NbItems      = short.Parse(element.Descendants("NbItems").Single().Value);

                    dbContext.PPArticlesEnPanier.Add(articleEnPanier);
                }

                document = XDocument.Load(Server.MapPath("\\static\\xml\\PPTypesPoids.xml"));
                racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPTypesPoids"))
                {
                    PPTypesPoids typePoids = new PPTypesPoids();
                    typePoids.CodePoids = short.Parse(element.Descendants("CodePoids").Single().Value);
                    typePoids.PoidsMin  = decimal.Parse(element.Descendants("PoidsMin").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    typePoids.PoidsMax  = decimal.Parse(element.Descendants("PoidsMax").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));

                    dbContext.PPTypesPoids.Add(typePoids);
                }

                document = XDocument.Load(Server.MapPath("\\static\\xml\\PPTypesLivraison.xml"));
                racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPTypesLivraison"))
                {
                    PPTypesLivraison typeLivraison = new PPTypesLivraison();
                    typeLivraison.CodeLivraison = short.Parse(element.Descendants("CodeLivraison").Single().Value);
                    typeLivraison.Description   = element.Descendants("Description").Single().Value;

                    dbContext.PPTypesLivraison.Add(typeLivraison);
                }

                document = XDocument.Load(Server.MapPath("\\static\\xml\\PPPoidsLivraisons.xml"));
                racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPPoidsLivraisons"))
                {
                    PPPoidsLivraisons poidsLivraison = new PPPoidsLivraisons();
                    poidsLivraison.CodeLivraison = short.Parse(element.Descendants("CodeLivraison").Single().Value);
                    poidsLivraison.CodePoids     = short.Parse(element.Descendants("CodePoids").Single().Value);
                    poidsLivraison.Tarif         = decimal.Parse(element.Descendants("Tarif").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));

                    dbContext.PPPoidsLivraisons.Add(poidsLivraison);
                }

                document = XDocument.Load(Server.MapPath("\\static\\xml\\PPCommandes.xml"));
                racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPCommandes"))
                {
                    PPCommandes commande = new PPCommandes();
                    commande.NoCommande           = long.Parse(element.Descendants("NoCommande").Single().Value);
                    commande.NoClient             = long.Parse(element.Descendants("NoClient").Single().Value);
                    commande.NoVendeur            = long.Parse(element.Descendants("NoVendeur").Single().Value);
                    commande.DateCommande         = DateTime.Parse(element.Descendants("DateCommande").Single().Value);
                    commande.CoutLivraison        = decimal.Parse(element.Descendants("CoutLivraison").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    commande.TypeLivraison        = short.Parse(element.Descendants("TypeLivraison").Single().Value);
                    commande.MontantTotAvantTaxes = decimal.Parse(element.Descendants("MontantTotAvantTaxes").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    commande.TPS            = decimal.Parse(element.Descendants("TPS").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    commande.TVQ            = decimal.Parse(element.Descendants("TVQ").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    commande.PoidsTotal     = decimal.Parse(element.Descendants("PoidsTotal").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    commande.Statut         = element.Descendants("Statut").Single().Value;
                    commande.NoAutorisation = element.Descendants("NoAutorisation").Single().Value;

                    dbContext.PPCommandes.Add(commande);
                }

                document = XDocument.Load(Server.MapPath("\\static\\xml\\PPDetailsCommandes.xml"));
                racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPDetailsCommandes"))
                {
                    PPDetailsCommandes detailCommande = new PPDetailsCommandes();
                    detailCommande.NoDetailCommandes = long.Parse(element.Descendants("NoDetailCommandes").Single().Value);
                    detailCommande.NoCommande        = long.Parse(element.Descendants("NoCommande").Single().Value);
                    detailCommande.NoProduit         = long.Parse(element.Descendants("NoProduit").Single().Value);
                    detailCommande.PrixVente         = decimal.Parse(element.Descendants("PrixVente").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    detailCommande.Quantité          = short.Parse(element.Descendants("Quantit_").Single().Value);

                    dbContext.PPDetailsCommandes.Add(detailCommande);
                }

                document = XDocument.Load(Server.MapPath("\\static\\xml\\PPVendeursClients.xml"));
                racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPVendeursClients"))
                {
                    PPVendeursClients vendeurClient = new PPVendeursClients();
                    vendeurClient.NoVendeur  = long.Parse(element.Descendants("NoVendeur").Single().Value);
                    vendeurClient.NoClient   = long.Parse(element.Descendants("NoClient").Single().Value);
                    vendeurClient.DateVisite = DateTime.Parse(element.Descendants("DateVisite").Single().Value);

                    dbContext.PPVendeursClients.Add(vendeurClient);
                }

                document = XDocument.Load(Server.MapPath("\\static\\xml\\PPHistoriquePaiements.xml"));
                racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPHistoriquePaiements"))
                {
                    PPHistoriquePaiements historiquePaiement = new PPHistoriquePaiements();
                    historiquePaiement.NoHistorique = long.Parse(element.Descendants("NoHistorique").Single().Value);
                    historiquePaiement.MontantVenteAvantLivraison = decimal.Parse(element.Descendants("MontantVenteAvantLivraison").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    historiquePaiement.NoVendeur      = long.Parse(element.Descendants("NoVendeur").Single().Value);
                    historiquePaiement.NoClient       = long.Parse(element.Descendants("NoClient").Single().Value);
                    historiquePaiement.NoCommande     = long.Parse(element.Descendants("NoCommande").Single().Value);
                    historiquePaiement.DateVente      = DateTime.Parse(element.Descendants("DateVente").Single().Value);
                    historiquePaiement.NoAutorisation = element.Descendants("NoCommande").Single().Value;
                    historiquePaiement.FraisLesi      = decimal.Parse(element.Descendants("FraisLesi").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    historiquePaiement.Redevance      = decimal.Parse(element.Descendants("Redevance").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    historiquePaiement.FraisLivraison = decimal.Parse(element.Descendants("FraisLivraison").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    historiquePaiement.FraisTPS       = decimal.Parse(element.Descendants("FraisTPS").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));
                    historiquePaiement.FraisTVQ       = decimal.Parse(element.Descendants("FraisTVQ").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));

                    dbContext.PPHistoriquePaiements.Add(historiquePaiement);
                }

                document = XDocument.Load(Server.MapPath("\\static\\xml\\PPTaxeProvinciale.xml"));
                racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPTaxeProvinciale"))
                {
                    PPTaxeProvinciale taxeProvinciale = new PPTaxeProvinciale();
                    taxeProvinciale.NoTVQ            = byte.Parse(element.Descendants("NoTVQ").Single().Value);
                    taxeProvinciale.DateEffectiveTVQ = DateTime.Parse(element.Descendants("DateEffectiveTVQ").Single().Value);
                    taxeProvinciale.TauxTVQ          = decimal.Parse(element.Descendants("TauxTVQ").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));

                    dbContext.PPTaxeProvinciale.Add(taxeProvinciale);
                }

                document = XDocument.Load(Server.MapPath("\\static\\xml\\PPTaxeFederale.xml"));
                racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPTaxeFederale"))
                {
                    PPTaxeFederale taxeFederale = new PPTaxeFederale();
                    taxeFederale.NoTPS            = byte.Parse(element.Descendants("NoTPS").Single().Value);
                    taxeFederale.DateEffectiveTPS = DateTime.Parse(element.Descendants("DateEffectiveTPS").Single().Value);
                    taxeFederale.TauxTPS          = decimal.Parse(element.Descendants("TauxTPS").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator));

                    dbContext.PPTaxeFederale.Add(taxeFederale);
                }

                document = XDocument.Load(Server.MapPath("\\static\\xml\\PPGestionnaires.xml"));
                racine   = document.Element("dataroot");
                foreach (var element in racine.Elements("PPGestionnaires"))
                {
                    PPGestionnaires gestionnaire = new PPGestionnaires();
                    gestionnaire.ID         = long.Parse(element.Descendants("ID").Single().Value);
                    gestionnaire.courriel   = element.Descendants("courriel").Single().Value;
                    gestionnaire.motDePasse = element.Descendants("motDePasse").Single().Value;

                    dbContext.PPGestionnaires.Add(gestionnaire);
                }

                dbContext.SaveChanges();
                transaction.Commit();

                lblMessage.Text     = "Les données du jeu d'essai ont été importées.";
                divMessage.CssClass = "alert alert-success alert-margins";
            }
            catch (DbUpdateException ex)
            {
                transaction.Rollback();

                if (ex.InnerException is UpdateException && ex.InnerException.InnerException is SqlException)
                {
                    lblMessage.Text = "Une erreur s'est produite lors de l'importation du jeu d'essai. Les données n'ont pas été importées. Voici l'erreur : " + ex.InnerException.InnerException.Message;
                }
                else
                {
                    lblMessage.Text = "Une erreur s'est produite lors de l'importation du jeu d'essai. Les données n'ont pas été importées. Voici l'erreur : " + ex.Message;
                }
                divMessage.CssClass = "alert alert-danger alert-margins";
                binOK = false;
            }
            catch (Exception ex)
            {
                transaction.Rollback();

                lblMessage.Text     = "Une erreur s'est produite lors de l'importation du jeu d'essai. Les données n'ont pas été importées. Voici l'erreur : " + ex.Message;
                divMessage.CssClass = "alert alert-danger alert-margins";
                binOK = false;
            }
        }

        divMessage.Visible = true;

        remplirTableau(true);

        if (binOK)
        {
            btnImporterDonnees.Visible = false;
            btnViderBD.Visible         = true;
        }
    }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Session.IsVendeur())
        {
            Response.Redirect(SessionManager.RedirectConnexionLink);
        }

        vendeur = Session.GetVendeur();

        //Requetes pour commandes non traitées
        //PPCommandes commandes = new PPCommandes();
        PPDetailsCommandes details = new PPDetailsCommandes();
        PPClients          clients = new PPClients();

        var commandesVendeur = from commande in commandes.Values
                               join monClient in clients.Values on commande.NoClient equals monClient.NoClient
                               where commande.NoVendeur == vendeur.NoVendeur && commande.Statut == "0"
                               orderby commande.DateCommande ascending
                               let lstDetails = details.Values.Where(x => x.NoCommande == commande.NoCommande).ToList()
                                                select new { Commande = commande, Client = monClient, Details = lstDetails };

        //Commandes
        int indexCom = 0;

        if (commandesVendeur.Count() > 0)
        {
            foreach (var com in commandesVendeur)
            {
                TableRow row          = new TableRow();
                long?    noCommande   = com.Commande.NoCommande;
                string   nomClient    = com.Client.Prenom + " " + com.Client.Nom;
                DateTime dateCommande = com.Commande.DateCommande.Value;

                decimal poidsCommande = com.Commande.PoidsTotal.Value;

                PPHistoriquePaiements historique = new PPHistoriquePaiements();
                //requete pour aller cherche le montant dans l'historique
                var montant = from montantHisto in historique.Values
                              where montantHisto.NoCommande == com.Commande.NoCommande
                              select montantHisto.MontantVenteAvantLivraison;

                decimal montantCom = montant.First().Value;

                string nomPDF = "";

                if (File.Exists(Server.MapPath("~/Factures/" + noCommande.ToString() + ".pdf")))
                {
                    nomPDF = noCommande.ToString() + ".pdf";
                }
                else
                {
                    nomPDF = "defaut.pdf";
                }

                TableCell cellNom = new TableCell();

                /* cellNom.Text = "Marcel Leboeuf";
                 * cellNom.Attributes.Add("OnClick", "window.location.assign('http://www.google.com');");*/
                //cellNom.BtnDyn("", nomClient, ouvrirInfosClients, "table btn btn-outline-secondary text-left");
                cellNom.Text = nomClient;
                cellNom.Attributes.Add("OnClick", "ouvrirPDF('" + nomPDF + "');");
                row.Cells.Add(cellNom);


                TableCell cellDate = new TableCell();
                cellDate.Text = dateCommande.ToString("yyyy/MM/dd");
                cellDate.Attributes.Add("OnClick", "ouvrirPDF('" + nomPDF + "');");
                row.Cells.Add(cellDate);

                TableCell cellPrix = new TableCell();
                cellPrix.CssClass = "text-right";
                cellPrix.Text     = montantCom.ToString("N2") + " $";

                cellPrix.Attributes.Add("OnClick", "ouvrirPDF('" + nomPDF + "');");
                row.Cells.Add(cellPrix);

                TableCell cellStatut = new TableCell();
                cellStatut.CssClass = "text-right";
                cellStatut.Text     = poidsCommande.ToString("N2") + " Lbs";
                cellStatut.Attributes.Add("OnClick", "ouvrirPDF('" + nomPDF + "');");
                row.Cells.Add(cellStatut);


                //modal (il faut faire référence à la div à cet effet dans le front-hand.
                modal(panelAvecModal, "myModal" + indexCom.ToString(), noCommande.ToString(), "btnAnnulerLiv" + indexCom.ToString(), "Livraison", "Voulez-vous vraiment confirmer la livraison de cette commande? (" + noCommande.ToString() + ")", true);

                TableCell cellBtn   = row.TdDyn();
                Button    btnLivrer = cellBtn.BtnDyn("", "Prêt à livrer", null, "btn btn-secondary btn-block btn-sm");

                btnLivrer.OnClientClick = "return false;";
                btnLivrer.Attributes.Add("data-toggle", "modal");
                btnLivrer.Attributes.Add("data-target", "#Contenu_ContenuPrincipal_myModal" + indexCom.ToString());

                row.Cells.Add(cellBtn);

                tableCommandesNonTraitee.Rows.Add(row);
                indexCom++;
            }
        }
        else
        {
            tableCommandesNonTraitee.Visible = false;
            pnUseless.LblDyn("", "Vous n'avez aucune commande non traités", "h4 text-info");
        }



        PPArticlesEnPanier articlesEnPanier = new PPArticlesEnPanier();
        PPProduits         produits         = new PPProduits();

        var yes = from article in articlesEnPanier.Values
                  //join vendeur in vendeurs.Values on article.NoVendeur equals vendeur.NoVendeur
                  join produit in produits.Values on article.NoProduit equals produit.NoProduit
                  where article.NoVendeur == vendeur.NoVendeur
                  orderby article.DateCreation ascending
                  select new { Article = article, Produit = produit };

        var grouped = from article in yes
                      group article by article.Article.NoClient into g
                      join client in clients.Values on g.Key equals client.NoClient
                      select new
        {
            NoClient = g.Key,
            Client   = client,
            Articles = g.ToList()
        };

        int index = 0;

        if (grouped.Count() > 0)
        {
            foreach (var group in grouped)
            {
                string   nomClient      = "Anonyme";
                string   noClient       = group.Client.NoClient.ToString();
                decimal  montant        = 0;
                int      nombreArticles = 0;
                DateTime datePanier     = DateTime.Now;

                if (group.Client.Prenom != null && group.Client.Nom != null)
                {
                    nomClient = group.Client.Prenom + " " + group.Client.Nom;
                }

                foreach (var article in group.Articles)
                {
                    nombreArticles++;
                    montant   += article.Produit.PrixDemande.Value * article.Article.NbItems.Value;
                    datePanier = article.Article.DateCreation.Value.Date;
                }

                Panel pnCard   = panelPanier.DivDyn("", "card mb-3");
                Panel pnHeader = pnCard.DivDyn("", "card-header fake-button");

                pnHeader.LblDyn("", "(" + noClient + ") ", "card-title h5 text-info");
                pnHeader.LblDyn("", nomClient, "card-title h5 text-info");
                pnHeader.LblDyn("", "valeur de " + montant.ToString("N2") + " $", "ml-3 card-title h6");
                pnHeader.LblDyn("", "Articles (" + nombreArticles.ToString() + ")", "ml-3 card-title h6");
                pnHeader.LblDyn("", datePanier.ToString("yyyy/MM/dd"), "ml-3 card-title h6 text-success");

                pnHeader.Attributes.Add("data-toggle", "collapse");
                pnHeader.Attributes.Add("data-target", "#Contenu_ContenuPrincipal_collapsePanierBas" + index.ToString());
                pnHeader.Attributes.Add("aria-expanded", "false");
                pnHeader.Attributes.Add("aria-controls", "Contenu_ContenuPrincipal_collapsePanierBas" + index.ToString());


                Panel collapsable  = pnCard.DivDyn("collapsePanierBas" + index.ToString(), "collapse collapse");
                Panel panelBodyCat = collapsable.DivDyn("", "card-body");

                //prix
                Panel rowTotal = panelBodyCat.DivDyn("", "row ml-3");
                rowTotal.LblDyn("", "total de ce panier : ", "h4 mb-3");
                rowTotal.LblDyn("", montant.ToString("N2") + " $", "h4 text-success mb-3 ml-2");


                Table          table    = panelBodyCat.TableDyn("", "table table-hover fake-button");
                TableHeaderRow rowTable = table.ThrDyn();
                rowTable.ThdDyn("");
                rowTable.ThdDyn("Produit");
                TableHeaderCell headerCss = rowTable.ThdDyn("Prix unitaire");
                headerCss.CssClass = "moneyDroite";
                headerCss          = rowTable.ThdDyn("Poids unitaire");
                headerCss.CssClass = "moneyDroite";
                headerCss          = rowTable.ThdDyn("Qte.");
                headerCss.CssClass = "text-center";
                headerCss          = rowTable.ThdDyn("Prix total (sans rabais)");
                headerCss.CssClass = "moneyDroite";

                /* for (int j = 0; j < 5; j++)
                 * {*/
                foreach (var article in group.Articles)
                {
                    string  lblRabais      = "";
                    string  nomArticle     = article.Produit.Nom;
                    decimal montantArticle = -1;
                    if (article.Produit.PrixVente != article.Produit.PrixDemande && article.Produit.DateVente >= DateTime.Today)
                    {
                        decimal montantRabais = article.Produit.PrixDemande.Value - article.Produit.PrixVente.Value;
                        lblRabais      = "<br/>rabais! (" + montantRabais.ToString("N2") + "$) finit le " + article.Produit.DateVente.Value.ToString("yyyy-MM-dd");
                        montantArticle = article.Produit.PrixDemande.Value;
                    }
                    else
                    {
                        montantArticle = article.Produit.PrixDemande.Value;
                    }
                    decimal poidsArticle = article.Produit.Poids.Value;
                    short   nbItems      = article.Article.NbItems.Value;
                    decimal prix         = article.Produit.PrixDemande.Value * article.Article.NbItems.Value;


                    TableRow nRow = table.TrDyn();
                    nRow.Attributes.Add("OnClick", "ouvrirDetailProduit('" + article.Produit.NoProduit.ToString() + "');");

                    TableCell cell1 = nRow.TdDyn("", "");
                    cell1.ImgDyn("", "~/Pictures/" + article.Produit.Photo, "imgResize");

                    TableCell cell2 = nRow.TdDyn("", "");
                    cell2.LblDyn("", nomArticle, "");

                    TableCell cell3 = nRow.TdDyn("", "moneyDroite");
                    cell3.LblDyn("", montantArticle.ToString("N2") + " $ ", "");
                    cell3.LblDyn("", lblRabais, "text-success");

                    TableCell cell4 = nRow.TdDyn("", "moneyDroite");
                    cell4.LblDyn("", poidsArticle.ToString("N2") + " Lbs", "");

                    TableCell cell5 = nRow.TdDyn("", "text-center");
                    cell5.LblDyn("", "(" + nbItems.ToString() + ")", "");

                    TableCell cell6 = nRow.TdDyn("", "moneyDroite");
                    cell6.LblDyn("", prix.ToString("N2") + " $", "text-success");
                }

                Panel  rowBtnSupprimer = collapsable.DivDyn("", "row ml-3 mr-3 mb-3");
                Button btnClient       = rowBtnSupprimer.BtnDyn("btnCourriel" + index.ToString(), "Courriel", btnCourriel_Click, "btn btn-outline-dark btn-block");
                btnClient.CommandArgument = (group.NoClient).ToString();
                index++;
            }
        }
        else
        {
            panelPanier.LblDyn("", "Vous n'avez aucun panier présentement", "h4 text-info");
        }

        panelNBVisite.LblDyn("", "Vous êtes présentement à ", "h5");

        //requete trouver nbVisites
        int visites = 0;
        PPVendeursClients clientsVendeur = new PPVendeursClients();
        VendeurClient     client2        = clientsVendeur.Values.Find(x => x.NoVendeur == vendeur.NoVendeur);

        foreach (VendeurClient vc in clientsVendeur.Values)
        {
            if (vc.NoVendeur == vendeur.NoVendeur)
            {
                visites++;
            }
        }
        panelNBVisite.LblDyn("", visites.ToString(), "text-primary h4");
        panelNBVisite.LblDyn("", " visites de clients", "h5");

        nombreClientParVendeur();

        //ajouter les stats ici
    }
    private void click_supprimer(object sender, EventArgs e)
    {
        Button     btn        = (Button)sender;
        PPProduits produits   = new PPProduits();
        Produit    aSupprimer = produits.Values.Where(x => x.NoProduit == long.Parse(btn.ID.ToString().Split('s')[1])).ToList().First();
        //je peux récupérer l'id a supprimer avec le code ci-haut
        bool                   panier      = false;
        bool                   commande    = false;
        string                 sortie      = aSupprimer.NoProduit.ToString() + " ---> ";
        PPArticlesEnPanier     paniers     = new PPArticlesEnPanier();
        List <ArticleEnPanier> listePanier = paniers.Values.Where(x => x.NoProduit == aSupprimer.NoProduit).ToList();

        if (listePanier.Count() != 0)
        {
            //Dans panier
            panier = true;
        }

        PPDetailsCommandes      detailsCommandes = new PPDetailsCommandes();
        List <DetailsCommandes> listeCommande    = detailsCommandes.Values.Where(x => x.NoProduit == aSupprimer.NoProduit).ToList();

        if (listeCommande.Count() != 0)
        {
            //Dans commande
            commande = true;
        }

        if (!panier && !commande)
        {
            //null part
            //panelTable.LblDyn("", "On peut supprimer le produit");
            produits.Remove(aSupprimer);
            produits.Update();
            File.Delete(Server.MapPath("~/Pictures/") + aSupprimer.Photo);
            Response.Redirect(Request.RawUrl);
        }
        else if (panier && !commande)
        {
            //panier mais pas commande
            PPMessages      ppM = new PPMessages();
            PPDestinataires ppd = new PPDestinataires();
            PPVendeurs      ppv = new PPVendeurs();
            long            noM = ppM.NextId();
            //@Marc ici on envoie un courriel a tous les clients ayant eu un panier pour le produit
            int     noV     = int.Parse(Session.GetVendeur().NoVendeur.ToString());
            Vendeur venMess = ppv.Values.Find(v => v.NoVendeur == aSupprimer.NoVendeur);
            Message m       = new Message(null)
            {
                NoMsg        = (int)noM,
                DescMsg      = $"Un des produits dans votre panier ({aSupprimer.Nom}) de {venMess.NomAffaires} fut supprimé.",
                objet        = "Un des produits dans votre panier fut supprimé.",
                Lieu         = 2,
                dateEnvoi    = DateTime.Now,
                NoExpediteur = noV
            };
            ppM.Add(m);
            ppM.Update();


            //supprimer les paniers liés a ce produit
            foreach (ArticleEnPanier article in listePanier)
            {
                Destinataire d = new Destinataire(null)
                {
                    NoDestinataire = (int)article.NoClient,
                    NoMsg          = (int)noM,
                    EtatLu         = 0,
                    Lieu           = 1
                };
                ppd.Add(d);
                ppd.Update();
                paniers.Remove(article);
            }
            paniers.Update();
            //supprimer le produit en question
            produits.Remove(aSupprimer);
            produits.Update();
            File.Delete(Server.MapPath("~/Pictures/") + aSupprimer.Photo);



            Response.Redirect(Request.RawUrl);


            //panelTable.LblDyn("", "Retirer des paniers, aviser le vendeur : nb Panier : " + listePanier.Count().ToString());
        }
        else if (!panier && commande)
        {
            //a revoir car pas vraiment supprimé... lol
            //dans commande mais pas panier
            aSupprimer.Disponibilité = false;
            aSupprimer.NombreItems   = -1;
            produits.NotifyUpdatedOutside(aSupprimer);
            produits.Update();
            Response.Redirect(Request.RawUrl);
            //panelTable.LblDyn("", "Reste au catalogue, qte devient 0 et dispo = non");
        }
        else if (panier && commande)
        {
            //partout
            PPMessages      ppM = new PPMessages();
            PPDestinataires ppd = new PPDestinataires();
            PPVendeurs      ppv = new PPVendeurs();
            long            noM = ppM.NextId();

            int     noV     = int.Parse(Session.GetVendeur().NoVendeur.ToString());
            Vendeur venMess = ppv.Values.Find(v => v.NoVendeur == aSupprimer.NoVendeur);
            Message m       = new Message(null)
            {
                NoMsg        = (int)noM,
                DescMsg      = $"Un des produits dans votre panier ({aSupprimer.Nom}) de {venMess.NomAffaires} fut supprimé.",
                objet        = "Un des produits dans votre panier fut supprimé.",
                Lieu         = 2,
                dateEnvoi    = DateTime.Now,
                NoExpediteur = noV
            };
            ppM.Add(m);
            ppM.Update();


            //supprime les paniers
            foreach (ArticleEnPanier article in listePanier)
            {
                Destinataire d = new Destinataire(null)
                {
                    NoDestinataire = (int)article.NoClient,
                    NoMsg          = (int)noM,
                    EtatLu         = 0,
                    Lieu           = 1
                };
                ppd.Add(d);
                ppd.Update();
                paniers.Remove(article);
            }
            paniers.Update();

            //change le statut a cause des commandes
            aSupprimer.Disponibilité = false;
            aSupprimer.NombreItems   = -1;
            produits.NotifyUpdatedOutside(aSupprimer);
            produits.Update();

            //@Marc ici on envoie un courriel a tous les clients ayant eu un panier pour le produit


            Response.Redirect(Request.RawUrl);
            //panelTable.LblDyn("", "Retirer panier et Mettre Qte a 0 et dispo = non");
        }
    }