예제 #1
0
        public static int TrocarSenha(int idUsuario, string senhaAtual, string SenhaNova)
        {
            try
            {
                string cryptoSenhaAtual = CoolEventsEncrypter.Encrypt(senhaAtual);
                string cryptoSenhaNova  = CoolEventsEncrypter.Encrypt(SenhaNova);

                BDConexao conexao = new BDConexao();
                conexao.connection.Open();
                conexao.command.CommandText = "SELECT COUNT(*) FROM TBL_USUARIO WHERE SENHA = @_SENHA AND ID_USUARIO = @IDUSUARIO";
                conexao.command.Parameters.Add("@_SENHA", SqlDbType.VarChar).Value = cryptoSenhaAtual;
                conexao.command.Parameters.Add("@IDUSUARIO", SqlDbType.Int).Value  = idUsuario;

                if ((int)conexao.command.ExecuteScalar() == 0)
                {
                    return(0);
                }

                conexao.command.Parameters.Clear();

                conexao.command.CommandText = "UPDATE TBL_USUARIO SET SENHA = @_NOVASENHA WHERE ID_USUARIO = @IDUSUARIO";
                conexao.command.Parameters.Add("@_NOVASENHA", SqlDbType.VarChar).Value = cryptoSenhaNova;
                conexao.command.Parameters.Add("@IDUSUARIO", SqlDbType.Int).Value      = idUsuario;

                conexao.command.ExecuteNonQuery();

                conexao.connection.Close();
                return(1);
            }
            catch (Exception)
            {
                return(2);
            }
        }
예제 #2
0
        public bool DoIt()
        {
            BDConexao conexao = new BDConexao();

            conexao.connection.Open();
            conexao.command.Parameters.Clear();
            conexao.command.CommandText = "SELECT id_usuario,nome FROM tbl_usuario WHERE EMAIL = @EMAIL AND SENHA = @SENHA";
            conexao.command.Parameters.Add("@EMAIL", SqlDbType.VarChar).Value = Email;
            conexao.command.Parameters.Add("@SENHA", SqlDbType.VarChar).Value = CoolEventsEncrypter.Encrypt(Senha);


            System.Data.SqlClient.SqlDataReader dr = conexao.command.ExecuteReader();

            if (dr.HasRows)
            {
                dr.Read();
                HttpContext.Current.Session["idUsuario"]   = dr.GetInt32(0);
                HttpContext.Current.Session["nomeUsuario"] = dr.GetString(1);
                conexao.connection.Close();
                return(true);
            }

            conexao.connection.Close();
            return(false);
        }
예제 #3
0
        public void AlterarSenha(string novaSenha)
        {
            BDConexao conexao = new BDConexao();

            conexao.connection.Open();
            conexao.command.Parameters.Clear();
            conexao.command.CommandText = "UPDATE CLIENTE SET SENHA = @NOVASENHA WHERE IDCLIENTE = @IDCLIENTE";
            conexao.command.Parameters.Add("@IDCLIENTE", SqlDbType.Int).Value     = (int)HttpContext.Current.Session["idUsuario"];
            conexao.command.Parameters.Add("@NOVASENHA", SqlDbType.VarChar).Value = CoolEventsEncrypter.Encrypt(novaSenha);

            conexao.command.ExecuteNonQuery();
            conexao.connection.Close();
        }
예제 #4
0
        public void RedefinirSenhaPorkey(string key, string novaSenha)
        {
            BDConexao conexao = new BDConexao();

            conexao.connection.Open();
            conexao.command.Parameters.Clear();
            conexao.command.CommandText = "UPDATE CLIENTE SET senha = @SENHA WHERE codSenha = @CODSENHA";
            conexao.command.Parameters.Add("@SENHA", SqlDbType.VarChar).Value    = CoolEventsEncrypter.Encrypt(novaSenha);
            conexao.command.Parameters.Add("@CODSENHA", SqlDbType.VarChar).Value = key;

            conexao.command.ExecuteNonQuery();
            conexao.connection.Close();
        }
예제 #5
0
        public bool verificaSenha(string senha)
        {
            BDConexao conexao = new BDConexao();

            conexao.connection.Open();
            conexao.command.Parameters.Clear();
            conexao.command.CommandText = "SELECT COUNT(*) FROM CLIENTE WHERE IDCLIENTE = @IDCLIENTE AND SENHA = @SENHA";
            conexao.command.Parameters.Add("@IDCLIENTE", SqlDbType.Int).Value = (int)HttpContext.Current.Session["idUsuario"];;
            conexao.command.Parameters.Add("@SENHA", SqlDbType.VarChar).Value = CoolEventsEncrypter.Encrypt(senha);

            int ok = (int)conexao.command.ExecuteScalar();

            conexao.connection.Close();

            if (ok == 0)
            {
                return(false);
            }

            else
            {
                return(true);
            }
        }
예제 #6
0
        //public bool Check() {

        //}

        public bool Cadastrar()
        {
            try {
                this.Pontuacao = 0;

                BDConexao conexao = new BDConexao();

                conexao.command.CommandText = "INSERT INTO tbl_USUARIO values (@NOME, @SOBRENOME, @EMAIL, @SENHA, @NASC, @GENERO, @FOTO, @APELIDO, @CIVIL, @UF, " +
                                              "@CIDADE, @CEP, @BAIRRO, @LOGRADOURO, @NUMERO, @COMPLEMENTO, @DESCRICAO, @PONTUACAO)";

                conexao.command.Parameters.Add("@NOME", SqlDbType.NVarChar).Value        = Nome;
                conexao.command.Parameters.Add("@SOBRENOME", SqlDbType.NVarChar).Value   = Sobrenome;
                conexao.command.Parameters.Add("@EMAIL", SqlDbType.NVarChar).Value       = Email;
                conexao.command.Parameters.Add("@SENHA", SqlDbType.NVarChar).Value       = CoolEventsEncrypter.Encrypt(Senha);
                conexao.command.Parameters.Add("@NASC", SqlDbType.Date).Value            = DataNascimento;
                conexao.command.Parameters.Add("@GENERO", SqlDbType.Char).Value          = Sexo;
                conexao.command.Parameters.Add("@FOTO", SqlDbType.NVarChar).Value        = "";
                conexao.command.Parameters.Add("@APELIDO", SqlDbType.NVarChar).Value     = Apelido;
                conexao.command.Parameters.Add("@CIVIL", SqlDbType.NVarChar).Value       = Civil;
                conexao.command.Parameters.Add("@UF", SqlDbType.NVarChar).Value          = UF;
                conexao.command.Parameters.Add("@CIDADE", SqlDbType.NVarChar).Value      = Cidade;
                conexao.command.Parameters.Add("@CEP", SqlDbType.NVarChar).Value         = CEP;
                conexao.command.Parameters.Add("@BAIRRO", SqlDbType.NVarChar).Value      = Bairro;
                conexao.command.Parameters.Add("@LOGRADOURO", SqlDbType.NVarChar).Value  = Logradouro;
                conexao.command.Parameters.Add("@NUMERO", SqlDbType.VarChar).Value       = Numero;
                conexao.command.Parameters.Add("@COMPLEMENTO", SqlDbType.NVarChar).Value = Complemento;
                conexao.command.Parameters.Add("@DESCRICAO", SqlDbType.NVarChar).Value   = Descricao;
                conexao.command.Parameters.Add("@PONTUACAO", SqlDbType.Int).Value        = Pontuacao;

                conexao.connection.Open();
                conexao.command.ExecuteNonQuery();
                conexao.connection.Close();

                return(true);
            }
            catch (Exception Ex)
            {
                return(false);
            }
        }