public List <JogoViewModel> Pesquisar(string nome, double preco, int categoria, int publicadora, int desenvolvedora)
        {
            SqlParameter[] parametros = new SqlParameter[]
            {
                new SqlParameter("Nome", nome),
                new SqlParameter("Preco", preco),
                new SqlParameter("Categoria", categoria),
                new SqlParameter("Publicadora", publicadora),
                new SqlParameter("Desenvolvedora", desenvolvedora)
            };

            if (string.IsNullOrEmpty(nome))
            {
                parametros[0].Value = "";
            }
            if (preco == 0)
            {
                parametros[1].Value = DBNull.Value;
            }

            DataTable tabela = HelperDAO.ExecutaProcSelect("sp_pesquisaJogos", parametros);

            List <JogoViewModel> lista = new List <JogoViewModel>();

            foreach (DataRow registro in tabela.Rows)
            {
                lista.Add(MontaModel(registro));
            }
            return(lista);
        }
Esempio n. 2
0
 public virtual void Apagar(int id)
 {
     SqlParameter[] parametros = new SqlParameter[]
     {
         new SqlParameter("id", id),
         new SqlParameter("tabela", Tabela)
     };
     HelperDAO.ExecutaProc("spDelete", parametros);
 }
Esempio n. 3
0
 public virtual void Apagar(int idUsuario, int idJogo)
 {
     SqlParameter[] parametros = new SqlParameter[]
     {
         new SqlParameter("idUsuario", idUsuario),
         new SqlParameter("idJogo", idJogo)
     };
     HelperDAO.ExecutaProc("spDeleteItemCarrinho", parametros);
 }
Esempio n. 4
0
        public virtual int ProximoId()
        {
            SqlParameter[] parametros = new SqlParameter[]
            {
                new SqlParameter("Tabela", Tabela)
            };
            DataTable tabela = HelperDAO.ExecutaProcSelect("spProximoId", parametros);

            return(Convert.ToInt32(tabela.Rows[0][0]));
        }
Esempio n. 5
0
        public List <CarrinhoViewModel> Listar(int IdUsuario)
        {
            SqlParameter[] parametros = new SqlParameter[]
            {
                new SqlParameter("idUsuario", IdUsuario)
            };
            DataTable tabela = HelperDAO.ExecutaProcSelect("spListagemCarrinho", parametros);
            List <CarrinhoViewModel> lista = new List <CarrinhoViewModel>();

            foreach (DataRow registro in tabela.Rows)
            {
                lista.Add(MontaModel(registro));
            }
            return(lista);
        }
Esempio n. 6
0
        public virtual List <T> Listar()
        {
            SqlParameter[] parametros = new SqlParameter[]
            {
                new SqlParameter("tabela", Tabela),
                new SqlParameter("ordem", "1")
            };
            DataTable tabela = HelperDAO.ExecutaProcSelect("spListagem", parametros);
            List <T>  lista  = new List <T>();

            foreach (DataRow registro in tabela.Rows)
            {
                lista.Add(MontaModel(registro));
            }
            return(lista);
        }
        public List <JogoViewModel> Consultar(string idUsuario)
        {
            List <JogoViewModel> lista = new List <JogoViewModel>();

            SqlParameter[] parametros = new SqlParameter[]
            {
                new SqlParameter("idUsuario", idUsuario)
            };
            DataTable tabela = HelperDAO.ExecutaProcSelect("spConsulta_Biblioteca", parametros);

            foreach (DataRow registro in tabela.Rows)
            {
                lista.Add(MontaModel(registro));
            }

            return(lista);
        }
        public UsuarioViewModel Consultar(string usuario, string senha)
        {
            SqlParameter[] parametros = new SqlParameter[]
            {
                new SqlParameter("login", usuario),
                new SqlParameter("senha", senha)
            };

            DataTable tabela = HelperDAO.ExecutaProcSelect("spConsulta_Usuario", parametros);

            if (tabela.Rows.Count == 0)
            {
                return(null);
            }
            else
            {
                return(MontaModel(tabela.Rows[0]));
            }
        }
Esempio n. 9
0
        public virtual T Consultar(int id)
        {
            SqlParameter[] parametros = new SqlParameter[]
            {
                new SqlParameter("id", id),
                new SqlParameter("tabela", Tabela)
            };

            DataTable tabela = HelperDAO.ExecutaProcSelect("spConsulta", parametros);

            if (tabela.Rows.Count == 0)
            {
                return(null);
            }
            else
            {
                return(MontaModel(tabela.Rows[0]));
            }
        }
Esempio n. 10
0
        public List <JogoViewModel> ConsultaItensCompra(int idCompra)
        {
            SqlParameter[] parametros = new SqlParameter[]
            {
                new SqlParameter("idCompra", idCompra)
            };

            DataTable tabela = HelperDAO.ExecutaProcSelect("spListagemItensCompra", parametros);

            List <JogoViewModel> lista = new List <JogoViewModel>();

            foreach (DataRow registro in tabela.Rows)
            {
                JogoViewModel jogo = new JogoViewModel();
                jogo.Id   = Convert.ToInt32(registro["idJogo"]);
                jogo.Nome = registro["nomeJogo"].ToString();
                lista.Add(jogo);
            }

            return(lista);
        }
Esempio n. 11
0
        public List <CompraViewModel> Pesquisar(int idUsuario, DateTime dataInicio, DateTime dataFim, double precoInicial, double precoFinal)
        {
            SqlParameter[] parametros = new SqlParameter[]
            {
                new SqlParameter("idUsuario", idUsuario),
                new SqlParameter("dataInicio", dataInicio),
                new SqlParameter("dataFim", dataFim.AddHours(23).AddMinutes(59).AddSeconds(59)),
                new SqlParameter("precoInicial", precoInicial),
                new SqlParameter("precoFinal", precoFinal)
            };

            if (parametros[1].Value == null || parametros[1].Value.ToString() == "01/01/0001 00:00:00")
            {
                parametros[1].Value = DBNull.Value;
            }
            if (parametros[2].Value == null || parametros[2].Value.ToString() == "01/01/0001 23:59:59")
            {
                parametros[2].Value = DBNull.Value;
            }
            if (parametros[3].Value == null || (double)parametros[3].Value == 0)
            {
                parametros[3].Value = DBNull.Value;
            }
            if (parametros[4].Value == null || (double)parametros[4].Value == 0)
            {
                parametros[4].Value = DBNull.Value;
            }

            DataTable tabela = HelperDAO.ExecutaProcSelect("sp_PesquisaCompras", parametros);

            List <CompraViewModel> lista = new List <CompraViewModel>();

            foreach (DataRow registro in tabela.Rows)
            {
                lista.Add(MontaModel(registro));
            }
            return(lista);
        }
Esempio n. 12
0
        public List <UsuarioViewModel> Pesquisar(string nome, int tipo)
        {
            SqlParameter[] parametros = new SqlParameter[]
            {
                new SqlParameter("Nome", nome),
                new SqlParameter("Tipo", tipo)
            };

            if (string.IsNullOrEmpty(nome))
            {
                parametros[0].Value = "";
            }

            DataTable tabela = HelperDAO.ExecutaProcSelect("sp_PesquisaUsuarios", parametros);

            List <UsuarioViewModel> lista = new List <UsuarioViewModel>();

            foreach (DataRow registro in tabela.Rows)
            {
                lista.Add(MontaModel(registro));
            }
            return(lista);
        }
Esempio n. 13
0
 public virtual void Alterar(T model)
 {
     HelperDAO.ExecutaProc("spUpdate_" + Tabela, CriaParametros(model));
 }
Esempio n. 14
0
 public virtual int Inserir(T model)
 {
     return(HelperDAO.ExecutaProc("spInsert_" + Tabela, CriaParametros(model), ChaveIdentity));
 }