private void btnTerminar_Click(object sender, EventArgs e)
        {
            if (dgvGrilla.RowCount > 0)
            {
                if (MessageBox.Show("Esta Seguro de Agregar Productos a Este Pedido?", "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    ProductoDto producto = new ProductoDto();

                    string  segunda = string.Empty;
                    decimal total   = 0;

                    foreach (var item in ListaVenta)
                    {
                        producto = productoServicio.ObtenerPorId(item.Id);

                        segunda += " " + producto.Descripcion + " ";

                        //stock
                        productoServicio.BajarStock(producto.Id, item.Cantidad);

                        total += item.Precio * item.Cantidad;
                    }

                    pedidoServicio.SumarTotal(_PedidoId, total);//sumar el total del pedido

                    foreach (var item in ListaVenta)
                    {
                        var aux = new Producto_Pedido_Dto
                        {
                            Cantidad    = item.Cantidad,
                            ProductoId  = productoServicio.ObtenerPorId(item.Id).Id,
                            Estado      = AccesoDatos.EstadoPedido.Esperando,
                            Talle       = item.Talle,
                            PedidoId    = _PedidoId,
                            Descripcion = segunda,
                            TalleId     = talleServicio.BuscarNombreDevuelveId(item.Talle),
                            Precio      = item.Precio
                        };

                        var _Id_Pedido = producto_Pedido_Servicio.NuevoProductoPedido(aux);

                        if (_Pedido.Proceso != AccesoDatos.Proceso.Guardado || _Pedido.Proceso != AccesoDatos.Proceso.Retirado)
                        {
                            if (_Semaforo)
                            {
                                //datos
                                if (productoServicio.ObtenerPorId(item.Id).Creacion)
                                {
                                    for (int i = 0; i < item.Cantidad; i++)
                                    {
                                        var dato = new Producto_Dato_Dto
                                        {
                                            EstadoPorPedido   = AccesoDatos.EstadoPorPedido.EnEspera,
                                            Producto_PedidoId = _Id_Pedido
                                        };

                                        producto_Dato_Servicio.Insertar(dato);
                                    }
                                }
                            }
                        }

                        var ctacte = ctaCteServicio.ObtenerPorIdDePedidosId(_PedidoId);

                        ctaCteServicio.SumarLoQueDebe(total, _clienteId, ctacte.Id);
                    }

                    Bandera = true;

#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 mensaje = new Afirmacion("Guardado", "Se Agregaron Productos");
#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'.
                    mensaje.ShowDialog();

                    btnVolver.PerformClick();
                }
            }
        }
示例#2
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);
            }
        }