コード例 #1
0
        protected void Ajout_Click(object sender, EventArgs e)
        {
            using (var ctx = new TaxiTraficEntities())
            {
                User user = new User();

                user.LAST_NAME  = ((TextBox)GridView1.FooterRow.FindControl("nom")).Text;
                user.FIRST_NAME = ((TextBox)GridView1.FooterRow.FindControl("prenom")).Text;
                user.PHONE      = ((TextBox)GridView1.FooterRow.FindControl("phone")).Text;
                user.EMAIL      = ((TextBox)GridView1.FooterRow.FindControl("email")).Text;

                user.PASSWORD = TaxiTraficSecurity.getPasswordMD5Hash(((TextBox)GridView1.FooterRow.FindControl("password")).Text);


                if (user.LAST_NAME == "" || user.FIRST_NAME == "" || user.PHONE == "" || user.EMAIL == "" || user.PASSWORD == "" || ((DropDownList)GridView1.FooterRow.FindControl("profil")).SelectedValue == "")
                {
                    ((Label)GridView1.FooterRow.FindControl("Required")).Text = " ***Tous les champs doivent être remplis";
                }
                else
                {
                    try
                    {
                        user.PROFIL = Int32.Parse(((DropDownList)GridView1.FooterRow.FindControl("profil")).SelectedValue);
                        ctx.Users.Add(user);
                        ctx.SaveChanges();
                        GridView1.DataBind();
                    }
                    catch
                    {
                        ((Label)GridView1.FooterRow.FindControl("Required")).Text = " ***ERREUR !!!! (@-mail doit être unique)";
                    }
                }
            }
        }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (var ctx = new TaxiTraficEntities())
     {
         var lu = ctx.Users.ToList();
         foreach (var user in lu)
         {
             user.PASSWORD = TaxiTraficSecurity.getPasswordMD5Hash("123456");
         }
         ctx.SaveChanges();
     }
 }
コード例 #3
0
        protected void ButtonLogin_Click(object sender, EventArgs e)
        {
            //bool isAuth = false;
            using (var ctx = new TaxiTraficEntities())
            {
                string hash    = TaxiTraficSecurity.getPasswordMD5Hash(password.Text);
                User   pretend = ctx.Users.Where(u => u.EMAIL == email.Text).Where(u => u.PASSWORD == hash).FirstOrDefault();

                if (pretend != null)
                {
                    Session["EMAIL"]      = pretend.EMAIL;
                    Session["ID"]         = pretend.ID;
                    Session["LAST_NAME"]  = pretend.LAST_NAME;
                    Session["FIRST_NAME"] = pretend.FIRST_NAME;
                    Session["PROFIL"]     = pretend.PROFIL;
                    Session["PHONE"]      = pretend.PHONE;

                    if (pretend.PROFIL == 1)
                    {
                        Response.Redirect(@"~\HomeAdmin.aspx");
                    }
                    else if (pretend.PROFIL == 2)
                    {
                        if (pretend.Taxis.Count > 0)
                        {
                            Session["taxi_ID"]        = pretend.Taxis.ElementAt(0).ID;
                            Session["taxi_matricule"] = pretend.Taxis.ElementAt(0).MATRICULE;
                            Session["taxi_type"]      = pretend.Taxis.ElementAt(0).TYPE;
                        }
                        Response.Redirect(@"~\HomeTaxiDriver.aspx");
                    }
                }
                else
                {
                    ErrorTOP.Text    = "*** LOGIN ou MOT DE PASSE invalide !!!!";
                    ErrorButtom.Text = "*** invalide !!!!";
                }
            }
        }
コード例 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (var ctx = new TaxiTraficEntities())
     {
         var user = ctx.Users.Where(u => u.EMAIL == "*****@*****.**").FirstOrDefault();
         if (user != null)
         {
             user.PASSWORD = TaxiTraficSecurity.getPasswordMD5Hash("123456");
         }
         else
         {
             User u = new User();
             u.FIRST_NAME = "ADMIN";
             u.LAST_NAME  = "SYSTEM";
             u.PHONE      = "06XXXXXX32";
             u.EMAIL      = "*****@*****.**";
             u.PASSWORD   = TaxiTraficSecurity.getPasswordMD5Hash("123456");
             u.PROFIL     = 1;
             ctx.Users.Add(u);
         }
         Label1.Text = TaxiTraficSecurity.getPasswordMD5Hash("123456");
         ctx.SaveChanges();
     }
 }
コード例 #5
0
 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     e.NewValues["PASSWORD"] = TaxiTraficSecurity.getPasswordMD5Hash((string)e.NewValues["PASSWORD"]);
 }