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 remplirGestionnaires(XNamespace ss, XElement worksheet) { PPGestionnaires gestionnaires = new PPGestionnaires(); 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() == 6) { gestionnaires.Add(new Gestionnaire(null) { NoAdmin = Convert.ToInt32(arrayStr[0]), Email = arrayStr[1], MotDePasse = arrayStr[2], DateCreation = Convert.ToDateTime(arrayStr[3]), Prenom = arrayStr[4], Nom = arrayStr[5] }); } } }
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 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; } }
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"); } } }
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"; } } } } }