public bool guardarDB(List <in_Producto_Composicion_Info> Lista)
        {
            try
            {
                using (Entities_inventario Context = new Entities_inventario())
                {
                    foreach (var item in Lista)
                    {
                        in_Producto_Composicion Entity = new in_Producto_Composicion
                        {
                            IdEmpresa       = item.IdEmpresa,
                            IdProductoPadre = item.IdProductoPadre,
                            IdProductoHijo  = item.IdProductoHijo,
                            IdUnidadMedida  = item.IdUnidadMedida,
                            Cantidad        = item.Cantidad,
                        };
                        Context.in_Producto_Composicion.Add(Entity);
                    }
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        public Boolean GrabarDB(List <in_Producto_Composicion_Info> ListInfo, decimal IdProductoPadre, ref string mensaje)
        {
            try
            {
                using (EntitiesInventario context = new EntitiesInventario())
                {
                    foreach (var item in ListInfo)
                    {
                        var address = new in_Producto_Composicion();

                        address.IdEmpresa       = item.IdEmpresa;
                        address.IdProductoPadre = IdProductoPadre;
                        address.IdProductoHijo  = item.IdProductoHijo;
                        address.IdUnidadMedida  = item.IdUnidadMedida;
                        address.Cantidad        = item.Cantidad;

                        context.in_Producto_Composicion.Add(address);
                        context.SaveChanges();
                    }
                    context.Dispose();
                    mensaje = "Guardado con exito";
                    return(true);
                }
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.ToString() + " " + ex.Message;
                throw new Exception(mensaje);
            }
        }