Пример #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;
        }
    }
Пример #2
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();
    }
Пример #3
0
    protected void remplirCategories(XNamespace ss, XElement worksheet)
    {
        PPCategories categories = new PPCategories();

        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() == 3)
            {
                categories.Add(new Categorie(null)
                {
                    NoCategorie = Convert.ToInt32(arrayStr[0]),
                    Description = arrayStr[1],
                    Details     = arrayStr[2]
                });
            }
        }
    }
    private void creerPage()
    {
        // Nom de l'entreprise
        PPVendeurs vendeur;

        phDynamique.Controls.Clear();
        //_header.Controls.Clear();


        Panel colImage = LibrairieControlesDynamique.divDYN(_rowHeader_, nomEntreprise + "_colImage_", "col-sm-2 text-center");

        if (dbContext.PPVendeurs.Where(c => c.NoVendeur == noVendeur).Any())
        {
            vendeur = dbContext.PPVendeurs.Where(c => c.NoVendeur == noVendeur).First();
            XDocument docXml   = XDocument.Load(Server.MapPath("\\static\\xml\\" + vendeur.Configuration));
            XElement  elements = docXml.Element("configuration");
            String    urlImg   = "~/static/images/" + elements.Descendants("urlImage").Single().Value;
            System.Web.UI.WebControls.Image img = LibrairieControlesDynamique.imgDYN(colImage, "", urlImg, "");
            img.Style.Add("width", "100px");
            String urlBackColor = elements.Descendants("couleurFond").Single().Value;
            String urlForeColor = elements.Descendants("couleurTexte").Single().Value;
            _base.BackColor = ColorTranslator.FromHtml(urlBackColor);
            _base.ForeColor = ColorTranslator.FromHtml(urlForeColor);
        }


        Panel colEntreprise = LibrairieControlesDynamique.divDYN(_rowHeader_, nomEntreprise + "_colEntreprise_", "col-sm-6");

        LibrairieControlesDynamique.lblDYN(colEntreprise, nomEntreprise + "_nom", nomEntreprise, "nom-entreprise");
        Panel colVendeurs = LibrairieControlesDynamique.divDYN(_rowHeader_, nomEntreprise + "_colDdlVendeur_", "col-sm-4 text-right prix_item");

        LibrairieControlesDynamique.lblDYN(colVendeurs, nomEntreprise + "_lblDDLVendeur", "Choisir un vendeur : ", "");
        DropDownList ddlVendeurs = LibrairieControlesDynamique.ddlDYN(colVendeurs, "lesVendeurs", "");

        ddlVendeurs.Items.Clear();
        ddlVendeurs.Items.Insert(0, new ListItem("Tous les vendeurs", ""));
        ddlVendeurs.AutoPostBack    = true;
        ddlVendeurs.EnableViewState = true;
        List <PPVendeurs> lesVendeurs = dbContext.PPVendeurs.Where(c => (c.Statut.Value.Equals(1)) && (c.PPProduits.Count() > 0)).ToList();

        for (int i = 0; i < lesVendeurs.Count; i++)
        {
            long   leNoVendeur      = lesVendeurs[i].NoVendeur;
            string strNomEntreprise = lesVendeurs[i].NomAffaires;
            ddlVendeurs.Items.Insert(i + 1, new ListItem(strNomEntreprise, leNoVendeur.ToString()));
        }
        ddlVendeurs.SelectedIndexChanged += ddlVendeurIndex;
        if (Convert.ToString(Session["NoVendeurCatalogue"]) != null && Convert.ToString(Session["NoVendeurCatalogue"]) != "")
        {
            ddlVendeurs.SelectedIndex = ddlVendeurs.Items.IndexOf(ddlVendeurs.Items.FindByValue(Convert.ToString(Session["NoVendeurCatalogue"])));
        }
        else if (ddlVendeurs.Items.Count > 0)
        {
            ddlVendeurs.SelectedIndex = 0;
        }
        // ddlVendeurs.SelectedItem.Value = noVendeur.ToString();

        // Liste des items + le total
        panelBody = LibrairieControlesDynamique.divDYN(phDynamique, nomEntreprise + "_body", "panel-body");
        int nbProduitsVendeur = dbContext.PPProduits.Where(c => c.NoVendeur == noVendeur).Count();


        // Rajouter les produits dans le panier
        if (nbProduitsVendeur > 0)
        {
            int laCategorieDDL = Convert.ToInt32(ddlCategorie.SelectedValue);
            Dictionary <string, List <PPProduits> > getProduitsSearch;
            if (laCategorieDDL != 1)
            {
                getProduitsSearch = getProduitsUneCategorie(_tbsearchText.Text.Trim());
            }
            else if (Convert.ToBoolean(Session["booTriDateStart"]))
            {
                getProduitsSearch = getProduitsParDate(_tbsearchText.Text.Trim());
            }
            else if (Convert.ToBoolean(Session["booTriNumeroStart"]))
            {
                getProduitsSearch = getProduitsParNumero(_tbsearchText.Text.Trim());
            }
            else
            {
                getProduitsSearch = getProduitsVendeurParCategorie(_tbsearchText.Text.Trim());
            }

            foreach (var keys in getProduitsSearch)
            {
                string descCategorie = keys.Key;
                if (descCategorie != "")
                {
                    Panel panCategorie   = LibrairieControlesDynamique.divDYN(panelBody, nomEntreprise + "_categorie_" + descCategorie, "flex-container");
                    Panel colCatAfficher = LibrairieControlesDynamique.divDYN(panCategorie, nomEntreprise + "_colLabelCategorie" + descCategorie, "");
                    LibrairieControlesDynamique.lblDYN(colCatAfficher, nomEntreprise + "_labelCategorie" + descCategorie, descCategorie, "infos-payage");
                }

                foreach (PPProduits produitCat in keys.Value)
                {
                    long   idItem     = Convert.ToInt64(produitCat.NoProduit);
                    String nomProduit = produitCat.Nom.ToString();
                    Double prix;

                    if (produitCat.DateVente > DateTime.Now.Date)
                    {
                        prix = Convert.ToDouble(produitCat.PrixVente);
                    }
                    else
                    {
                        prix = Convert.ToDouble(produitCat.PrixDemande);
                    }
                    decimal?montantRabais = produitCat.PrixDemande - produitCat.PrixVente;
                    if (produitCat.DateVente < DateTime.Now)
                    {
                        montantRabais = 0;
                    }
                    String       urlImage   = "../static/images/" + produitCat.Photo;
                    int          noCat      = produitCat.NoCategorie.Value;
                    PPCategories pCategorie = dbContext.PPCategories.Where(c => c.NoCategorie.Equals(noCat)).First();
                    String       categorie  = pCategorie.Description;

                    Panel rowItem = LibrairieControlesDynamique.divDYN(panelBody, nomEntreprise + "_rowItem_" + idItem, "row valign top15");

                    // ajouter l'image
                    Panel colImg = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colImg_" + idItem, "col-sm-2");
                    LibrairieControlesDynamique.imgDYN(colImg, nomEntreprise + "_img_" + idItem, urlImage, "img-size center-block");
                    LibrairieControlesDynamique.lblDYN(colImg, nomEntreprise + "_noproduit_" + idItem, idItem.ToString(), "caption center-block text-center");

                    // Nom du produit
                    Panel      colNom    = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colNom_" + idItem, "col-sm-3 text-justify LiensProduits nomClient");
                    LinkButton leProduit = LibrairieControlesDynamique.lbDYN(colNom, nomEntreprise + "_nom_" + idItem, nomProduit, null);
                    leProduit.PostBackUrl = "~/Pages/AffichageProduitDetaille.aspx?&NoProduit=" + idItem;

                    // Categorie
                    Panel colCat = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colCategorie_" + idItem, "col-sm-2");
                    LibrairieControlesDynamique.lblDYN(colCat, nomEntreprise + "_categorie_" + idItem, categorie, "cat_item");

                    // Prix item
                    Panel colPrix = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colPrix_" + idItem, "col-sm-1 text-right");
                    LibrairieControlesDynamique.lblDYN(colPrix, nomEntreprise + "_prixDemande_" + idItem, prix.ToString("C", CultureInfo.CurrentCulture), "prix_item");
                    LibrairieControlesDynamique.brDYN(colPrix);
                    LibrairieControlesDynamique.lblDYN(colPrix, "lblRabais" + idItem, (montantRabais > 0) ? "Rabais de " + Decimal.Round((Decimal)montantRabais, 2).ToString("C", CultureInfo.CurrentCulture) : "", "rabais");

                    // Quantité restant
                    colQuantite = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colQuantite_" + idItem, "col-sm-2 text-center");

                    TextBox tbQuantite = LibrairieControlesDynamique.numericUpDownDYN(colQuantite, "quantite_" + idItem, (produitCat.NombreItems < 1) ? "0" : "1"
                                                                                      , (produitCat.NombreItems < 1) ? "0" : produitCat.NombreItems.ToString(), "numUD form-control border-quantite");
                    LibrairieControlesDynamique.lblDYN(colQuantite, nomEntreprise + "_nbQuantiteMax_" + idItem, "<br>Quantité : " + produitCat.NombreItems, "");

                    colAjout = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colAjout_" + idItem, "col-sm-2 text-center");
                    Button btnAjout = LibrairieControlesDynamique.btnDYN(colAjout, "btnAjouter_" + idItem, "btn valignMessage btnPageOrange", "Ajouter au panier", btnAjouter_click);
                    btnAjout.UseSubmitBehavior = false;
                    LibrairieControlesDynamique.lblDYN(colAjout, nomEntreprise + "_espaceGlyph_" + idItem, "<br>", "");
                    long  leVendeurProduit  = produitCat.NoVendeur.Value;
                    short nbProduitEnPanier = 0;
                    if (dbContext.PPArticlesEnPanier.Where(c => (c.NoClient.Value.Equals(noClient)) && (c.NoVendeur.Value.Equals(leVendeurProduit)) && (c.NoProduit.Value.Equals(idItem))).Any())
                    {
                        nbProduitEnPanier = dbContext.PPArticlesEnPanier.Where(c => (c.NoClient.Value.Equals(noClient)) && (c.NoVendeur.Value.Equals(leVendeurProduit)) && (c.NoProduit.Value.Equals(idItem))).First().NbItems.Value;
                    }
                    LibrairieControlesDynamique.lblDYN(colAjout, nomEntreprise + "_nbEnPanier_" + idItem, "(" + nbProduitEnPanier + ")", "glyphicon glyphicon-shopping-cart");

                    if (produitCat.NombreItems < 1)
                    {
                        tbQuantite.Enabled = false;
                        LibrairieControlesDynamique.lblDYN(colQuantite, "lblRupture" + idItem, "<br>Rupture de stock", "rupture-stock");
                        btnAjout.Enabled  = false;
                        btnAjout.CssClass = "btn valignMessage btnPageOrange disabled";
                    }
                    else
                    {
                        tbQuantite.Enabled = true;
                        btnAjout.Enabled   = true;
                        btnAjout.CssClass  = "btn valignMessage btnPageOrange";
                    }
                }
            }
        }
    }
    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;
        }
    }
    private void creerPage()
    {
        System.Diagnostics.Debug.WriteLine("PAGE LOAD LE DDL = " + nbMois);

        Panel panelGroup = LibrairieControlesDynamique.divDYN(phDynamique, nomEntreprise + "_PanelGroup2", "panel-group container-fluid marginFluid");
        Panel panelBase  = LibrairieControlesDynamique.divDYN(panelGroup, nomEntreprise + "_base2", "panel panel-default");
        // Nom de l'entreprise
        Panel panelHeader = LibrairieControlesDynamique.divDYN(panelBase, nomEntreprise + "_header2", "panel-heading");

        Panel rowInactif = LibrairieControlesDynamique.divDYN(panelHeader, nomEntreprise + "_rowInactif2_", "row");
        Panel colInactif = LibrairieControlesDynamique.divDYN(rowInactif, nomEntreprise + "_colInactif2_", "col-sm-12");

        LibrairieControlesDynamique.lblDYN(colInactif, nomEntreprise + "_nom2", nomEntreprise + " - " + leVendeur.AdresseEmail, "nom-entreprise");
        panelBody2 = LibrairieControlesDynamique.divDYN(panelBase, nomEntreprise + "_PanelBody2", "panel-body");

        DateTime dateParMois    = DateTime.Now.AddMonths(-nbMois);
        DateTime dateParMoisMax = DateTime.Now.AddMonths(-(nbMois + 1));

        System.Diagnostics.Debug.WriteLine(" LE NBMOIS = " + nbMois + " dateParMois = " + dateParMois + " dateParMoisMAx = " + dateParMoisMax);
        if (nbMois == 7)
        {
            dateParMoisMax = DateTime.MinValue;
        }
        List <PPArticlesEnPanier> lstPaniersEntreprise = new List <PPArticlesEnPanier>();
        List <PPArticlesEnPanier> lstArticles          = dbContext.PPArticlesEnPanier.GroupBy(x => x.NoClient).Select(t => t.OrderBy(c => c.DateCreation).FirstOrDefault()).ToList();

        foreach (PPArticlesEnPanier lesArticles in lstArticles)
        {
            if ((lesArticles.DateCreation <= dateParMois) && (lesArticles.DateCreation >= dateParMoisMax))
            {
                lstPaniersEntreprise.AddRange(dbContext.PPArticlesEnPanier.Where(c => (c.NoVendeur == noVendeur) && (c.NoClient == lesArticles.NoClient)).OrderBy(C => C.DateCreation).ToList());
            }
        }
        panelBody2.Controls.Clear();
        Panel panCategorie   = LibrairieControlesDynamique.divDYN(panelBody2, nomEntreprise + "_pretLivraison2_", "row text-center");
        Panel colCatAfficher = LibrairieControlesDynamique.divDYN(panCategorie, nomEntreprise + "_colLabelPretLivraison2", "col-sm-12");

        LibrairieControlesDynamique.lblDYN(colCatAfficher, nomEntreprise + "_labelCategorie2", "Panier Courants ", "infos-payage OrangeTitle");
        LibrairieControlesDynamique.hrDYN(colCatAfficher, "OrangeBorderPanier", 5);

        // Rajouter les produits dans le panier

        if (lstPaniersEntreprise.Count > 0)
        {
            long ancienID = 0;
            for (int i = 0; i < lstPaniersEntreprise.Count; i++)
            {
                long         idItem      = lstPaniersEntreprise[i].NoPanier;
                long         idProduit   = lstPaniersEntreprise[i].NoProduit.Value;
                PPProduits   leProduit   = dbContext.PPProduits.Where(c => c.NoProduit == idProduit).First();
                PPCategories laCategorie = dbContext.PPCategories.Where(c => c.NoCategorie == leProduit.NoCategorie).First();
                long         idClient    = lstPaniersEntreprise[i].NoClient.Value;
                int          NbVisites   = dbContext.PPVendeursClients.Where(c => (c.NoClient == idClient) && (c.NoVendeur == noVendeur)).Count();
                PPClients    leClient    = dbContext.PPClients.Where(c => c.NoClient == idClient).First();
                decimal      prix        = leProduit.PrixDemande.Value;
                String       nomProduit  = leProduit.Nom.ToString();
                String       urlImage    = "../static/images/" + leProduit.Photo.ToString();


                if (ancienID != lstPaniersEntreprise[i].NoClient.Value)
                {
                    //Trigger panel pour accordeon
                    Panel panelTrigger = LibrairieControlesDynamique.divDYN(panelBody2, nomEntreprise + "_PanelTrigger" + i, "trigger");
                    Panel rowClient    = LibrairieControlesDynamique.divDYN(panelTrigger, nomEntreprise + "_rowTrigger_" + idItem, "row top15 text-center border-left");
                    // Col Glyph
                    Panel colGlyph = LibrairieControlesDynamique.divDYN(rowClient, nomEntreprise + "_colGlyph_" + idItem, "col-sm-2");
                    LibrairieControlesDynamique.lblDYN(colGlyph, nomEntreprise + "_GlyphPanier_" + idItem, "", "glyphicon glyphicon-shopping-cart text-left");
                    //Nom Client
                    Panel  colNomClient = LibrairieControlesDynamique.divDYN(rowClient, nomEntreprise + "_colClient2_" + idItem, "col-sm-2 text-left");
                    string nomClient    = (leClient.Nom != null && leClient.Nom != "") ? "Client : " + leClient.Prenom + " " + leClient.Nom : "Client : " + leClient.AdresseEmail;
                    LibrairieControlesDynamique.lblDYN(colNomClient, nomEntreprise + "_NomClient2_" + idItem, nomClient, "nomClient prix_item");
                    // Nb Visites du client
                    Panel colClientVisites = LibrairieControlesDynamique.divDYN(rowClient, nomEntreprise + "_colVisites_" + idItem, "col-sm-2 text-left");
                    LibrairieControlesDynamique.lblDYN(colClientVisites, nomEntreprise + "_VisiteClient_" + idItem, " Nombre de visites : " + NbVisites, "nomClient prix_item");

                    //Date
                    Panel colDate = LibrairieControlesDynamique.divDYN(rowClient, nomEntreprise + "_colDate_" + idItem, "col-sm-2 text-left");
                    LibrairieControlesDynamique.lblDYN(colDate, nomEntreprise + "_date_" + idItem, "Date de création : " + Convert.ToDateTime(lstPaniersEntreprise[i].DateCreation).ToShortDateString(), "prix_item");

                    //SousTotal du panier
                    decimal sousTotalPanier = 0;
                    for (int j = 0; j < lstPaniersEntreprise.Count; j++)
                    {
                        if (lstPaniersEntreprise[j].NoClient == leClient.NoClient)
                        {
                            long    idItem2         = lstPaniersEntreprise[j].NoProduit.Value;
                            decimal calculSousTotal = (decimal)dbContext.PPProduits.Where(c => c.NoProduit == idItem2).First().PrixDemande;
                            sousTotalPanier += calculSousTotal * lstPaniersEntreprise[j].NbItems.Value;
                        }
                    }
                    Panel colSousTotal = LibrairieControlesDynamique.divDYN(rowClient, nomEntreprise + "_colSousTotalPanier_" + idItem, "col-sm-2 text-center");
                    LibrairieControlesDynamique.lblDYN(colSousTotal, nomEntreprise + "_SousTotalPanier_" + idItem, sousTotalPanier.ToString("C", CultureInfo.CurrentCulture), "nomClient prix_item");

                    if (nbMois == 7)
                    {
                        Panel  colDel       = LibrairieControlesDynamique.divDYN(rowClient, nomEntreprise + "_colDel_", "col-sm-2");
                        Button btnSupprimer = LibrairieControlesDynamique.btnDYN(colDel, "btnSupprimer_" + idClient, "btn btn-danger", "Supprimer", btnSupprimer_click);
                        btnSupprimer.OnClientClick = "if( !PanierDeleteConfirmation()) return false;";
                        //btnSupprimer.Attributes.Add("onClientClick", );
                    }


                    //Panneau Accordeon
                    PanelCollapse = LibrairieControlesDynamique.divDYN(panelBody2, nomEntreprise + "_PanelCollapse" + i, "panel panelAccord");
                }

                Panel rowItem = LibrairieControlesDynamique.divDYN(PanelCollapse, nomEntreprise + "_rowItem2_" + idItem, "row valign top15");

                // ajouter l'image
                Panel colImg = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colImg2_" + idItem, "col-sm-2 ");
                LibrairieControlesDynamique.imgDYN(colImg, nomEntreprise + "_img2_" + idItem, urlImage, "img-size center-block");
                LibrairieControlesDynamique.lblDYN(colImg, nomEntreprise + "_noproduit2_" + idItem, idProduit.ToString(), "caption center-block text-center");


                // Nom du produit
                Panel colNom = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colNom2_" + idItem, "col-sm-3 LiensProduits nomClient");
                LibrairieControlesDynamique.lbDYN(colNom, nomEntreprise + "_nom2_" + idItem + "-" + idProduit, nomProduit, descriptionProduit);

                // Quantité restant
                Panel colQuantite = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colQuantite2_" + idItem, "col-sm-2 text-right");
                LibrairieControlesDynamique.lblDYN(colQuantite, nomEntreprise + "_quantite2_" + idItem, "Qte : " + lstPaniersEntreprise[i].NbItems, "prix_item");

                // Categorie
                Panel colCat = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colCategorie_" + idItem, "col-sm-3 text-right");
                LibrairieControlesDynamique.lblDYN(colCat, nomEntreprise + "_categorie2_" + idItem, laCategorie.Description.ToString(), "cat_item");

                // Prix item
                Panel colPrix = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colPri2x_" + idItem, "col-sm-2 text-center");
                LibrairieControlesDynamique.lblDYN(colPrix, nomEntreprise + "_prix2_" + idItem, "Prix Unitaire<br>" + prix.ToString("C", CultureInfo.CurrentCulture), "prix_item");



                ancienID = idClient;
            }
            LibrairieControlesDynamique.hrDYN(panelBody2, "OrangeBorderPanier", 5);
        }
        else
        {
            Panel row              = LibrairieControlesDynamique.divDYN(panelBody2, nomEntreprise + "_rowPanierVide", "row marginFluid text-center");
            Panel message          = LibrairieControlesDynamique.divDYN(row, nomEntreprise + "_messagePanierVide", "message text-center top15");
            Panel messageContainer = LibrairieControlesDynamique.divDYN(message, nomEntreprise + "_divMessage", "alert alert-danger alert-margins");
            LibrairieControlesDynamique.lblDYN(messageContainer, nomEntreprise + "_leMessageLabel", "Vous avez aucun panier courant.");
            LibrairieControlesDynamique.hrDYN(panelBody2, "OrangeBorderPanier", 5);
        }
    }
Пример #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        bool connecte = false;

        if (Session.IsClient())
        {
            panelInformations.Visible = true;
            pnClientPanier.Visible    = true;
            PanelVendeurs.Visible     = true;
            connecte = true;
        }

        PPCategories categories = new PPCategories();
        PPVendeurs   vendeurs   = new PPVendeurs();
        PPProduits   produits   = new PPProduits();

        var groupe = from produit in produits.Values
                     group produit by produit.NoCategorie into groupement
                     join categorie in categories.Values on groupement.Key equals categorie.NoCategorie
                     select new { LCategories = groupement.ToList(), Categories = categorie };

        //for pour remplir le pnHaut (Correspond au panel avec le titre : catégorie
        int   index  = 0;
        int   index2 = 0;
        Panel rows   = null;

        foreach (var categorie in groupe)
        {
            //requete pour grouper les vendeurs
            var groupement = (from gr in categorie.LCategories.AsEnumerable()
                              group gr by gr.NoVendeur into ok
                              join vendeur in vendeurs.Values on ok.Key equals vendeur.NoVendeur
                              select new { Vendeurs = vendeur }).Where(v => v.Vendeurs.Statut != -1);

            string nomCategorie = categorie.Categories.Description;

            if (index % 2 == 0)
            {
                rows = pnHaut.DivDyn("", "row");
                index2++;
            }

            //header des categories
            Panel panelCard = rows.DivDyn("", "col-lg-6 mb-3");

            panelCard.CardDynCollapse("", "", index2 == 1 && index == 0 ? "show" : "",
                                      header =>
            {
                header.LblDyn("", nomCategorie, "card-title h5 text-primary");
                header.LblDyn("", $"({groupement.Count()} vendeurs)", "card-title ml-3 h5 text-primary");
            },
                                      body =>
            {
                Table table             = body.TableDyn("", "table table-hover fake-button");
                TableHeaderRow rowTable = table.ThrDyn();
                rowTable.ThdDyn("");
                rowTable.ThdDyn("Vendeur");
                rowTable.ThdDyn("Quantité d'articles dans cette catégorie");
                foreach (var vendeur in groupement)
                {
                    PPProduits produitsCount = new PPProduits();
                    List <Produit> liste     = produits.Values.Where(x => x.NoVendeur == vendeur.Vendeurs.NoVendeur && x.NoCategorie == categorie.Categories.NoCategorie).ToList();
                    //contenu des collapse

                    TableRow nRow = table.TrDyn();
                    if (connecte)
                    {
                        nRow.Attributes.Add("OnClick", "window.location.assign('/Pages/Client/Catalogue.aspx?NoVendeur=" + vendeur.Vendeurs.NoVendeur + "&NoCategorie=" + categorie.Categories.NoCategorie + "');");
                    }
                    else
                    {
                        nRow.Attributes.Add("OnClick", "window.location.assign('/Pages/Nouveautes.aspx');");
                    }
                    string strLogo = "placeholder.png";
                    if (vendeur.Vendeurs.Configuration != null)
                    {
                        strLogo = vendeur.Vendeurs.Configuration.Split(';')[0];
                    }
                    TableCell cell1 = nRow.TdDyn("", "");
                    cell1.ImgDyn("", "~/Logos/" + strLogo, "imgResize");

                    TableCell cell2 = nRow.TdDyn();
                    cell2.LblDyn("", vendeur.Vendeurs.NomAffaires, "text-info h5");

                    TableCell cell3 = nRow.TdDyn();
                    cell3.LblDyn("", "(" + liste.Count() + ")", "");
                }
                index++;
            });
        }

        //section client
        if (connecte)
        {
            Client client = Session.GetClient();
            //row de recherche
            //panel pnInfos

            Panel rowInfos   = pnInfos.DivDyn("", "row");
            Panel pnPourConn = rowInfos.DivDyn("", "col-md-6");
            pnPourConn.LblDyn("", "Votre nombre de connexions : ", "align-self-center h5");
            pnPourConn.LblDyn("lblNbCo", client.NbConnexions.ToString(), "text-primary align-self-center h5");

            Panel pnDate = rowInfos.DivDyn("", "col-md-6");
            pnDate.LblDyn("", "Dernière connexion : ", "align-self-center h5");
            pnDate.LblDyn("", client.DateDerniereConnexion.Value.ToString("yyyy/MM/dd"), "align-self-center h5 text-primary");



            PPArticlesEnPanier articlesEnPanier = new PPArticlesEnPanier();


            var panierArticlesParVendeurs = (from article in articlesEnPanier.Values
                                             join produit in produits.Values on article.NoProduit equals produit.NoProduit
                                             where article.NoClient == client.NoClient
                                             select new
            {
                Article = article,
                Produit = produit
            } into articleProduit
                                             group articleProduit by articleProduit.Article.NoVendeur into g
                                             join vendeur in vendeurs.Values on g.Key equals vendeur.NoVendeur
                                             select new
            {
                Vendeur = vendeur,
                Articles = g.ToList()
            }).Where(v => v.Vendeur.Statut != -1);
            index  = 0;
            index2 = 0;
            rows   = null;
            foreach (var group in panierArticlesParVendeurs)
            {
                string   nomVendeur     = group.Vendeur.NomAffaires;
                string   noVendeur      = group.Vendeur.NoVendeur.ToString();
                decimal  montant        = 0;
                int      nombreArticles = 0;
                DateTime datePanier     = DateTime.Now;


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

                // Panel card = pnHaut.DivDyn("card" + i.ToString(), "card");
                if (index % 2 == 0)
                {
                    rows = pnPaniers.DivDyn("", "row");
                    index2++;
                }

                //header des categories
                Panel panelCard = rows.DivDyn("", "col-xl-6 mb-3");

                panelCard.CardDynCollapse("", "", "",
                                          header =>
                {
                    header.LblDyn("", nomVendeur, "card-title h5 text-info");
                    header.LblDyn("", $"valeur de {montant.ToString("N2")}$", "card-title ml-3 h6");
                    header.LblDyn("", $"Articles ({nombreArticles})", "card-title ml-3 h6");
                },
                                          body =>
                {
                    body.BtnClientDyn("", "Aller au panier", $"panierVendeur({noVendeur}); return false;", "btn btn-secondary btn-block mb-3");

                    //colones header
                    Table table             = body.TableDyn("", "table table-hover fake-button");
                    TableHeaderRow rowTable = table.ThrDyn();
                    rowTable.ThdDyn("");
                    rowTable.ThdDyn("Produit");
                    rowTable.ThdDyn("Poids unitaire");
                    rowTable.ThdDyn("Quantite");
                    rowTable.ThdDyn("Prix unitaire");
                    rowTable.ThdDyn("Prix total");

                    foreach (var article in group.Articles)
                    {
                        //contenu des collapse

                        string nomArticle      = article.Produit.Nom;
                        decimal montantArticle = article.Produit.PrixVente.Value;
                        decimal poidsArticle   = article.Produit.Poids.Value;
                        short nbItems          = article.Article.NbItems.Value;
                        decimal prix           = article.Produit.PrixVente.Value * article.Article.NbItems.Value;

                        TableRow nRow = table.TrDyn();
                        nRow.Attributes.Add("OnClick", "window.location.assign('/Pages/Client/InfoProduit.aspx?ID=" + article.Produit.NoProduit + "');");

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

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

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

                        TableCell cell4 = nRow.TdDyn();
                        cell4.LblDyn("", "(" + nbItems.ToString() + ")", "");

                        TableCell cell5 = nRow.TdDyn();
                        cell5.CssClass  = "moneyDroite";
                        cell5.LblDyn("", montantArticle.ToString("N2") + " $", "moneyDroite");

                        TableCell cell6 = nRow.TdDyn();
                        cell6.CssClass  = "moneyDroite";
                        cell6.LblDyn("", prix.ToString("N2") + " $", "text-success moneyDroite");
                    }
                    //prix total
                    Panel rowTotal = body.DivDyn("", "moneyDroite");
                    rowTotal.LblDyn("", "Total de ce panier : ", "h4 mb-3");
                    rowTotal.LblDyn("", montant.ToString("N2") + " $", "h4 text-success mb-3 ml-2");
                    index++;
                });
            }
            index  = 0;
            index2 = 0;
            rows   = null;
            foreach (var vendeur in vendeurs.Values.Where(v => v.Statut == 1))
            {
                string nomVendeur = vendeur.NomAffaires;
                if (index % 2 == 0)
                {
                    rows = pnVendeurs.DivDyn("", "row");
                    index2++;
                }
                //header des categories
                Panel panelCard            = rows.DivDyn("", "col-md-6 mb-3");
                Panel card                 = panelCard.DivDyn("", "card");
                Panel panelTitreCategories = card.DivDyn("", "card-header fake-button");
                var   prod                 = produits.Values.Where(v => v.NoVendeur.Equals(vendeur.NoVendeur)).Count();
                panelTitreCategories.LblDyn("", nomVendeur + " (" + prod + " produits)", "card-title h5 text-primary");
                panelTitreCategories.Attributes.Add("OnClick", "window.location.assign('/Pages/Client/Catalogue.aspx?NoVendeur=" + vendeur.NoVendeur + "');");
                index++;
            }
        }
    }
    private void creerPage()
    {
        dbContext.SaveChanges();
        Panel panelGroup = LibrairieControlesDynamique.divDYN(phDynamique, nomEntreprise + "_PanelGroup", "panel-group container-fluid marginFluid");
        Panel panelBase  = LibrairieControlesDynamique.divDYN(panelGroup, nomEntreprise + "_base", "panel panel-default");
        // Nom de l'entreprise
        Panel panelHeader = LibrairieControlesDynamique.divDYN(panelBase, nomEntreprise + "_header", "panel-heading");

        Panel rowInactif = LibrairieControlesDynamique.divDYN(panelHeader, nomEntreprise + "_rowInactif_", "row");
        Panel colInactif = LibrairieControlesDynamique.divDYN(rowInactif, nomEntreprise + "_colInactif_", "col-sm-12");

        LibrairieControlesDynamique.lblDYN(colInactif, nomEntreprise + "_nom", nomEntreprise + " - " + nomVendeur, "nom-entreprise");
        panelBody = LibrairieControlesDynamique.divDYN(panelBase, nomEntreprise + "_PanelBody", "panel-body");

        panelBody.Controls.Clear();
        // Btn Delete

        // btnSupprimer.Style.Add("width", "105px");
        LibrairieControlesDynamique.hrDYN(panelBody, "OrangeBorder", 30);

        // Chercher les produits de la compagnie
        List <PPProduits> lesProduits = dbContext.PPProduits.Where(c => (c.NoVendeur == noVendeur) && (c.Disponibilité != null)).ToList();

        // Rajouter les produits dans le panier
        if (lesProduits.Count > 0)
        {
            for (int i = 0; i < lesProduits.Count; i++)
            {
                long         idItem        = Convert.ToInt64(lesProduits[i].NoProduit);
                String       nomProduit    = lesProduits[i].Nom.ToString();
                Double       prix          = Convert.ToDouble(lesProduits[i].PrixDemande);
                Double       prixVente     = Convert.ToDouble(lesProduits[i].PrixVente);
                String       urlImage      = "../static/images/" + lesProduits[i].Photo;
                int          noCat         = lesProduits[i].NoCategorie.Value;
                PPCategories pCategorie    = dbContext.PPCategories.Where(c => c.NoCategorie.Equals(noCat)).First();
                String       categorie     = pCategorie.Description;
                String       disponibilite = lesProduits[i].Disponibilité == true ? "Disponible" : "Indisponible";

                Panel rowItem = LibrairieControlesDynamique.divDYN(panelBody, nomEntreprise + "_rowItem_" + idItem, "row valign top15");

                // ajouter l'image
                Panel colImg = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colImg_" + idItem, "col-sm-1 ");
                LibrairieControlesDynamique.imgDYN(colImg, nomEntreprise + "_img_" + idItem, urlImage, "img-size center-block");
                LibrairieControlesDynamique.lblDYN(colImg, nomEntreprise + "_noproduit_" + idItem, idItem.ToString(), "caption center-block text-center");

                // Nom du produit
                Panel colNom = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colNom_" + idItem, "col-sm-2 LiensProduits nomClient breakWord");
                LibrairieControlesDynamique.lbDYN(colNom, nomEntreprise + "_nom_" + idItem, nomProduit, modifierProduit);

                // Modification
                Panel colMod = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colMod_" + idItem, "col-sm-1 text-center");
                LibrairieControlesDynamique.btnDYN(colMod, "btnModifier_" + idItem, "btn btnPageOrange", "Modifier", btnModifier_Click);

                // Quantité restant
                Panel colQuantite = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colQuantite_" + idItem, "col-sm-1");
                LibrairieControlesDynamique.lblDYN(colQuantite, nomEntreprise + "_quantite_" + idItem, "Qte : " + lesProduits[i].NombreItems, "prix_item");

                // Categorie
                Panel colCat = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colCategorie_" + idItem, "col-sm-2 breakWord");
                LibrairieControlesDynamique.lblDYN(colCat, nomEntreprise + "_categorie_" + idItem, categorie, "cat_item");

                // Dispo
                Panel colDispo = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colDispo_" + idItem, "col-sm-1");
                LibrairieControlesDynamique.lblDYN(colDispo, nomEntreprise + "_Disponibilite_" + idItem, disponibilite, "cat_item");

                // Prix item
                Panel colPrix = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colPrix_" + idItem, "col-sm-2 text-right");
                if (lesProduits[i].PrixVente != null)
                {
                    if (lesProduits[i].DateVente > DateTime.Now)
                    {
                        LibrairieControlesDynamique.lblDYN(colPrix, nomEntreprise + "_prixVente_" + idItem, "Prix de vente : " + prixVente.ToString("C", CultureInfo.CurrentCulture) + "<br>", "prix_item");
                    }
                    else
                    {
                        LibrairieControlesDynamique.lblDYN(colPrix, nomEntreprise + "_prixVente_" + idItem, "Prix de vente : " + prixVente.ToString("C", CultureInfo.CurrentCulture) + "<br>", "prix_item produitNonVente");
                    }
                }
                else
                {
                    LibrairieControlesDynamique.lblDYN(colPrix, nomEntreprise + "_prixVente_" + idItem, "Prix de vente : N/A" + "<br>", "prix_item");
                }

                LibrairieControlesDynamique.lblDYN(colPrix, nomEntreprise + "_prixDemande_" + idItem, "Prix demandé : " + prix.ToString("C", CultureInfo.CurrentCulture), "prix_item");

                // Panel rowDel = LibrairieControlesDynamique.divDYN(panelBody, nomEntreprise + "_rowDel_", "row text-right");
                Panel      colDel        = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colDel_" + idItem, "col-sm-2 text-center");
                HtmlButton btnSupprimmer = LibrairieControlesDynamique.htmlbtnDYN(colDel, "btnSupprimer_" + idItem, "btn btn-danger", "Supprimer", "glyphicon glyphicon-remove", btnSupprimer_click);
                //btnSupprimer.Attributes.Add("onclick", "Confirm();");
                // CheckBox (Supprimer plusieurs)
                //Panel colCB = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colCB_" + idItem, "col-sm-2 text-center");
                //CheckBox cbDelete = LibrairieControlesDynamique.cb(colCB, nomEntreprise + "_cbSupprimer_" + idItem, "");
            }
        }
        else
        {
            Panel row              = LibrairieControlesDynamique.divDYN(panelBody, nomEntreprise + "_rowPanierVide", "row marginFluid text-center");
            Panel message          = LibrairieControlesDynamique.divDYN(row, nomEntreprise + "_messagePanierVide", "message text-center top15");
            Panel messageContainer = LibrairieControlesDynamique.divDYN(message, nomEntreprise + "_divMessage", "alert alert-danger alert-margins");
            LibrairieControlesDynamique.lblDYN(messageContainer, nomEntreprise + "_leMessageLabel", "Vous avez aucun produit dans votre catalogue");
        }
        LibrairieControlesDynamique.hrDYN(panelBody, "OrangeBorder", 30);
    }
Пример #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Session.IsClient())
        {
            Response.Redirect(SessionManager.RedirectConnexionLink);
        }
        if (!IsPostBack)
        {
            var url = Request.UrlReferrer;
            if (url != null)
            {
                ViewState["PreviousPageUrl"] = url.ToString();
            }
        }
        long produitARG;

        // se faire passer la valeur du produit par ce tag [ID] i.e : ?ID=noProduit
        if (long.TryParse(Request.QueryString["ID"], out produitARG))
        {
            //long produitARG = 1200001;
            PPProduits produits   = new PPProduits();
            Produit    monProduit = new Produit(null);
            foreach (Produit prod in produits.Values.Where(x => x.NoProduit == (long?)produitARG))
            {
                monProduit = produits.Values.Where(x => x.NoProduit == (long?)produitARG).ToList().First();
            }

            if (monProduit.NoProduit != null)
            {
                panelImage.Visible = true;
                Image img = panelImage.ImgDyn("", "~/Pictures/" + monProduit.Photo, "img-fluid");


                Table     table   = panelDetails.TableDyn("", "table table-striped");
                TableRow  rowDet  = table.TrDyn();
                TableCell colDet1 = rowDet.TdDyn();
                TableCell colDet2 = rowDet.TdDyn();

                //nom
                colDet1.LblDyn("", "Nom du produit", "text-info h3");
                colDet2.LblDyn("", monProduit.Nom, "h3 text-success");

                PPCategories categos = new PPCategories();
                Categorie    categ   = new Categorie(null);
                foreach (Categorie cat in categos.Values.Where(x => x.NoCategorie == monProduit.NoCategorie))
                {
                    categ = cat;
                }
                if (categ.NoCategorie != null)
                {
                    //Catégorie
                    rowDet  = table.TrDyn();
                    colDet1 = rowDet.TdDyn();
                    colDet2 = rowDet.TdDyn();

                    colDet1.LblDyn("", "Catégorie", "text-info h5");
                    colDet2.LblDyn("", categ.Description, "h5");

                    //Description
                    rowDet  = table.TrDyn();
                    colDet1 = rowDet.TdDyn();
                    colDet2 = rowDet.TdDyn();

                    colDet1.LblDyn("", "Description du produit", "text-info h5");
                    colDet2.LblDyn("", monProduit.Description, "h5");

                    //Prix demandé
                    rowDet  = table.TrDyn();
                    colDet1 = rowDet.TdDyn();
                    colDet2 = rowDet.TdDyn();

                    colDet1.LblDyn("", "Prix demandé", "text-info h5");
                    colDet2.LblDyn("", monProduit.PrixDemande.Value.ToString("N2") + " $", "h5");

                    //Prix Vente
                    rowDet  = table.TrDyn();
                    colDet1 = rowDet.TdDyn();
                    colDet2 = rowDet.TdDyn();

                    colDet1.LblDyn("", "Prix de vente", "text-info h5");
                    if (monProduit.PrixVente.Value != monProduit.PrixDemande.Value)
                    {
                        colDet2.LblDyn("", monProduit.PrixVente.Value.ToString("N2") + " $", "h5");
                    }
                    else
                    {
                        colDet2.LblDyn("", "Pas en vente", "h5");
                    }

                    //qte
                    rowDet  = table.TrDyn();
                    colDet1 = rowDet.TdDyn();
                    colDet2 = rowDet.TdDyn();

                    colDet1.LblDyn("", "Quantité disponible", "text-info h5");
                    if (monProduit.NombreItems == 0)
                    {
                        colDet2.LblDyn("", "Aucun article disponible", "h5");
                    }
                    else
                    {
                        colDet2.LblDyn("", monProduit.NombreItems.ToString(), "h5");
                    }


                    //Poids
                    rowDet  = table.TrDyn();
                    colDet1 = rowDet.TdDyn();
                    colDet2 = rowDet.TdDyn();

                    colDet1.LblDyn("", "Poids du produit", "text-info h5");
                    colDet2.LblDyn("", monProduit.Poids.Value.ToString("N2") + " Lbs", "h5");

                    //Date de vente
                    rowDet  = table.TrDyn();
                    colDet1 = rowDet.TdDyn();
                    colDet2 = rowDet.TdDyn();

                    string dateVente = "indéfénie";
                    if (monProduit.DateVente.HasValue)
                    {
                        dateVente = monProduit.DateVente.Value.ToString("yyyy/MM/dd");
                    }

                    colDet1.LblDyn("", "Fin de la vente", "text-info h5");
                    colDet2.LblDyn("", dateVente, "h5");

                    if (monProduit.NombreItems != 0)
                    {
                        rowDet = table.TrDyn();

                        colDet1 = rowDet.TdDyn();
                        colDet1.LblDyn("", "Quantité à commander: ", "text-info h5");
                        colDet2 = rowDet.TdDyn();
                        DropDownList ddl = new DropDownList();
                        for (int i = 0; i < monProduit.NombreItems.Value; i++)
                        {
                            ddl.Items.Add((i + 1).ToString());
                        }
                        ddl.SelectedIndex = 0;
                        ddl.CssClass      = "form-control w-25 d-inline align-middle mr-3";
                        colDet2.Controls.Add(ddl);
                        TableCell colDet3 = rowDet.TdDyn();
                        Button    btn     = colDet2.BtnClientDyn("", "Ajouter au panier", $"ajouterArticle({Session.GetClient().NoClient},{monProduit.NoProduit},'{ddl.ClientID}');return false;", "btn btn-success d-inline");
                    }
                    panelDetails.BtnDyn("", "Retour", retour, "btn  btn-outline-dark classBoutonsMargins100");


                    Button btnContactV = panelDetails.BtnDyn("", "Contacter le vendeur", btnCourrielVendeur_Click, "btn btn-secondary classBoutonsMargins100");
                    btnContactV.CommandArgument = monProduit.NoVendeur.ToString();
                    btnContactV.CommandName     = monProduit.Nom;
                }
            }
        }
    }