示例#1
0
        public static void GenerarRemision(RNOrdenRecepcion recepcion, List <RNPartidasRecepcion> partidas, List <RNRecepcion.Lotes> lotes)
        {
            // generar la remision en la inportadora
            int    numEmpresa     = RNLbInventory.ObtenerImportadora().NumEmpresa;
            int    folio          = 0;
            string cveDocRecpcion = GenerarCveRemision("R", null, numEmpresa, out folio);
            List <RNPartidasRemision> partidasRemision = null;
            RNOrdenRemision           remision         = RNOrdenRemision.GenerarRemision(cveDocRecpcion, recepcion, folio, numEmpresa, partidas, lotes, out partidasRemision);

            // actualizar las existencias
            foreach (var part in partidasRemision)
            {
                RNLbInventory.ActualizarExistencias(part.CVE_ART, recepcion.NUM_ALMA, -1, part.CANT, numEmpresa);
            }
        }
        public static void GenerarRecepcion(DataGridView dataGridCompras, string cveDoc, int numEmpresa, RNPedimento pedimento)
        {
            try
            {
                List <Lotes> lotes = new List <Lotes>();
                // se obtiene el folio y la clave de la Recepción
                int    folio          = 0;
                string cveDocRecpcion = GenerarRecepcion("r", null, numEmpresa, out folio);
                List <RNPartidasRecepcion> partidas = new List <RNPartidasRecepcion>();
                // se crea el documento de recepción y sus partidas
                //registrar cabecera y patidas
                RNOrdenRecepcion recepcion = new RNOrdenRecepcion().GenerarRecepcion(cveDoc, cveDocRecpcion, folio, numEmpresa, out partidas);


                for (int fila = 0; fila < dataGridCompras.Rows.Count; fila++)
                {
                    for (int col = 8; col < dataGridCompras.Rows[fila].Cells.Count; col = col + 2)
                    {
                        if (lotes.Any(x => x.lote == dataGridCompras.Rows[fila].Cells[col].Value.ToString()))
                        {
                            foreach (var l in lotes)
                            {
                                if (l.lote == dataGridCompras.Rows[fila].Cells[col].Value.ToString())
                                {
                                    l.contador++;
                                }
                            }
                        }
                        else
                        {
                            Lotes lotes1 = new Lotes();
                            lotes1.articulo  = dataGridCompras.Rows[fila].Cells[6].Value.ToString();
                            lotes1.contador  = 1;
                            lotes1.lote      = dataGridCompras.Rows[fila].Cells[col].Value.ToString();
                            lotes1.caducidad = Convert.ToDateTime(dataGridCompras.Rows[fila].Cells[col + 1].Value.ToString());
                            lotes1.partida   = Convert.ToInt32(dataGridCompras.Rows[fila].Cells[0].Value.ToString());
                            lotes.Add(lotes1);
                        }
                    }
                }
                foreach (var l in lotes)
                {
                    if (ValidarLote(l.lote, pedimento.numPedimento, numEmpresa))
                    {
                        l.reg_ltpd        = AgregarLote(l.lote, pedimento, l.articulo, l.caducidad, l.contador, 1, "A", DateTime.Now, numEmpresa);
                        l.reg_ltpd_Enlace = RNLbInventory.RegistrarEnlace(l.reg_ltpd, l.contador, numEmpresa);
                        l.minve_id        = RNLbInventory.RegistrarMovInveRecepcion(partidas.Where(x => x.NUM_PAR == l.partida).FirstOrDefault(), recepcion, l.reg_ltpd_Enlace, 1, numEmpresa);
                    }
                    else
                    {
                        l.reg_ltpd        = ActualizarLote(l.lote, pedimento.numPedimento, l.articulo, l.caducidad, l.contador, 1, "A", DateTime.Now, numEmpresa);
                        l.reg_ltpd_Enlace = RNLbInventory.RegistrarEnlace(l.reg_ltpd, l.contador, numEmpresa);
                        l.minve_id        = RNLbInventory.RegistrarMovInveRecepcion(partidas.Where(x => x.NUM_PAR == l.partida).FirstOrDefault(), recepcion, l.reg_ltpd_Enlace, 1, numEmpresa);
                    }

                    RNPartidasRecepcion.ActualizarPartida(recepcion.CVE_DOC, l.partida, l.reg_ltpd_Enlace, l.minve_id, numEmpresa);
                    RNLbInventory.ActualizarExistencias(partidas.Where(x => x.NUM_PAR == l.partida).FirstOrDefault().CVE_ART, recepcion.NUM_ALMA, 1, partidas.Where(x => x.NUM_PAR == l.partida).FirstOrDefault().CANT, numEmpresa);
                }
                if (RNLbInventory.ObtenerImportadora().NumEmpresa == numEmpresa)
                {
                    RNRemision.GenerarRemision(recepcion, partidas, lotes);
                    GenerarRecepcionComercializadora(recepcion, partidas, lotes, pedimento);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Error al generar la recepción:  " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }