Example #1
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text != "")
            {
                SqlConnection conn = new ConnectionBD().seConnecter();
                conn.Open();

                string cmdString = "Select msg from Users where user_Name = '" + TextBox3.Text + "'";

                SqlCommand    cmd   = new SqlCommand(cmdString, conn);
                SqlDataReader sqlDR = null;
                try
                {
                    sqlDR = cmd.ExecuteReader();
                }
                catch (Exception)
                {
                    Label1.Text = "Erreur du format de la requette !!!";
                }

                if (sqlDR != null)
                {
                    if (sqlDR.Read())
                    {
                        recpmsg = sqlDR.GetString(sqlDR.GetOrdinal("msg"));
                    }
                }
                else
                {
                    Label1.Text = "Erreur du format de la requette !!!";
                }
            }
        }
Example #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text != "")
            {
                SqlConnection conn = new ConnectionBD().seConnecter();
                conn.Open();

                string message = TextBox2.Text;
                Console.WriteLine("message : " + message);
                string cmdString = "Update Users Set msg = ' " + message + "' where user_Name = '" + TextBox1.Text + "'";

                SqlCommand    cmd   = new SqlCommand(cmdString, conn);
                SqlDataReader sqlDR = null;
                try
                {
                    sqlDR = cmd.ExecuteReader();
                }
                catch (Exception ex)
                {
                    Label1.Text = "Erreur du format de la requette !!!: " + ex.ToString();
                }

                if (sqlDR != null)
                {
                    if (sqlDR.Read())
                    {
                        Label1.Text = "veuillez passer a la deuxieme etape!";
                    }
                }
                else
                {
                    Label1.Text = "Erreur du format de la requette !!!";
                }
            }
        }
Example #3
0
        protected void btnConnect_Click(object sender, EventArgs e)
        {
            if (tbLogin.Text != "" && tbMdop.Text != "")
            {
                lblErreur.Text = "";
                //connection BDD
                SqlConnection conn = new ConnectionBD().seConnecter();
                conn.Open();

                string     commandText = "SELECT * FROM Users " + "WHERE user_Name=@login AND User_Pwd = @mdp";
                SqlCommand cmd         = new SqlCommand(commandText, conn);
                cmd.Parameters.AddWithValue("@login", tbLogin.Text);
                cmd.Parameters.AddWithValue("@mdp", tbMdop.Text);

                SqlDataReader sqlDR = null;
                try
                {
                    sqlDR = cmd.ExecuteReader();
                }
                catch (Exception)
                {
                    lblErreur.Text = "Erreur du format de la requette !!!";
                }
                if (sqlDR != null)
                {
                    if (sqlDR.Read())
                    {
                        string nom       = sqlDR.GetString(sqlDR.GetOrdinal("user_Name"));
                        string prenom    = sqlDR.GetString(sqlDR.GetOrdinal("User_Pwd"));
                        string statut    = sqlDR.GetString(sqlDR.GetOrdinal("statut"));
                        string lienPhoto = sqlDR.GetString(sqlDR.GetOrdinal("photoLink"));

                        HttpCookie cookie = new HttpCookie("InfosUsers"); //Utilisation des cookies
                        cookie["login"]  = nom;
                        cookie["mdp"]    = prenom;
                        cookie["statut"] = statut;
                        cookie["photo"]  = lienPhoto;

                        cookie.Expires = DateTime.Now.AddDays(15); //la cookie va etre garder sur l'ordi pendant 15 jours

                        Response.Cookies.Add(cookie);              //Ajouter le cookie

                        //redirection vers la page d'affichage du profil correspondant
                        Response.Redirect("~/profil.aspx");
                    }
                    else
                    {
                        Response.Redirect("~/ControlAccesFonctionnel.aspx");;
                    }
                }
            }
            else
            {
                lblErreur.Text = "Veuillez remplir les champs!!!";
            }
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["id"] != null && Request.QueryString["id"] != null)
            {
                string id = Request.QueryString["id"];

                //connection BDD
                SqlConnection conn = new ConnectionBD().seConnecter();
                conn.Open();

                string     commandText = "SELECT * FROM Users " + "WHERE user_ID = @id";
                SqlCommand cmd         = new SqlCommand(commandText, conn);
                cmd.Parameters.AddWithValue("@id", id);

                SqlDataReader sqlDR = null;
                try
                {
                    sqlDR = cmd.ExecuteReader();
                }
                catch (Exception)
                {
                    Response.Redirect("~/RDNSO.aspx");
                }
                if (sqlDR != null)
                {
                    if (sqlDR.Read())
                    {
                        try
                        {
                            LbName.Text    = sqlDR.GetString(sqlDR.GetOrdinal("user_Name"));
                            LbPrenom.Text  = sqlDR.GetString(sqlDR.GetOrdinal("user_Name"));
                            LbStatut.Text  = sqlDR.GetString(sqlDR.GetOrdinal("statut"));
                            Image.ImageUrl = sqlDR.GetString(sqlDR.GetOrdinal("photoLink"));
                        }
                        catch (Exception)
                        {
                            Response.Redirect(string.Format("~/RDNSO_profile.aspx?id={0}", Session["id"]));
                        }
                    }
                    else
                    {
                        Response.Redirect("~/RDNSO.aspx");
                    }
                }
            }
            else
            {
                Response.Redirect("~/RDNSO.aspx");;
            }
        }
Example #5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TBlogin.Text != "" && TBpassword.Text != "")
            {
                //connection BDD
                SqlConnection conn = new ConnectionBD().seConnecter();
                conn.Open();

                string     commandText = "SELECT * FROM Users " + "WHERE user_Name=@login AND User_Pwd = @mdp";
                SqlCommand cmd         = new SqlCommand(commandText, conn);
                cmd.Parameters.AddWithValue("@login", TBlogin.Text);
                cmd.Parameters.AddWithValue("@mdp", TBpassword.Text);

                SqlDataReader sqlDR = null;
                try
                {
                    sqlDR = cmd.ExecuteReader();
                }
                catch (Exception)
                {
                    Response.Redirect("~/RDNSO.aspx");
                }
                if (sqlDR != null)
                {
                    if (sqlDR.Read())
                    {
                        int id = sqlDR.GetInt32(sqlDR.GetOrdinal("user_ID"));
                        Session["id"] = id;

                        //redirection vers la page d'affichage du profil
                        Response.Redirect(string.Format("~/RDNSO_profile.aspx?id={0}", id));
                    }
                    else
                    {
                        Response.Redirect("~/RDNSO.aspx");
                    }
                }
            }
            else
            {
                Response.Redirect("~/RDNSO.aspx");;
            }
        }
Example #6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text != "")
            {
                SqlConnection conn = new ConnectionBD().seConnecter();
                conn.Open();

                string     commandText = "SELECT * FROM Users " + "WHERE User_Name=@login";
                SqlCommand cmd         = new SqlCommand(commandText, conn);
                cmd.Parameters.AddWithValue("@login", TextBox1.Text);

                SqlDataReader sqlDR = null;

                try
                {
                    sqlDR = cmd.ExecuteReader();
                }
                catch (Exception)
                {
                    MSG_result.Text = "Vous etes un pirate? perte de temps !!!";
                }

                if (sqlDR != null)
                {
                    if (sqlDR.Read())
                    {
                        MSG_result.Text = "Vous êtres bien identtifié!";
                        //MSG_result.Text = "";
                    }
                    else
                    {
                        MSG_result.Text = "Vous n'êtes pas identifié";
                        //LblSucces.Text = "";
                    }
                }
                else
                {
                    MSG_result.Text = "";
                }
            }
        }
Example #7
0
        protected void BtnConnect_Click(object sender, EventArgs e)
        {
            if (TbxLogin.Text != "")
            {
                SqlConnection conn = new ConnectionBD().seConnecter();
                conn.Open();

                string cmdString = "Select distinct * FROM Users WHERE User_Name = '" + TbxLogin.Text + "'";

                SqlCommand    cmd   = new SqlCommand(cmdString, conn);
                SqlDataReader sqlDR = null;
                try
                {
                    sqlDR = cmd.ExecuteReader();
                }
                catch (Exception)
                {
                    LblErruer.Text = "Erreur du format de la requette !!!";
                }

                if (sqlDR != null)
                {
                    int count = sqlDR.FieldCount;
                    while (sqlDR.Read())
                    {
                        for (int i = 0; i < count; i++)
                        {
                            mabase += "&nbsp;&nbsp;&nbsp;" + sqlDR.GetName(i) + " =    " + sqlDR.GetValue(i);
                        }
                        mabase += "<br />";
                    }

                    LblErruer.Text = mabase;
                }
                else
                {
                    LblErruer.Text = "Erreur du format de la requette !!!";
                }
            }
        }
Example #8
0
        protected void BtnConnect_Click(object sender, EventArgs e)
        {
            if (TbxLogin.Text != "")
            {
                SqlConnection conn = new ConnectionBD().seConnecter();
                conn.Open();

                string cmdString = "Select * FROM Users WHERE User_Name = '" + TbxLogin.Text + "'";

                SqlCommand    cmd   = new SqlCommand(cmdString, conn);
                SqlDataReader sqlDR = null;
                try
                {
                    sqlDR = cmd.ExecuteReader();
                }
                catch (Exception)
                {
                    LblErruer.Text = "Erreur du format de la requette !!!";
                }

                if (sqlDR != null)
                {
                    if (sqlDR.Read())
                    {
                        LblSucces.Text = "Vous êtes bien identtifié!";
                        LblErruer.Text = "";
                    }
                    else
                    {
                        LblErruer.Text = "Vous n'êtes pas identifié";
                        LblSucces.Text = "";
                    }
                }
                else
                {
                    LblErruer.Text = "Erreur du format de la requette !!!";
                }
            }
        }