Ejemplo n.º 1
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            lblRes.Text = "";
            dbData   conec   = new dbData();
            Usuarios logUser = new Usuarios();
            string   res     = logUser.Register(txtUser.Text, txtPass.Text);

            if (res == txtUser.Text)
            {
                Session["userLog"] = res;
                Response.Redirect("theChatRoom.aspx");
            }
            else
            {
                lblRes.Text = res;
            }
        }
Ejemplo n.º 2
0
        public string Register(string user, string passw)
        {
            Security sec      = new Security();
            string   passwEnc = sec.generarMD5(passw);
            dbData   conec    = new dbData();
            DataSet  res      = conec.ExecuteQuery("select * from Users where userLogin='******'");

            if (res.Tables[0].Rows.Count > 0)
            {
                return("El usuario ya se encuentra registrado.");
            }
            else
            {
                int resIns = conec.ExecuteNonQuery("insert into Users (userLogin,passWord,lastLogin) values ('" + user + "','" + passwEnc + "','" + DateTime.Now.ToString() + "')");
                if (resIns > 0)
                {
                    return(user);
                }
                else
                {
                    return("No se pudo realizar el registro del usuario.");
                }
            }
        }
Ejemplo n.º 3
0
        public string Login(string user, string passw)
        {
            Security sec      = new Security();
            string   passwEnc = sec.generarMD5(passw);
            dbData   conec    = new dbData();
            DataSet  res      = conec.ExecuteQuery("select * from Users where userLogin='******'");

            if (res.Tables[0].Rows.Count > 0)
            {
                if (res.Tables[0].Rows[0]["passWord"].ToString() == passwEnc)
                {
                    conec.ExecuteQuery("update Users set lastLogin='******' where userLogin='******'");
                    return(user);
                }
                else
                {
                    return("Password incorrecto.");
                }
            }
            else
            {
                return("El usuario no existe, por favor de clic en registrar.");
            }
        }