Пример #1
0
        public void BTN_Modifier_Click(object sender, EventArgs e)
        {
            TableUsers modifierUser = new TableUsers((string)Application["MainBD"], this);

            modifierUser.ID       = (Int64)Session["USER_ID"];
            modifierUser.Fullname = TB_FullName.Text;
            modifierUser.Username = TB_UserName.Text;
            modifierUser.Password = TB_Password.Text;
            modifierUser.Email    = TB_Email.Text;
            modifierUser.Avatar   = IMG_Avatar.ImageUrl;
            modifierUser.Update();
            //String DBPath = Server.MapPath(@"~\App_Data\MainBD.mdf");
            //String ConnectString = @"Data Source=(LocalDB)\v11.0;AttachDbFilename='" + DBPath + "';Integrated Security=True";
            //String sql = @"Update USERS SET Username='******', Password='******', Fullname= '"+ TB_FullName.Text +"',Email='"+ TB_Email.Text + "',Avatar= '"+IMG_Avatar.ImageUrl+ "'";
            //SqlConnection DataBase_Connection = new SqlConnection(ConnectString);

            //try
            //{
            //    SqlCommand sqlCommand = new SqlCommand(sql);
            //    sqlCommand.Connection = DataBase_Connection;
            //    DataBase_Connection.Open();
            //    sqlCommand.ExecuteNonQuery();
            //    Session["StartTime"] = DateTime.Now;
            //    Response.Redirect("Index.aspx");
            //    DataBase_Connection.Close();
            //}
            //catch (Exception ex)
            //{
            //    Response.Write(ex.Message);
            //}
        }
Пример #2
0
        public void BTN_Login_Click(object sender, EventArgs e)
        {
            /////////////////////////////////////////////////
            //
            // Changer ici pour utiliser la classe tableusers
            //
            /////////////////////////////////////////////////

            // Nous créons ici une instance de TableUsers pour cette session
            Session["Utilisateur"] = new TableUsers((String)Application["MainBD"], this);
            TableUsers usager = new TableUsers((String)Application["MainBD"], this);

            // Je cherche comment affecter le username à cette session
            // ??????????

            // Nous créons une instance de TableLogins pour cette session
            Session["Login"] = new TableLogins((String)Application["MainBD"], this);

            ///////////////////////////////////////Douteux.com//Javou.ca//////////////////////////////////////////
            String        DBPath              = Server.MapPath(@"~\App_Data\MainBD.mdf");
            String        ConnectString       = @"Data Source=(LocalDB)\v11.0;AttachDbFilename='" + DBPath + "';Integrated Security=True";
            String        sql                 = @"Select PASSWORD, USERNAME, AVATAR, ID From USERS where UserName = '******'";
            SqlConnection DataBase_Connection = new SqlConnection(ConnectString);

            try
            {
                SqlCommand sqlCommand = new SqlCommand(sql);
                sqlCommand.Connection = DataBase_Connection;
                DataBase_Connection.Open();
                SqlDataReader dataReader = sqlCommand.ExecuteReader();
                dataReader.Read();
                Session["Username"] = dataReader.GetString(1);
                Session["Avatar"]   = dataReader.GetString(2);
                Session["USER_ID"]  = dataReader.GetInt64(3);
                if (TB_Password.Text == dataReader.GetString(0))
                {
                    ClientAlert(this, "Login est un succes!");
                    //((TableUsers)Session["Users"]).Online = 1;
                    //((TableUsers)Session["Users"]).Update();
                    Session["StartTime"]  = DateTime.Now;
                    Session["USER_LOGIN"] = DateTime.Now;
                    usager.ID             = (Int64)Session["USER_ID"];
                    usager.Enligne        = true;
                    usager.userEnligne();
                    Response.Redirect("Index.aspx");
                }
                else
                {
                    ClientAlert(this, "Mot de passe incorrect!");
                }

                dataReader.Close();
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            //////////////////////////////////////fin de douteux.com//////////////////////////////////////
        }
Пример #3
0
        protected void AfficherGridView()
        {
            TableUsers table = new TableUsers((String)Application["MainBD"], this);

            table.SelectAll();
            table.MakeGridView(PN_GridView, "");//Jai du mettre une ligne en commentaire(dans SQLExpressUtilities) pour que sa fonctionne, a vérifier!
            table.EndQuerySQL();
        }
Пример #4
0
        protected void AfficherGridView()
        {
            TableUsers table = new TableUsers((String)Application["MainBD"], this);

            table.SelectAll();
            table.MakeGridView(PN_GridView, "");
            table.EndQuerySQL();
        }
Пример #5
0
        public bool VerifierExistanceUser(string userName)
        {
            bool       userExist = false;
            TableUsers leUser    = new TableUsers((String)Application["MainBD"], this);

            leUser.Username = userName;
            if (leUser.userExists())
            {
                userExist = true;
            }
            return(userExist);
        }
Пример #6
0
 public void BTN_Inscription_Click(object sender, EventArgs e)
 {
     if (!VerifierExistanceUser(TB_UserName.Text))
     {
         TableUsers table_users = new TableUsers((string)Application["MainBD"], this);
         table_users.Fullname = TB_FullName.Text;
         table_users.Username = TB_UserName.Text;
         table_users.Password = TB_Password.Text;
         table_users.Email    = TB_Email.Text;
         table_users.Avatar   = IMG_Avatar.ImageUrl;
         table_users.Insert();
         Session["StartTime"] = DateTime.Now;
         Response.Redirect("Login.aspx");
     }
     else
     {
         ClientAlert(this, "Le Username est déjà utilisé!");
     }
 }
Пример #7
0
        protected void EnregistrementLogin()
        {
            Session["USER_LOGOUT"] = DateTime.Now;
            //TableLogins logins = (TableLogins)Session["Logins"]; //Erreur, sa dit qu'il n'est jamais créé
            TableLogins logins = new TableLogins((String)Application["MainBD"], this);
            TableUsers  users  = (TableUsers)Session["Utilisateur"];

            // Rendre l'usager Offline
            users.ID      = (Int64)Session["USER_ID"];
            users.Enligne = false;
            users.userEnligne();

            // Insertion du nouveau log
            logins.User_ID     = (Int64)Session["USER_ID"];
            logins.Login_Date  = (DateTime)Session["USER_LOGIN"];
            logins.Logout_Date = (DateTime)Session["USER_LOGOUT"];
            logins.IP          = GetIP();
            logins.Insert();
        }