Example #1
0
        // POST: api/Venta
        public void Post([FromBody] VentaDto value)
        {
            using (var session = Database.SessionFactory.OpenSession())
            {
                var venta = new Venta
                {
                    Cliente = session.Load <Cliente>(value.IdCliente),
                    Items   = new List <Item>()
                };

                foreach (var itemDto in value.Items)
                {
                    var producto = session.Load <Producto>(itemDto.IdProducto);
                    venta.Items.Add(
                        new Item
                    {
                        Producto = producto,
                        Cantidad = itemDto.Cantidad,
                        Venta    = venta
                    });
                }

                session.Save(venta);
                session.Flush();
            }
        }
Example #2
0
        //// PUT: api/Venta/5
        //public void Put(int id, [FromBody]string cliente)
        //{
        //}

        // DELETE: api/Venta/5
        public GenericResponse <String> Delete(int id)
        {
            GenericResponse <String> response = new GenericResponse <String>();

            try
            {
                JwtDecodeModel usuarioActual = UsuarioUtil.GetUsuarioActual();

                bool esVendedor = UsuarioUtil.EsVendedor();


                VentaDto venta = servicio.BuscarPorId(id);

                if (esVendedor && venta.Trabajador.Id != usuarioActual.Id)
                {
                    throw new CustomResponseException("No estas autorizado para realizar esta acción", 400);
                }

                servicio.Eliminar(id);
                response = ResponseUtil.CrearRespuestaOk();
            }
            catch (CustomResponseException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new CustomResponseException(ex.Message, 500);
            }


            return(response);
        }
Example #3
0
        public Venta()
        {
            InitializeComponent();

            productoServicio    = new ProductoServicio();
            producto_vent       = new Producto_Venta_Servicio();
            ventaServicio       = new VentaServicio();
            producto            = new ProductoDto();
            detalleCajaServicio = new DetalleCajaServicio();
            cajaServicio        = new CajaServicio();
            clienteServicio     = new ClienteServicio();
            talleServicio       = new TalleServicio();

            CargarTalle();

            ListaVenta  = new List <VentaDto2>();
            ListaCtaCte = new List <Producto_Venta_Dto>();
            ventaDto    = new VentaDto();

            ConsumidorFinall();

            CargarGrilla(ListaVenta);

            btnSeleccionProducto.Select();

            CargarImageEnGeneral();
        }
        public AgregarProductos(long pedidoId, bool semaforo)
        {
            InitializeComponent();

            productoServicio         = new ProductoServicio();
            producto_vent            = new Producto_Venta_Servicio();
            ventaServicio            = new VentaServicio();
            detalleCajaServicio      = new DetalleCajaServicio();
            cajaServicio             = new CajaServicio();
            clienteServicio          = new ClienteServicio();
            talleServicio            = new TalleServicio();
            pedidoServicio           = new PedidoServicio();
            producto_Dato_Servicio   = new Producto_Dato_Servicio();
            producto_Pedido_Servicio = new Producto_Pedido_Servicio();
            ctaCteServicio           = new CtaCteServicio();

            producto   = new ProductoDto();
            ListaVenta = new List <VentaDto2>();
            ventaDto   = new VentaDto();

            _Semaforo = semaforo;

            _PedidoId  = pedidoId;
            _Pedido    = pedidoServicio.BuscarIDPedidos(pedidoId);
            _clienteId = _Pedido.ClienteId;
            Bandera    = false;

            CargarTalle();
            CargarDatos();
            CargarGrilla(ListaVenta);

            CargarImageEnGeneral();
        }
Example #5
0
        private void btnLimpiar_Click(object sender, EventArgs e)
        {
            txtProducto.Text  = string.Empty;
            txtColegio.Text   = string.Empty;
            nudCantidad.Value = 1;
            nudPrecio.Value   = 0;

            nudTotal.Value      = 0;
            txtVuelto.Text      = string.Empty;
            txtDescripcion.Text = string.Empty;

            nudPagaron.Value    = 0;
            nudTotalVenta.Value = 0;

            _total = 0;

            _productoId = 0;
            _clienteId  = 0;

            cmbTalle.SelectedIndex = 0;

            ListaVenta  = new List <VentaDto2>();
            ListaCtaCte = new List <Producto_Venta_Dto>();
            ventaDto    = new VentaDto();

            ConsumidorFinall();

            CargarGrilla(ListaVenta);
        }
Example #6
0
        private void btnCobro_Click(object sender, EventArgs e)
        {
            if (cajaServicio.BuscarCajaAbierta() != null)
            {
                if (nudCobro.Value > 0)
                {
                    if (MessageBox.Show("Esta Por Cobrar Un Adelanto, Desea Continuar?", "Adelanto", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        arregloServicio.Cobrar(_ArregloId, nudCobro.Value);

                        //caja
                        var detalle = new DetalleCajaDto
                        {
                            Descripcion = $"{lblCliente.Text} - Cobro Adelanto",
                            Fecha       = DateTime.Now.ToLongDateString(),
                            Total       = _Debe,
                            CajaId      = detalleCajaServicio.BuscarCajaAbierta()
                        };

                        TipoPago(detalle);

                        detalleCajaServicio.AgregarDetalleCaja(detalle);

                        cajaServicio.SumarDineroACaja(nudCobro.Value);
                        var venta = new VentaDto
                        {
                            ClienteId = _ArregloDto.ClienteId,
                            Descuento = 0,
                            Fecha     = DateTime.Now,
                            Total     = nudCobro.Value
                        };

                        ventaServicio.NuevaVenta(venta);

                        Datos();

                        //limpieza
                        nudCobro.Value = 0;

                        VerificarSiEstaPagado();

                        var mensaje = new Afirmacion("Adelanto Cobrado", "Continue Con Las Ventas");
                        mensaje.ShowDialog();
                    }

                    return;
                }
                else
                {
                    MessageBox.Show("Error El Valor Tiene Que Ser Mayor a 0", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("La Caja Esta Cerrada", "Caja Cerrada", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
Example #7
0
        private void btnCobro_Click(object sender, EventArgs e)
        {
            if (nudCobro.Value > 0)
            {
                if (MessageBox.Show("Esta Por Cobrar Un Adelanto, Desea Continuar?", "Adelanto", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    var pedido = pedidoServicio.Buscar(PedidoId);

                    //Total Cta Cte

                    var cuentaId = new CtaCteDto();

                    cuentaId = ctaCteServicio.ObtenerPorIdDePedidosId(pedido.Id);

                    ctaCteServicio.Pagar(nudCobro.Value, pedido.ClienteId, cuentaId.Id);

                    //caja

                    var detalle = new DetalleCajaDto
                    {
                        Descripcion = $"{lblPersona.Text} - Adelanto de Pedido",
                        Fecha       = DateTime.Now.ToLongDateString(),
                        Total       = nudCobro.Value,
                        CajaId      = detalleCajaServicio.BuscarCajaAbierta()
                    };

                    TipoPago(detalle);

                    detalleCajaServicio.AgregarDetalleCaja(detalle);

                    cajaServicio.SumarDineroACaja(nudCobro.Value);

                    pedidoServicio.CambiarRamas(nudCobro.Value, PedidoId);

                    var venta = new VentaDto
                    {
                        ClienteId = pedido.ClienteId,
                        Descuento = 0,
                        Fecha     = DateTime.Now,
                        Total     = nudCobro.Value
                    };

                    ventaServicio.NuevaVenta(venta);

#pragma warning disable CS0436 // El tipo 'Afirmacion' de 'C:\Users\Pepe\Source\Repos\JoseSabeckis\KosakoJean\Presentacion.Core\Mensaje\Afirmacion.cs' está en conflicto con el tipo importado 'Afirmacion' de 'Presentacion, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se usará el tipo definido en 'C:\Users\Pepe\Source\Repos\JoseSabeckis\KosakoJean\Presentacion.Core\Mensaje\Afirmacion.cs'.
                    var completado = new Afirmacion("Felicidades!", $"Completado \nSe obtuvo de ganancias $ {nudCobro.Value}\nTipo de Pago: {detalle.TipoPago}");
#pragma warning restore CS0436 // El tipo 'Afirmacion' de 'C:\Users\Pepe\Source\Repos\JoseSabeckis\KosakoJean\Presentacion.Core\Mensaje\Afirmacion.cs' está en conflicto con el tipo importado 'Afirmacion' de 'Presentacion, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se usará el tipo definido en 'C:\Users\Pepe\Source\Repos\JoseSabeckis\KosakoJean\Presentacion.Core\Mensaje\Afirmacion.cs'.
                    completado.ShowDialog();

                    nudCobro.Value = 0;

                    Datos(PedidoId);
                }
            }
        }
Example #8
0
        public static Venta ToVenta(VentaDto dto)
        {
            Venta venta = new Venta
            {
                Id         = dto.Id,
                Descuento  = dto.Descuento,
                Fecha      = dto.Fecha,
                Trabajador = TrabajadorMapper.ToTrabajador(dto.Trabajador),
                Cliente    = ClienteMapper.ToCliente(dto.Cliente),
                Activo     = dto.Activo,
                Detalles   = ToDetalles(dto.Detalles)
            };

            return(venta);
        }
Example #9
0
        public long NuevaVenta(VentaDto ventaDto)
        {
            using (var context = new KosakoDBEntities())
            {
                var nueva = new AccesoDatos.Venta
                {
                    Descuento = ventaDto.Descuento,
                    Fecha     = ventaDto.Fecha,
                    Total     = ventaDto.Total,
                    ClienteId = ventaDto.ClienteId
                };

                context.Ventas.Add(nueva);

                context.SaveChanges();

                return(nueva.Id);
            }
        }
        public CtaCteClientePedido(long clienteId, decimal total, List <Producto_Venta_Dto> listProductoVenta, List <VentaDto2> listVentaDto2)
        {
            InitializeComponent();

            productoServicio         = new ProductoServicio();
            producto_vent            = new Producto_Venta_Servicio();
            producto_Pedido_Servicio = new Producto_Pedido_Servicio();
            clienteServicio          = new ClienteServicio();
            ctaCteServicio           = new CtaCteServicio();
            cajaServicio             = new CajaServicio();
            detallCajaServicio       = new DetalleCajaServicio();
            ventaServicio            = new VentaServicio();
            pedidoServicio           = new PedidoServicio();
            talleServicio            = new TalleServicio();

            ventaDto = new VentaDto();

            ListaVentasDto2 = listVentaDto2;
            ListaVenta      = listProductoVenta;

            var cliente = clienteServicio.ObtenerPorId(clienteId);

            cmbHorario.SelectedIndex = 0;

            txtApellido.Text = cliente.Apellido;
            txtNombre.Text   = cliente.Nombre;

            if (txtApellido.Text == "Consumidor Final")
            {
                txtApellido.Text = string.Empty;

                txtApellido.Enabled = true;
                txtNombre.Enabled   = true;
            }

            nudAdelanto.Maximum = total;

            _Total = total;

            _Cliente = cliente;
        }
Example #11
0
        // POST: api/Venta
        public GenericResponse <String> Post([FromBody] VentaDto venta)
        {
            GenericResponse <String> response = new GenericResponse <String>();

            try
            {
                servicio.Crear(venta);
                response = ResponseUtil.CrearRespuestaOk();
            }
            catch (CustomResponseException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new CustomResponseException(ex.Message, 500);
            }


            return(response);
        }
        private void btnLimpiar_Click(object sender, EventArgs e)
        {
            txtProducto.Text  = string.Empty;
            txtColegio.Text   = string.Empty;
            nudCantidad.Value = 1;
            nudPrecio.Value   = 0;

            nudTotal.Value = 0;

            _total = 0;

            _productoId = 0;
            _clienteId  = 0;

            cmbTalle.SelectedIndex = 0;

            ListaVenta = new List <VentaDto2>();
            ventaDto   = new VentaDto();

            CargarGrilla(ListaVenta);
        }
Example #13
0
 public void Crear(VentaDto venta)
 {
     repositorio.Crear(VentaMapper.ToVenta(venta));
 }
Example #14
0
        private void btnTerminar_Click(object sender, EventArgs e)
        {
            if (cajaServicio.BuscarCajaAbierta() != null)
            {
                if (MessageBox.Show("Esta por Terminar el Pedido, Esta Seguro?", "Preguntar", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    var pedido = pedidoServicio.Buscar(PedidoId);

                    pedidoServicio.CambiarProcesoRetirado(pedido.Id);

                    pedidoServicio.CambiarFechaRetirado(pedido.Id);

                    producto_Pedido_Servicio.CambiarEstado(pedido.Id);

                    //Total Cta Cte

                    var cuentaId = new CtaCteDto();

                    if (pedido.ClienteId != 1)
                    {
                        cuentaId = ctaCteServicio.ObtenerPorIdDePedidosId(pedido.Id);

                        ctaCteServicio.Pagar(_Debe, pedido.ClienteId, cuentaId.Id);
                    }

                    //Fin Cta Cte

                    btnTerminar.Visible = false;

                    //caja

                    var detalle = new DetalleCajaDto
                    {
                        Descripcion = $"{lblPersona.Text} - Pedido Terminado",
                        Fecha       = DateTime.Now.ToLongDateString(),
                        Total       = _Debe,
                        CajaId      = detalleCajaServicio.BuscarCajaAbierta()
                    };

                    TipoPago(detalle);

                    detalleCajaServicio.AgregarDetalleCaja(detalle);

                    cajaServicio.SumarDineroACaja(_Debe);

                    pedidoServicio.CambiarRamas(_Debe, PedidoId);

                    var venta = new VentaDto
                    {
                        ClienteId = pedido.ClienteId,
                        Descuento = 0,
                        Fecha     = DateTime.Now,
                        Total     = _Debe
                    };

                    ventaServicio.NuevaVenta(venta);

#pragma warning disable CS0436 // El tipo 'Afirmacion' de 'C:\Users\Pepe\Source\Repos\JoseSabeckis\KosakoJean\Presentacion.Core\Mensaje\Afirmacion.cs' está en conflicto con el tipo importado 'Afirmacion' de 'Presentacion, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se usará el tipo definido en 'C:\Users\Pepe\Source\Repos\JoseSabeckis\KosakoJean\Presentacion.Core\Mensaje\Afirmacion.cs'.
                    var completado = new Afirmacion("Felicidades!", $"Completado \nse obtuvo de ganancias $ {_Debe}\nTipo de Pago: {detalle.TipoPago}");
#pragma warning restore CS0436 // El tipo 'Afirmacion' de 'C:\Users\Pepe\Source\Repos\JoseSabeckis\KosakoJean\Presentacion.Core\Mensaje\Afirmacion.cs' está en conflicto con el tipo importado 'Afirmacion' de 'Presentacion, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se usará el tipo definido en 'C:\Users\Pepe\Source\Repos\JoseSabeckis\KosakoJean\Presentacion.Core\Mensaje\Afirmacion.cs'.
                    completado.ShowDialog();

                    Datos(PedidoId);

                    lblVendido.Visible                    = true;
                    btnAgregarProductos.Visible           = false;
                    btnVolverPedidoNoRetirado.Visible     = true;
                    btnEliminarPedidoSeleccionado.Visible = false;
                }
            }
            else
            {
                MessageBox.Show("la Caja se encuentra cerrada", "Cerrada", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }