예제 #1
0
 public UsuarioDAO()
 {
     this.cont     = new Contato.Contato();
     this.contDAO  = new Contato.ContatoDAO();
     this.local    = new Local.Local();
     this.localDAO = new Local.LocalDAO();
 }
예제 #2
0
        public Usuario ObterUsuario(Int64 chave)
        {
            try
            {
                this.AbrirConexao();
                cmd = new SqlCommand("SELECT * FROM [USUARIO] WHERE [COD_USU] = @COD_USU", con, tran);
                cmd.Parameters.AddWithValue("@COD_USU", chave);
                Usuario         usu     = new Usuario();
                Contato.Contato auxCont = new Contato.Contato();
                Local.Local     auxLoc  = new Local.Local();
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    usu.Cod_usu      = Convert.ToInt64((dr["COD_USU"]));
                    usu.Dsc_username = Convert.ToString((dr["DSC_USERNAME"]));
                    usu.Cod_sup      = Convert.ToInt64((dr["COD_SUP"]));
                    usu.Dsc_nome_usu = Convert.ToString((dr["DSC_NOME_USU"]));

                    auxLoc = this.localDAO.ObterLocal(usu.Cod_usu);
                    if (auxLoc != null)
                    {
                        usu.Cep      = auxLoc.Cep;
                        usu.Endereco = auxLoc.Endereco;
                        usu.Numero   = auxLoc.Numero;
                        usu.Cidade   = auxLoc.Cidade;
                        usu.Bairro   = auxLoc.Bairro;
                        usu.Uf       = auxLoc.Uf;
                    }

                    auxCont = this.contDAO.ObterContato(usu.Cod_usu);
                    if (auxCont != null)
                    {
                        usu.Email    = auxCont.Email;
                        usu.Telefone = auxCont.Telefone;
                        usu.Celular  = auxCont.Celular;
                    }
                }
                return(usu);
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao obter dados do Usuario: " + ex.Message);
            }
            finally
            {
                this.FecharConexao();
            }
        }
예제 #3
0
        public Boolean ValidaUsuario(String username, String senha)
        {
            Boolean value = false;

            try
            {
                this.AbrirConexao();
                cmd = new SqlCommand("SELECT * FROM [USUARIO] WHERE [DSC_USERNAME] = @DSC_USERNAME AND [PASSWORD] = @PASSWORD", tran.Connection, tran);
                cmd.Parameters.AddWithValue("@DSC_USERNAME", username);
                cmd.Parameters.AddWithValue("@PASSWORD", senha);
                Usuario         usu     = new Usuario();
                Contato.Contato auxCont = new Contato.Contato();
                Local.Local     auxLoc  = new Local.Local();
                dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    if (dr.Read())
                    {
                        usu.Dsc_username = Convert.ToString(String.IsNullOrEmpty(dr["DSC_USERNAME"].ToString()) ? "" : dr["DSC_USERNAME"]);
                        usu.Passoword    = Convert.ToString(String.IsNullOrEmpty(dr["PASSWORD"].ToString()) ? "" : dr["PASSWORD"]);
                        usu.Cod_sup      = Convert.ToInt64(dr["COD_SUP"] == DBNull.Value ? 0 : dr["COD_SUP"]);
                        if (username.Equals(usu.Dsc_username) && senha.Equals(usu.Passoword) && usu.Cod_sup.Equals(0))
                        {
                            value = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao obter dados do Usuario: " + ex.Message);
            }
            finally
            {
                this.FecharConexao();
            }
            return(value);
        }