예제 #1
0
        /// <summary>
        /// Almacena el registro de una ENTIDAD de registro de Tipo ListaDePrecioDetalle
        /// En la BASE de DATO la Tabla : [GestionComercial.ListaDePrecioDetalle]
        /// <summary>
        /// <param name="listaListaDePrecioDetalle"></param>
        /// <param name="listaProductoPrecio"></param>
        /// <returns></returns>
        public ReturnValor InsertDetalle(List <BEListaDePrecioDetalle> lstListaDePrecioDetalle, List <BEProductoPrecio> lstProductoPrecio)
        {
            try
            {
                using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required))
                {
                    int indPRECIO_UPDATE = -1;
                    foreach (BEListaDePrecioDetalle listaPrecioDetalle in lstListaDePrecioDetalle)
                    {
                        returnValor.codRetorno = listaDePrecioDetalleData.Insert(listaPrecioDetalle);
                        if (returnValor.codRetorno != 0)
                        {
                            returnValor.Exitosa = true;
                        }
                        ProductoPrecioData productoPrecioData = new ProductoPrecioData();
                        lstProductoPrecio = productoPrecioData.List(new BaseFiltro {
                            codProducto = listaPrecioDetalle.codProducto, codRegMoneda = string.Empty, codListaPrecio = null, codPerEmpresa = listaPrecioDetalle.CodigoPersonaEmpre, codPuntoVenta = listaPrecioDetalle.CodigoPuntoVenta, indEstado = true
                        });
                        if (lstProductoPrecio.Count == 1)
                        {
                            if (listaPrecioDetalle.refEsParaVenta)
                            {
                                lstProductoPrecio[0].ValorVenta = listaPrecioDetalle.PrecioUnitario;
                            }
                            else
                            {
                                lstProductoPrecio[0].ValorCosto = listaPrecioDetalle.PrecioUnitario;
                            }
                            lstProductoPrecio[0].SegUsuarioCrea  = listaPrecioDetalle.segUsuarioEdita;
                            lstProductoPrecio[0].SegUsuarioEdita = listaPrecioDetalle.segUsuarioEdita;

                            lstProductoPrecio[0].CodigoArguMoneda  = listaPrecioDetalle.CodigoArguMoneda;
                            lstProductoPrecio[0].codProducto       = listaPrecioDetalle.codProducto;
                            lstProductoPrecio[0].CodigoPuntoVenta  = listaPrecioDetalle.CodigoPuntoVenta;
                            lstProductoPrecio[0].CodigoListaPrecio = listaPrecioDetalle.CodigoLista;
                            lstProductoPrecio[0].Estado            = true;

                            indPRECIO_UPDATE = productoPrecioData.Insert(lstProductoPrecio[0]);
                        }
                    }
                    if (returnValor.Exitosa && indPRECIO_UPDATE != 0)
                    {
                        returnValor.Message = HelpEventos.MessageEvento(HelpEventos.Process.NEW);
                        tx.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                returnValor = HelpException.mTraerMensaje(ex);
            }
            return(returnValor);
        }
예제 #2
0
        /// <summary>
        /// Almacena el registro de una ENTIDAD de registro de Tipo ListaDePrecioDetalle
        /// En la BASE de DATO la Tabla : [GestionComercial.ListaDePrecioDetalle]
        /// <summary>
        /// <param name="itemListaDePrecioDetalle"></param>
        /// <param name="listaProductoPrecio"></param>
        /// <returns></returns>
        public ReturnValor UpdateDetalle(BEListaDePrecioDetalle itemListaDePrecioDetalle, List <BEProductoPrecio> listaProductoPrecio)
        {
            try
            {
                using (TransactionScope tx = new TransactionScope(TransactionScopeOption.Required))
                {
                    int indPrecioUpdate = -1;
                    returnValor.Exitosa = listaDePrecioDetalleData.Update(itemListaDePrecioDetalle);

                    ProductoPrecioData productoPrecioData = new ProductoPrecioData();
                    //listaProductoPrecio = oProductoPrecioData.List(itemListaDePrecioDetalle.CodigoProducto, string.Empty, null, itemListaDePrecioDetalle.CodigoPersonaEmpre, itemListaDePrecioDetalle.CodigoPuntoVenta, true);
                    if (listaProductoPrecio.Count == 1)
                    {
                        if (itemListaDePrecioDetalle.refEsParaVenta)
                        {
                            listaProductoPrecio[0].ValorVenta = itemListaDePrecioDetalle.PrecioUnitario;
                        }
                        else
                        {
                            listaProductoPrecio[0].ValorCosto = itemListaDePrecioDetalle.PrecioUnitario;
                        }
                        listaProductoPrecio[0].SegUsuarioCrea  = itemListaDePrecioDetalle.segUsuarioEdita;
                        listaProductoPrecio[0].SegUsuarioEdita = itemListaDePrecioDetalle.segUsuarioEdita;
                        indPrecioUpdate = productoPrecioData.Insert(listaProductoPrecio[0]);
                    }
                    if (returnValor.Exitosa && indPrecioUpdate != 0)
                    {
                        returnValor.Message = HelpEventos.MessageEvento(HelpEventos.Process.EDIT);
                        tx.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                returnValor = HelpException.mTraerMensaje(ex);
            }
            return(returnValor);
        }