Beispiel #1
0
        public virtual void Excluir(int id, int idusuariologado)
        {
            var p = new SqlParameter[]
            {
                new SqlParameter($"Id", id),
                new SqlParameter("tabela", Tabela),
                new SqlParameter("usuario", idusuariologado)
            };

            HelperDAO.ExecutaProc("spDelete", p);
        }
Beispiel #2
0
        public virtual T Consulta(int id)
        {
            var p = new SqlParameter[]
            {
                new SqlParameter("id", id),
                new SqlParameter("tabela", Tabela)
            };
            var tabela = HelperDAO.ExecutaProcSelect("spConsulta", p);

            if (tabela.Rows.Count == 0)
            {
                return(null);
            }
            else
            {
                return(MontaModel(tabela.Rows[0]));
            }
        }
Beispiel #3
0
        public UsuarioViewModel ConsultaEmail(string email)
        {
            var p = new SqlParameter[]
            {
                new SqlParameter("email", email.Trim()),
                new SqlParameter("tabela", Tabela)
            };

            var tabela = HelperDAO.ExecutaProcSelect("spConsultaEmail", p);

            if (tabela.Rows.Count == 0)
            {
                return(null);
            }
            else
            {
                return(MontaModel(tabela.Rows[0]));
            }
        }
Beispiel #4
0
        /*public override List<ProdutoViewModel> Listar()
         * {
         *  var p = new SqlParameter[]
         *  {
         *      new SqlParameter("Ordem", "1")
         *  };
         *
         *  var tabela = HelperDAO.ExecutaProcSelect("spListagem_Produto", p);
         *  List<ProdutoViewModel> lista = new List<ProdutoViewModel>();
         *  foreach (DataRow registro in tabela.Rows)
         *  {
         *      lista.Add(MontaModel(registro));
         *  }
         *  return lista;
         * }*/

        public List <ProdutoViewModel> ListarBusca(string pesquisa, int ordem)
        {
            var p = new SqlParameter[]
            {
                new SqlParameter("pesquisa", pesquisa),
                new SqlParameter("ordem", ordem)
            };
            var tabela = HelperDAO.ExecutaProcSelect("PesquisaProdutos", p);
            List <ProdutoViewModel> lista = new List <ProdutoViewModel>();

            foreach (DataRow registro in tabela.Rows)
            {
                if (lista.Count == 1 && lista[0].Id == 0)
                {
                    lista.Clear();
                }
                lista.Add(MontaModel(registro));
            }
            return(lista);
        }
Beispiel #5
0
        public virtual List <T> Listar()
        {
            var p = new SqlParameter[]
            {
                new SqlParameter("tabela", Tabela),
                new SqlParameter("Ordem", "1")
            };

            var      tabela = HelperDAO.ExecutaProcSelect("spListagem", p);
            List <T> lista  = new List <T>();
            bool     skip   = true; //Necessário para evadir a listagem do elemento zero (trash)

            foreach (DataRow registro in tabela.Rows)
            {
                if (skip)
                {
                    skip = false;
                    continue;
                }
                lista.Add(MontaModel(registro));
            }
            return(lista);
        }
Beispiel #6
0
 public virtual void Alterar(T model)
 {
     HelperDAO.ExecutaProc("spUpdate_" + Tabela, CriaParametros(model));
 }
Beispiel #7
0
 public virtual int Inserir(T model)
 {
     return(HelperDAO.ExecutaProc("spInsert_" + Tabela, CriaParametros(model), ChaveIdentity));
 }