// get le pourcentage de taxes public static Decimal?getPourcentageTaxes(String typeTaxe, long?noVendeur) { BD6B8_424SEntities dataContext = new BD6B8_424SEntities(); var tableTPS = dataContext.PPTaxeFederale; var tableTVQ = dataContext.PPTaxeProvinciale; var tableVendeur = dataContext.PPVendeurs; PPVendeurs vendeur = (from v in tableVendeur where v.NoVendeur == noVendeur select v).First(); bool appliqueTaxes = (bool)vendeur.Taxes; bool appliqueTVQ = (vendeur.Province == "QC") ? true : false; Decimal?taxe = 0; if (appliqueTaxes) { switch (typeTaxe) { case "TPS": taxe = (from tps in tableTPS orderby tps.DateEffectiveTPS descending select tps).First().TauxTPS; break; case "TVQ": taxe = (appliqueTVQ) ? (from tvq in tableTVQ orderby tvq.DateEffectiveTVQ descending select tvq).First().TauxTVQ : 0; break; } } return(taxe); }
public void afficherFormCourriel(String message, bool accepte) { PPVendeurs vendeur = LibrairieLINQ.getInfosVendeur(this.noVendeur); String infos = "Courriel: " + vendeur.AdresseEmail + "\n" + "Mot de passe: " + vendeur.MotDePasse; LibrairieControlesDynamique.btnDYN(phDynamique, "", "btn btn-warning", "Retour", (accepte) ? new EventHandler(retourRedevance_click) : new EventHandler(retourDetails_click)); LibrairieControlesDynamique.brDYN(phDynamique); LibrairieControlesDynamique.brDYN(phDynamique); LibrairieControlesDynamique.lblDYN(phDynamique, "", "Destinataire :").Style.Add("font-size", "20px"); Panel panelDefault = LibrairieControlesDynamique.divDYN(phDynamique, "", "panel panel-default"); Panel panelBody = LibrairieControlesDynamique.divDYN(panelDefault, "", "panel-body"); LibrairieControlesDynamique.spaceDYN(panelBody); Label lbl = LibrairieControlesDynamique.lblDYN(panelBody, "", vendeur.Prenom + " " + vendeur.Nom, "badge"); lbl.Style.Add("background-color", "orange !important"); // objet Panel divObjet = LibrairieControlesDynamique.divDYN(phDynamique, "", "form-group"); LibrairieControlesDynamique.lblDYN(divObjet, "", "Objet :"); this.objet = LibrairieControlesDynamique.tbDYN(divObjet, "", "Demande de vendeur", "form-control"); // message Panel divMessage = LibrairieControlesDynamique.divDYN(phDynamique, "", "form-group"); LibrairieControlesDynamique.lblDYN(divObjet, "", "Message :"); this.message = LibrairieControlesDynamique.textAreaDYN(divObjet, "", 10, "form-control", ((accepte) ? infos + "\n\n" : "") + message); // bouton envoyer LibrairieControlesDynamique.btnDYN(phDynamique, "", "btn btn-warning", "Envoyer", (accepte) ? new EventHandler(envoyerCourrielAccepte_click) : new EventHandler(envoyerCourrielRefuse_click)); }
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; } }
protected void Page_Load(object sender, EventArgs e) { verifierPermissions("V"); Page.Title = "Gestion des paniers inactifs"; if (Session["ddlMoisInactif"] != null && !IsPostBack) { if (Convert.ToInt32(Session["ddlMoisInactif"]) == 7) { ddlMois.SelectedIndex = ddlMois.Items.IndexOf(ddlMois.Items.FindByText("7+")); } else { ddlMois.SelectedIndex = ddlMois.Items.IndexOf(ddlMois.Items.FindByText(Convert.ToString(Session["ddlMoisInactif"]))); } } nbMois = Session["ddlMoisInactif"] != null && Convert.ToInt32(Session["ddlMoisInactif"]) != 0 ? Convert.ToInt32(Session["ddlMoisInactif"]) : 1; if (Session["NoVendeur"] != null) { noVendeur = Convert.ToInt32((Session["NoVendeur"])); } leVendeur = dbContext.PPVendeurs.Where(c => c.NoVendeur == noVendeur).First(); nomEntreprise = leVendeur.NomAffaires; creerPage(); }
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"; } }
// désactiver compte client public static void desactiverCompteVendeur(long noVendeur) { BD6B8_424SEntities dataContext = new BD6B8_424SEntities(); var tableVendeur = dataContext.PPVendeurs; PPVendeurs vendeur = (from v in tableVendeur where v.NoVendeur == noVendeur select v).First(); foreach (PPProduits produit in vendeur.PPProduits.ToList()) { foreach (PPArticlesEnPanier ap in produit.PPArticlesEnPanier.ToList()) { dataContext.PPArticlesEnPanier.Remove(ap); } if (produit.PPDetailsCommandes.Count() == 0) { dataContext.PPProduits.Remove(produit); } else { produit.Disponibilité = false; } } vendeur.Statut = 0; dataContext.SaveChanges(); }
protected void Page_Load(object sender, EventArgs e) { if (!Session.IsClient()) { Response.Redirect(SessionManager.RedirectConnexionLink); } Client client = Session.GetClient(); PPCommandes commandes = new PPCommandes(); PPDetailsCommandes detailsCommandes = new PPDetailsCommandes(); PPVendeurs vendeurs = new PPVendeurs(); PPTypesLivraison typesLivraison = new PPTypesLivraison(); var listeCommandes = from commande in commandes.Values join vendeur in vendeurs.Values on commande.NoVendeur equals vendeur.NoVendeur join typeLivraison in typesLivraison.Values on commande.TypeLivraison equals typeLivraison.CodeLivraison where commande.NoClient == client.NoClient let listeDetails = detailsCommandes.Values.Where(x => x.NoCommande == commande.NoCommande) select new { Commande = commande, TypeLivraison = typeLivraison, Vendeur = vendeur, Details = listeDetails }; pnlContent.CardDyn( "", "mb-3", lbl => lbl.Text = "Historique des commandes", body => { Table table = body.TableDyn("", "table table-padding"); TableHeaderRow hrow = table.ThrDyn(); hrow.ThdDyn("No Commande"); hrow.ThdDyn("Nom du vendeur"); hrow.ThdDyn("Date de la commande"); hrow.ThdDyn("Prix total avant taxes"); foreach (var commande in listeCommandes) { TableRow row = table.TrDyn(); TableCell cellBtnCommande = row.TdDyn(); string path = $"Factures/{commande.Commande.NoCommande}.pdf"; if (File.Exists(Server.MapPath($"~/{path}"))) { cellBtnCommande.BtnClientDyn("", commande.Commande.NoCommande.ToString(), $"window.open('/{path}'); return false;", "btn btn-outline-secondary btn-block"); } else { cellBtnCommande.BtnClientDyn("", commande.Commande.NoCommande.ToString(), $"window.open('/Factures/defaut.pdf'); return false", "btn btn-outline-secondary btn-block"); } TableCell cellLinkVendeur = row.TdDyn(); cellLinkVendeur.HlinkDYN("", $"~/Pages/Client/Catalogue.aspx?NoVendeur={commande.Vendeur.NoVendeur}", commande.Vendeur.NomAffaires); row.TdDyn(commande.Commande.DateCommande.ToString()); row.TdDyn(commande.Commande.MontantTotAvantTaxes.Value.ToString("N2") + "$"); } }); }
// modifier redevance vendeur public static void modifierRedevanceVendeur(long noVendeur, Decimal redevance) { BD6B8_424SEntities dataContext = new BD6B8_424SEntities(); var tableVendeur = dataContext.PPVendeurs; PPVendeurs vendeur = (from v in tableVendeur where v.NoVendeur == noVendeur select v).First(); vendeur.Pourcentage = redevance; dataContext.SaveChanges(); }
public void afficherFormRedevance() { LibrairieControlesDynamique.btnDYN(phDynamique, "", "btn btn-warning", "Retour", retourDetails_click); LibrairieControlesDynamique.brDYN(phDynamique); LibrairieControlesDynamique.brDYN(phDynamique); PPVendeurs vendeur = LibrairieLINQ.getInfosVendeur(this.noVendeur); // créer le tableau avec les infos Panel panelBase = LibrairieControlesDynamique.divDYN(phDynamique, "", "panel panel-default"); Panel panelBody = LibrairieControlesDynamique.divDYN(panelBase, "", "panel-body"); Panel row = LibrairieControlesDynamique.divDYN(panelBody, "", "row"); Panel colNomEntreprise = LibrairieControlesDynamique.divDYN(row, "", "col-md-12"); LibrairieControlesDynamique.lblDYN(colNomEntreprise, "", vendeur.NomAffaires, "header-nom"); Panel divHR = LibrairieControlesDynamique.divDYN(row, "", "col-md-12"); LibrairieControlesDynamique.hrDYN(divHR); Panel colLblRedevances = LibrairieControlesDynamique.divDYN(row, "", "col-md-12"); Panel rowPourcentage = LibrairieControlesDynamique.divDYN(colLblRedevances, "", "row"); Panel colLBL = LibrairieControlesDynamique.divDYN(rowPourcentage, "", "col-md-3"); LibrairieControlesDynamique.lblDYN(colLBL, "", "Redevances par commande", "autres-infos"); LibrairieControlesDynamique.spaceDYN(colLblRedevances); Panel colTB = LibrairieControlesDynamique.divDYN(rowPourcentage, "", "col-md-2"); Panel div = LibrairieControlesDynamique.divDYN(colTB, "", "input-group"); LibrairieControlesDynamique.lblDYN(div, "", "%", "input-group-addon"); TextBox tb = LibrairieControlesDynamique.numericUpDownDYN(div, "", this.redevance, "0", "100", "form-control"); tb.Style.Add("width", "70px"); tb.MaxLength = 3; this.tbRedevance = tb; Panel colMessageConfirmation = LibrairieControlesDynamique.divDYN(row, "", "col-md-12"); LibrairieControlesDynamique.brDYN(colMessageConfirmation); LibrairieControlesDynamique.brDYN(colMessageConfirmation); LibrairieControlesDynamique.lblDYN(colMessageConfirmation, "", "En continuant vous acceptez que " + vendeur.Prenom + " " + vendeur.Nom + " ait un accès complet comme vendeur sur le site Les Petites Puces.", "autres-infos"); LibrairieControlesDynamique.brDYN(colMessageConfirmation); LibrairieControlesDynamique.brDYN(colMessageConfirmation); LibrairieControlesDynamique.btnDYN(LibrairieControlesDynamique.divDYN(row, "", "col-md-12"), "btnConf_" + vendeur.NoVendeur, "btn btn-warning", "Confirmer", confirmer_click); }
// aller chercher les compagnies de chaques catégories public static Dictionary <Nullable <long>, List <PPVendeurs> > getEntreprisesTriesParCategories() { BD6B8_424SEntities dataContext = new BD6B8_424SEntities(); var tableProduits = dataContext.PPProduits; var tableVendeurs = dataContext.PPVendeurs; Dictionary <Nullable <long>, List <PPVendeurs> > lstCategories = new Dictionary <long?, List <PPVendeurs> >(); var produits = from produit in tableProduits group produit by new { produit.NoCategorie, produit.NoVendeur } into listeProduits select listeProduits; foreach (var keys in produits) { List <PPVendeurs> lstTempo; if (lstCategories.TryGetValue(keys.Key.NoCategorie, out lstTempo)) { PPVendeurs vendeur = (from v in tableVendeurs where v.NoVendeur == keys.Key.NoVendeur select v).First(); lstTempo.Add(vendeur); } else { List <PPVendeurs> lst = new List <PPVendeurs>(); PPVendeurs vendeur = (from v in tableVendeurs where v.NoVendeur == keys.Key.NoVendeur select v).First(); lst.Add(vendeur); lstCategories.Add(keys.Key.NoCategorie, lst); } } /*foreach(var produit in produits) * { * List<PPProduits> lstTempo; * if (lstCategories.TryGetValue(produit.NoVendeur, out lstTempo)) * { * lstTempo.Add(produit); * } * else * { * List<PPProduits> lst = new List<PPProduits>(); * lst.Add(produit); * lstCategories.Add(produit.NoVendeur, lst); * } * }*/ return(lstCategories); }
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"); } } }
protected void ViderBD() { PPGestionnaires gestionnaires = new PPGestionnaires(); gestionnaires.RemoveAll(); PPDetailsCommandes detailsCommandes = new PPDetailsCommandes(); detailsCommandes.RemoveAll(); PPCommandes commandes = new PPCommandes(); commandes.RemoveAll(); PPPoidsLivraisons poidLivraison = new PPPoidsLivraisons(); poidLivraison.RemoveAll(); PPTypesLivraison typeLivraison = new PPTypesLivraison(); typeLivraison.RemoveAll(); PPTypesPoids typePoids = new PPTypesPoids(); typePoids.RemoveAll(); PPVendeursClients vendeursClients = new PPVendeursClients(); vendeursClients.RemoveAll(); PPArticlesEnPanier articlesEnPanier = new PPArticlesEnPanier(); articlesEnPanier.RemoveAll(); PPClients clients = new PPClients(); clients.RemoveAll(); PPProduits produits = new PPProduits(); produits.RemoveAll(); PPVendeurs vendeurs = new PPVendeurs(); vendeurs.RemoveAll(); PPCategories categories = new PPCategories(); categories.RemoveAll(); PPHistoriquePaiements historique = new PPHistoriquePaiements(); historique.RemoveAll(); PPTaxeFederale taxeFed = new PPTaxeFederale(); taxeFed.RemoveAll(); PPTaxeProvinciale taxeProv = new PPTaxeProvinciale(); taxeProv.RemoveAll(); afficherLesDonnees(); }
protected void Page_Load(object sender, EventArgs e) { verifierPermissions("V"); Page.Title = "Gestion des commandes"; Page.MaintainScrollPositionOnPostBack = true; if (Session["NoVendeur"] != null) { noVendeur = Convert.ToInt32((Session["NoVendeur"])); } leVendeur = dbContext.PPVendeurs.Where(c => c.NoVendeur == noVendeur).First(); nomEntreprise = leVendeur.NomAffaires; creerPage(); }
protected void Page_Load(object sender, EventArgs e) { verifierPermissions("V"); Page.Title = "Page d'accueil"; if (Session["NoVendeur"] != null) { noVendeur = Convert.ToInt32((Session["NoVendeur"])); } leVendeur = dbContext.PPVendeurs.Where(c => c.NoVendeur == noVendeur).First(); nomEntreprise = leVendeur.NomAffaires; creerSectionPretLivraison(); creerPage(); }
public void envoyerCourrielRefuse_click(Object sender, EventArgs e) { if (objet.Text != "" && message.Value != "") { PPVendeurs vendeur = LibrairieLINQ.getInfosVendeur(this.noVendeur); LibrairieLINQ.accepterOuDeleteDemandeVendeur(this.noVendeur, false, ""); String url = "~/Pages/DemandesVendeur.aspx?Notification=refuse"; Response.Redirect(url, true); } else { Panel erreur = LibrairieControlesDynamique.divDYN(phErreur, "", "alert alert-danger"); LibrairieControlesDynamique.lblDYN(erreur, "", "Le courriel doit contenir un objet et un message."); } }
// accepter ou delete la demande d'un vendeur public static void accepterOuDeleteDemandeVendeur(long noVendeur, bool accepte, String redevance) { BD6B8_424SEntities dataContext = new BD6B8_424SEntities(); var tableVendeurs = dataContext.PPVendeurs; PPVendeurs vendeur = (from v in tableVendeurs where v.NoVendeur == noVendeur select v).First(); if (accepte) { vendeur.Statut = 1; vendeur.Pourcentage = Decimal.Parse(redevance); } else { dataContext.PPVendeurs.Remove(vendeur); } dataContext.SaveChanges(); }
protected void remplirVendeur(XNamespace ss, XElement worksheet) { PPVendeurs vendeurs = new PPVendeurs(); 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); } //Response.Write(arrayStr.Count()); if (arrayStr.Count() == 21) { vendeurs.Add(new Vendeur(null) { NoVendeur = Convert.ToInt64(arrayStr[0]), NomAffaires = arrayStr[1], Nom = arrayStr[2], Prenom = arrayStr[3], Rue = arrayStr[4], Ville = arrayStr[5], Province = arrayStr[6] == "NULL" ? "" : arrayStr[6], CodePostal = arrayStr[7], Pays = arrayStr[8] == "NULL" ? "":arrayStr[8], Tel1 = arrayStr[9], Tel2 = arrayStr[10], AdresseEmail = arrayStr[11], MotDePasse = arrayStr[12], PoidsMaxLivraison = arrayStr[13] == "NULL" ? nullableInt : Convert.ToInt32(arrayStr[13]), LivraisonGratuite = arrayStr[14] == "NULL" ? nullableInt : Convert.ToInt32(arrayStr[14]), Taxes = (arrayStr[15] == "1" ? true : false), Pourcentage = arrayStr[16] == "NULL" ? nullableInt:Convert.ToInt32(arrayStr[16]), Configuration = arrayStr[17] == "NULL" ? null : arrayStr[17], DateCreation = DateTime.Parse(arrayStr[18]), DateMAJ = arrayStr[19] == "NULL" ? nullableDate : DateTime.Parse(arrayStr[19]), Statut = Convert.ToInt16(arrayStr[20]) }); } /*foreach (XElement cell in row.Descendants(ss + "Data")) * { * //Response.Write(cell.Value); * }*/ } }
protected void btnSauvegarderMDP_OnClick(object sender, EventArgs e) { tbAncienMDP.DefaultControl(); tbNouveauMDP.DefaultControl(); tbConfirmationMDP.DefaultControl(); Vendeur vendeur = Session.GetVendeur(); if (tbAncienMDP.Text != vendeur.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 == vendeur.MotDePasse) { tbNouveauMDP.Invalidate(); tbConfirmationMDP.Invalidate(); lblErrorNouveauMDP.Text = "Le nouveau mot de passe doit être différent de l'ancien"; } else { vendeur.MotDePasse = tbNouveauMDP.Text; PPVendeurs vendeurs = new PPVendeurs(); vendeurs.NotifyUpdatedOutside(vendeur); vendeurs.Update(); Response.Redirect("~/Pages/Vendeur/ProfilVendeur.aspx?ReussiteMDP=true"); } } } }
public void encaisser_click(Object sender, EventArgs e) { Button btn = (Button)sender; String id = btn.ID.Replace("btnEncaisser_", ""); long lgId = long.Parse(id); BD6B8_424SEntities dataContext = new BD6B8_424SEntities(); PPVendeurs v = dataContext.PPVendeurs.Where(ven => ven.NoVendeur.Equals(lgId)).First(); foreach (PPCommandes commande in v.PPCommandes) { commande.Statut = "2"; } dataContext.SaveChanges(); String url = "~/Pages/VisualiserRedevances.aspx?TrieVendeur=" + this.trieVendeur; Response.Redirect(url, true); }
protected void Page_Load(object sender, EventArgs e) { string url = null; if (Session["TypeUtilisateur"] == null) { url = "~/Pages/AccueilInternaute.aspx?"; } else if (Session["TypeUtilisateur"].ToString() != "V") { if (Session["TypeUtilisateur"].ToString() == "C") { url = "~/Pages/AccueilClient.aspx?"; } else { url = "~/Pages/AcceuilGestionnaire.aspx?"; } } if (url != null) { Response.Redirect(url, true); } Page.Title = "Devenir client"; if (!IsPostBack) { long noVendeur = Convert.ToInt64(Session["NoVendeur"]); PPVendeurs vendeur = dbContext.PPVendeurs.Where(v => v.NoVendeur == noVendeur).Single(); tbNom.Text = vendeur.Nom; tbPrenom.Text = vendeur.Prenom; tbAdresse.Text = vendeur.Rue; tbVille.Text = vendeur.Ville; ddlProvince.SelectedValue = vendeur.Province; tbCodePostal.Text = vendeur.CodePostal.Substring(0, 3) + " " + vendeur.CodePostal.Substring(3, 3); tbTelephone1.Text = "(" + vendeur.Tel1.Substring(0, 3) + ") " + vendeur.Tel1.Substring(3, 3) + "-" + vendeur.Tel1.Substring(6); if (vendeur.Tel2 != null) { tbTelephone2.Text = "(" + vendeur.Tel2.Substring(0, 3) + ") " + vendeur.Tel2.Substring(3, 3) + "-" + vendeur.Tel2.Substring(6); } } }
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"); } } }
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"; } } }
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; }
private void btnCourrielVendeur_Click(object sender, EventArgs e) { Button btn = (Button)sender; PPVendeurs ppv = new PPVendeurs(); Vendeur v = ppv.Values.Find(vf => vf.NoVendeur == 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='courrielV' value='{0}'>", v.AdresseEmail); sb.AppendFormat("<input type='hidden' name='sujet' value='{0}'>", btn.CommandName); 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(); }
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; }
private void getVendeur() { BD6B8_424SEntities dataContext = new BD6B8_424SEntities(); var tableVendeurs = dataContext.PPVendeurs; long n = 0; if (Request.QueryString["NoVendeur"] == null || !long.TryParse(Request.QueryString["NoVendeur"], out n)) { this.vendeur = null; } else { var v = from vend in tableVendeurs where vend.NoVendeur == n select vend; if (v.Count() > 0 && v.First().PPCommandes.Count() < 1 && v.First().Statut == 1) { this.vendeur = v.First(); } else { this.vendeur = null; } } }
protected void btnImporterDonnees_Click(object sender, EventArgs e) { bool binOK = true; using (var transaction = dbContext.Database.BeginTransaction()) { try { XDocument document = XDocument.Load(Server.MapPath("\\static\\xml\\PPVendeurs.xml")); XElement racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPVendeurs")) { PPVendeurs vendeur = new PPVendeurs(); vendeur.NoVendeur = long.Parse(element.Descendants("NoVendeur").Single().Value); vendeur.NomAffaires = element.Descendants("NomAffaires").Single().Value; vendeur.Nom = element.Descendants("Nom").Single().Value; vendeur.Prenom = element.Descendants("Prenom").Single().Value; vendeur.Rue = element.Descendants("Rue").Single().Value; vendeur.Ville = element.Descendants("Ville").Single().Value; vendeur.Province = element.Descendants("Province").Single().Value; vendeur.CodePostal = element.Descendants("CodePostal").Single().Value; vendeur.Pays = element.Descendants("Pays").Single().Value; vendeur.Tel1 = element.Descendants("Tel1").Single().Value; vendeur.Tel2 = element.Descendants("Tel2").Single().Value == "NULL" ? null : element.Descendants("Tel2").Single().Value; vendeur.AdresseEmail = element.Descendants("AdresseEmail").Single().Value; vendeur.MotDePasse = element.Descendants("MotDePasse").Single().Value; vendeur.PoidsMaxLivraison = int.Parse(element.Descendants("PoidsMaxLivraison").Single().Value); vendeur.LivraisonGratuite = decimal.Parse(element.Descendants("LivraisonGratuite").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); vendeur.Taxes = element.Descendants("Taxes").Single().Value == "1" ? true : false; if (element.Descendants("Pourcentage").Single().Value == "NULL") { vendeur.Pourcentage = null; } else { vendeur.Pourcentage = decimal.Parse(element.Descendants("Pourcentage").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); } vendeur.Configuration = element.Descendants("Configuration").Single().Value; if (element.Descendants("DateCreation").Single().Value == "NULL") { vendeur.DateCreation = null; } else { vendeur.DateCreation = DateTime.Parse(element.Descendants("DateCreation").Single().Value); } if (element.Descendants("DateMAJ").Single().Value == "NULL") { vendeur.DateMAJ = null; } else { vendeur.DateMAJ = DateTime.Parse(element.Descendants("DateMAJ").Single().Value); } if (element.Descendants("Statut").Single().Value == "NULL") { vendeur.Statut = null; } else { vendeur.Statut = short.Parse(element.Descendants("Statut").Single().Value); } dbContext.PPVendeurs.Add(vendeur); XDocument configuration = new XDocument(); XElement urlImage = new XElement("urlImage"); urlImage.Value = "image_magasin.jpg"; XElement couleurFond = new XElement("couleurFond"); couleurFond.Value = "#ffffff"; XElement couleurTexte = new XElement("couleurTexte"); couleurTexte.Value = "#000000"; configuration.Add(new XElement("configuration", urlImage, couleurFond, couleurTexte)); configuration.Save(Server.MapPath("\\static\\xml\\" + vendeur.Configuration)); } document = XDocument.Load(Server.MapPath("\\static\\xml\\PPClients.xml")); racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPClients")) { PPClients client = new PPClients(); client.NoClient = long.Parse(element.Descendants("NoClient").Single().Value); client.AdresseEmail = element.Descendants("AdresseEmail").Single().Value; client.MotDePasse = element.Descendants("MotDePasse").Single().Value; client.Nom = element.Descendants("Nom").Single().Value == "NULL" ? null : element.Descendants("Nom").Single().Value; client.Prenom = element.Descendants("Prenom").Single().Value == "NULL" ? null : element.Descendants("Prenom").Single().Value; client.Rue = element.Descendants("Rue").Single().Value == "NULL" ? null : element.Descendants("Rue").Single().Value; client.Ville = element.Descendants("Ville").Single().Value == "NULL" ? null : element.Descendants("Ville").Single().Value; client.Province = element.Descendants("Province").Single().Value == "NULL" ? null : element.Descendants("Province").Single().Value; client.CodePostal = element.Descendants("CodePostal").Single().Value == "NULL" ? null : element.Descendants("CodePostal").Single().Value; client.Pays = element.Descendants("Pays").Single().Value == "NULL" ? null : element.Descendants("Pays").Single().Value; client.Tel1 = element.Descendants("Tel1").Single().Value == "NULL" ? null : element.Descendants("Tel1").Single().Value; client.Tel2 = element.Descendants("Tel2").Single().Value == "NULL" ? null : element.Descendants("Tel2").Single().Value; client.DateCreation = DateTime.Parse(element.Descendants("DateCreation").Single().Value); if (element.Descendants("DateMAJ").Single().Value == "NULL") { client.DateMAJ = null; } else { client.DateMAJ = DateTime.Parse(element.Descendants("DateMAJ").Single().Value); } client.NbConnexions = short.Parse(element.Descendants("NbConnexions").Single().Value); if (element.Descendants("DateDerniereConnexion").Single().Value == "NULL") { client.DateDerniereConnexion = null; } else { client.DateDerniereConnexion = DateTime.Parse(element.Descendants("DateDerniereConnexion").Single().Value); } client.Statut = short.Parse(element.Descendants("Statut").Single().Value); dbContext.PPClients.Add(client); } document = XDocument.Load(Server.MapPath("\\static\\xml\\PPCategories.xml")); racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPCategories")) { PPCategories categorie = new PPCategories(); categorie.NoCategorie = int.Parse(element.Descendants("NoCategorie").Single().Value); categorie.Description = element.Descendants("Description").Single().Value; categorie.Details = element.Descendants("Details").Single().Value; dbContext.PPCategories.Add(categorie); } document = XDocument.Load(Server.MapPath("\\static\\xml\\PPProduits.xml")); racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPProduits")) { PPProduits produit = new PPProduits(); produit.NoProduit = long.Parse(element.Descendants("NoProduit").Single().Value); produit.NoVendeur = long.Parse(element.Descendants("NoVendeur").Single().Value); produit.NoCategorie = int.Parse(element.Descendants("NoCategorie").Single().Value); produit.Nom = element.Descendants("Nom").Single().Value; produit.Description = element.Descendants("Description").Single().Value; produit.Photo = element.Descendants("Photo").Single().Value; produit.PrixDemande = decimal.Parse(element.Descendants("PrixDemande").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); produit.NombreItems = short.Parse(element.Descendants("NombreItems").Single().Value); produit.Disponibilité = element.Descendants("Disponibilit_").Single().Value == "1" ? true : false; if (element.Descendants("DateVente").Single().Value == "NULL") { produit.DateVente = null; } else { produit.DateVente = DateTime.Parse(element.Descendants("DateVente").Single().Value); } if (element.Descendants("PrixVente").Single().Value == "NULL") { produit.PrixVente = null; } else { produit.PrixVente = decimal.Parse(element.Descendants("PrixVente").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); } produit.Poids = decimal.Parse(element.Descendants("Poids").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); produit.DateCreation = DateTime.Parse(element.Descendants("DateCreation").Single().Value); if (element.Descendants("DateMAJ").Single().Value == "NULL") { produit.DateMAJ = null; } else { produit.DateMAJ = DateTime.Parse(element.Descendants("DateMAJ").Single().Value); } dbContext.PPProduits.Add(produit); } document = XDocument.Load(Server.MapPath("\\static\\xml\\PPArticlesEnPanier.xml")); racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPArticlesEnPanier")) { PPArticlesEnPanier articleEnPanier = new PPArticlesEnPanier(); articleEnPanier.NoPanier = long.Parse(element.Descendants("NoPanier").Single().Value); articleEnPanier.NoClient = long.Parse(element.Descendants("NoClient").Single().Value); articleEnPanier.NoVendeur = long.Parse(element.Descendants("NoVendeur").Single().Value); articleEnPanier.NoProduit = long.Parse(element.Descendants("NoProduit").Single().Value); articleEnPanier.DateCreation = DateTime.Parse(element.Descendants("DateCreation").Single().Value); articleEnPanier.NbItems = short.Parse(element.Descendants("NbItems").Single().Value); dbContext.PPArticlesEnPanier.Add(articleEnPanier); } document = XDocument.Load(Server.MapPath("\\static\\xml\\PPTypesPoids.xml")); racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPTypesPoids")) { PPTypesPoids typePoids = new PPTypesPoids(); typePoids.CodePoids = short.Parse(element.Descendants("CodePoids").Single().Value); typePoids.PoidsMin = decimal.Parse(element.Descendants("PoidsMin").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); typePoids.PoidsMax = decimal.Parse(element.Descendants("PoidsMax").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); dbContext.PPTypesPoids.Add(typePoids); } document = XDocument.Load(Server.MapPath("\\static\\xml\\PPTypesLivraison.xml")); racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPTypesLivraison")) { PPTypesLivraison typeLivraison = new PPTypesLivraison(); typeLivraison.CodeLivraison = short.Parse(element.Descendants("CodeLivraison").Single().Value); typeLivraison.Description = element.Descendants("Description").Single().Value; dbContext.PPTypesLivraison.Add(typeLivraison); } document = XDocument.Load(Server.MapPath("\\static\\xml\\PPPoidsLivraisons.xml")); racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPPoidsLivraisons")) { PPPoidsLivraisons poidsLivraison = new PPPoidsLivraisons(); poidsLivraison.CodeLivraison = short.Parse(element.Descendants("CodeLivraison").Single().Value); poidsLivraison.CodePoids = short.Parse(element.Descendants("CodePoids").Single().Value); poidsLivraison.Tarif = decimal.Parse(element.Descendants("Tarif").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); dbContext.PPPoidsLivraisons.Add(poidsLivraison); } document = XDocument.Load(Server.MapPath("\\static\\xml\\PPCommandes.xml")); racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPCommandes")) { PPCommandes commande = new PPCommandes(); commande.NoCommande = long.Parse(element.Descendants("NoCommande").Single().Value); commande.NoClient = long.Parse(element.Descendants("NoClient").Single().Value); commande.NoVendeur = long.Parse(element.Descendants("NoVendeur").Single().Value); commande.DateCommande = DateTime.Parse(element.Descendants("DateCommande").Single().Value); commande.CoutLivraison = decimal.Parse(element.Descendants("CoutLivraison").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); commande.TypeLivraison = short.Parse(element.Descendants("TypeLivraison").Single().Value); commande.MontantTotAvantTaxes = decimal.Parse(element.Descendants("MontantTotAvantTaxes").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); commande.TPS = decimal.Parse(element.Descendants("TPS").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); commande.TVQ = decimal.Parse(element.Descendants("TVQ").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); commande.PoidsTotal = decimal.Parse(element.Descendants("PoidsTotal").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); commande.Statut = element.Descendants("Statut").Single().Value; commande.NoAutorisation = element.Descendants("NoAutorisation").Single().Value; dbContext.PPCommandes.Add(commande); } document = XDocument.Load(Server.MapPath("\\static\\xml\\PPDetailsCommandes.xml")); racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPDetailsCommandes")) { PPDetailsCommandes detailCommande = new PPDetailsCommandes(); detailCommande.NoDetailCommandes = long.Parse(element.Descendants("NoDetailCommandes").Single().Value); detailCommande.NoCommande = long.Parse(element.Descendants("NoCommande").Single().Value); detailCommande.NoProduit = long.Parse(element.Descendants("NoProduit").Single().Value); detailCommande.PrixVente = decimal.Parse(element.Descendants("PrixVente").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); detailCommande.Quantité = short.Parse(element.Descendants("Quantit_").Single().Value); dbContext.PPDetailsCommandes.Add(detailCommande); } document = XDocument.Load(Server.MapPath("\\static\\xml\\PPVendeursClients.xml")); racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPVendeursClients")) { PPVendeursClients vendeurClient = new PPVendeursClients(); vendeurClient.NoVendeur = long.Parse(element.Descendants("NoVendeur").Single().Value); vendeurClient.NoClient = long.Parse(element.Descendants("NoClient").Single().Value); vendeurClient.DateVisite = DateTime.Parse(element.Descendants("DateVisite").Single().Value); dbContext.PPVendeursClients.Add(vendeurClient); } document = XDocument.Load(Server.MapPath("\\static\\xml\\PPHistoriquePaiements.xml")); racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPHistoriquePaiements")) { PPHistoriquePaiements historiquePaiement = new PPHistoriquePaiements(); historiquePaiement.NoHistorique = long.Parse(element.Descendants("NoHistorique").Single().Value); historiquePaiement.MontantVenteAvantLivraison = decimal.Parse(element.Descendants("MontantVenteAvantLivraison").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); historiquePaiement.NoVendeur = long.Parse(element.Descendants("NoVendeur").Single().Value); historiquePaiement.NoClient = long.Parse(element.Descendants("NoClient").Single().Value); historiquePaiement.NoCommande = long.Parse(element.Descendants("NoCommande").Single().Value); historiquePaiement.DateVente = DateTime.Parse(element.Descendants("DateVente").Single().Value); historiquePaiement.NoAutorisation = element.Descendants("NoCommande").Single().Value; historiquePaiement.FraisLesi = decimal.Parse(element.Descendants("FraisLesi").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); historiquePaiement.Redevance = decimal.Parse(element.Descendants("Redevance").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); historiquePaiement.FraisLivraison = decimal.Parse(element.Descendants("FraisLivraison").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); historiquePaiement.FraisTPS = decimal.Parse(element.Descendants("FraisTPS").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); historiquePaiement.FraisTVQ = decimal.Parse(element.Descendants("FraisTVQ").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); dbContext.PPHistoriquePaiements.Add(historiquePaiement); } document = XDocument.Load(Server.MapPath("\\static\\xml\\PPTaxeProvinciale.xml")); racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPTaxeProvinciale")) { PPTaxeProvinciale taxeProvinciale = new PPTaxeProvinciale(); taxeProvinciale.NoTVQ = byte.Parse(element.Descendants("NoTVQ").Single().Value); taxeProvinciale.DateEffectiveTVQ = DateTime.Parse(element.Descendants("DateEffectiveTVQ").Single().Value); taxeProvinciale.TauxTVQ = decimal.Parse(element.Descendants("TauxTVQ").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); dbContext.PPTaxeProvinciale.Add(taxeProvinciale); } document = XDocument.Load(Server.MapPath("\\static\\xml\\PPTaxeFederale.xml")); racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPTaxeFederale")) { PPTaxeFederale taxeFederale = new PPTaxeFederale(); taxeFederale.NoTPS = byte.Parse(element.Descendants("NoTPS").Single().Value); taxeFederale.DateEffectiveTPS = DateTime.Parse(element.Descendants("DateEffectiveTPS").Single().Value); taxeFederale.TauxTPS = decimal.Parse(element.Descendants("TauxTPS").Single().Value.Replace(".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator)); dbContext.PPTaxeFederale.Add(taxeFederale); } document = XDocument.Load(Server.MapPath("\\static\\xml\\PPGestionnaires.xml")); racine = document.Element("dataroot"); foreach (var element in racine.Elements("PPGestionnaires")) { PPGestionnaires gestionnaire = new PPGestionnaires(); gestionnaire.ID = long.Parse(element.Descendants("ID").Single().Value); gestionnaire.courriel = element.Descendants("courriel").Single().Value; gestionnaire.motDePasse = element.Descendants("motDePasse").Single().Value; dbContext.PPGestionnaires.Add(gestionnaire); } dbContext.SaveChanges(); transaction.Commit(); lblMessage.Text = "Les données du jeu d'essai ont été importées."; divMessage.CssClass = "alert alert-success alert-margins"; } catch (DbUpdateException ex) { transaction.Rollback(); if (ex.InnerException is UpdateException && ex.InnerException.InnerException is SqlException) { lblMessage.Text = "Une erreur s'est produite lors de l'importation du jeu d'essai. Les données n'ont pas été importées. Voici l'erreur : " + ex.InnerException.InnerException.Message; } else { lblMessage.Text = "Une erreur s'est produite lors de l'importation du jeu d'essai. Les données n'ont pas été importées. Voici l'erreur : " + ex.Message; } divMessage.CssClass = "alert alert-danger alert-margins"; binOK = false; } catch (Exception ex) { transaction.Rollback(); lblMessage.Text = "Une erreur s'est produite lors de l'importation du jeu d'essai. Les données n'ont pas été importées. Voici l'erreur : " + ex.Message; divMessage.CssClass = "alert alert-danger alert-margins"; binOK = false; } } divMessage.Visible = true; remplirTableau(true); if (binOK) { btnImporterDonnees.Visible = false; btnViderBD.Visible = true; } }
public void afficherInfosClient() { LibrairieControlesDynamique.btnDYN(phDynamique, "", "btn btn-warning", "Retour", retourDashboard_click); LibrairieControlesDynamique.brDYN(phDynamique); LibrairieControlesDynamique.brDYN(phDynamique); PPVendeurs vendeur = LibrairieLINQ.getInfosVendeur(this.noVendeur); // créer le tableau avec les infos Panel panelBase = LibrairieControlesDynamique.divDYN(phDynamique, "", "panel panel-default"); Panel panelBody = LibrairieControlesDynamique.divDYN(panelBase, "", "panel-body"); Panel panelFooter = LibrairieControlesDynamique.divDYN(panelBase, "", "panel-footer"); Panel rowVendeur = LibrairieControlesDynamique.divDYN(panelBody, "", "row"); // section image Panel colPhoto = LibrairieControlesDynamique.divDYN(rowVendeur, "", "col-md-3"); LibrairieControlesDynamique.imgDYN(colPhoto, "", "../static/images/user-management.png", "img-rounded").Style.Add("width", "180px"); // section informations Panel colInfos = LibrairieControlesDynamique.divDYN(rowVendeur, "", "col-md-9"); Panel rowInfos = LibrairieControlesDynamique.divDYN(colInfos, "", "row"); Panel colHeader = LibrairieControlesDynamique.divDYN(rowInfos, "", "col-md-12 align-left"); Label lblHeaderNom = LibrairieControlesDynamique.lblDYN(colHeader, "", vendeur.NomAffaires, "header-nom"); LibrairieControlesDynamique.hrDYN(LibrairieControlesDynamique.divDYN(rowInfos, "", "col-md-12")); Panel colAutreInfos = LibrairieControlesDynamique.divDYN(rowInfos, "", "col-md-11"); Panel rowAutresInfos = LibrairieControlesDynamique.divDYN(colAutreInfos, "", "row align-left"); Panel colLBLNom = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-4"); LibrairieControlesDynamique.lblDYN(colLBLNom, "", "Nom:", "autres-infos"); Panel colNom = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-8"); LibrairieControlesDynamique.lblDYN(colNom, "", vendeur.Prenom + " " + vendeur.Nom, "autres-infos"); Panel colLBLEmail = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-4"); LibrairieControlesDynamique.lblDYN(colLBLEmail, "", "Courriel:", "autres-infos"); Panel colEmail = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-8"); LibrairieControlesDynamique.lblDYN(colEmail, "", vendeur.AdresseEmail, "autres-infos"); Panel colLBLTel = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-4"); LibrairieControlesDynamique.lblDYN(colLBLTel, "", "Téléphone:", "autres-infos"); Panel colTel = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-8"); LibrairieControlesDynamique.lblDYN(colTel, "", vendeur.Tel1, "autres-infos"); Panel colLBLAdresse = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-4"); LibrairieControlesDynamique.lblDYN(colLBLAdresse, "", "Adresse:", "autres-infos"); Panel colAdresse = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-8"); LibrairieControlesDynamique.lblDYN(colAdresse, "", vendeur.Rue + ", " + vendeur.Ville + ", " + vendeur.Province + ", " + vendeur.Pays, "autres-infos"); LibrairieControlesDynamique.brDYN(rowAutresInfos); LibrairieControlesDynamique.brDYN(rowAutresInfos); Panel colLBLNoVendeur = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-4"); LibrairieControlesDynamique.lblDYN(colLBLNoVendeur, "", "No vendeur:", "autres-infos"); Panel colNoVendeur = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-8"); LibrairieControlesDynamique.lblDYN(colNoVendeur, "", vendeur.NoVendeur.ToString(), "autres-infos"); Panel colLBLPoids = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-4"); LibrairieControlesDynamique.lblDYN(colLBLPoids, "", "Poids maximal:", "autres-infos"); Panel colPoids = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-8"); LibrairieControlesDynamique.lblDYN(colPoids, "", vendeur.PoidsMaxLivraison.ToString() + " lbs", "autres-infos"); Panel colLBLLivGratuite = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-4"); LibrairieControlesDynamique.lblDYN(colLBLLivGratuite, "", "Livraison gratuite:", "autres-infos"); Panel colLivGratuite = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-8"); LibrairieControlesDynamique.lblDYN(colLivGratuite, "", (vendeur.LivraisonGratuite != null) ? Decimal.Round((decimal)vendeur.LivraisonGratuite, 2).ToString("C", CultureInfo.CurrentCulture) : "", "autres-infos"); Panel colLBLTaxes = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-4"); LibrairieControlesDynamique.lblDYN(colLBLTaxes, "", "Taxes:", "autres-infos"); Panel colTaxes = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-8"); LibrairieControlesDynamique.lblDYN(colTaxes, "", (vendeur.Taxes == true) ? "Oui" : "Non", "autres-infos"); Panel colLBLDateCreation = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-4"); LibrairieControlesDynamique.lblDYN(colLBLDateCreation, "", "Date création:", "autres-infos"); Panel colDateCreation = LibrairieControlesDynamique.divDYN(rowAutresInfos, "", "col-md-8"); LibrairieControlesDynamique.lblDYN(colDateCreation, "", vendeur.DateCreation.ToString(), "autres-infos"); Panel rowBoutons = LibrairieControlesDynamique.divDYN(panelFooter, "", "row"); Panel colBtnOui = LibrairieControlesDynamique.divDYN(rowBoutons, "", "col-md-1"); Panel colBtnNon = LibrairieControlesDynamique.divDYN(rowBoutons, "", "col-md-1"); // btn oui HtmlButton btnOui = LibrairieControlesDynamique.htmlbtnDYN(colBtnOui, "btnOui_" + vendeur.NoVendeur, "btn btn-success", "", "glyphicon glyphicon-ok", btnOui_click); LibrairieControlesDynamique.spaceDYN(rowBoutons); // btn non HtmlButton btnNon = LibrairieControlesDynamique.htmlbtnDYN(colBtnNon, "btnNon_" + vendeur.NoVendeur, "btn btn-danger", "", "glyphicon glyphicon-remove", btnNon_click); }
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(); }
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"); } } }