Exemple #1
0
 public System.Collections.IList getDescripciones()
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from d in context.descripcions select d;
         return(query.ToList());
     }
 }
 public void guardarLenguaje(lenguaje lenguaje)
 {
     using (var context = new dbEntities())
     {
         context.lenguajes.Add(lenguaje);
         context.SaveChanges();
     }
 }
 public System.Collections.IList getUnidadesDeMedida()
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from um in context.unidad_med select um;
         return(query.ToList());
     }
 }
 public System.Collections.IList getRegistroById(int id)
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from r in context.registros where r.registro_id == id select r;
         return(query.ToList());
     }
 }
 public System.Collections.IList getBomsById(int id)
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from b in context.boms where b.bom_id == id select b;
         return(query.ToList());
     }
 }
 public System.Collections.IList getRegistros()
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from r in context.registros select r;
         return(query.ToList());
     }
 }
 public System.Collections.IList getArticulos()
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from a in context.articuloes select a;
         return(query.ToList());
     }
 }
 public System.Collections.IList getUnidadMedidaById(int id)
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from um in context.unidad_med where um.unidad_id == id select um;
         return(query.ToList());
     }
 }
 public System.Collections.IList getArticuloById(int id)
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from a in context.articuloes where a.articulo_id == id select a;
         return(query.ToList());
     }
 }
 public System.Collections.IList listarLenguajes()
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from c in context.lenguajes select c;
         return(query.ToList());
     }
 }
Exemple #11
0
 public System.Collections.IList getDescripcionById(int id)
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from d in context.descripcions where d.descripcion_id == id select d;
         return(query.ToList());
     }
 }
 public System.Collections.IList getBoms()
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from b in context.boms
                     select b;
         return(query.ToList());
     }
 }
 public void borrarLenguaje(int id)
 {
     using (dbEntities context = new dbEntities())
     {
         lenguaje leng = context.lenguajes.First(l => l.lenguaje_id == id);
         context.lenguajes.Remove(leng);
         context.SaveChanges();
     }
 }
 public void deleteArticulo(int id)
 {
     using (dbEntities context = new dbEntities())
     {
         articulo art = context.articuloes.First(a => a.articulo_id == id);
         context.articuloes.Remove(art);
         context.SaveChanges();
     }
 }
 public System.Collections.IList getBomsByWeek(int week)
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from b in context.boms
                     where b.semana_inicio == week
                     select b;
         return(query.ToList());
     }
 }
 public System.Collections.IList getArticuloDescripcion()
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from a in context.articuloes
                     from d in context.descripcions
                     where a.descripcion_id == d.descripcion_id
                     select new { a.articulo_id, d.descripcion_str };
         return(query.ToList());
     }
 }
        public void updateArticulo(articulo art)
        {
            using (dbEntities context = new dbEntities())
            {
                articulo articulo = context.articuloes.First(a => a.articulo_id == art.articulo_id);

                context.articuloes.Attach(context.articuloes.Single(a => a.articulo_id == art.articulo_id));
                ((IObjectContextAdapter)context).ObjectContext.ApplyCurrentValues("articulos", art);
                context.SaveChanges();
            }
        }
 public System.Collections.IList getDescripcionUM()
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from um in context.unidad_med
                     from d in context.descripcions
                     where um.descripcion_id == d.descripcion_id
                     select new { um.unidad_id, d.descripcion_str };
         return(query.ToList());
     }
 }
        public int addRegistro()
        {
            using (dbEntities context = new dbEntities())
            {
                registro reg = new registro();

                context.registros.Add(reg);
                context.SaveChanges();

                return(reg.registro_id);
            }
        }
 public System.Collections.IList buscarArticulos(string nombre)
 {
     using (dbEntities context = new dbEntities())
     {
         var query = from a in context.articuloes
                     from d in context.descripcions
                     where a.descripcion_id == d.descripcion_id
                     where d.descripcion_str.Contains(nombre)
                     select new  { d.descripcion_str, a.articulo_id };
         return(query.ToList());
     }
 }
        public System.Collections.IList getBomsByWeek(DateTime date)
        {
            int week = WeekOfTheYear(date);

            using (dbEntities context = new dbEntities())
            {
                var query = from b in context.boms
                            where b.semana_inicio == week
                            select b;
                return(query.ToList());
            }
        }
 public System.Collections.IList getTipoArticulos()
 {
     using (dbEntities context = new dbEntities())
     {
         DescripcionDAO dDAO  = new DescripcionDAO();
         var            query = from ta in context.tipo_articulo
                                from d in context.descripcions
                                where ta.descripcion_id == d.descripcion_id
                                select new { ta.tipo_id, d.descripcion_str };
         return(query.ToList());
     }
 }
        public void addTipoArticulo(string descripcion)
        {
            DescripcionDAO dDAO = new DescripcionDAO();
            tipo_articulo  tArt = new tipo_articulo();

            tArt.descripcion_id = dDAO.addDescripcion(descripcion);

            using (dbEntities context = new dbEntities())
            {
                context.tipo_articulo.Add(tArt);
                context.SaveChanges();
            }
        }
 public System.Collections.IList getDescripcionTAById(int id)
 {
     using (dbEntities context = new dbEntities())
     {
         DescripcionDAO dDAO  = new DescripcionDAO();
         var            query = from ta in context.tipo_articulo
                                from d in context.descripcions
                                where ta.descripcion_id == d.descripcion_id
                                where ta.tipo_id == id
                                select d.descripcion_str;
         return(query.ToList());
     }
 }
 public void deleteBom(int id)
 {
     using (dbEntities context = new dbEntities())
     {
         RegistroDAO rDAO = new RegistroDAO();
         bom         bom  = context.boms.First(b => b.bom_id == id);
         //bom.registro_id = rDAO.addRegistro();
         bom.registro_id = 1;
         bom.activo      = 0;
         ((IObjectContextAdapter)context).ObjectContext.ApplyCurrentValues("boms", bom);
         context.SaveChanges();
     }
 }
Exemple #26
0
        public int addDescripcion(string descripcion)
        {
            using (dbEntities context = new dbEntities())
            {
                descripcion d = new descripcion();

                d.lenguaje_id     = 1;
                d.descripcion_str = descripcion;

                context.descripcions.Add(d);
                context.SaveChanges();
                return(d.descripcion_id);
            }
        }
 public void addBom(bom bom)
 {
     using (dbEntities context = new dbEntities())
     {
         RegistroDAO rDAO = new RegistroDAO();
         bom.registro_id = rDAO.addRegistro();
         //bom.registro_id = 1;
         bom.activo        = 1;
         bom.semana_inicio = WeekOfTheYear(bom.fecha_inicio);
         bom.semana_fin    = WeekOfTheYear(bom.fecha_fin);
         context.boms.Add(bom);
         context.SaveChanges();
     }
 }
 public void addArticulo(float precioStd, string descripcion, int tipoArticulo, int um)
 {
     using (dbEntities context = new dbEntities())
     {
         articulo       art  = new articulo();
         DescripcionDAO dDAO = new DescripcionDAO();
         RegistroDAO    rDAO = new RegistroDAO();
         art.descripcion_id = dDAO.addDescripcion(descripcion);
         art.precio_std     = precioStd;
         //art.codigo = codigo;
         art.tipo_articulo = tipoArticulo;
         art.unidad_med    = um;
         art.registro_id   = rDAO.addRegistro();
         context.articuloes.Add(art);
         context.SaveChanges();
     }
 }
 public System.Collections.IList Implosion(List <int> id)
 {
     using (dbEntities context = new dbEntities())
     {
         var idPadres = getPadres(id);
         if (idPadres == id)
         {
             return(null);
         }
         else
         {
             var arts = from a in context.articuloes
                        where idPadres.Contains(a.articulo_id)
                        select new { a.articulo_id, a.tipo_articulo, a.descripcion_id };
             return(arts.ToList());
         }
     }
 }
        //Implosion

        public List <int> getPadres(List <int> idHijos)
        {
            using (dbEntities context = new dbEntities())
            {
                var idPadres = context.boms
                               .Where(padre => idHijos.Contains(padre.articulo_hijo))
                               .Select(padre => padre.articulo_padre)
                               .ToList();
                if (idPadres.Count == 0)
                {
                    return(idHijos);
                }
                else
                {
                    return(getPadres(idPadres));
                }
            }
        }