コード例 #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
    private void click_supprimer_confirme(object sender, EventArgs e)
    {
        Button             btn      = (Button)sender;
        string             id       = btn.ID;
        PPArticlesEnPanier articles = new PPArticlesEnPanier();

        List <ArticleEnPanier> listePanier = articles.Values.Where(x => x.NoVendeur == vendeur.NoVendeur && x.NoClient == int.Parse(id)).ToList();

        /*foreach (ArticleEnPanier article in listePanier)
         * {
         *  articles.Remove(article);
         * }
         * articles.Update();*/

        articles.Remove(listePanier);
        PPClients ppc = new PPClients();
        Client    cl  = ppc.Values.Find(c => c.NoClient == int.Parse(id));

        Response.Clear();
        var sb = new System.Text.StringBuilder();

        sb.Append("<html>");
        sb.AppendFormat("<body onload='document.forms[0].submit()'>");
        sb.AppendFormat("<form action='{0}' method='post'>", "/Pages/Courriel.aspx");
        sb.AppendFormat("<input type='hidden' name='courrielC' value='{0}'>", cl.AdresseEmail);
        sb.AppendFormat("<input type='hidden' name='sujet' value='Votre panier a été supprimé.'>");
        sb.AppendFormat("<input type='hidden' name='contenu' value='Raison:'>");
        sb.AppendFormat("<input type='hidden' name='boutonAnnuler' value='Raison:'>");
        sb.Append("</form>");
        sb.Append("</body>");
        sb.Append("</html>");
        Response.Write(sb.ToString());
        Response.End();
    }
コード例 #3
0
    protected void btnEnvoyerMotDePasse_Click(object sender, EventArgs e)
    {
        if (dbContext.PPClients.Where(c => c.AdresseEmail == tbCourrielMotDePasseOublie.Text).Any() ||
            dbContext.PPVendeurs.Where(v => v.AdresseEmail == tbCourrielMotDePasseOublie.Text).Any())
        {
            MailMessage message = null;

            if (dbContext.PPClients.Where(c => c.AdresseEmail == tbCourrielMotDePasseOublie.Text).Any())
            {
                PPClients client = dbContext.PPClients.Where(c => c.AdresseEmail == tbCourrielMotDePasseOublie.Text).Single();

                message            = new MailMessage("*****@*****.**", client.AdresseEmail);
                message.Subject    = "Mot de passe oublié Les Petites Puces";
                message.IsBodyHtml = true;
                message.Body       = string.Format("Bonjour,<br /><br />" +
                                                   "Suite à votre demande, nous vous envoyons vos informations de connexion.<br /><br />" +
                                                   "Identifiant : {0}<br />" +
                                                   "Mot de passe : {1}<br /><br />" +
                                                   "Vous pouvez suivre ce lien pour vous connecter à nouveau : <a href=\"http://424s.cgodin.qc.ca/Pages/Connexion.aspx\">http://424s.cgodin.qc.ca/Pages/Connexion.aspx</a>.<br /><br />" +
                                                   "Merci de faire affaire avec nous,<br />" +
                                                   "Les Petites Puces",
                                                   client.AdresseEmail,
                                                   client.MotDePasse);
            }
            else
            {
                PPVendeurs vendeur = dbContext.PPVendeurs.Where(v => v.AdresseEmail == tbCourrielMotDePasseOublie.Text).Single();

                message            = new MailMessage("*****@*****.**", vendeur.AdresseEmail);
                message.Subject    = "Mot de passe oublié Les Petites Puces";
                message.IsBodyHtml = true;
                message.Body       = string.Format("Bonjour,<br /><br />" +
                                                   "Suite à votre demande, nous vous envoyons vos informations de connexion.<br /><br />" +
                                                   "Identifiant : {0}<br />" +
                                                   "Mot de passe : {1}<br /><br />" +
                                                   "Vous pouvez suivre ce lien pour vous connecter à nouveau : <a href=\"http://424s.cgodin.qc.ca/Pages/Connexion.aspx\">http://424s.cgodin.qc.ca/Pages/Connexion.aspx</a>.<br /><br />" +
                                                   "Merci de faire affaire avec nous,<br />" +
                                                   "Les Petites Puces",
                                                   vendeur.AdresseEmail,
                                                   vendeur.MotDePasse);
            }

            lblMessage.Text     = "Votre mot de passe vous a été envoyé par courriel.";
            divMessage.CssClass = "alert alert-success alert-margins";
            divMessage.Visible  = true;

            tbExpediteur.Text   = message.From.ToString();
            tbDestinataire.Text = message.To.ToString();
            tbSujet.Text        = message.Subject;
            divCorps.InnerHtml  = message.Body;
            divCourriel.Visible = true;

            ScriptManager.RegisterClientScriptBlock(Page, GetType(), "cacherModal", "$('#modalMotDePasseOublie').modal('hide');", true);
        }
        else
        {
            errCourrielMotDePasseOublie.Text     = "Le courriel que vous avez entré ne correspond pas à un profil client ou un profil vendeur";
            errCourrielMotDePasseOublie.CssClass = "text-danger";
        }
    }
コード例 #4
0
    // désactiver compte client
    public static void desactiverCompteClient(long noClient)
    {
        BD6B8_424SEntities dataContext = new BD6B8_424SEntities();
        var       tableClient          = dataContext.PPClients;
        PPClients client = (from c in tableClient where c.NoClient == noClient select c).First();

        // delete le compte s'il n'a jamais visité de vendeur
        if (client.PPVendeursClients.Count() == 0)
        {
            dataContext.PPClients.Remove(client);
        }
        else if (client.PPCommandes.Count() == 0)
        {
            foreach (PPArticlesEnPanier ap in client.PPArticlesEnPanier.ToList())
            {
                dataContext.PPArticlesEnPanier.Remove(ap);
            }
            dataContext.PPClients.Remove(client);
        }
        else
        {
            foreach (PPArticlesEnPanier ap in client.PPArticlesEnPanier.ToList())
            {
                dataContext.PPArticlesEnPanier.Remove(ap);
            }
            client.Statut = 0;
        }


        dataContext.SaveChanges();
    }
コード例 #5
0
    protected void btnConfirmer_Click(object sender, EventArgs e)
    {
        // Reset everything
        Courriel1.DefaultControl();
        Courriel2.DefaultControl();
        MDP.DefaultControl();
        MDP2.DefaultControl();

        // Check for errors
        bool[] arrError = new bool[]
        {
            InvalidateIfEmpty(Courriel1, lblErrorCourriel1, "Le courriel doit être présent") ||
            CheckFormatCourriel(Courriel1, lblErrorCourriel1) ||
            CheckMatch(Courriel1, Courriel2, lblErrorCourriel1, lblErrorCourriel2, "Les courriels ne sont pas identiques"),
            InvalidateIfEmpty(Courriel2, lblErrorCourriel2, "La confirmation de courriel doit être présente") ||
            CheckFormatCourriel(Courriel2, lblErrorCourriel2),
            InvalidateIfEmpty(MDP, lblErrorMDP, "Le mot de passe doit être présent") ||
            CheckMatch(MDP, MDP2, lblErrorMDP, lblErrorMDP2, "Les mots de passes ne sont pas identiques"),
            InvalidateIfEmpty(MDP2, lblErrorMDP2, "La confirmation de mot de passe doit être présente")
        };

        if (!arrError.Contains(true))
        {
            PPClients       clients       = new PPClients();
            PPVendeurs      vendeurs      = new PPVendeurs();
            PPGestionnaires gestionnaires = new PPGestionnaires();
            if (clients.Values.Any(x => x.AdresseEmail == Courriel1.Text) ||
                vendeurs.Values.Any(x => x.AdresseEmail == Courriel1.Text) ||
                gestionnaires.Values.Any(x => x.Email == Courriel1.Text))
            {
                Courriel1.Invalidate();
                lblErrorCourriel1.Text = "Ce courriel est déjà utilisé par un autre utilisateur";
            }
            else
            {
                Client newClient = new Client(null)
                {
                    NoClient     = clients.NextId(),
                    AdresseEmail = Courriel1.Text,
                    MotDePasse   = MDP.Text,
                    DateCreation = DateTime.Now,
                    NbConnexions = 0,
                    Pays         = "Canada"
                };

                clients.Add(newClient);

                Response.Redirect("~/Pages/Inscription.aspx?Reussite=true");
            }
        }
    }
コード例 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string url = null;

        if (Session["TypeUtilisateur"] == null)
        {
            url = "~/Pages/AccueilInternaute.aspx?";
        }
        else if (Session["TypeUtilisateur"].ToString() != "C")
        {
            if (Session["TypeUtilisateur"].ToString() == "V")
            {
                url = "~/Pages/ConnexionVendeur.aspx?";
            }
            else
            {
                url = "~/Pages/AcceuilGestionnaire.aspx?";
            }
        }
        if (url != null)
        {
            Response.Redirect(url, true);
        }

        Page.Title = "Devenir vendeur";

        if (!IsPostBack)
        {
            long      noClient = Convert.ToInt64(Session["NoClient"]);
            PPClients client   = dbContext.PPClients.Where(c => c.NoClient == noClient).Single();
            tbNom.Text                = client.Nom;
            tbPrenom.Text             = client.Prenom;
            tbAdresse.Text            = client.Rue;
            tbVille.Text              = client.Ville;
            ddlProvince.SelectedValue = client.Province;
            if (client.CodePostal != null && client.CodePostal != "")
            {
                tbCodePostal.Text = client.CodePostal.Substring(0, 3) + " " + client.CodePostal.Substring(3, 3);
            }
            if (client.Tel1 != null && client.Tel1 != "")
            {
                tbTelephone1.Text = "(" + client.Tel1.Substring(0, 3) + ") " + client.Tel1.Substring(3, 3) + "-" + client.Tel1.Substring(6);
            }
            if (client.Tel2 != null && client.Tel2 != "")
            {
                tbTelephone2.Text = "(" + client.Tel2.Substring(0, 3) + ") " + client.Tel2.Substring(3, 3) + "-" + client.Tel2.Substring(6);
            }
        }
    }
コード例 #7
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();
    }
コード例 #8
0
    protected void btnSauvegarderMDP_OnClick(object sender, EventArgs e)
    {
        tbAncienMDP.DefaultControl();
        tbNouveauMDP.DefaultControl();
        tbConfirmationMDP.DefaultControl();

        Client client = Session.GetClient();

        if (tbAncienMDP.Text != client.MotDePasse)
        {
            tbAncienMDP.Invalidate();
            lblErrorAncienMDP.Text = "L'ancien mot de passe doit correspondre au mot de passe courrant";
        }
        else
        {
            if (!tbNouveauMDP.InvalidateIfEmpty(lblErrorNouveauMDP, "Le mot de passe doit être définit") ||
                !tbConfirmationMDP.InvalidateIfEmpty(lblErrorConfirmationMDP, "Le mot de passe doit être définit"))
            {
                if (tbNouveauMDP.Text != tbConfirmationMDP.Text)
                {
                    tbNouveauMDP.Invalidate();
                    tbConfirmationMDP.Invalidate();
                    lblErrorNouveauMDP.Text = "Les mots de passes doivent correspondre";
                }
                else if (tbNouveauMDP.Text == client.MotDePasse)
                {
                    tbNouveauMDP.Invalidate();
                    tbConfirmationMDP.Invalidate();
                    lblErrorNouveauMDP.Text = "Le nouveau mot de passe doit être différent de l'ancien";
                }
                else
                {
                    client.MotDePasse = tbNouveauMDP.Text;

                    PPClients clients = new PPClients();
                    clients.NotifyUpdatedOutside(client);

                    clients.Update();

                    Response.Redirect("~/Pages/Client/ProfilClient.aspx?ReussiteMDP=true");
                }
            }
        }
    }
コード例 #9
0
    protected void btnConfirmerNouveauMDP_OnClick(object sender, EventArgs e)
    {
        tbMDP1.DefaultControl();
        tbMDP2.DefaultControl();

        bool[] errors = new bool[]
        {
            tbMDP1.InvalidateIfEmpty(lblErrorMDP1, "Le mot de passe doit être présent") ||
            tbMDP1.CheckMatch(tbMDP2, lblErrorMDP1, lblErrorMDP2, "Les mots de passes ne sont pas identiques"),
            tbMDP2.InvalidateIfEmpty(lblErrorMDP2, "La confirmation de mot de passe doit être présente")
        };

        if (!errors.Contains(true))
        {
            string id   = Request["Id"];
            string type = Request["Type"];
            if (type == "client")
            {
                PPClients clients = new PPClients();
                Client    client  = clients.Values.Find(x => x.NoClient.Value == long.Parse(id));

                client.MotDePasse = tbMDP1.Text;

                clients.NotifyUpdated(client);
                clients.Update();

                Response.Redirect("~/Pages/OubliMDP.aspx?Reussite=true");
            }
            else if (type == "vendeur")
            {
                PPVendeurs vendeurs = new PPVendeurs();
                Vendeur    vendeur  = vendeurs.Values.Find(x => x.NoVendeur.Value == long.Parse(id));

                vendeur.MotDePasse = tbMDP1.Text;
                vendeurs.NotifyUpdated(vendeur);
                vendeurs.Update();

                Response.Redirect("~/Pages/OubliMDP.aspx?Reussite=true");
            }
        }
    }
コード例 #10
0
    private void btnCourriel_Click(object sender, EventArgs e)
    {
        Button    btn = (Button)sender;
        PPClients ppv = new PPClients();
        Client    v   = ppv.Values.Find(vf => vf.NoClient == long.Parse(btn.CommandArgument));

        Response.Clear();
        var sb = new System.Text.StringBuilder();

        sb.Append("<html>");
        sb.AppendFormat("<body onload='document.forms[0].submit()'>");
        sb.AppendFormat("<form action='{0}' method='post'>", "/Pages/Courriel.aspx");
        sb.AppendFormat("<input type='hidden' name='courrielC' value='{0}'>", v.AdresseEmail);
        sb.AppendFormat("<input type='hidden' name='sujet' value='Sujet du message'>");
        sb.AppendFormat("<input type='hidden' name='contenu' value='Contenu du message'>");
        sb.Append("</form>");
        sb.Append("</body>");
        sb.Append("</html>");
        Response.Write(sb.ToString());
        Response.End();
    }
コード例 #11
0
    public void afficherCourriel()
    {
        // rajouter les boutons d'option
        Panel colComplet = LibrairieControlesDynamique.divDYN(phCourriel, "", "col-md-12");
        Panel row        = LibrairieControlesDynamique.divDYN(colComplet, "", "row");
        Panel col1       = LibrairieControlesDynamique.divDYN(row, "", "col-md-1");

        LibrairieControlesDynamique.btnDYN(col1, "", "btn btn-warning", "Retour", retourChoix_click);

        // afficher les destinataires
        foreach (CheckBox cb in lstCbVendeurs)
        {
            if (cb.Checked)
            {
                String     id      = cb.ID.Replace("cbVendeur_", "");
                PPVendeurs vendeur = LibrairieLINQ.getInfosVendeur(long.Parse(id));
                //Panel col = LibrairieControlesDynamique.divDYN(divDestinataires, "", "col-md-2");
                LibrairieControlesDynamique.spaceDYN(divDestinataires);
                Label lbl = LibrairieControlesDynamique.lblDYN(divDestinataires, "", vendeur.AdresseEmail, "badge");
                lbl.Style.Add("background-color", "orange !important");
            }
        }

        foreach (CheckBox cb in lstCbClients)
        {
            if (cb.Checked)
            {
                String    id     = cb.ID.Replace("cbClient_", "");
                PPClients client = LibrairieLINQ.getFicheInformationsClient(long.Parse(id));
                //Panel col = LibrairieControlesDynamique.divDYN(divDestinataires, "", "col-md-2");
                LibrairieControlesDynamique.spaceDYN(divDestinataires);
                Label lbl = LibrairieControlesDynamique.lblDYN(divDestinataires, "", client.AdresseEmail, "badge");
                lbl.Style.Add("background-color", "orange !important");
            }
        }


        divChoixDestinataires.Visible = false;
        divCourriel.Visible           = true;
    }
コード例 #12
0
    protected void btnOubliMDP_OnClick(object sender, EventArgs e)
    {
        pnlFakeEmail.Visible = true;

        PPClients clients = new PPClients();
        Client    client  = clients.Values.Find(x => x.AdresseEmail.ToLower() == tbAdresseEmail.Text.ToLower());

        if (client != null)
        {
            if (client.Nom == null || client.Prenom == null)
            {
                lblFakeEmail.Text = $"{client.AdresseEmail},<br/><br/>";
            }
            else
            {
                lblFakeEmail.Text = $"{client.Nom} {client.Prenom},<br/><br/>";
            }

            lblFakeEmail.Text += "Une demande de changement de mot de passe vous a été envoyé.<br/>";
            lblFakeEmail.Text += $"Cliquez sur <a href=\"/Pages/OubliMDP.aspx?Id={client.NoClient}&Type=client\">ce lien</a> pour le changer.";
        }
        else
        {
            PPVendeurs vendeurs = new PPVendeurs();
            Vendeur    vendeur  = vendeurs.Values.Find(x => x.AdresseEmail.ToLower() == tbAdresseEmail.Text.ToLower());
            if (vendeur != null)
            {
                lblFakeEmail.Text  = $"{vendeur.Nom} {vendeur.Prenom},<br/><br/>";
                lblFakeEmail.Text += "Une demande de changement de mot de passe vous a été envoyé.<br/>";
                lblFakeEmail.Text += $"Cliquez sur <a href=\"/Pages/OubliMDP.aspx?Id={vendeur.NoVendeur}&Type=vendeur\">ce lien</a> pour le changer.";

                Response.Redirect($"~/Pages/OubliMDP.aspx?Id={vendeur.NoVendeur}&Type=vendeur");
            }
            else
            {
                pnlError.Visible = true;
                lblError.Text    = "Ce compte n'existe pas";
            }
        }
    }
コード例 #13
0
    private void btnEnvoyer(object sender, EventArgs e)
    {
        PPClients leClient = new PPClients();

        if (dbContext.PPClients.Where(c => c.NoClient == noClient).Any())
        {
            leClient = dbContext.PPClients.Where(c => c.NoClient == noClient).First();
        }
        PPVendeurs leVendeur = new PPVendeurs();

        if (dbContext.PPVendeurs.Where(c => c.NoVendeur == noVendeur).Any())
        {
            leVendeur = dbContext.PPVendeurs.Where(c => c.NoVendeur == noVendeur).First();
        }
        PPProduits produitAfficher = new PPProduits();

        if (dbContext.PPProduits.Where(c => c.NoProduit == noProduit).Any())
        {
            produitAfficher = dbContext.PPProduits.Where(c => c.NoProduit == noProduit).First();
        }
        MailMessage message = new MailMessage(leVendeur.AdresseEmail, leClient.AdresseEmail);

        message.Subject = noProduit + " : " + produitAfficher.Nom;
        message.Body    = string.Format("Bonjour,\n\n" +
                                        "J'ai quelques questions à propos du produit {0} \n\n" +
                                        "Bonne journée\n" +
                                        "{1}, {2}\n",
                                        noProduit,
                                        leClient.Nom,
                                        leClient.Prenom);

        tbExpediteur.Text   = message.From.ToString();
        tbDestinataire.Text = message.To.ToString();
        tbSujet.Text        = message.Subject;
        tbCorps.Text        = message.Body;
        divCourriel.Visible = !divCourriel.Visible;
    }
コード例 #14
0
    protected void remplirClients(XNamespace ss, XElement worksheet)
    {
        PPClients clients = new PPClients();

        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() == 17)
            {
                clients.Add(new Client(null)
                {
                    NoClient              = Convert.ToInt64(arrayStr[0]),
                    AdresseEmail          = arrayStr[1],
                    MotDePasse            = arrayStr[2],
                    Nom                   = (arrayStr[3] == "NULL" ? null : arrayStr[3]),
                    Prenom                = (arrayStr[4] == "NULL" ? null : arrayStr[4]),
                    Rue                   = (arrayStr[5] == "NULL" ? null : arrayStr[5]),
                    Ville                 = (arrayStr[6] == "NULL" ? null : arrayStr[6]),
                    Province              = (arrayStr[7] == "NULL" ? null : arrayStr[7]),
                    CodePostal            = (arrayStr[8] == "NULL" ? null : arrayStr[8]),
                    Pays                  = (arrayStr[9] == "NULL" ? null : arrayStr[9]),
                    Tel1                  = (arrayStr[10] == "NULL" ? null : arrayStr[10]),
                    Tel2                  = (arrayStr[11] == "NULL" ? null : arrayStr[11]),
                    DateCreation          = DateTime.Parse(arrayStr[12]),
                    DateMAJ               = (arrayStr[13] == "NULL" ? nullableDate : Convert.ToDateTime(arrayStr[13])),
                    NbConnexions          = Convert.ToInt16(arrayStr[14]),
                    DateDerniereConnexion = DateTime.Parse(arrayStr[15]),
                    Statut                = Convert.ToInt16(arrayStr[16])
                });
            }
        }
    }
コード例 #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            verifierPermissions("C");

            Page.Title = "Gérer mon profil";

            long      noClient = Convert.ToInt64(Session["NoClient"]);
            PPClients client   = dbContext.PPClients.Where(v => v.NoClient == noClient).Single();
            tbNom.Text                = client.Nom;
            tbPrenom.Text             = client.Prenom;
            tbAdresse.Text            = client.Rue;
            tbVille.Text              = client.Ville;
            ddlProvince.SelectedValue = client.Province;
            tbCodePostal.Text         = client.CodePostal != null && client.CodePostal != "" ? client.CodePostal.Substring(0, 3) + " " + client.CodePostal.Substring(3, 3) : "";
            tbTelephone1.Text         = client.Tel1 != null && client.Tel1 != "" ? "(" + client.Tel1.Substring(0, 3) + ") " + client.Tel1.Substring(3, 3) + "-" + client.Tel1.Substring(6) : "";
            if (client.Tel2 != null && client.Tel2 != "")
            {
                tbTelephone2.Text = "(" + client.Tel2.Substring(0, 3) + ") " + client.Tel2.Substring(3, 3) + "-" + client.Tel2.Substring(6);
            }
            tbCourriel.Text = client.AdresseEmail;
        }
    }
コード例 #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Session.IsVendeur())
        {
            Response.Redirect(SessionManager.RedirectConnexionLink);
        }

        Vendeur vendeur = Session.GetVendeur();

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

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

        //Commandes
        int indexCom = 0;

        //commandes non-traitées

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

                decimal poidsCommande = com.Commande.PoidsTotal.Value;

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

                decimal montantCom = montant.First().Value;

                TableCell cellNom = new TableCell();

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

                string nomPDF = "";

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

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


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

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

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


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

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

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

                row.Cells.Add(cellBtn);

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

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

        int index = 0;

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

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

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

                decimal poidsCommande = com.Commande.PoidsTotal.Value;

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

                decimal montantCom = montant.First().Value;

                TableCell cellNom = new TableCell();

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


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

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

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


                //modal (il faut faire référence à la div à cet effet dans le front-hand.
                modal(panelAvecModal, "myModalH" + index.ToString(), "btnOkLivH" + index.ToString(), "btnAnnulerLivH" + index.ToString(), "Livraison", "Voulez-vous vraiment confirmer la livraison de cette commande? (" + nomClient + ")", true);
                tableHistorique.Rows.Add(row);
                index++;
            }
        }
        else
        {
            tableHistorique.Visible = false;
            divBTN2.Visible         = false;
            pnCommandesTraitees.LblDyn("", "Vous n'avez aucune commande dans l'historique", "h4 text-info ml-3");
        }
    }
コード例 #17
0
    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;
        }
    }
コード例 #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        verifierPermissions("G");

        Page.Title = "Visualisation des statistiques";

        getNoVendeur();
        getNoClient();
        getNoVendeurStats();

        BD6B8_424SEntities dataContext = new BD6B8_424SEntities();
        var tableVendeur         = dataContext.PPVendeurs;
        var tableClients         = dataContext.PPClients;
        var tableVendeursClients = dataContext.PPVendeursClients;

        // 1) Tous les vendeurs sur le site
        totalVendeurs = (from vendeur in tableVendeur where vendeur.Statut == 1 select vendeur).Count();

        // 2) Nouveaux vendeurs depuis 1,3,6,12, toujours
        DateTime d1 = DateTime.Now.AddMonths(-1);

        mois1 = (from v1 in tableVendeur where v1.DateCreation <= d1 select v1).Count();

        DateTime d3 = DateTime.Now.AddMonths(-3);

        mois3 = (from v1 in tableVendeur where v1.DateCreation <= d3 select v1).Count();

        DateTime d6 = DateTime.Now.AddMonths(-6);

        mois6 = (from v1 in tableVendeur where v1.DateCreation <= d6 select v1).Count();

        DateTime d12 = DateTime.Now.AddMonths(-12);

        mois12 = (from v1 in tableVendeur where v1.DateCreation <= d12 select v1).Count();

        moisToujours = (from v1 in tableVendeur select v1).Count();

        // 3) Nombre total de clients
        clientsActifs     = (from client in tableClients where client.PPCommandes.Count > 0 select client).Count();
        clientsPotentiels = (from client in tableClients where client.PPCommandes.Count == 0 && client.PPArticlesEnPanier.Count() > 0 select client).Count();
        clientsVisiteurs  = (from client in tableClients where client.PPCommandes.Count == 0 && client.PPArticlesEnPanier.Count() == 0 select client).Count();



        // 4) Nombre de visites d'un client pour un vendeur
        // populer liste des vendeurs
        List <PPVendeurs> lstVendeurs = (from vendeur in tableVendeur where vendeur.Statut == 1 select vendeur).ToList();

        foreach (PPVendeurs vendeur in lstVendeurs)
        {
            ddlVendeurs.Items.Add(new ListItem(vendeur.NomAffaires, vendeur.NoVendeur.ToString()));
        }

        // populer liste des clients
        List <PPClients> lstClients = (from client in tableClients where client.Statut == 1 select client).ToList();

        foreach (PPClients client in lstClients)
        {
            ddlClients.Items.Add(new ListItem(client.AdresseEmail, client.NoClient.ToString()));
        }

        // mettre le nb de visites
        if (lstClients.Count == 0)
        {
            nbVisitesClientVendeur = "N/A";
        }
        else
        {
            PPVendeurs vendeur = (this.noVendeurSelectionne != -1) ? (from v in tableVendeur where v.NoVendeur == this.noVendeurSelectionne select v).First() : lstVendeurs.First();
            PPClients  client  = (this.noClientSelectionne != -1) ? (from c in tableClients where c.NoClient == this.noClientSelectionne select c).First() : lstClients.First();
            nbVisitesClientVendeur = (from v in client.PPVendeursClients where v.NoVendeur == vendeur.NoVendeur select v).Count().ToString();
        }

        // 5) Nombre de nouveaux clients depuis 3, 6, 9, 12 mois
        DateTime d3C = DateTime.Now.AddMonths(-3);

        mois3Client = (from c in tableClients where c.DateCreation <= d3C select c).Count();

        DateTime d6C = DateTime.Now.AddMonths(-6);

        mois6Client = (from c in tableClients where c.DateCreation <= d6C select c).Count();

        DateTime d9C = DateTime.Now.AddMonths(-9);

        mois9Client = (from c in tableClients where c.DateCreation <= d9C select c).Count();

        DateTime d12C = DateTime.Now.AddMonths(-12);

        mois12Client = (from c in tableClients where c.DateCreation <= d12C select c).Count();

        // 6) Nombre connexions clients
        foreach (PPClients client in tableClients)
        {
            tabClients.Add(client.AdresseEmail);
            tabNbConnexions.Add((short)client.NbConnexions);
        }

        // 7) Liste des 10,20,30 dernières connexions clients
        string strMax = dataContext.PPClients.Where(c => c.DateDerniereConnexion != null).OrderByDescending(c => c.DateDerniereConnexion).Count().ToString();

        nbConnexions.Attributes.Add("max", strMax);
        List <PPClients> lstClientsVendeurs = dataContext.PPClients.Where(c => c.DateDerniereConnexion != null).OrderByDescending(c => c.DateDerniereConnexion)
                                              .Take(Convert.ToInt32(nbConnexions.Text)).ToList();



        TableRow  rowClients;
        TableCell cellValeurs;

        foreach (PPClients clients in lstClientsVendeurs)
        {
            rowClients = new TableRow();
            long noClient = clients.NoClient;
            cellValeurs      = new TableCell();
            cellValeurs.Text = clients.DateDerniereConnexion.ToString();
            rowClients.Cells.Add(cellValeurs);
            cellValeurs      = new TableCell();
            cellValeurs.Text = noClient.ToString();
            rowClients.Cells.Add(cellValeurs);
            cellValeurs = new TableCell();
            if (clients.Nom != "" && clients.Prenom != "" && clients.Nom != null && clients.Prenom != null)
            {
                cellValeurs.Text = clients.Nom + ", " + clients.Prenom;
            }
            else
            {
                cellValeurs.Text = "";
            }
            rowClients.Cells.Add(cellValeurs);
            cellValeurs      = new TableCell();
            cellValeurs.Text = clients.NbConnexions.ToString();
            rowClients.Cells.Add(cellValeurs);
            tConnexions.Rows.Add(rowClients);
        }



        // 8) Total des commandes d'un client par vendeur
        var commandesParClient = from commande in dataContext.PPCommandes
                                 orderby commande.NoClient
                                 group commande by commande.PPClients;

        foreach (var commandesClient in commandesParClient)
        {
            PPClients client = commandesClient.Key;
            var       commandesParVendeur = from commande in commandesClient
                                            orderby commande.NoVendeur
                                            group commande by commande.PPVendeurs;

            bool premierVendeur = true;
            foreach (var commandesVendeur in commandesParVendeur)
            {
                PPVendeurs vendeur = commandesVendeur.Key;
                decimal    montantTotalCommandes = 0;
                DateTime   dateDeniereCommande   = DateTime.MinValue;
                foreach (PPCommandes commande in commandesVendeur)
                {
                    montantTotalCommandes += (decimal)(commande.MontantTotAvantTaxes + commande.CoutLivraison + commande.TPS + commande.TVQ);
                    if (commande.DateCommande > dateDeniereCommande)
                    {
                        dateDeniereCommande = (DateTime)commande.DateCommande;
                    }
                }

                TableRow  row = new TableRow();
                TableCell cell;
                if (premierVendeur)
                {
                    cell         = new TableCell();
                    cell.RowSpan = commandesParVendeur.Count();
                    cell.Text    = client.NoClient.ToString();
                    row.Cells.Add(cell);
                    cell         = new TableCell();
                    cell.RowSpan = commandesParVendeur.Count();
                    cell.Text    = client.Prenom + " " + client.Nom;
                    row.Cells.Add(cell);
                }
                cell      = new TableCell();
                cell.Text = vendeur.NoVendeur.ToString();
                row.Cells.Add(cell);
                cell      = new TableCell();
                cell.Text = vendeur.Prenom + " " + vendeur.Nom;
                row.Cells.Add(cell);
                cell = new TableCell();
                cell.HorizontalAlign = HorizontalAlign.Right;
                cell.Text            = montantTotalCommandes.ToString("C", CultureInfo.CurrentCulture);
                row.Cells.Add(cell);
                cell = new TableCell();
                cell.HorizontalAlign = HorizontalAlign.Right;
                cell.Text            = dateDeniereCommande.ToString("yyyy'-'MM'-'dd HH':'mm");
                row.Cells.Add(cell);
                tabTotalCommandesClientsParVendeur.Rows.Add(row);

                premierVendeur = false;
            }
        }
        //9 Nombre clients par vendeur
        List <PPVendeurs> lstVendeursStats = dataContext.PPVendeurs.Where(c => c.Statut.Value.Equals(1)).ToList();

        foreach (PPVendeurs leVendeur in lstVendeurs)
        {
            ddlVendeursStats.Items.Add(new ListItem(leVendeur.NomAffaires, leVendeur.NoVendeur.ToString()));
        }
        if (ddlVendeursStats.Items.Count > 1 && noVendeurStats == -1)
        {
            noVendeurStats = long.Parse(ddlVendeursStats.Items[0].Value);
        }
        clientsActifsVendeurs     = dataContext.PPClients.Where(c => (c.PPCommandes.Count() > 0) && (c.PPCommandes.Where(v => v.NoVendeur.Value.Equals(noVendeurStats)).Count() > 0)).Count();
        clientsPotentielsVendeurs = dataContext.PPClients.Where(c => (c.PPCommandes.Where(v => v.NoVendeur.Value.Equals(noVendeurStats)).Count() == 0) && (c.PPArticlesEnPanier.Count() > 0) &&
                                                                (c.PPArticlesEnPanier.Where(v => v.NoVendeur.Value.Equals(noVendeurStats)).Count() > 0)).Count();
        clientsVisiteursVendeurs = dataContext.PPClients.Where(c => (c.PPCommandes.Where(v => v.NoVendeur.Value.Equals(noVendeurStats)).Count() == 0) &&
                                                               (c.PPArticlesEnPanier.Where(v => v.NoVendeur.Value.Equals(noVendeurStats)).Count() == 0) && (c.PPVendeursClients.Where(v => v.NoVendeur.Equals(noVendeurStats)).Count() > 0)).Count();
    }
コード例 #19
0
    protected void btnConfirmer_Click(object sender, EventArgs e)
    {
        // Reset everything
        Courriel1.DefaultControl();
        Courriel2.DefaultControl();
        MDP.DefaultControl();
        MDP2.DefaultControl();
        tbNomAffaires.DefaultControl();
        tbPrenom.DefaultControl();
        tbNom.DefaultControl();
        tbRue.DefaultControl();
        tbVille.DefaultControl();
        tbCodePostal.DefaultControl();
        tbTelephone.DefaultControl();
        tbTelephone2.DefaultControl();
        tbPoidsMax.DefaultControl();
        tbPrixLivGratuite.DefaultControl();

        int     poidsMax       = -1;
        decimal prixLivGratuit = -1;

        // Check for errors
        bool[] arrError = new bool[]
        {
            // Courriel
            Courriel1.InvalidateIfEmpty(lblErrorCourriel1, "Le courriel doit être présent") ||
            Courriel1.CheckFormatCourriel(lblErrorCourriel1) ||
            Courriel1.CheckMatch(Courriel2, lblErrorCourriel1, lblErrorCourriel2, "Les courriels ne sont pas identiques"),
            Courriel2.InvalidateIfEmpty(lblErrorCourriel2, "La confirmation de courriel doit être présente") ||
            Courriel2.CheckFormatCourriel(lblErrorCourriel2),
            // Mot de passe
            MDP.InvalidateIfEmpty(lblErrorMDP, "Le mot de passe doit être présent") ||
            MDP.CheckMatch(MDP2, lblErrorMDP, lblErrorMDP2, "Les mots de passes ne sont pas identiques"),
            MDP2.InvalidateIfEmpty(lblErrorMDP2, "La confirmation de mot de passe doit être présente"),
            // Nom d'affaires
            tbNomAffaires.InvalidateIfEmpty(lblErrorNomAffaires, "Le nom d'affaires doit être présent"),
            tbPrenom.InvalidateIfEmpty(lblErrorPrenom, "Le prénom doit être présent") ||
            tbPrenom.CheckFormatNomPrenom(lblErrorPrenom),
            tbNom.InvalidateIfEmpty(lblErrorNom, "Le nom doit être présent") ||
            tbNom.CheckFormatNomPrenom(lblErrorNom),
            tbRue.InvalidateIfEmpty(lblErrorRue, "Les informations sur la rue (No Civique et Rue)") ||
            tbRue.CheckFormatNomPrenom(lblErrorRue),
            tbVille.InvalidateIfEmpty(lblErrorVille, "Le nom de la ville doit être présent") ||
            tbVille.CheckFormatNomPrenom(lblErrorVille),
            tbCodePostal.InvalidateIfEmpty(lblErrorCodePostal, "Le code postal doit être présent") ||
            tbCodePostal.CheckContains(lblErrorCodePostal, "Le code postal doit être entré au complet", "_"),
            tbTelephone.InvalidateIfEmpty(lblErrorTelephone, "Le numéro de téléphone doit être présent") ||
            tbTelephone.CheckContains(lblErrorTelephone, "Le numéro de téléphone doit être entré au complet", "_"),
            tbTelephone2.CheckContains(lblErrorTelephone2, "Le numéro de téléphone doit être entré au complet", "_"),
            // Poids Max
            tbPoidsMax.InvalidateIfEmpty(lblErrorPoidsMax, "Le poids maximal pour une livraison doit être présent") ||
            tbPoidsMax.CheckInt(lblErrorPoidsMax, "Le poids maximal doit être un nomber entier", out poidsMax) ||
            tbPoidsMax.CheckIntOver0(lblErrorPoidsMax, poidsMax),
            // Poids livraison gratuite
            //tbPrixLivGratuite.InvalidateIfEmpty(lblErrorPoidsLivGratuit, "Le poids auquel une livraison devient gratuite doit être présent")
            tbPrixLivGratuite.Text != "" && (
                tbPrixLivGratuite.CheckDecimal(lblErrorPoidsLivGratuit, "Le prix auquel une livraison devient gratuite doit être un nombre décimal", out prixLivGratuit) ||
                tbPrixLivGratuite.CheckDecimalOver0(lblErrorPoidsLivGratuit, prixLivGratuit)
                )
        };

        if (!arrError.Contains(true))
        {
            PPVendeurs      vendeurs      = new PPVendeurs();
            PPClients       clients       = new PPClients();
            PPGestionnaires gestionnaires = new PPGestionnaires();

            bool errorsDB = false;

            if (vendeurs.Values.Any(x => x.AdresseEmail == Courriel1.Text))
            {
                Courriel1.Invalidate();
                lblErrorCourriel1.Text = "Ce courriel est déjà utilisé par un vendeur";
                errorsDB = true;
            }
            else if (clients.Values.Any(x => x.AdresseEmail == Courriel1.Text))
            {
                Courriel1.Invalidate();
                lblErrorCourriel1.Text = "Ce courriel est déjà utilisé par un client";
                errorsDB = true;
            }
            else if (gestionnaires.Values.Any(x => x.Email == Courriel1.Text))
            {
                Courriel1.Invalidate();
                lblErrorCourriel1.Text = "Ce courriel est déjà utilisé par un gestionnaire";
                errorsDB = true;
            }

            if (vendeurs.Values.Any(x => x.NomAffaires == tbNomAffaires.Text))
            {
                tbNomAffaires.Invalidate();
                lblErrorNomAffaires.Text = "Ce nom d'affaires est déjà utilisé par un autre vendeur";
                errorsDB = true;
            }

            if (!errorsDB)
            {
                Vendeur newVendeur = new Vendeur(null)
                {
                    NoVendeur         = vendeurs.NextId(),
                    NomAffaires       = tbNomAffaires.Text,
                    Nom               = tbNom.Text,
                    Prenom            = tbPrenom.Text,
                    Rue               = tbRue.Text,
                    Ville             = tbVille.Text,
                    Province          = ddlProvince.SelectedValue,
                    CodePostal        = tbCodePostal.Text.ToUpper(),
                    Pays              = tbPays.Text,
                    Tel1              = tbTelephone.Text,
                    Tel2              = tbTelephone2.Text.ToStringEmptyNull(),
                    AdresseEmail      = Courriel1.Text,
                    MotDePasse        = MDP.Text,
                    PoidsMaxLivraison = poidsMax,
                    LivraisonGratuite = prixLivGratuit <= 0 ? null : (decimal?)prixLivGratuit,
                    Taxes             = rbTaxesOui.Checked,
                    DateCreation      = DateTime.Now,
                    Statut            = 0
                };

                vendeurs.Add(newVendeur);

                Response.Redirect("~/Pages/InscriptionVendeur.aspx?Reussite=true");
            }
        }
    }
コード例 #20
0
    private void creerPage()
    {
        phDynamique.Controls.Clear();
        ulSideBar.Controls.Clear();
        // Créer le panier du vendeur X
        Panel panelGroup = LibrairieControlesDynamique.divDYN(phDynamique, nomEntreprise + "_PanelGroup", "panel-group container-fluid marginFluidSmall");
        Panel panelBase  = LibrairieControlesDynamique.divDYN(panelGroup, nomEntreprise + "_base", "panel panel-default");


        // Nom de l'entreprise
        Panel panelHeader = LibrairieControlesDynamique.divDYN(panelBase, nomEntreprise + "_header", "panel-heading");

        LibrairieControlesDynamique.lblDYN(panelHeader, nomEntreprise + "_nom", nomEntreprise + " - " + leVendeur.AdresseEmail, "nom-entreprise");

        // Liste des items + le total

        //Label lblCollapse = LibrairieControlesDynamique.lblDYN(panelHeader, nomEntreprise + "_lblPanelTitle", "panel-title","panel-title");
        // LibrairieControlesDynamique.aDYN(panelHeader, "Collapsible panel", "#contentBody_"+nomEntreprise + "_PanelCollapse", true);
        //Panel panelCollaspe = LibrairieControlesDynamique.divDYN(panelBase, nomEntreprise + "_PanelCollapse", "panel-collapse collapse");
        Panel panelBody = LibrairieControlesDynamique.divDYN(panelBase, nomEntreprise + "_PanelBody", "panel-body");

        Panel panCategorie   = LibrairieControlesDynamique.divDYN(panelBody, nomEntreprise + "_pretLivraison_", "row text-center");
        Panel colCatAfficher = LibrairieControlesDynamique.divDYN(panCategorie, nomEntreprise + "_colLabelPretLivraison", "col-sm-12");

        LibrairieControlesDynamique.lblDYN(colCatAfficher, nomEntreprise + "_labelCategorie", "Prêt pour livraison ", "infos-payage OrangeTitle");
        LibrairieControlesDynamique.liDYN(ulSideBar, "#contentBody_" + nomEntreprise + "_labelCategorie", "Prêt pour livraison", "");



        //LibrairieControlesDynamique.hrDYN(panelBody);
        LibrairieControlesDynamique.hrDYN(panelBody, "OrangeBorderPanier", 5);
        List <PPCommandes> lstCommandes = dbContext.PPCommandes.Where(c => c.Statut.Equals("0") && c.NoVendeur == noVendeur).OrderByDescending(c => c.DateCommande).ToList();

        // Rajouter les produits dans le panier
        if (lstCommandes.Count > 0)
        {
            for (int i = 0; i < lstCommandes.Count; i++)
            {
                long idItem = lstCommandes[i].NoCommande;

                decimal   prix      = lstCommandes[i].MontantTotAvantTaxes.Value;
                long      idClient  = lstCommandes[i].NoClient.Value;
                PPClients leClient  = dbContext.PPClients.Where(c => c.NoClient == idClient).First();
                int       NbVisites = dbContext.PPVendeursClients.Where(c => (c.NoClient == idClient) && (c.NoVendeur == noVendeur)).Count();

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

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


                // Date de la commande
                Panel colDate = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colDate_" + idItem, "col-sm-2 text-center ");
                LibrairieControlesDynamique.lblDYN(colDate, nomEntreprise + "_date_" + idItem, "Date de la commande<br>" + lstCommandes[i].DateCommande.Value.ToShortDateString(), "prix_item");

                //Button Facture Commande
                Panel colFacture = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colFacture_" + idItem, "col-sm-2 text-center");
                if (File.Exists(Server.MapPath("~/static/pdf/" + idItem + ".pdf")))
                {
                    LibrairieControlesDynamique.htmlbtnDYN(colFacture, "btnFactures" + idItem, "btn btn-default Orange", "Facture", "glyphicon glyphicon-list-alt", btnFacture);
                }
                else
                {
                    HtmlButton btn = LibrairieControlesDynamique.htmlbtnDYN(colFacture, "btnFactureDisabled" + idItem, "btn btn-default Orange disabled", "Facture", "glyphicon glyphicon-list-alt", btnFacture);
                    btn.Attributes.Add("disabled", "disabled");
                }



                // Pooids total commande
                Panel colPoids = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colPoids_" + idItem, "col-sm-1 text-center");
                LibrairieControlesDynamique.lblDYN(colPoids, nomEntreprise + "_Poids_" + idItem, "Poids <br>" + lstCommandes[i].PoidsTotal + " lbs", "border-quantite prix_item");

                // Nom du client
                Panel colNomClient = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colClient_" + idItem, "col-sm-2 text-center");
                LibrairieControlesDynamique.lblDYN(colNomClient, nomEntreprise + "_NomClient_" + idItem, "Client<br>" + leClient.Prenom + " " + leClient.Nom, "nomClient prix_item");

                // Visites
                Panel colVisites = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colVisite_" + idItem, "col-sm-1 text-center");
                LibrairieControlesDynamique.lblDYN(colVisites, nomEntreprise + "_Visites_" + idItem, "Visite(s)<br>" + NbVisites, "prix_item");

                // Total avant taxes
                Panel colPrix = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colPrix_" + idItem, "col-sm-2 text-center");
                LibrairieControlesDynamique.lblDYN(colPrix, nomEntreprise + "_prix_" + idItem, "Total<br>(sans taxes)<br>" + prix.ToString("C", CultureInfo.CurrentCulture), "prix_item");


                Panel  colLivrer = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colLivrer" + idItem, "col-sm-1 text-center");
                Button btnLivrer = LibrairieControlesDynamique.btnDYN(colLivrer, "btnLivre" + idItem, "btn btn-default OrangeButton", "Livrer", btnLivre);
                btnLivrer.OnClientClick = "if( !livraisonConfirm()) return false;";

                //   LibrairieControlesDynamique.hrDYN(panelBody);
            }
        }
        else
        {
            Panel row              = LibrairieControlesDynamique.divDYN(panelBody, nomEntreprise + "_rowPretLivraisonVide", "row marginFluid text-center ");
            Panel message          = LibrairieControlesDynamique.divDYN(row, nomEntreprise + "_messagePretLivraisonVide", "message text-center top15");
            Panel messageContainer = LibrairieControlesDynamique.divDYN(message, nomEntreprise + "_divMessageLivraison", "alert alert-danger alert-margins valignMessage");
            LibrairieControlesDynamique.lblDYN(messageContainer, nomEntreprise + "_leMessageLabelLivraison", "Vous avez aucune commande prête pour la livraison.");
        }

        LibrairieControlesDynamique.hrDYN(panelBody, "OrangeBorderPanier", 5);

        Panel panCategorie2   = LibrairieControlesDynamique.divDYN(panelBody, nomEntreprise + "_Livre_", "row text-center");
        Panel colCatAfficher2 = LibrairieControlesDynamique.divDYN(panCategorie2, nomEntreprise + "_colLabelLivre", "col-sm-12");

        LibrairieControlesDynamique.lblDYN(colCatAfficher2, nomEntreprise + "_labelLivre", "Commandes livrés ", "infos-payage OrangeTitle");
        HtmlGenericControl li = LibrairieControlesDynamique.liDYN(ulSideBar, "#contentBody_" + nomEntreprise + "_labelLivre", "Commandes livrés", "");

        LibrairieControlesDynamique.hrDYN(panelBody, "OrangeBorderPanier", 5);


        List <PPCommandes> lstCommandesLivre = dbContext.PPCommandes.Where(c => !c.Statut.Equals("0") && c.NoVendeur == noVendeur).OrderByDescending(c => c.DateCommande).ToList();

        // Rajouter les produits dans le panier
        if (lstCommandesLivre.Count > 0)
        {
            for (int i = 0; i < lstCommandesLivre.Count; i++)
            {
                long idItem = lstCommandesLivre[i].NoCommande;

                decimal   prix      = lstCommandesLivre[i].MontantTotAvantTaxes.Value;
                long      idClient  = lstCommandesLivre[i].NoClient.Value;
                PPClients leClient  = dbContext.PPClients.Where(c => c.NoClient == idClient).First();
                int       NbVisites = dbContext.PPVendeursClients.Where(c => (c.NoClient == idClient) && (c.NoVendeur == noVendeur)).Count();

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

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


                // Date de la commande
                Panel colDate = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colDate2_" + idItem, "col-sm-2 text-center ");
                LibrairieControlesDynamique.lblDYN(colDate, nomEntreprise + "_date2_" + idItem, "Date de la commande<br>" + lstCommandesLivre[i].DateCommande.Value.ToShortDateString(), "prix_item");

                //Button Facture Commande
                Panel colFacture = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colFacture2_" + idItem, "col-sm-2 text-center");
                if (File.Exists(Server.MapPath("~/static/pdf/" + idItem + ".pdf")))
                {
                    LibrairieControlesDynamique.htmlbtnDYN(colFacture, "btnFacture2" + idItem, "btn btn-default Orange", "Facture", "glyphicon glyphicon-list-alt", btnFactures);
                }
                else
                {
                    HtmlButton btn = LibrairieControlesDynamique.htmlbtnDYN(colFacture, "btnFacture2" + idItem, "btn btn-default Orange disabled", "Facture", "glyphicon glyphicon-list-alt", btnFactures);
                    btn.Attributes.Add("disabled", "disabled");
                }



                // Pooids total commande
                Panel colPoids = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colPoids2_" + idItem, "col-sm-1 text-center");
                LibrairieControlesDynamique.lblDYN(colPoids, nomEntreprise + "_Poids2_" + idItem, "Poids <br>" + lstCommandesLivre[i].PoidsTotal + " lbs", "border-quantite prix_item");

                // Nom du client
                Panel colNomClient = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colClient2_" + idItem, "col-sm-2 text-center");
                LibrairieControlesDynamique.lblDYN(colNomClient, nomEntreprise + "_NomClient2_" + idItem, "Client<br>" + leClient.Prenom + " " + leClient.Nom, "nomClient prix_item");

                // Visites
                Panel colVisites = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colVisite_" + idItem, "col-sm-1 text-center");
                LibrairieControlesDynamique.lblDYN(colVisites, nomEntreprise + "_Visites_" + idItem, "Visite(s)<br>" + NbVisites, "prix_item");

                List <PPDetailsCommandes> lstDetailsCommandes = dbContext.PPDetailsCommandes.Where(c => c.NoCommande == idItem).ToList();
                int nbItems = 0;
                for (int j = 0; j < lstDetailsCommandes.Count; j++)
                {
                    nbItems++;
                }

                // Nombre items
                Panel colNbItem = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colNbItem_" + idItem, "col-sm-1 text-center");
                LibrairieControlesDynamique.lblDYN(colNbItem, nomEntreprise + "_nbItems_" + idItem, "Nombres d'items<br>" + nbItems, "nomClient prix_item");

                // Total avant taxes
                Panel colPrix = LibrairieControlesDynamique.divDYN(rowItem, nomEntreprise + "_colPrix2_" + idItem, "col-sm-2 text-center");
                LibrairieControlesDynamique.lblDYN(colPrix, nomEntreprise + "_prix2_" + idItem, "Total (sans taxes)<br>" + prix.ToString("C", CultureInfo.CurrentCulture), "prix_item");
            }//   LibrairieControlesDynamique.hrDYN(panelBody);
        }

        else
        {
            Panel row              = LibrairieControlesDynamique.divDYN(panelBody, nomEntreprise + "_rowCommLivrer", "row marginFluid text-center ");
            Panel message          = LibrairieControlesDynamique.divDYN(row, nomEntreprise + "_messageCommLivrer", "message text-center top15");
            Panel messageContainer = LibrairieControlesDynamique.divDYN(message, nomEntreprise + "_divCommLivrer", "alert alert-danger alert-margins valignMessage");
            LibrairieControlesDynamique.lblDYN(messageContainer, nomEntreprise + "_leMessageLabelCommLivrer", "Vous avez aucune commande prête pour la livraison.");
        }


        LibrairieControlesDynamique.hrDYN(panelBody, "OrangeBorderPanier", 5);
    }
コード例 #21
0
    protected void btnInscription_Click(object sender, EventArgs e)
    {
        if (validerPage())
        {
            long      noClient = Convert.ToInt64(Session["NoClient"]);
            PPClients client   = dbContext.PPClients.Where(v => v.NoClient == noClient).Single();

            client.Nom = tbNom.Text.Trim();

            client.Prenom = tbPrenom.Text.Trim();

            client.Rue = tbAdresse.Text.Trim();

            client.Ville = tbVille.Text.Trim();

            client.Province = ddlProvince.SelectedValue;

            client.CodePostal = tbCodePostal.Text.ToUpper().Replace(" ", "").Replace("-", "").Trim();
            client.Pays       = "Canada";

            client.Tel1 = tbTelephone1.Text.Replace("(", "").Replace(")", "").Replace("-", "").Replace(" ", "");

            client.Tel2         = tbTelephone2.Text.Replace("(", "").Replace(")", "").Replace("-", "").Replace(" ", "");
            client.AdresseEmail = client.AdresseEmail;
            client.MotDePasse   = client.MotDePasse;
            client.DateCreation = client.DateCreation;
            client.DateMAJ      = DateTime.Now;
            client.NbConnexions = client.NbConnexions;
            client.Statut       = client.Statut;

            bool binOK = true;

            try
            {
                dbContext.SaveChanges();
                lblMessage.Text     = "Le profil a été modifié.";
                divMessage.CssClass = "alert alert-success alert-margins";
                divMessage.Visible  = true;
            }
            catch (Exception)
            {
                binOK = false;
            }

            if (binOK)
            {
                lblMessage.Text     = "Votre profil a été modifié.";
                divMessage.CssClass = "alert alert-success alert-margins";
            }
            else
            {
                lblMessage.Text     = "Votre profil n'a pas pu être modifié. Réessayez ultérieurement.";
                divMessage.CssClass = "alert alert-danger alert-margins";
            }
            divMessage.Visible = true;
        }
        else
        {
            afficherErreurs();
        }
    }
コード例 #22
0
    protected void btnInscription_Click(object sender, EventArgs e)
    {
        if (validerPage())
        {
            if (dbContext.PPClients.Where(c => c.AdresseEmail == tbCourriel.Text).Any() ||
                dbContext.PPVendeurs.Where(v => v.AdresseEmail == tbCourriel.Text).Any() ||
                dbContext.PPGestionnaires.Where(g => g.courriel == tbCourriel.Text).Any())
            {
                tbExpediteur.Text   = "";
                tbDestinataire.Text = "";
                tbSujet.Text        = "";
                tbCorps.Text        = "";
                divCourriel.Visible = false;

                lblMessage.Text     = "Il y a déjà un profil associé à ce courriel";
                divMessage.CssClass = "alert alert-danger alert-margins";
            }
            else
            {
                PPClients client = new PPClients();
                client.NoClient     = dbContext.PPClients.Max(c => c.NoClient) + 1;
                client.AdresseEmail = tbCourriel.Text;
                client.MotDePasse   = tbMotPasse.Text;
                client.DateCreation = DateTime.Now;
                client.NbConnexions = 0;
                client.Statut       = 1;

                dbContext.PPClients.Add(client);

                bool binOK = true;

                try
                {
                    dbContext.SaveChanges();
                }
                catch (Exception)
                {
                    binOK = false;
                }

                if (binOK)
                {
                    MailMessage message = new MailMessage("*****@*****.**", client.AdresseEmail);
                    message.Subject = "Création profil Les Petites Puces";
                    message.Body    = string.Format("Bonjour,\n\n" +
                                                    "Suite à votre demande, votre profil Les Petites Puces a été créé. Votre numéro de client est {0}. Voici vos informations de connexion :\n" +
                                                    "Identifiant : {1}\n" +
                                                    "Mot de passe : {2}\n\n" +
                                                    "Merci de faire affaire avec nous,\n" +
                                                    "Les Petites Puces",
                                                    client.NoClient,
                                                    client.AdresseEmail,
                                                    client.MotDePasse);

                    tbExpediteur.Text   = message.From.ToString();
                    tbDestinataire.Text = message.To.ToString();
                    tbSujet.Text        = message.Subject;
                    tbCorps.Text        = message.Body;
                    divCourriel.Visible = true;

                    lblMessage.Text     = "Votre profil a été créé. Vos informations de connexion vous ont été envoyées par courriel.";
                    divMessage.CssClass = "alert alert-success alert-margins";
                }
            }

            foreach (Control controle in Page.Form.Controls)
            {
                if (controle is TextBox)
                {
                    ((TextBox)controle).Text = "";
                }
            }
            divMessage.Visible = true;
        }
        else
        {
            afficherErreurs();
        }
    }
コード例 #23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Session.IsVendeur())
        {
            Response.Redirect(SessionManager.RedirectConnexionLink);
        }

        vendeur = Session.GetVendeur();

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

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

        //Commandes
        int indexCom = 0;

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

                decimal poidsCommande = com.Commande.PoidsTotal.Value;

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

                decimal montantCom = montant.First().Value;

                string nomPDF = "";

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

                TableCell cellNom = new TableCell();

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


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

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

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

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


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

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

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

                row.Cells.Add(cellBtn);

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



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

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

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

        int index = 0;

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

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

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

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

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

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


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

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


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

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


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

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

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

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

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

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

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

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

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

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

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

        nombreClientParVendeur();

        //ajouter les stats ici
    }
コード例 #24
0
    protected void btnConnexion_Click(object sender, EventArgs e)
    {
        if (valMDP.IsValid && valNomU.IsValid)
        {
            // Essayer de se connecter en tant que client en premier
            PPClients clients = new PPClients();

            Client client = clients.Values.Find(cli => cli.AdresseEmail.ToLower() == tbNomU.Text.ToLower());
            if (client != null)
            {
                if (client.MotDePasse == tbMDP.Text)
                {
                    if (client.StatutEnum() == ClientStatut.Disabled)
                    {
                        lblErreurSQL.Text = "Ce compte est désactivé";
                    }
                    else
                    {
                        client.NbConnexions++;
                        client.DateDerniereConnexion = DateTime.Now;

                        clients.NotifyUpdated(client);
                        clients.Update();

                        Session.SetClient(client);
                        Response.Redirect("~/Pages/Accueil.aspx");
                    }
                }
                else
                {
                    lblErreurSQL.Text = "L'adresse email ou le mot de passe n'est pas correcte";
                }
            }
            else
            {
                // Essayer en tant que vendeur si le client n'existe pas
                PPVendeurs vendeurs = new PPVendeurs();

                Vendeur vendeur = vendeurs.Values.Find(ven => ven.AdresseEmail.ToLower() == tbNomU.Text.ToLower());
                if (vendeur != null)
                {
                    if (vendeur.MotDePasse == tbMDP.Text)
                    {
                        if (vendeur.StatutEnum() == VendeurStatut.Disabled)
                        {
                            lblErreurSQL.Text = "Ce compte est désactivé";
                        }
                        else if (vendeur.StatutEnum() == VendeurStatut.Pending)
                        {
                            lblErreurSQL.Text = "Ce compte n'a pas encore été accepté par le gestionnaire";
                        }
                        else
                        {
                            Session.SetVendeur(vendeur);
                            Response.Redirect("~/Pages/Vendeur/AccueilVendeur.aspx");
                        }
                    }
                    else
                    {
                        lblErreurSQL.Text = "L'adresse email ou le mot de passe n'est pas correcte";
                    }
                }
                else
                {
                    // Essayer en tant que gestionnaire comme dernier recours
                    PPGestionnaires gestionnaires = new PPGestionnaires();

                    Gestionnaire admin = gestionnaires.Values.Find(adm => adm.Email.ToLower() == tbNomU.Text.ToLower());
                    if (admin != null)
                    {
                        if (admin.MotDePasse == tbMDP.Text)
                        {
                            Session.SetAdmin(admin);
                            Response.Redirect("~/Pages/Admin/PageAccueilAdmin.aspx");
                        }
                        else
                        {
                            lblErreurSQL.Text = "L'adresse email ou le mot de passe n'est pas correcte";
                        }
                    }
                    else
                    {
                        lblErreurSQL.Text = "L'utilisateur n'existe pas";
                    }
                }
            }
        }
    }
コード例 #25
0
    public void btnConnexion_click(Object sender, EventArgs e)
    {
        String typeUtilisateur = null;
        String courriel        = tbCourriel.Text;
        String MDP             = tbMDP.Text;

        if (dbContext.PPClients.Where(c => c.AdresseEmail == courriel).Any())
        {
            typeUtilisateur = "C";
        }
        else if (dbContext.PPVendeurs.Where(v => v.AdresseEmail == courriel).Any())
        {
            typeUtilisateur = "V";
        }
        else if (dbContext.PPGestionnaires.Where(g => g.courriel == courriel).Any())
        {
            typeUtilisateur = "G";
        }

        bool   verdictConnexion = false;
        String url = "";

        int codeErreur = typeUtilisateur != null?LibrairieLINQ.connexionOK(courriel, MDP, typeUtilisateur) : 401;

        if (typeUtilisateur != null)
        {
            if (typeUtilisateur == "C" && codeErreur == 400)
            {
                verdictConnexion = true;
                List <String> lstInfos = LibrairieLINQ.infosBaseClient(courriel);
                Session["TypeUtilisateur"] = "C";
                Session["NoClient"]        = lstInfos[0];
                Session["Nom"]             = lstInfos[1];
                Session["Prenom"]          = lstInfos[2];
                Session["Courriel"]        = lstInfos[3];
                url = "~/Pages/AccueilClient.aspx?";

                PPClients client = dbContext.PPClients.Where(c => c.AdresseEmail == courriel).Single();
                if (client.DateDerniereConnexion != null)
                {
                    if (client.DateDerniereConnexion.Value.Date != DateTime.Now.Date)
                    {
                        client.NbConnexions++;
                        client.DateDerniereConnexion = DateTime.Now;
                    }
                }
                else
                {
                    client.NbConnexions++;
                    client.DateDerniereConnexion = DateTime.Now;
                }

                try
                {
                    dbContext.SaveChanges();
                }
                catch { }
            }
            else if (typeUtilisateur == "V" && codeErreur == 400)
            {
                verdictConnexion = true;
                List <String> lstInfos = LibrairieLINQ.infosBaseVendeur(courriel);
                Session["TypeUtilisateur"] = "V";
                Session["NoVendeur"]       = lstInfos[0];
                Session["NomAffaire"]      = lstInfos[1];
                Session["Nom"]             = lstInfos[2];
                Session["Prenom"]          = lstInfos[3];
                Session["Courriel"]        = lstInfos[4];
                url = "~/Pages/ConnexionVendeur.aspx?";
            }
            else if (typeUtilisateur == "G" && codeErreur == 400)
            {
                verdictConnexion           = true;
                Session["TypeUtilisateur"] = "G";
                url = "~/Pages/AcceuilGestionnaire.aspx?";
            }
        }

        if (verdictConnexion)
        {
            if (cbSeSouvenir.Checked)
            {
                HttpCookie cookie = new HttpCookie("idPetitesPuces");
                cookie.Value   = courriel;
                cookie.Expires = DateTime.MaxValue;
                Response.Cookies.Add(cookie);
            }

            Response.Redirect(url, true);
        }
        else
        {
            tbCourriel.CssClass = "form-control erreur";
            tbMDP.CssClass      = "form-control erreur";

            alert_erreur.Visible = true;
            if (codeErreur == 401)
            {
                lblMessageErreur.Text = "Courriel ou mot de passe incorrect";
            }
            else if (codeErreur == 402)
            {
                lblMessageErreur.Text = "Impossible d'établir une connexion";
            }
            else if (codeErreur == 403)
            {
                lblMessageErreur.Text = "Demande en attente d'acceptation";
            }
        }
    }
コード例 #26
0
    protected void btnSauvegarder_OnClick(object sender, EventArgs e)
    {
        // Reset everything
        tbPrenom.DefaultControl();
        tbNom.DefaultControl();
        tbNoCiviqueRue.DefaultControl();
        tbVille.DefaultControl();
        ddlProvince.DefaultControl();
        tbCodePostal.DefaultControl();
        tbTelephone.DefaultControl();
        tbCellulaire.DefaultControl();

        Client client = Session.GetClient();

        bool[] arrError = new bool[]
        {
            tbPrenom.InvalidateIfEmpty(lblErrorPrenom, "Le prénom doit être présent") ||
            tbPrenom.CheckFormatNomPrenom(lblErrorPrenom),
            tbNom.InvalidateIfEmpty(lblErrorNom, "Le nom doit être présent") ||
            tbNom.CheckFormatNomPrenom(lblErrorNom),
            tbNoCiviqueRue.InvalidateIfEmpty(lblErrorNoCiviqueRue, "Les informations sur la rue (No Civique et Rue)") ||
            tbNoCiviqueRue.CheckFormatNomPrenom(lblErrorNoCiviqueRue),
            tbVille.InvalidateIfEmpty(lblErrorVille, "Le nom de la ville doit être présent") ||
            tbVille.CheckFormatNomPrenom(lblErrorVille),
            ddlProvince.InvalidateIfEmpty(lblErrorProvince, "La province doit être selectionnée"),
            tbCodePostal.InvalidateIfEmpty(lblErrorCodePostal, "Le code postal doit être présent") ||
            tbCodePostal.CheckContains(lblErrorCodePostal, "Le code postal doit être entré au complet", "_"),
            tbTelephone.InvalidateIfEmpty(lblErrorTelephone, "Le numéro de téléphone doit être présent") ||
            tbTelephone.CheckContains(lblErrorTelephone, "Le numéro de téléphone doit être entré au complet", "_"),
            tbCellulaire.CheckContains(lblErrorCellulaire, "Le numéro de téléphone doit être entré au complet", "_")
        };

        if (!arrError.Contains(true))
        {
            // Check if there are any differences
            bool modifications = false;
            if (client.Prenom != tbPrenom.Text)
            {
                client.Prenom = tbPrenom.Text;
                modifications = true;
            }
            if (client.Nom != tbNom.Text)
            {
                client.Nom    = tbNom.Text;
                modifications = true;
            }
            if (client.Rue != tbNoCiviqueRue.Text)
            {
                client.Rue    = tbNoCiviqueRue.Text;
                modifications = true;
            }
            if (client.Ville != tbVille.Text)
            {
                client.Ville  = tbVille.Text;
                modifications = true;
            }
            if (client.Province != ddlProvince.SelectedValue)
            {
                client.Province = ddlProvince.SelectedValue;
                modifications   = true;
            }
            if (client.CodePostal != tbCodePostal.Text)
            {
                client.CodePostal = tbCodePostal.Text.ToUpper();
                modifications     = true;
            }
            if (client.Tel1 != tbTelephone.Text)
            {
                client.Tel1   = tbTelephone.Text;
                modifications = true;
            }
            if (client.Tel2 != tbCellulaire.Text)
            {
                client.Tel2   = tbCellulaire.Text;
                modifications = true;
            }

            if (modifications)
            {
                client.DateMAJ = DateTime.Now;
                PPClients clients = new PPClients();
                clients.NotifyUpdatedOutside(client);

                clients.Update();

                Response.Redirect("~/Pages/Client/ProfilClient.aspx?Reussite=true");
            }
        }
    }
コード例 #27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Session.IsVendeur())
        {
            Response.Redirect(SessionManager.RedirectConnexionLink);
        }

        if (!IsPostBack)
        {
            ddlChoix.Items.Add(new ListItem("1 mois", "1"));
            ddlChoix.Items.Add(new ListItem("2 mois", "2"));
            ddlChoix.Items.Add(new ListItem("3 mois", "3"));
            ddlChoix.Items.Add(new ListItem("6 mois", "6"));

            ddlChoix.SelectedValue = "6";
        }
        //for pour remplir les paniers
        vendeur = Session.GetVendeur();

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

        int      nbMois = int.Parse(ddlChoix.SelectedValue);
        DateTime min    = DateTime.Today.AddMonths(-1 * nbMois);

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

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

        int   index  = 0;
        int   index2 = 0;
        Panel rows   = null;

        /* if (grouped.Count() == 0)
         * {
         *   rows = pnHaut.DivDyn("", "row mb-3");
         *   rows.DivDyn("", "col-2");
         *   Panel pnCol = rows.DivDyn("", "");
         *   pnCol.LblDyn("lblVide", "Vous n'avez aucun panier pour cette période de temps : " + ddlChoix.SelectedItem, "h4 text-info");
         * }
         * else { */

        bool auMoinsUNPanier = false;

        foreach (var group in grouped)
        {
            bool dateChecker = false;
            foreach (var ap in group.Articles)
            {
                if (ap.Article.DateCreation.Value.Date >= min)
                {
                    dateChecker     = true;
                    auMoinsUNPanier = true;
                }
            }

            if (dateChecker)
            {
                string   nomClient      = "Annonyme";
                string   noClient       = group.Client.NoClient.ToString();
                decimal  montant        = 0;
                int      nombreArticles = 0;
                DateTime datePanier     = DateTime.Now;

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

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

                rows = pnHaut.DivDyn("", "row mb-3");

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


                //header des categories
                Panel panelCard            = rows.DivDyn("", "col-12");
                Panel card                 = panelCard.DivDyn("", "card");
                Panel panelTitreCategories = card.DivDyn("", "card-header fake-button");
                panelTitreCategories.LblDyn("", nomClient, "card-title h5 text-info");
                panelTitreCategories.LblDyn("", "valeur de " + montant.ToString("N2") + " $", "ml-3 card-title h6");
                panelTitreCategories.LblDyn("", "Articles (" + nombreArticles.ToString() + ")", "ml-3 card-title h6");
                panelTitreCategories.LblDyn("", datePanier.ToString("yyyy/MM/dd"), "ml-3 card-title h6 text-success");

                //Assigner les options de collapse au header
                panelTitreCategories.Attributes.Add("data-toggle", "collapse");
                panelTitreCategories.Attributes.Add("data-target", "#Contenu_ContenuPrincipal_collapsePanier" + index.ToString() + index2.ToString());
                panelTitreCategories.Attributes.Add("aria-expanded", "false");
                panelTitreCategories.Attributes.Add("aria-controls", "Contenu_ContenuPrincipal_collapsePanier" + index.ToString() + index2.ToString());


                Panel collapsable;
                //body des categories

                collapsable = card.DivDyn("collapsePanier" + index.ToString() + index2.ToString(), "collapse collapse");


                Panel panelBodyCat = collapsable.DivDyn("", "card-body");

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

                //colones header

                Table           table    = panelBodyCat.TableDyn("", "table table-hover fake-button");
                TableHeaderRow  rowTable = table.ThrDyn();
                TableHeaderCell CellCss  = rowTable.ThdDyn("");

                rowTable.ThdDyn("Produit");
                CellCss          = rowTable.ThdDyn("Prix unitaire");
                CellCss.CssClass = "text-right";
                CellCss          = rowTable.ThdDyn("Poids unitaire");
                CellCss.CssClass = "text-right";
                CellCss          = rowTable.ThdDyn("Qte");
                CellCss.CssClass = "text-center";
                CellCss          = rowTable.ThdDyn("Prix total (sans rabais)");
                CellCss.CssClass = "text-right";

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

                    string  nomArticle     = article.Produit.Nom;
                    string  lblRabais      = "";
                    decimal montantArticle = -1;
                    if (article.Produit.PrixVente != article.Produit.PrixDemande && article.Produit.DateVente >= DateTime.Today)
                    {
                        decimal montantRabais = article.Produit.PrixDemande.Value - article.Produit.PrixVente.Value;
                        lblRabais      = "rabais! (" + montantRabais.ToString("N2") + "$) finit le " + article.Produit.DateVente.Value.ToString("yyyy-MM-dd");
                        montantArticle = article.Produit.PrixDemande.Value;
                    }
                    else
                    {
                        montantArticle = article.Produit.PrixDemande.Value;
                    }
                    decimal poidsArticle = article.Produit.Poids.Value;
                    short   nbItems      = article.Article.NbItems.Value;
                    decimal prix         = article.Produit.PrixDemande.Value * article.Article.NbItems.Value;

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

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

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

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

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

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

                    TableCell cell6 = nRow.TdDyn("", "text-right");
                    cell6.LblDyn("", prix.ToString("N2") + " $", "text-success");
                }
                Panel  rowBtnSupprimer = collapsable.DivDyn("", "row ml-3 mr-3 mb-3");
                Button btnClient       = rowBtnSupprimer.BtnDyn("btn" + group.NoClient, "Courriel", btnCourriel_Click, "btn btn-outline-dark btn-block");
                btnClient.CommandArgument = (group.NoClient).ToString();
            }
            index++;
        }

        if (!auMoinsUNPanier)
        {
            rows = pnHaut.DivDyn("", "row mb-3");
            rows.DivDyn("", "col-2");
            Panel pnCol = rows.DivDyn("", "");
            pnCol.LblDyn("lblVide", "Vous n'avez aucun panier pour cette période de temps : " + ddlChoix.SelectedItem, "h4 text-info");
        }
        // }

        //paniers du bas
        PPArticlesEnPanier articlesEnPanier2 = new PPArticlesEnPanier();
        PPProduits         produits2         = new PPProduits();
        PPClients          clients2          = new PPClients();

        rows = null;
        min  = DateTime.Today.AddMonths(-6);
        var yes2 = from article in articlesEnPanier2.Values
                                                                //join vendeur in vendeurs.Values on article.NoVendeur equals vendeur.NoVendeur
                   join produit in produits2.Values on article.NoProduit equals produit.NoProduit
                   where article.NoVendeur == vendeur.NoVendeur //&& article.DateCreation.Value.Date < min // Mettre la variable pour gérer les mois
                   orderby article.DateCreation ascending
                   select new { Article = article, Produit = produit };

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


        index  = 0;
        index2 = 0;

        bool auMoinsUNPanierH = false;

        if (groupedBas.Count() <= 0)
        {
            auMoinsUNPanierH = true;
        }

        foreach (var group in groupedBas)
        {
            bool dateChecker = false;
            foreach (var ap in group.Articles)
            {
                if (ap.Article.DateCreation.Value.Date > min)
                {
                    dateChecker = true;
                }
            }

            if (!dateChecker)
            {
                auMoinsUNPanierH = true;
                string   nomClient      = "Annonyme";
                string   noClient       = group.Client.NoClient.ToString();
                decimal  montant        = 0;
                int      nombreArticles = 0;
                DateTime datePanier     = DateTime.Now;

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

                foreach (var article in group.Articles)
                {
                    nombreArticles++;
                    montant   += article.Produit.PrixDemande.Value * article.Article.NbItems.Value;
                    datePanier = article.Article.DateCreation.Value.Date;
                }
                rows = panelVieux.DivDyn("", "row mb-3");

                /*  if (index % 2 == 0)
                 * {
                 *    rows = panelVieux.DivDyn("", "row mb-3");
                 *    index2++;
                 * }*/

                //header des categories
                Panel panelCard            = rows.DivDyn("", "col-12");
                Panel card                 = panelCard.DivDyn("", "card");
                Panel panelTitreCategories = card.DivDyn("", "card-header fake-button");

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


                //Assigner les options de collapse au header
                panelTitreCategories.Attributes.Add("data-toggle", "collapse");
                panelTitreCategories.Attributes.Add("data-target", "#Contenu_ContenuPrincipal_collapsePanierBas" + index.ToString() + index2.ToString());
                panelTitreCategories.Attributes.Add("aria-expanded", "false");
                panelTitreCategories.Attributes.Add("aria-controls", "Contenu_ContenuPrincipal_collapsePanierBas" + index.ToString() + index2.ToString());


                Panel collapsable;
                //body des categories

                collapsable = card.DivDyn("collapsePanierBas" + index.ToString() + index2.ToString(), "collapse collapse");


                Panel panelBodyCat = collapsable.DivDyn("", "card-body");

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

                //colones header
                Table           table    = panelBodyCat.TableDyn("", "table table-hover fake-button");
                TableHeaderRow  rowTable = table.ThrDyn();
                TableHeaderCell CellCss  = rowTable.ThdDyn("");

                rowTable.ThdDyn("Produit");
                CellCss          = rowTable.ThdDyn("Prix unitaire");
                CellCss.CssClass = "text-right";
                CellCss          = rowTable.ThdDyn("Poids unitaire");
                CellCss.CssClass = "text-right";
                CellCss          = rowTable.ThdDyn("Qte");
                CellCss.CssClass = "text-center";
                CellCss          = rowTable.ThdDyn("Prix total (sans rabais)");
                CellCss.CssClass = "text-right";

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

                    string  nomArticle     = article.Produit.Nom;
                    string  lblRabais      = "";
                    decimal montantArticle = -1;
                    if (article.Produit.PrixVente != article.Produit.PrixDemande && article.Produit.DateVente >= DateTime.Today)
                    {
                        decimal montantRabais = article.Produit.PrixDemande.Value - article.Produit.PrixVente.Value;
                        lblRabais      = "rabais! (" + montantRabais.ToString("N2") + "$) finit le" + article.Produit.DateVente.Value.ToString("yyyy-MM-dd");
                        montantArticle = article.Produit.PrixDemande.Value;
                    }
                    else
                    {
                        montantArticle = article.Produit.PrixDemande.Value;
                    }
                    decimal poidsArticle = article.Produit.Poids.Value;
                    short   nbItems      = article.Article.NbItems.Value;
                    decimal prix         = article.Produit.PrixDemande.Value * article.Article.NbItems.Value;

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

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

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

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

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

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

                    TableCell cell6 = nRow.TdDyn("", "text-right");
                    cell6.LblDyn("", prix.ToString("N2") + " $", "text-success");
                }
                Panel  rowBtnSupprimer = collapsable.DivDyn("", "row ml-3 mr-3 mb-3");
                Button btnClient       = rowBtnSupprimer.BtnDyn("", "Courriel", btnCourriel_Click, "btn btn-outline-dark col-5");
                btnClient.CommandArgument = group.NoClient.ToString();
                rowBtnSupprimer.DivDyn("", "col-2");
                Button btn = rowBtnSupprimer.BtnDyn("", "Supprimer", null, "btn btn-outline-danger col-5");

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

                modal(panelAvecModal, "myModal" + index.ToString() + index2.ToString(), group.NoClient.ToString(), "idBtnAnnuler" + index.ToString() + index2.ToString(), "Supression", "Voulez vous supprimer ce panier", true);
            }
            index++;
        }

        if (!auMoinsUNPanierH)
        {
            panelVieux.LblDyn("", "Vous n'avez aucun panier vieux de plus de 6 mois", "text-info h4");
        }

        /* }
         * else
         * {
         *   panelVieux.LblDyn("", "Vous n'avez aucun panier vieux de plus de 6 mois", "text-info h4");
         * }*/
    }
コード例 #28
0
    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);
        }
    }