Esempio n. 1
0
        public int actualizarSubCategoria(int idCSubategoria, string nombre)
        {
            tblSubCategorias cat = DbContext.tblSubCategorias.FirstOrDefault(p => p.id_subcategoria == idCSubategoria);

            if (cat != null)
            {
                cat.nombre = nombre;
            }
            return(DbContext.SaveChanges());
        }
Esempio n. 2
0
        protected void lbSubcategorias_SelectedIndexChanged(object sender, EventArgs e)
        {
            AdminCategorias  aCat = new AdminCategorias();
            tblSubCategorias cat  = aCat.obtenerSubCategoriaById(Convert.ToInt32(lbSubcategorias.SelectedValue));

            if (cat != null)
            {
                txtSubCategoria.Text   = cat.nombre;
                lknEliminarSub.Visible = true;
                lknGuardarSub.Visible  = true;
            }
        }
Esempio n. 3
0
        public int crearSubCategoria(string nombre, int idCategoria)
        {
            tblSubCategorias cat = new tblSubCategorias();

            cat.nombre       = nombre;
            cat.id_categoria = idCategoria;
            DbContext.tblSubCategorias.Add(cat);
            int res = DbContext.SaveChanges();

            if (res > 0)
            {
                DbContext.Entry(cat).GetDatabaseValues();
                return(cat.id_subcategoria);
            }
            return(res);
        }
Esempio n. 4
0
        public int eliminarSubCategoria(int idSubCategoria)
        {
            tblSubCategorias cat = DbContext.tblSubCategorias.FirstOrDefault(p => p.id_subcategoria == idSubCategoria);

            if (cat != null)
            {
                int productos = DbContext.tblProductos.Count(p => p.id_subcategoria == cat.id_subcategoria);
                if (productos > 0)
                {
                    return(-2);
                }
                else
                {
                    DbContext.tblSubCategorias.Remove(cat);
                }
            }


            return(DbContext.SaveChanges());
        }
Esempio n. 5
0
        public tblSubCategorias obtenerSubCategoriaById(int id_subcategoria)
        {
            tblSubCategorias categoria = DbContext.tblSubCategorias.FirstOrDefault(p => p.id_subcategoria == id_subcategoria);

            return(categoria);
        }