Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Usagers connecte = (Usagers)Session["usagerConnecte"];

            using (MagasinJouetsEntities1 entityArticles = new MagasinJouetsEntities1())
            {
                try
                {
                    var tousLesSkis = from skis in entityArticles.Skis
                                      select skis;

                    this.gridSkis.DataSource = tousLesSkis.ToList();
                    gridSkis.DataBind();
                }
                catch (EntityDataSourceValidationException exc)
                {
                    var msg = exc.Message;
                }
            }

            if (connecte.type.ToString() == "e")
            {
            }
            else
            {
            }
        }
Beispiel #2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                using (MagasinJouetsEntities1 magasinSkiEntite = new MagasinJouetsEntities1())
                {
                    try
                    {
                        // string mdpEncrypt = EncrypterMdp();
                        var usagerRes = (from Usagers in magasinSkiEntite.Usagers
                                         where Usagers.pseudo.Equals(this.txtUsager.Text)
                                         & Usagers.motPasse.Equals(this.txtMdp.Text)
                                         select Usagers).FirstOrDefault();
                        if (usagerRes != null)
                        {
                            Session["usagerConnecte"] = (Usagers)usagerRes;
                        }
                    }


                    catch (EntityDataSourceValidationException exc)
                    {
                        var msg = exc.Message;
                    }
                }
            }
            if (this.SeSouvenir.Checked == true)
            {
                Response.Cookies["pseudoVagabones"].Value   = this.txtUsager.Text;
                Response.Cookies["pseudoVagabones"].Expires = DateTime.Now.AddMonths(3);
            }
            Response.Redirect(Request.RawUrl);
        }
Beispiel #3
0
        protected void btnModifier_Click(object sender, EventArgs e)
        {
            Usagers connecte = (Usagers)Session["usagerConnecte"];

            try
            {
                MagasinJouetsEntities1 monEntite = new MagasinJouetsEntities1();

                var usaConnecte = from Usagers in monEntite.Usagers
                                  where Usagers.nom == connecte.nom
                                  select Usagers;

                foreach (Usagers u in usaConnecte)
                {
                    u.pseudo     = this.txtPseudo.Text;
                    u.motPasse   = EncrypterMdp(this.TextBoxMotPasse.Text);
                    u.nom        = this.txtNom.Text;
                    u.prenom     = this.txtPrenom.Text;
                    u.type       = this.drdType.SelectedValue.ToString();
                    u.adresse    = this.txtAdresse.Text;
                    u.ville      = this.txtVille.Text;
                    u.codePostal = this.txtCodeP.Text;
                    u.téléphone  = this.txtTelephone.Text;
                }

                monEntite.SaveChanges();
            }
            catch (Exception ex)
            {
                var message = ex.Message;
            }
        }
Beispiel #4
0
        protected void ButtonEnvoyer_Click(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                //Ajout d'un usager dans la base de données

                //Entité LINQ
                MagasinJouetsEntities1 entityUsager = new MagasinJouetsEntities1();

                Usagers usagerAjout = new Usagers
                {
                    pseudo     = this.txtPseudo.Text,
                    motPasse   = EncrypterMdp(this.TextBoxMotPasse.Text),
                    nom        = this.txtNom.Text,
                    prenom     = this.txtPrenom.Text,
                    type       = this.drdType.SelectedValue.ToString(),
                    adresse    = this.txtAdresse.Text,
                    ville      = this.txtVille.Text,
                    codePostal = this.txtCodeP.Text,
                    téléphone  = this.txtTelephone.Text
                };

                entityUsager.Usagers.Add(usagerAjout);
                entityUsager.SaveChanges();
                this.messagePost.Text = "L'usager a bien été ajouté!";
            }
        }