Пример #1
0
    protected void btnConfirmer_Click(object sender, EventArgs e)
    {
        // Reset everything
        Courriel1.DefaultControl();
        Courriel2.DefaultControl();
        MDP.DefaultControl();
        MDP2.DefaultControl();

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

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

                clients.Add(newClient);

                Response.Redirect("~/Pages/Inscription.aspx?Reussite=true");
            }
        }
    }
Пример #2
0
    protected void remplirClients(XNamespace ss, XElement worksheet)
    {
        PPClients clients = new PPClients();

        foreach (XElement row in worksheet.Descendants(ss + "Row"))
        {
            List <String> arrayStr = new List <string>();
            foreach (XElement cell in row.Descendants(ss + "Data"))
            {
                arrayStr.Add(cell.Value);
            }
            if (arrayStr.Count() == 17)
            {
                clients.Add(new Client(null)
                {
                    NoClient              = Convert.ToInt64(arrayStr[0]),
                    AdresseEmail          = arrayStr[1],
                    MotDePasse            = arrayStr[2],
                    Nom                   = (arrayStr[3] == "NULL" ? null : arrayStr[3]),
                    Prenom                = (arrayStr[4] == "NULL" ? null : arrayStr[4]),
                    Rue                   = (arrayStr[5] == "NULL" ? null : arrayStr[5]),
                    Ville                 = (arrayStr[6] == "NULL" ? null : arrayStr[6]),
                    Province              = (arrayStr[7] == "NULL" ? null : arrayStr[7]),
                    CodePostal            = (arrayStr[8] == "NULL" ? null : arrayStr[8]),
                    Pays                  = (arrayStr[9] == "NULL" ? null : arrayStr[9]),
                    Tel1                  = (arrayStr[10] == "NULL" ? null : arrayStr[10]),
                    Tel2                  = (arrayStr[11] == "NULL" ? null : arrayStr[11]),
                    DateCreation          = DateTime.Parse(arrayStr[12]),
                    DateMAJ               = (arrayStr[13] == "NULL" ? nullableDate : Convert.ToDateTime(arrayStr[13])),
                    NbConnexions          = Convert.ToInt16(arrayStr[14]),
                    DateDerniereConnexion = DateTime.Parse(arrayStr[15]),
                    Statut                = Convert.ToInt16(arrayStr[16])
                });
            }
        }
    }