Example #1
0
        public void Recibir(Recepcion recepcion)
        {
            foreach (var detalle in recepcion.Detalle)
            {
                int idArticulo = detalle.Articulo.Id;
                int cantidad   = detalle.Cantidad;

                var stock = this.Obtener(recepcion.UbicacionDestino.Id, idArticulo);
                if (stock == null)
                {
                    stock = new Stock()
                    {
                        Ubicacion = recepcion.UbicacionDestino,
                        Articulo  = detalle.Articulo,
                        Cantidad  = 0
                    };
                    this.Alta(stock);
                }
                stock.Cantidad += cantidad;
                this.Modificacion(stock);
            }
        }
 partial void DeleteRecepcion(Recepcion instance);
 partial void UpdateRecepcion(Recepcion instance);
 partial void InsertRecepcion(Recepcion instance);
Example #5
0
        public void ObtenerArchivoCSV(string Location, decimal nitCli, decimal idUser)
        {
            try
            {
                //EN CASO DE QUE OMITA LA RECEPCION ESTO SON LOS DATOS POR DEFAULT
                decimal nitCliente = nitCli;
                decimal idUsuario  = idUser;

                DirectoryInfo info = new DirectoryInfo(Location);
                foreach (DirectoryInfo info2 in info.GetDirectories())
                {
                    long    idRecepcion = 0;
                    decimal numeroLote  = 0;

                    //SI ENCUENTRA UNA CARPETA CON STRINGS LA OMITE
                    try
                    {
                        numeroLote = Convert.ToDecimal(info2.Name);
                    }
                    catch (Exception)
                    {
                        continue;
                    }

                    int omiteRecepcion = Int16.Parse(bd.Parametros.Where(c => c.codigo == "OMITE_RECEP").First().valor);

                    //OMITO EL MODULO DE RECEPCION
                    if (omiteRecepcion == 0)
                    {
                        int reg_recep = bd.Recepcion.Where(c => c.numeroLote == numeroLote && c.estado == 0 && c.activo == true).Count();
                        //BUSCO QUE EL LOTE HAYA SIDO RECEPCIONADO DE LO CONTRARIO NO LO CARGA
                        if (reg_recep > 0)
                        {
                            Recepcion reg_recepcion = bd.Recepcion.Where(c => c.numeroLote == numeroLote && c.estado == 0 && c.activo == true).First();
                            idRecepcion = reg_recepcion.id;

                            reg_recepcion.estado      = 1;
                            reg_recepcion.fechaCargue = DateTime.Now;

                            nitCliente = (decimal)reg_recepcion.nitCliente;
                            idUsuario  = (decimal)reg_recepcion.idUsuario;

                            bd.SubmitChanges();
                        }
                        else
                        {
                            continue;
                        }
                    }

                    foreach (FileInfo info3 in info2.GetFiles("*.CSV"))
                    {
                        var source = from b in this.ObtenerRegistrosArchivoCSV(info3.FullName, Path.GetFileName(info3.Name), nitCliente, info2.Name, idUsuario)
                                     group b by new { NomArchivo = b.NomArchivo, lfecha = b.LoteFecha.ToString("MM/dd/yyyy"), Lote = b.Lote, ConsecutivoLote = b.ConsecutivoLote, CodBarras = b.CodBarras } into g
                                             select new { NomArchivo = g.Key.NomArchivo, lfecha = g.Key.lfecha, Lote = g.Key.Lote, ConsecutivoLote = g.Key.ConsecutivoLote, cuenta = g.Count <BOCargueLotes>(), CodBarras = g.Key.CodBarras };
                        List <BOCargueLotes> lst = new List <BOCargueLotes>();
                        foreach (var type in source.ToList())
                        {
                            BOCargueLotes item = new BOCargueLotes
                            {
                                NomArchivo      = type.NomArchivo,
                                Lote            = type.Lote,
                                Paginas         = type.cuenta,
                                ConsecutivoLote = type.ConsecutivoLote,
                                FechaCargue     = DateTime.Now,
                                Usuario         = idUsuario,
                                idRecepcion     = idRecepcion,
                                CodBarras       = type.CodBarras,
                                //LoteFecha = Convert.ToDateTime(type.lfecha),
                                LoteFecha  = DateTime.Now,
                                Cliente    = nitCliente,
                                LoteScaner = info2.Name
                            };
                            lst.Add(item);
                        }
                        this.InsertarCargueLotes(lst);
                    }
                }
            }
            catch (Exception exception)
            {
                log.WriteEntry("Error en BLLCargue  " + exception.Message, EventLogEntryType.Error);
                throw;
            }
        }