Esempio n. 1
0
        public void GenerarCotizacion()
        {
            // Se guarda la cotización en la base de datos
            var dAhora = DateTime.Now;
            var oCot   = new VentaCotizacion()
            {
                Fecha      = dAhora,
                SucursalID = GlobalClass.SucursalID,
                ClienteID  = this.oControlVentas.Cliente.ClienteID,
                VendedorID = this.oControlVentas.ctlCobro.VendodorID
            };

            Datos.Guardar <VentaCotizacion>(oCot);
            // Detalle
            var oVentaDetalle = this.oControlVentas.GenerarVentaDetalle();

            foreach (var oReg in oVentaDetalle)
            {
                var oParteCot = new VentaCotizacionDetalle()
                {
                    VentaCotizacionID = oCot.VentaCotizacionID,
                    ParteID           = oReg.ParteID,
                    Cantidad          = oReg.Cantidad,
                    PrecioUnitario    = oReg.PrecioUnitario,
                    Iva = oReg.Iva
                };
                Datos.Guardar <VentaCotizacionDetalle>(oParteCot);
            }

            // Para generar el ticket de la cotización
            var oVendedor = Datos.GetEntity <Usuario>(q => q.UsuarioID == this.oControlVentas.ctlCobro.VendodorID && q.Estatus);
            var oVentaV   = new VentasView()
            {
                Fecha      = dAhora,
                Cliente    = this.oControlVentas.Cliente.Nombre,
                Vendedor   = oVendedor.NombrePersona,
                Total      = this.oControlVentas.Total,
                SucursalID = GlobalClass.SucursalID
            };
            List <VentasDetalleView> oVentaDetalleV = new List <VentasDetalleView>();
            Parte oParte;

            foreach (var oDet in oVentaDetalle)
            {
                oParte = Datos.GetEntity <Parte>(q => q.ParteID == oDet.ParteID && q.Estatus);
                oVentaDetalleV.Add(new VentasDetalleView()
                {
                    NumeroParte    = oParte.NumeroParte,
                    NombreParte    = oParte.NombreParte,
                    Cantidad       = oDet.Cantidad,
                    PrecioUnitario = oDet.PrecioUnitario,
                    Iva            = oDet.Iva
                });
            }
            VentasLoc.GenerarTicketDeCotizacion(oVentaV, oVentaDetalleV);
        }
Esempio n. 2
0
        public void GenerarCotizacion()
        {
            // Se guarda la cotización en la base de datos
            var dAhora = DateTime.Now;
            var oCot = new VentaCotizacion()
            {
                Fecha = dAhora,
                SucursalID = GlobalClass.SucursalID,
                ClienteID = this.oControlVentas.Cliente.ClienteID,
                VendedorID = this.oControlVentas.ctlCobro.VendodorID
            };
            Datos.Guardar<VentaCotizacion>(oCot);
            // Detalle
            var oVentaDetalle = this.oControlVentas.GenerarVentaDetalle();
            foreach (var oReg in oVentaDetalle)
            {
                var oParteCot = new VentaCotizacionDetalle()
                {
                    VentaCotizacionID = oCot.VentaCotizacionID,
                    ParteID = oReg.ParteID,
                    Cantidad = oReg.Cantidad,
                    PrecioUnitario = oReg.PrecioUnitario,
                    Iva = oReg.Iva
                };
                Datos.Guardar<VentaCotizacionDetalle>(oParteCot);
            }

            // Para generar el ticket de la cotización
            var oVendedor = Datos.GetEntity<Usuario>(q => q.UsuarioID == this.oControlVentas.ctlCobro.VendodorID && q.Estatus);
            var oVentaV = new VentasView()
            {
                Fecha = dAhora,
                Cliente = this.oControlVentas.Cliente.Nombre,
                Vendedor = oVendedor.NombrePersona,
                Total = this.oControlVentas.Total,
                SucursalID = GlobalClass.SucursalID
            };
            List<VentasDetalleView> oVentaDetalleV = new List<VentasDetalleView>();
            Parte oParte;
            foreach (var oDet in oVentaDetalle)
            {
                oParte = Datos.GetEntity<Parte>(q => q.ParteID == oDet.ParteID && q.Estatus);
                oVentaDetalleV.Add(new VentasDetalleView()
                {
                    NumeroParte = oParte.NumeroParte,
                    NombreParte = oParte.NombreParte,
                    Cantidad = oDet.Cantidad,
                    PrecioUnitario = oDet.PrecioUnitario,
                    Iva = oDet.Iva
                });
            }
            VentasLoc.GenerarTicketDeCotizacion(oVentaV, oVentaDetalleV);
        }
Esempio n. 3
0
        public CommandResult Handle(InsertarActualizarVentaCotizacionCommand command)
        {
            if (command == null)
            {
                throw new ArgumentException("Tiene que ingresar una cliente");
            }


            VentaCotizacion dominio = null;

            if (command.idcotizacion.HasValue)
            {
                dominio = _VentaCotizacionRepository.Get(x => x.idcotizacion == command.idcotizacion).LastOrDefault();
            }
            else
            {
                dominio = new VentaCotizacion();
            }



            switch (command.__tipooperacion)
            {
            case 1:
                dominio.fechahoraregistro    = command.fechahoraregistro;
                dominio.aceptado             = command.aceptado;
                dominio.descuento            = command.descuento;
                dominio.descuentonotacredito = command.descuentonotacredito;
                dominio.generoventa          = command.generoventa;
                dominio.idcliente            = command.idcliente;
                dominio.idmoneda             = command.idmoneda;
                dominio.idnotacredito        = command.idnotacredito;
                dominio.idordenservicio      = command.idordenservicio;
                dominio.idsucursal           = command.idsucursal;
                dominio.idusuarioregistro    = command.idusuarioregistro;
                dominio.igv         = command.igv;
                dominio.notacredito = command.notacredito;
                dominio.subtotal    = command.subtotal;
                dominio.tipocambio  = command.tipocambio;
                dominio.total       = command.total;
                break;

            case 2:
                dominio.aceptado = command.aceptado;
                break;

            default:
                break;
            }



            try
            {
                if (!command.idcotizacion.HasValue)
                {
                    _VentaCotizacionRepository.Add(dominio);
                }
                _VentaCotizacionRepository.Commit();


                return(new InsertarActualizarVentaCotizacionOutput()
                {
                    idcotizacion = dominio.idcotizacion
                });
            }
            catch (Exception ex)
            {
                //  _ValortablaRepository.Delete(dominio);
                //_ValortablaRepository.Commit();
                throw;
            }
        }