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;
        }
    }
Beispiel #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") + "$");
            }
        });
    }
    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();
    }
    protected void remplirTypesLivraison(XNamespace ss, XElement worksheet)
    {
        PPTypesLivraison typesLivraison = new PPTypesLivraison();

        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() == 2)
            {
                typesLivraison.Add(new TypeLivraison(null)
                {
                    CodeLivraison = Convert.ToInt16(arrayStr[0]),
                    Description   = arrayStr[1]
                });
            }
        }
    }
    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;
        }
    }
        public ActionResult ajouterLesDonnees()
        {
            try
            {
                /*
                 * PPTypesPoids
                 */
                var docTypePoids = (from typePoids in XDocument
                                    .Load(Server.MapPath("/XML/PPTypesPoids.xml")).Descendants("row")
                                    select new
                {
                    CodePoids = typePoids.Element("CodePoids").Value,
                    PoidsMin = typePoids.Element("PoidsMin").Value,
                    PoidsMax = typePoids.Element("PoidsMax").Value
                }).ToList();

                PPTypesPoid typesPoid;

                foreach (var type in docTypePoids)
                {
                    typesPoid = new PPTypesPoid();


                    typesPoid.CodePoids = Convert.ToInt16(type.CodePoids);
                    typesPoid.PoidsMin  = Convert.ToDecimal(type.PoidsMin, culture);
                    typesPoid.PoidsMax  = Convert.ToDecimal(type.PoidsMax, culture);

                    context.PPTypesPoids.InsertOnSubmit(typesPoid);
                }

                /*
                 * PPTypesLivraison
                 */
                var docTypeLivraison = (from typeLivraison in XDocument
                                        .Load(Server.MapPath("/XML/PPTypesLivraison.xml")).Descendants("row")
                                        select new
                {
                    CodeLivraison = typeLivraison.Element("CodeLivraison").Value,
                    Description = typeLivraison.Element("Description").Value
                }).ToList();
                PPTypesLivraison objTypesLivraison;

                foreach (var type in docTypeLivraison)
                {
                    objTypesLivraison = new PPTypesLivraison();

                    objTypesLivraison.CodeLivraison = Convert.ToInt16(type.CodeLivraison);
                    objTypesLivraison.Description   = type.Description;

                    context.PPTypesLivraisons.InsertOnSubmit(objTypesLivraison);
                }

                /*
                 * PPPoidsLivraison
                 */
                var docPoidsLivraison = (from poidslivraison in XDocument
                                         .Load(Server.MapPath("/XML/PPPoidsLivraison.xml")).Descendants("row")
                                         select new
                {
                    CodeLivraison = poidslivraison.Element("CodeLivraison").Value,
                    CodePoids = poidslivraison.Element("CodePoids").Value,
                    Tarif = poidslivraison.Element("Tarif").Value
                }).ToList();

                PPPoidsLivraison podLivraison;

                foreach (var type in docPoidsLivraison)
                {
                    podLivraison = new PPPoidsLivraison();

                    podLivraison.CodeLivraison = Convert.ToInt16(type.CodeLivraison);
                    podLivraison.CodePoids     = Convert.ToInt16(type.CodePoids);
                    podLivraison.Tarif         = Convert.ToDecimal(type.Tarif, culture);


                    context.PPPoidsLivraisons.InsertOnSubmit(podLivraison);
                }

                /*
                 * PPCategories
                 */
                var docCategorie = (from unCategorie in XDocument
                                    .Load(Server.MapPath("/XML/PPCategorie.xml")).Descendants("row")
                                    select new
                {
                    NoCategorie = unCategorie.Element("NoCategorie").Value,
                    Description = unCategorie.Element("Description").Value,
                    Details = unCategorie.Element("Details").Value
                }).ToList();

                PPCategory category;

                foreach (var unCat in docCategorie)
                {
                    category = new PPCategory();

                    category.NoCategorie = Convert.ToInt32(unCat.NoCategorie);
                    category.Details     = unCat.Details;
                    category.Description = unCat.Description;

                    context.PPCategories.InsertOnSubmit(category);
                }

                /*
                 * PPGestionnaires
                 */
                var objGestionnaire = (from unGestionnaire in XDocument
                                       .Load(Server.MapPath("/XML/PPGestionnaire.xml")).Descendants("row")
                                       select new PPGestionnaire
                {
                    NoGestionnaire = Convert.ToInt64(unGestionnaire.Element("NoGestionnaire").Value),
                    Nom = unGestionnaire.Element("Nom").Value,
                    Prenom = unGestionnaire.Element("Prenom").Value,
                    AdresseEmail = unGestionnaire.Element("AdresseEmail").Value,
                    MotDePasse = unGestionnaire.Element("MotDePasse").Value
                }).ToList();

                foreach (var objG in objGestionnaire)
                {
                    using (SqlConnection connection =
                               new SqlConnection(
                                   WebConfigurationManager.ConnectionStrings["BD6B8_424QConnectionString"].ToString()))
                    {
                        connection.Open();
                        SqlCommand insert = new SqlCommand
                        {
                            CommandText = string.Format(
                                "INSERT INTO PPGestionnaires (NoGestionnaire, Nom, Prenom, AdresseEmail, MotDePasse) VALUES (" +
                                "{0}, '{1}', '{2}', '{3}', '{4}')", objG.NoGestionnaire, objG.Nom, objG.Prenom,
                                objG.AdresseEmail, objG.MotDePasse),
                            Connection = connection
                        };
                        insert.ExecuteNonQuery();
                        connection.Close();
                    }
                }


                /*
                 * PPClients
                 */
                var docClient = (from unClient in XDocument
                                 .Load(Server.MapPath("/XML/PPClients.xml")).Descendants("row")
                                 select new
                {
                    NoClient = unClient.Element("NoClient").Value,
                    AdresseEmail = unClient.Element("AdresseEmail").Value,
                    MotDePasse = unClient.Element("MotDePasse").Value,
                    Nom = unClient.Element("Nom").Value,
                    Prenom = unClient.Element("Prenom").Value,
                    Rue = unClient.Element("Rue").Value,
                    Ville = unClient.Element("Ville").Value,
                    Province = unClient.Element("Province").Value,
                    CodePostal = unClient.Element("CodePostal").Value,
                    Pays = unClient.Element("Pays").Value,
                    Tel1 = unClient.Element("Tel1").Value,
                    Tel2 = unClient.Element("Tel2").Value,
                    DateCreation = unClient.Element("DateCreation").Value,
                    DateMAJ = unClient.Element("DateMAJ").Value,
                    NbConnexions = unClient.Element("NbConnexions").Value,
                    DateDerniereConnexion = unClient.Element("DateDerniereConnexion").Value,
                    Statut = unClient.Element("Statut").Value
                }).ToList();

                PPClient objClient;

                foreach (var unclient in docClient)
                {
                    objClient = new PPClient();

                    objClient.NoClient     = Convert.ToInt64(unclient.NoClient);
                    objClient.AdresseEmail = unclient.AdresseEmail;
                    objClient.MotDePasse   = unclient.MotDePasse;
                    objClient.Nom          = unclient.Nom;
                    objClient.Prenom       = unclient.Prenom;
                    objClient.Rue          = unclient.Rue;
                    objClient.Ville        = unclient.Ville;
                    objClient.Province     = unclient.Province;
                    objClient.CodePostal   = unclient.CodePostal;
                    objClient.Pays         = unclient.Pays;
                    objClient.Tel1         = unclient.Tel1;
                    objClient.Tel2         = unclient.Tel2;
                    if (unclient.DateCreation != "")
                    {
                        objClient.DateCreation = Convert.ToDateTime(unclient.DateCreation);
                    }
                    if (unclient.DateMAJ != "")
                    {
                        objClient.DateMAJ = Convert.ToDateTime(unclient.DateMAJ);
                    }
                    if (unclient.DateDerniereConnexion != "")
                    {
                        objClient.DateDerniereConnexion = Convert.ToDateTime(unclient.DateDerniereConnexion);
                    }
                    objClient.NbConnexions = Convert.ToInt16(unclient.NbConnexions);
                    objClient.Statut       = Convert.ToInt16(unclient.Statut);

                    context.PPClients.InsertOnSubmit(objClient);
                }

                /*
                 * PPVendeurs
                 */
                var docVendeur = (from unVendeur in XDocument
                                  .Load(Server.MapPath("/XML/PPVendeur.xml")).Descendants("row")
                                  select new
                {
                    NoVendeur = unVendeur.Element("NoVendeur").Value,
                    NomAffaires = unVendeur.Element("NomAffaires").Value,
                    Nom = unVendeur.Element("Nom").Value,
                    Prenom = unVendeur.Element("Prenom").Value,
                    Rue = unVendeur.Element("Rue").Value,
                    Ville = unVendeur.Element("Ville").Value,
                    Province = unVendeur.Element("Province").Value,
                    CodePostal = unVendeur.Element("CodePostal").Value,
                    Pays = unVendeur.Element("Pays").Value,
                    Tel1 = unVendeur.Element("Tel1").Value,
                    Tel2 = unVendeur.Element("Tel2").Value,
                    AdresseEmail = unVendeur.Element("AdresseEmail").Value,
                    MotDePasse = unVendeur.Element("MotDePasse").Value,
                    PoidsMaxLivraison = unVendeur.Element("PoidsMaxLivraison").Value,
                    LivraisonGraduite = unVendeur.Element("LivraisonGraduite").Value,
                    Taxes = unVendeur.Element("Taxes").Value,
                    Pourcentage = unVendeur.Element("Pourcentage").Value,
                    Configuration = unVendeur.Element("Configuration").Value,
                    DateCreation = unVendeur.Element("DateCreation").Value,
                    DateMAJ = unVendeur.Element("DateMAJ").Value,
                    Statut = unVendeur.Element("Statut").Value
                }).ToList();

                PPVendeur objVendeur;

                foreach (var unVendeur in docVendeur)
                {
                    objVendeur = new PPVendeur();

                    objVendeur.NoVendeur = Convert.ToInt64(unVendeur.NoVendeur);

                    objVendeur.NomAffaires       = unVendeur.NomAffaires;
                    objVendeur.Nom               = unVendeur.Nom;
                    objVendeur.Prenom            = unVendeur.Prenom;
                    objVendeur.Rue               = unVendeur.Rue;
                    objVendeur.Ville             = unVendeur.Ville;
                    objVendeur.Province          = unVendeur.Province;
                    objVendeur.CodePostal        = unVendeur.CodePostal;
                    objVendeur.Pays              = unVendeur.Pays;
                    objVendeur.Tel1              = unVendeur.Tel1;
                    objVendeur.Tel2              = unVendeur.Tel2;
                    objVendeur.AdresseEmail      = unVendeur.AdresseEmail;
                    objVendeur.MotDePasse        = unVendeur.MotDePasse;
                    objVendeur.PoidsMaxLivraison = Convert.ToInt32(unVendeur.PoidsMaxLivraison);
                    objVendeur.LivraisonGratuite = Convert.ToDecimal(unVendeur.LivraisonGraduite, culture);
                    objVendeur.Taxes             = unVendeur.Taxes == "1" ? true : false;
                    objVendeur.Pourcentage       = Convert.ToDecimal(unVendeur.Pourcentage, culture);
                    if (unVendeur.DateCreation != "")
                    {
                        objVendeur.DateCreation = Convert.ToDateTime(unVendeur.DateCreation);
                    }
                    if (unVendeur.DateMAJ != "")
                    {
                        objVendeur.DateMAJ = Convert.ToDateTime(unVendeur.DateMAJ);
                    }
                    objVendeur.Configuration = unVendeur.Configuration;
                    objVendeur.Statut        = Convert.ToInt16(unVendeur.Statut);

                    context.PPVendeurs.InsertOnSubmit(objVendeur);
                }

                /*
                 * PPVendeursClients
                 */
                var docVendeurClient = (from unVendeurClient in XDocument
                                        .Load(Server.MapPath("/XML/PPVendeurClient.xml")).Descendants("row")
                                        select new
                {
                    NoVendeur = unVendeurClient.Element("NoVendeur").Value,
                    NoClient = unVendeurClient.Element("NoClient").Value,
                    DateVisite = unVendeurClient.Element("DateVisite").Value
                }).ToList();

                PPVendeursClient objVendeursClient;

                foreach (var unvendeursClient in docVendeurClient)
                {
                    objVendeursClient = new PPVendeursClient();

                    objVendeursClient.NoVendeur = Convert.ToInt64(unvendeursClient.NoVendeur);
                    objVendeursClient.NoClient  = Convert.ToInt64(unvendeursClient.NoClient);
                    if (unvendeursClient.DateVisite != "")
                    {
                        objVendeursClient.DateVisite = Convert.ToDateTime(unvendeursClient.DateVisite);
                    }

                    context.PPVendeursClients.InsertOnSubmit(objVendeursClient);
                }

                /*
                 * PPTaxeFederale
                 */
                var docTPS = (from taxFederal in XDocument
                              .Load(Server.MapPath("/XML/PPTaxeFederale.xml")).Descendants("row")
                              select new
                {
                    NoTPS = taxFederal.Element("NoTPS").Value,
                    DateEffectiveTPS = taxFederal.Element("DateEffectiveTPS").Value,
                    TauxTPS = taxFederal.Element("TauxTPS").Value
                }).ToList();

                PPTaxeFederale objTaxeFederale;

                foreach (var taxe in docTPS)
                {
                    objTaxeFederale = new PPTaxeFederale();

                    objTaxeFederale.NoTPS            = Convert.ToByte(taxe.NoTPS);
                    objTaxeFederale.DateEffectiveTPS = Convert.ToDateTime(taxe.DateEffectiveTPS);
                    objTaxeFederale.TauxTPS          = Convert.ToDecimal(taxe.TauxTPS, culture);

                    context.PPTaxeFederales.InsertOnSubmit(objTaxeFederale);
                }

                /*
                 * PPTaxeProvinciale
                 */
                var docTVQ = (from taxeTVQ in XDocument
                              .Load(Server.MapPath("/XML/PPTaxeProvinciale.xml")).Descendants("row")
                              select new
                {
                    NoTVQ = taxeTVQ.Element("NoTVQ").Value,
                    DateEffectiveTVQ = taxeTVQ.Element("DateEffectiveTVQ").Value,
                    TauxTVQ = taxeTVQ.Element("TauxTVQ").Value
                }).ToList();

                PPTaxeProvinciale objTaxeProvinciale;

                foreach (var taxe in docTVQ)
                {
                    objTaxeProvinciale = new PPTaxeProvinciale();

                    objTaxeProvinciale.NoTVQ            = Convert.ToByte(taxe.NoTVQ);
                    objTaxeProvinciale.DateEffectiveTVQ = Convert.ToDateTime(taxe.DateEffectiveTVQ);
                    objTaxeProvinciale.TauxTVQ          = Convert.ToDecimal(taxe.TauxTVQ, culture);

                    context.PPTaxeProvinciales.InsertOnSubmit(objTaxeProvinciale);
                }


                /*
                 * PPProduits
                 */
                var docProduits = (from unProduit in XDocument
                                   .Load(Server.MapPath("/XML/PPProduits.xml")).Descendants("row")
                                   select new
                {
                    NoProduit = unProduit.Element("NoProduit").Value,
                    NoVendeur = unProduit.Element("NoVendeur").Value,
                    NoCategorie = unProduit.Element("NoCategorie").Value,
                    Nom = unProduit.Element("Nom").Value,
                    Description = unProduit.Element("Description").Value,
                    Photo = unProduit.Element("Photo").Value,
                    PrixDemande = unProduit.Element("PrixDemande").Value,
                    NombreItems = unProduit.Element("NombreItems").Value,
                    Disponibilite = unProduit.Element("Disponibilite").Value,
                    DateVente = unProduit.Element("DateVente").Value,
                    PrixVente = unProduit.Element("PrixVente").Value,
                    Poids = unProduit.Element("Poids").Value,
                    DateCreation = unProduit.Element("DateCreation").Value,
                    DateMAJ = unProduit.Element("DateMAJ").Value
                }).ToList();
                PPProduit objProduit;

                foreach (var type in docProduits)
                {
                    objProduit = new PPProduit();

                    objProduit.NoProduit     = Convert.ToInt64(type.NoProduit);
                    objProduit.NoVendeur     = Convert.ToInt64(type.NoVendeur);
                    objProduit.NoCategorie   = Convert.ToInt32(type.NoCategorie);
                    objProduit.Nom           = type.Nom;
                    objProduit.Description   = type.Description;
                    objProduit.Photo         = type.Photo;
                    objProduit.Disponibilité = type.Disponibilite != "1" ? false : true;
                    objProduit.PrixDemande   = Convert.ToDecimal(type.PrixDemande, culture);
                    objProduit.NombreItems   = Convert.ToInt16(type.NombreItems);
                    if (type.DateVente != "")
                    {
                        objProduit.DateVente = Convert.ToDateTime(type.DateVente, culture);
                    }
                    if (type.PrixVente != "")
                    {
                        objProduit.PrixVente = Convert.ToDecimal(type.PrixVente, culture);
                    }
                    objProduit.Poids        = Convert.ToDecimal(type.Poids, culture);
                    objProduit.DateCreation = Convert.ToDateTime(type.DateCreation);
                    if (type.DateMAJ != "")
                    {
                        objProduit.DateMAJ = Convert.ToDateTime(type.DateMAJ);
                    }

                    context.PPProduits.InsertOnSubmit(objProduit);
                }

                /*
                 * PPArticlesEnPanier
                 */
                var docArticleEnPanier = (from unPanier in XDocument
                                          .Load(Server.MapPath("/XML/PPArticlesEnPanier.xml")).Descendants("row")
                                          select new
                {
                    NoPanier = unPanier.Element("NoPanier").Value,
                    NoClient = unPanier.Element("NoClient").Value,
                    NoVendeur = unPanier.Element("NoVendeur").Value,
                    NoProduit = unPanier.Element("NoProduit").Value,
                    DateCreation = unPanier.Element("DateCreation").Value,
                    NbItems = unPanier.Element("NbItems").Value
                }).ToList();

                PPArticlesEnPanier objPanier;

                foreach (var type in docArticleEnPanier)
                {
                    objPanier = new PPArticlesEnPanier();

                    objPanier.NoPanier     = Convert.ToInt64(type.NoPanier);
                    objPanier.NoClient     = Convert.ToInt64(type.NoClient);
                    objPanier.NoVendeur    = Convert.ToInt64(type.NoVendeur);
                    objPanier.NoProduit    = Convert.ToInt64(type.NoProduit);
                    objPanier.DateCreation = Convert.ToDateTime(type.DateCreation);
                    objPanier.NbItems      = Convert.ToInt16(type.NbItems);

                    context.PPArticlesEnPaniers.InsertOnSubmit(objPanier);
                }

                /*
                 * PPCommandes
                 */
                var docCommande = (from commande in XDocument
                                   .Load(Server.MapPath("/XML/PPCommandes.xml")).Descendants("row")
                                   select new
                {
                    NoCommande = commande.Element("NoCommande").Value,
                    NoClient = commande.Element("NoClient").Value,
                    NoVendeur = commande.Element("NoVendeur").Value,
                    DateCommande = commande.Element("DateCommande").Value,
                    CoutLivraison = commande.Element("CoutLivraison").Value,
                    TypeLivraison = commande.Element("TypeLivraison").Value,
                    MontantTotAvantTaxes = commande.Element("MontantTotAvantTaxes").Value,
                    TPS = commande.Element("TPS").Value,
                    TVQ = commande.Element("TVQ").Value,
                    PoidsTotal = commande.Element("PoidsTotal").Value,
                    Statut = commande.Element("Statut").Value,
                    NoAutorisation = commande.Element("NoAutorisation").Value
                }).ToList();

                PPCommande objcommande;

                foreach (var type in docCommande)
                {
                    objcommande = new PPCommande();

                    objcommande.NoCommande   = Convert.ToInt64(type.NoCommande);
                    objcommande.NoClient     = Convert.ToInt64(type.NoClient);
                    objcommande.NoVendeur    = Convert.ToInt64(type.NoVendeur);
                    objcommande.DateCommande = Convert.ToDateTime(type.DateCommande);
                    if (type.CoutLivraison != "")
                    {
                        objcommande.CoutLivraison = Convert.ToDecimal(type.CoutLivraison, culture);
                    }
                    objcommande.TypeLivraison        = Convert.ToInt16(type.TypeLivraison);
                    objcommande.MontantTotAvantTaxes = Convert.ToDecimal(type.MontantTotAvantTaxes, culture);
                    if (type.TPS != "")
                    {
                        objcommande.TPS = Convert.ToDecimal(type.TPS, culture);
                    }
                    if (type.TVQ != "")
                    {
                        objcommande.TVQ = Convert.ToDecimal(type.TVQ, culture);
                    }
                    objcommande.PoidsTotal     = Convert.ToDecimal(type.PoidsTotal, culture);
                    objcommande.Statut         = Convert.ToChar(type.Statut);
                    objcommande.NoAutorisation = type.NoAutorisation;

                    context.PPCommandes.InsertOnSubmit(objcommande);
                }


                /*
                 * PPDetailsCommande
                 */
                var docDetailsCommande = (from unDetailCommande in XDocument
                                          .Load(Server.MapPath("/XML/PPDetailsCommande.xml")).Descendants("row")
                                          select new
                {
                    NoDetailCommandes = unDetailCommande.Element("NoDetailCommandes").Value,
                    NoCommande = unDetailCommande.Element("NoCommande").Value,
                    NoProduit = unDetailCommande.Element("NoProduit").Value,
                    PrixVente = unDetailCommande.Element("PrixVente").Value,
                    Quantité = unDetailCommande.Element("Quantité").Value
                }).ToList();

                PPDetailsCommande objDetailsCommande;

                foreach (var type in docDetailsCommande)
                {
                    objDetailsCommande = new PPDetailsCommande();

                    objDetailsCommande.NoDetailCommandes = Convert.ToInt64(type.NoDetailCommandes);
                    objDetailsCommande.NoCommande        = Convert.ToInt64(type.NoCommande);
                    objDetailsCommande.NoProduit         = Convert.ToInt64(type.NoProduit);
                    objDetailsCommande.PrixVente         = Convert.ToDecimal(type.PrixVente, culture);
                    objDetailsCommande.Quantité          = Convert.ToInt16(type.Quantité);

                    context.PPDetailsCommandes.InsertOnSubmit(objDetailsCommande);
                }

                /*
                 * PPHistoriquePayement
                 */
                var docHistorique = (from uneHistorique in XDocument
                                     .Load(Server.MapPath("/XML/PPHistoriquePayement.xml"))
                                     .Descendants("row")
                                     select new
                {
                    NoHistorique = uneHistorique.Element("NoHistorique").Value,
                    MontantVenteAvantLivraison = uneHistorique.Element("MontantVenteAvantLivraison").Value,
                    NoVendeur = uneHistorique.Element("NoVendeur").Value,
                    NoClient = uneHistorique.Element("NoClient").Value,
                    NoCommande = uneHistorique.Element("NoCommande").Value,
                    DateVente = uneHistorique.Element("DateVente").Value,
                    NoAutoristion = uneHistorique.Element("NoAutoristion").Value,
                    FraisLesi = uneHistorique.Element("FraisLesi").Value,
                    Redevance = uneHistorique.Element("Redevance").Value,
                    FraisLivraison = uneHistorique.Element("FraisLivraison").Value,
                    FraisTPS = uneHistorique.Element("FraisTPS").Value,
                    FraisTVQ = uneHistorique.Element("FraisTVQ").Value
                }).ToList();

                PPHistoriquePaiement objHistoriquePaiement;

                foreach (var unHistorique in docHistorique)
                {
                    objHistoriquePaiement = new PPHistoriquePaiement();

                    objHistoriquePaiement.NoHistorique = Convert.ToInt32(unHistorique.NoHistorique);
                    objHistoriquePaiement.MontantVenteAvantLivraison =
                        Convert.ToDecimal(unHistorique.MontantVenteAvantLivraison, culture);
                    objHistoriquePaiement.NoVendeur      = Convert.ToInt64(unHistorique.NoVendeur);
                    objHistoriquePaiement.NoClient       = Convert.ToInt64(unHistorique.NoClient);
                    objHistoriquePaiement.NoCommande     = Convert.ToInt64(unHistorique.NoCommande);
                    objHistoriquePaiement.DateVente      = Convert.ToDateTime(unHistorique.DateVente);
                    objHistoriquePaiement.NoAutorisation = unHistorique.NoAutoristion;
                    objHistoriquePaiement.FraisLesi      = Convert.ToDecimal(unHistorique.FraisLesi, culture);
                    objHistoriquePaiement.Redevance      = Convert.ToDecimal(unHistorique.Redevance, culture);
                    if (unHistorique.FraisLivraison != "")
                    {
                        objHistoriquePaiement.FraisLivraison = Convert.ToDecimal(unHistorique.FraisLivraison, culture);
                    }
                    if (unHistorique.FraisTPS != "")
                    {
                        objHistoriquePaiement.FraisTPS = Convert.ToDecimal(unHistorique.FraisTPS, culture);
                    }
                    if (unHistorique.FraisTVQ != "")
                    {
                        objHistoriquePaiement.FraisTVQ = Convert.ToDecimal(unHistorique.FraisTVQ, culture);
                    }


                    context.PPHistoriquePaiements.InsertOnSubmit(objHistoriquePaiement);
                }

                /*
                 * PPLieu
                 */
                var docLieu = (from unLieu in XDocument.Load(Server.MapPath("/XML/PPLieu.xml"))
                               .Descendants("row")
                               select new
                {
                    NoLieu = unLieu.Element("NoLieu").Value,
                    Description = unLieu.Element("Description").Value
                }).ToList();

                PPLieu objLieu;

                foreach (var unLieu in docLieu)
                {
                    objLieu = new PPLieu();

                    objLieu.NoLieu      = Convert.ToInt16(unLieu.NoLieu);
                    objLieu.Description = unLieu.Description;


                    context.PPLieus.InsertOnSubmit(objLieu);
                }


                /*
                 * PPDestinataires
                 *
                 * var docDestinataires = (from unDestinataire in XDocument
                 *      .Load(Server.MapPath("/XML/PPDestinataires.xml"))
                 *      .Descendants("row")
                 *  select new
                 *  {
                 *      NoMsg = unDestinataire.Element("NoMsg").Value,
                 *      NoDestinataire = unDestinataire.Element("NoDestinataire").Value,
                 *      EtatLu = unDestinataire.Element("EtatLu").Value,
                 *      Lieu = unDestinataire.Element("Lieu").Value
                 *  }).ToList();
                 *
                 * PPDestinataire ppDestinataire;
                 *
                 * foreach (var unDest in docDestinataires)
                 * {
                 *  ppDestinataire=new PPDestinataire();
                 *
                 *  ppDestinataire.NoMsg = Convert.ToInt32(unDest.NoMsg);
                 *  ppDestinataire.NoDestinataire = Convert.ToInt32(unDest.NoDestinataire);
                 *  ppDestinataire.EtatLu = Convert.ToInt16(unDest.EtatLu);
                 *  ppDestinataire.Lieu = Convert.ToInt16(unDest.Lieu);
                 *
                 *
                 *
                 *  context.PPDestinataires.InsertOnSubmit(ppDestinataire);
                 * }
                 *
                 *
                 * PPMessages
                 *
                 * var docMessages = (from unMessage in XDocument
                 *      .Load(Server.MapPath("/XML/PPMessages.xml"))
                 *      .Descendants("row")
                 *  select new
                 *  {
                 *      NoMsg = unMessage.Element("NoMsg").Value,
                 *      NoExpediteur = unMessage.Element("NoExpediteur").Value,
                 *      DescMsg = unMessage.Element("DescMsg").Value,
                 *      FichierJoint = unMessage.Element("FichierJoint").Value,
                 *      Lieu = unMessage.Element("Lieu").Value,
                 *      dateEnvoi = unMessage.Element("dateEnvoi").Value,
                 *      objet = unMessage.Element("objet").Value
                 *  }).ToList();
                 *
                 * PPMessage objMessage;
                 *
                 * foreach (var unMessages in docMessages)
                 * {
                 *  objMessage = new PPMessage();
                 *
                 *  objMessage.NoMsg = Convert.ToInt32(unMessages.NoMsg);
                 *  objMessage.NoExpediteur = Convert.ToInt32(unMessages.NoExpediteur);
                 *  objMessage.DescMsg = unMessages.DescMsg;
                 *  objMessage.FichierJoint = unMessages.FichierJoint;
                 *  objMessage.Lieu = Convert.ToInt16(unMessages.Lieu);
                 *  objMessage.dateEnvoi = Convert.ToDateTime(unMessages.dateEnvoi);
                 *  objMessage.objet = unMessages.objet;
                 *
                 *  context.PPMessages.InsertOnSubmit(objMessage);
                 * }
                 *
                 * PPEvaluation
                 */
                var docEvalu = (from uneEvaluation in XDocument
                                .Load(Server.MapPath("/XML/PPEvaluations.xml"))
                                .Descendants("row")
                                select new
                {
                    NoClient = uneEvaluation.Element("NoClient").Value,
                    NoProduit = uneEvaluation.Element("NoProduit").Value,
                    Cote = uneEvaluation.Element("Cote").Value,
                    Commentaire = uneEvaluation.Element("Commentaire").Value,
                    DateMAJ = uneEvaluation.Element("DateMAJ").Value,
                    DateCreation = uneEvaluation.Element("DateCreation").Value
                }).ToList();

                PPEvaluation objEvaluation;

                foreach (var uneEvalu in docEvalu)
                {
                    objEvaluation = new PPEvaluation();

                    objEvaluation.NoClient      = Convert.ToInt32(uneEvalu.NoClient);
                    objEvaluation.NoProduit     = Convert.ToInt32(uneEvalu.NoProduit);
                    objEvaluation.Cote_         = Convert.ToDecimal(uneEvalu.Cote);
                    objEvaluation.Commentaire_  = uneEvalu.Commentaire;
                    objEvaluation.DateMAJ_      = Convert.ToDateTime(uneEvalu.DateMAJ);
                    objEvaluation.DateCreation_ = Convert.ToDateTime(uneEvalu.DateCreation);

                    context.PPEvaluations.InsertOnSubmit(objEvaluation);
                }
                try
                {
                    context.SubmitChanges();
                }
                catch (Exception e)
                {
                    ViewBag.lsMessageRemplir = e.Message;
                }


                return(RedirectToAction("Index", new { status = "vider" }));
            }
            catch (Exception e)
            {
                return(Content("Remplissage échoué: " + e));
            }
        }