Пример #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);
        }
        public CommandResult Handle(InsertarActualizarVentaCotizacionDetalleCommand command)
        {
            if (command == null)
            {
                throw new ArgumentException("Tiene que ingresar una cliente");
            }


            VentaCotizacionDetalle dominio = null;

            if (command.idcotizaciondetalle.HasValue)
            {
                dominio = _VentaCotizacionDetalleRepository.Get(x => x.idcotizaciondetalle == command.idcotizaciondetalle).LastOrDefault();
            }
            else
            {
                dominio = new VentaCotizacionDetalle();
            }


            dominio.cantidad          = command.cantidad;
            dominio.costototal        = command.costototal;
            dominio.costounitario     = command.costounitario;
            dominio.descripcion       = command.descripcion;
            dominio.descuentounitario = command.descuentounitario;
            dominio.idcotizacion      = command.idcotizacion;
            dominio.iddiagnostico     = command.iddiagnostico;
            dominio.idproducto        = command.idproducto;
            dominio.idreparacion      = command.idreparacion;

            try
            {
                if (!command.idcotizaciondetalle.HasValue)
                {
                    _VentaCotizacionDetalleRepository.Add(dominio);
                }
                _VentaCotizacionDetalleRepository.Commit();


                return(new InsertarActualizarVentaCotizacionDetalleOutput()
                {
                    idcotizaciondetalle = dominio.idcotizaciondetalle
                });
            }
            catch (Exception ex)
            {
                //  _ValortablaRepository.Delete(dominio);
                //_ValortablaRepository.Commit();
                throw;
            }
        }
Пример #3
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);
        }