Example #1
0
    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");
                }
            }
        }
    }
Example #2
0
    protected void btnSauvegarder_OnClick(object sender, EventArgs e)
    {
        tbPoidsMax.DefaultControl();
        tbNomAffaires.DefaultControl();
        tbNom.DefaultControl();
        tbPrenom.DefaultControl();
        tbPrixLivGratuite.DefaultControl();
        tbRue.DefaultControl();
        tbCodePostal.DefaultControl();
        tbTelephone.DefaultControl();
        tbCell.DefaultControl();
        ddlProvince.DefaultControl();
        tbVille.DefaultControl();

        string couleurBG   = couleurFond.Text;
        string couleurTEXT = couleurText.Text;

        int     poidsMax        = -1;
        decimal prixLivGratuite = -1;

        bool[] arrError = new bool[]
        {
            // Nom d'affaires
            tbNomAffaires.InvalidateIfEmpty(lblErrorNomAffaires, "Le nom d'affaires doit être présent"),
            tbPrenom.InvalidateIfEmpty(lblErrorPrenom, "Le prénom doit être présent"),
            tbNom.InvalidateIfEmpty(lblErrorNom, "Le nom doit être présent"),
            tbRue.InvalidateIfEmpty(lblErrorRue, "Les informations sur la rue (No Civique et Rue)"),
            ddlProvince.InvalidateIfEmpty(lblErrorProvince, "La province doit être selectionnée"),
            tbVille.InvalidateIfEmpty(lblErrorVille, "Le nom de la ville doit être présent"),
            tbCodePostal.InvalidateIfEmpty(lblErrorCodePostal, "Le code postal doit être présent"),
            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", "_"),
            tbCell.CheckContains(lblErrorCell, "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 nombre décimal", out poidsMax) ||
            tbPoidsMax.CheckIntOver0(lblErrorPoidsMax, poidsMax),
            // Poids livraison gratuite
            tbPrixLivGratuite.CheckDecimal(lblErrorPoidsLivGratuit, "Le prix auquel une livraison devient gratuite doit être un nombre décimal", out prixLivGratuite) ||
            tbPrixLivGratuite.CheckDecimalOver0(lblErrorPoidsLivGratuit, prixLivGratuite),
            validationFichier(),
        };

        if (!arrError.Contains(true))
        {
            bool modifications = false;

            bool modificationFile    = upload(vendeur);
            bool modificationCouleur = modifCouleur(vendeur, "fond");
            bool modificationTexte   = modifCouleur(vendeur, "text");

            if (vendeur.NomAffaires != tbNomAffaires.Text)
            {
                vendeur.NomAffaires = tbNomAffaires.Text;
                modifications       = true;
            }
            if (vendeur.Prenom != tbPrenom.Text)
            {
                vendeur.Prenom = tbPrenom.Text;
                modifications  = true;
            }
            if (vendeur.Nom != tbNom.Text)
            {
                vendeur.Nom   = tbNom.Text;
                modifications = true;
            }
            if (vendeur.Rue != tbRue.Text)
            {
                vendeur.Rue   = tbRue.Text;
                modifications = true;
            }
            if (vendeur.Ville != tbVille.Text)
            {
                vendeur.Ville = tbVille.Text;
                modifications = true;
            }
            if (vendeur.Province != ddlProvince.SelectedValue)
            {
                vendeur.Province = ddlProvince.SelectedValue;
                modifications    = true;
            }
            if (vendeur.CodePostal != tbCodePostal.Text)
            {
                vendeur.CodePostal = tbCodePostal.Text;
                modifications      = true;
            }
            if (vendeur.Tel1 != tbTelephone.Text)
            {
                vendeur.Tel1  = tbTelephone.Text;
                modifications = true;
            }
            if (vendeur.Tel2 != tbCell.Text)
            {
                vendeur.Tel2  = tbCell.Text;
                modifications = true;
            }
            if (vendeur.Taxes.HasValue)
            {
                if (vendeur.Taxes.Value && rbNonTaxes.Checked)
                {
                    vendeur.Taxes = false;
                    modifications = true;
                }
                else if (!vendeur.Taxes.Value && rbOuiTaxes.Checked)
                {
                    vendeur.Taxes = true;
                    modifications = true;
                }
            }
            if (vendeur.PoidsMaxLivraison != poidsMax)
            {
                vendeur.PoidsMaxLivraison = poidsMax;
                modifications             = true;
            }
            if (vendeur.LivraisonGratuite != prixLivGratuite)
            {
                vendeur.LivraisonGratuite = prixLivGratuite;
                modifications             = true;
            }

            if (modifications || modificationFile || modificationCouleur || modificationTexte)
            {
                PPVendeurs vendeurs = new PPVendeurs();
                vendeurs.NotifyUpdatedOutside(vendeur);

                vendeurs.Update();
                Response.Redirect("~/Pages/Vendeur/AccueilVendeur.aspx");
                //Response.Redirect("~/Pages/Vendeur/ProfilVendeur.aspx?Reussite=true");
            }
        }
    }