protected void LinkButtonAtualizarDados_Click(object sender, EventArgs e)
 {
     x = new Usuario();
     x.Bairro = TxBairro.Text.ToUpper();
     x.CEP = TxCEP.Text;
     x.Complemento = TxComplemento.Text;
     x.DataNascimento = DateTime.Parse(TxDTNascimento.Text);
     x.Email = TxEmail.Text.ToUpper();
     x.Logradouro = TxLogradouro.Text.ToUpper();
     x.Nome = TXNome.Text.ToUpper();
     x.Numero = int.Parse(TxNumero.Text);
     x.Telefone_Fixo = TxFixo.Text;
     x.Telefone_Celular = TxCell.Text;
     x.CPF = LbCPFLogin.Text;
     x.AtualizarUsuario(x);
     CarregarDados(x.LerUsuario(x.CPF));
 }
        /// <summary>
        /// Metodo para cadastrar ou logar o usuario no sistema
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLogar_Click(object sender, EventArgs e)
        {
            user = new Usuario();
            user.CPF = txCPF.Text;
            user.Senha = txSenha.Text;

            ValidarCPF validar = new ValidarCPF();

            if (btnLogar.Text.Equals("Login") )
            {
                if (user.PesquisaUsuarioDataTable(user) && validar.ValidaCPF(user.CPF))
                {
                    user = user.LerUsuario(user.CPF);
                    Session["Usuario"] = user;
                    Response.Write("<script LANGUAGE='JavaScript' >alert('Login efetuado com sucesso!');document.location='" +
                        ResolveClientUrl("~/Interface/Usuario.aspx") + "';</script>");
                }
                else
                {
                    Response.Write("<script LANGUAGE='JavaScript' >alert('Login ou senha incorretos');document.location='" +
                        ResolveClientUrl("~/Interface/LoginUsuario.aspx") + "';</script>");
                }
            }
            else
            {
                if (txSenha.Text.Equals(TxConfirmarSenha.Text) && validar.ValidaCPF(user.CPF))
                {
                    user.InserirUsuario(user);
                    Response.Write("<script LANGUAGE='JavaScript' >alert('Cadastro realizado com sucesso!')</script>");
                }
                else
                {
                    Response.Write("<script LANGUAGE='JavaScript' >alert('Senhas incorretas, ou cpf incorreto!')</script>");
                }

                TxConfirmarSenha.Visible = false;
                lbConfirmarSenha.Visible = false;
                btnLogar.Text = "Login";
                btnLogar.Width = 70;
            }
        }
        public bool PesquisaDataTable(Usuario __objUsuario)
        {
            try
            {
                DataTable tabela = usuario.GetData();
                foreach (var item in tabela.Rows)
                {
                    DataRow linha = (DataRow)item;
                    if (linha["CPF"].ToString().Equals(__objUsuario.CPF) && linha["SENHA"].ToString().Equals(__objUsuario.Senha))
                        return true;
                }

                return false;

            }
            catch (Exception)
            {

                throw;
            }
            finally
            {

            }
        }
        public Usuario LerUsuario(string cpf)
        {
            try
            {
                Usuario x = new Usuario();
                DataTable tabela = usuario.RetornaDataTableporCPF(cpf);

                x.Bairro = tabela.Rows[0]["BAIRRO"].ToString();
                x.CEP = tabela.Rows[0]["CEP"].ToString();
                x.Complemento = tabela.Rows[0]["COMPLEMENTO"].ToString();
                x.CPF = tabela.Rows[0]["CPF"].ToString();
                x.DataNascimento = (DateTime)tabela.Rows[0]["DATANASCIMENTO"];
                x.Email = tabela.Rows[0]["EMAIL"].ToString();
                x.Logradouro = tabela.Rows[0]["LOGRADOURO"].ToString();
                x.Nome = tabela.Rows[0]["NOME"].ToString();
                x.Numero = (int)tabela.Rows[0]["NUMERO"];
                x.Senha = tabela.Rows[0]["SENHA"].ToString();
                x.Telefone_Celular = tabela.Rows[0]["TELEFONECELULAR"].ToString();
                x.Telefone_Fixo = tabela.Rows[0]["TELEFONEFIXO"].ToString();

                return x;
            }
            catch (Exception err)
            {

                throw;
            }
            finally
            {
                usuario.Connection.Close();
            }
        }
 public bool InerirUsuario(Usuario objUsuario)
 {
     Usuario x = objUsuario;
     try
     {
         usuario.InserirUsuario(x.CPF, x.Senha, x.Nome, x.DataNascimento, x.CEP, x.Logradouro, x.Numero, x.Complemento, x.Bairro, x.Telefone_Fixo, x.Telefone_Celular, x.Email);
         return true;
     }
     catch (Exception err)
     {
         return false;
     }
     finally
     {
         usuario.Connection.Close();
     }
 }
        /// <summary>
        /// Metodo para consultar se o usuáio está cadastrado
        /// </summary>
        /// <param name="_usuario">Objeto do tipo Usuario</param>
        /// <returns>Verdadeiro ou falso</returns>
        public bool ConsultarUsuario(Usuario _usuario)
        {
            try
            {
                var nome = usuario.PesquisaCPFSenha(_usuario.CPF, _usuario.Senha);

                if (nome != null)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception err)
            {

                throw;
            }
            finally
            {
                usuario.Connection.Close();
            }
        }
 public bool AtualizarUsuario(Usuario x)
 {
     try
     {
         usuario.AtualizarUsuario(x.Nome, x.DataNascimento, x.CEP, x.Logradouro, x.Numero, x.Complemento, x.Bairro, x.Telefone_Fixo, x.Telefone_Celular, x.Email, x.CPF);
         return true;
     }
     catch (Exception)
     {
         return false;
         throw;
     }
     finally
     {
         usuario.Connection.Close();
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (LbCPFLogin.Text.Equals("0"))
     {
         x = new Usuario();
         x = (Usuario)Session["Usuario"];
         CarregarDados(x);
         DtgDados.DataSource = x.DemandasPorUsuario(x.CPF);
         DtgDados.DataBind();
     }
     else
     {
         x = new Usuario();
         DtgDados.DataSource = x.DemandasPorUsuario(LbCPFLogin.Text);
         DtgDados.DataBind();
     }
 }
 protected void LinkButtonConsultarCEP_Click(object sender, EventArgs e)
 {
     x = new Usuario();
     string cep = x.ConsultarCEP(TxCEP.Text);
 }
 private void CarregarDados(Usuario z)
 {
     TxBairro.Text = z.Bairro.ToUpper();
     TxCEP.Text = z.CEP;
     TxComplemento.Text = z.Complemento;
     TxDTNascimento.Text = z.DataNascimento.ToShortDateString();
     TxEmail.Text = z.Email.ToUpper();
     TxLogradouro.Text = z.Logradouro.ToUpper();
     TXNome.Text = z.Nome.ToUpper();
     TxNumero.Text = z.Numero.ToString();
     TxFixo.Text = z.Telefone_Fixo;
     TxCell.Text = z.Telefone_Celular;
     LbCPFLogin.Text = z.CPF;
 }
Exemple #11
0
 public bool PesquisaUsuarioDataTable(Usuario user)
 {
     return bdUsuario.PesquisaDataTable(user);
 }
Exemple #12
0
 public bool InserirUsuario(Usuario _user)
 {
     return bdUsuario.InerirUsuario(_user);
 }
Exemple #13
0
 public bool ConsultaUsuario(Usuario _user)
 {
     return bdUsuario.ConsultarUsuario(_user);
 }
Exemple #14
0
 public bool AtualizarUsuario(Usuario user)
 {
     return bdUsuario.AtualizarUsuario(user);
 }