Ejemplo n.º 1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            DataAccesDataContext dbcontext = new DataAccesDataContext();
            AstreeDonnees        a         = new AstreeDonnees();
            UtilisateurDB        user      = new UtilisateurDB();
            adresseDB            adr       = new adresseDB();

            user = a.GetUser(txtUsername.Text, txtpassword.Text);
            UtilisateurDB user1 = a.GetUser().Where(w => w.login.Trim() == txtUsername.Text.Trim()).FirstOrDefault();
            int           i     = 0;

            if (Session["nbreTentative"] == null)
            {
                i = 0;
            }
            else
            {
                i = Convert.ToInt32(Session["nbreTentative"]);
            }
            Session["nbreTentative"] = i + 1;

            if (user == null)
            {
                msgerror.Visible = true;
                msgerror.Text    = "login ou Mot de passe incorrect";
                PnlMdp.Visible   = true;

                if (i > 3)
                {
                    if (user1 != null)
                    {
                        if (txtUsername.Text != "")
                        {
                            if (user1.login == txtUsername.Text)
                            {
                                user1.Etat = "N";
                                a.modifierEtat(user1);
                                msgerror.Text = "Votre compte est désactivé!";
                            }
                            else
                            {
                                msgerror.Text = "Vous n'avez pas un compte!";
                            }
                        }
                    }
                }
            }

            else
            {
                Session["code_profil"]      = Convert.ToString(user.code_profil);// creation session
                Session["code_utilisateur"] = user.code_utilisateur.ToString();
                if (user.code_profil == 101)
                {
                    Response.Redirect("Statistique.aspx");
                }
                else if (user.code_profil == 202)
                {
                    Response.Redirect("DemanderDevis.aspx");
                }
                else if (user.code_profil == 303)
                {
                    Response.Redirect("RepondreCommandeFournisseur.aspx");
                }
                else if (user.code_profil == 404)
                {
                    Response.Redirect("RepondreCommandeIntermidiaire.aspx");
                }
                else if (user.code_profil == 505)
                {
                    Response.Redirect("AfficherDevis.aspx");
                }
                else if (user.code_profil == 606)
                {
                    Response.Redirect("AfficherDerogation.aspx");
                }
                else if (user.code_profil == 808)
                {
                    Response.Redirect("index.aspx");
                }
            }
        }