Ejemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            SqlWhereUsuario where = new SqlWhereUsuario();
            SqlCommand     sql     = where.verificaLoginUsuario("a", "a");
            List <Usuario> usuario = usuarioDAL.GetALL(sql);

            foreach (Usuario item in usuario)
            {
                richTextBox1.Text += " " + item.ID;
                richTextBox1.Text += " " + (string)item.Nome;
                richTextBox1.Text += " " + item.Sobrenome;
                richTextBox1.Text += " " + (string)item.Senha;
                richTextBox1.Text += " " + (string)item.Localizacao;
                richTextBox1.Text += " " + (string)item.ListaFavoritos;
                richTextBox1.Text += " " + (string)item.UltimaLista;
                richTextBox1.Text += " " + (string)item.Email;
            }
        }
Ejemplo n.º 2
0
        public Usuario selecionarPorID(int ID)
        {
            SqlWhereUsuario where = new SqlWhereUsuario();
            SqlCommand     comando = where.selecionarPorID(ID);
            List <Usuario> lista   = usuarioDAL.GetALL(comando);
            Usuario        retorno = new Usuario();

            foreach (Usuario item in lista)
            {
                retorno.ID             = item.ID;
                retorno.Nome           = item.Nome;
                retorno.Sobrenome      = item.Sobrenome;
                retorno.Senha          = item.Senha;
                retorno.Localizacao    = item.Localizacao;
                retorno.Email          = item.Email;
                retorno.ListaFavoritos = item.ListaFavoritos;
                retorno.UltimaLista    = item.UltimaLista;
                return(retorno);
            }
            return(null);
        }
Ejemplo n.º 3
0
        private Boolean verificaDisponibilidadeDeEmailSupermercado(string email)
        {
            SupermercadoDAL usuario = new SupermercadoDAL();

            SqlWhereUsuario where = new SqlWhereUsuario();
            try
            {
                SqlCommand          comando       = where.selecionaSeExistirEmail(email);
                List <Supermercado> supermercados = usuario.GetALL(comando);

                if (supermercados.Count <= 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public object verificaLogin(string login, string senha)
        {
            //objetos
            List <Usuario>      usuario      = new List <Usuario>();
            List <Supermercado> supermercado = new List <Supermercado>();

            SqlWhereSupermercado wheres = new SqlWhereSupermercado();

            SqlWhereUsuario where = new SqlWhereUsuario();
            UsuarioDAL      usuariodal      = new UsuarioDAL();
            SupermercadoDAL supermercadodal = new SupermercadoDAL();

            try
            {
                SqlCommand comando = where.verificaLoginUsuario(login, senha);
                usuario = usuariodal.GetALL(comando);
                if (usuario.Count <= 0)
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                try
                {
                    SqlCommand comando = wheres.verificaLoginSupermercado(login, senha);
                    supermercado = supermercadodal.GetALL(comando);
                }
                catch (Exception)
                {
                    //mensagem de login invalido
                    throw;
                }
            }
            //verificação de objeto
            try
            {
                if (usuario.Count > 0)
                {
                    Usuario usuarioReturn = new Usuario();
                    foreach (Usuario item in usuario)
                    {
                        usuarioReturn.ID          = item.ID;
                        usuarioReturn.Nome        = item.Nome;
                        usuarioReturn.Senha       = item.Senha;
                        usuarioReturn.Sobrenome   = item.Sobrenome;
                        usuarioReturn.UltimaLista = item.UltimaLista;
                        usuarioReturn.Localizacao = item.Localizacao;
                        ///
                        return(usuarioReturn);
                    }
                }
            }
            catch (Exception)
            {
                Supermercado supermercadoReturn = new Supermercado();
                foreach (Supermercado item in supermercado)
                {
                    supermercadoReturn.ID = item.ID;
                    return(supermercadoReturn);
                }
            }


            return(null);
        }