Example #1
0
 internal int Adicionar(Categoria novaCategoria)
 {
     ComandoSQL.Parameters.Clear();
     ComandoSQL.CommandText = @"insert into categorias(cat_nome)
         values (@nome)";
     ComandoSQL.Parameters.AddWithValue("@nome", novaCategoria.Nome);
     return ExecutaComando(false);
 }
 public int Adicionar(Categoria novaCategoria)
 {
     if (novaCategoria.Nome.Trim().Length > 0)
     {
         return catBD.Adicionar(novaCategoria);
     }
     else
         return -1;
 }
Example #3
0
        internal Categoria Obter(int categoriaCod)
        {
            var c = new Categoria{Codigo = categoriaCod};
            try
            {
                ComandoSQL.Parameters.Clear();
                ComandoSQL.CommandText = "select cat_nome from categorias where cat_codigo = @catId";
                ComandoSQL.Parameters.AddWithValue("@catId", c.Codigo);
                c.Nome = ExecutaScalar().ToString();

            }
            catch (Exception)
            {

                c = null;
            }

            return c;
        }