Esempio n. 1
0
        private void CargarDGVListarCliente()
        {
            string InformacionDelError = string.Empty;

            ClsTiposDeMontos   TipoDeMonto  = new ClsTiposDeMontos();
            List <TipoDeMonto> ListarMontos = TipoDeMonto.LeerListado(ClsTiposDeMontos.ETipoDeListado.CrearRegistro, ref InformacionDelError);

            ClsCajas    Cajas             = new ClsCajas();
            List <Caja> BuscarCajaAbierta = Cajas.LeerListado(ClsCajas.ETipoListado.CajaAbierta, ref InformacionDelError);

            if (ListarMontos != null && BuscarCajaAbierta != null)
            {
                bool OcultatCierreAperturaCaja = false;

                foreach (TipoDeMonto Elemento in ListarMontos)
                {
                    OcultatCierreAperturaCaja = false;

                    if (BuscarCajaAbierta.Count > 0 && Elemento.ID_TipoDeMonto == (int)ClsTiposDeMontos.ETiposDeMontos.AperturaCaja)
                    {
                        OcultatCierreAperturaCaja = true;
                    }
                    else if (BuscarCajaAbierta.Count == 0 && Elemento.ID_TipoDeMonto == (int)ClsTiposDeMontos.ETiposDeMontos.CierreCaja)
                    {
                        OcultatCierreAperturaCaja = true;
                    }

                    if (!OcultatCierreAperturaCaja)
                    {
                        int NumeroDeFila = dgvListarRegistros.Rows.Add();

                        dgvListarRegistros.Rows[NumeroDeFila].Cells[(int)ENumColDGVRegistro.ID_Cuenta].Value    = Elemento.ID_TipoDeMonto;
                        dgvListarRegistros.Rows[NumeroDeFila].Cells[(int)ENumColDGVRegistro.Nombre].Value       = Elemento.Nombre;
                        dgvListarRegistros.Rows[NumeroDeFila].Cells[(int)ENumColDGVRegistro.Tipo].Value         = Elemento.TipoDeMovimiento.Nombre;
                        dgvListarRegistros.Rows[NumeroDeFila].Cells[(int)ENumColDGVRegistro.EnviarCuenta].Value = "Enviar";
                    }
                }
            }
            else if (InformacionDelError == string.Empty)
            {
                MessageBox.Show("Fallo al listar los montos", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 2
0
        private void BtnImprimir_Click(object sender, EventArgs e)
        {
            if (dgvCaja.Rows.Count > 0)
            {
                string InformacionDelError = string.Empty;

                ClsCajas    Mesas       = new ClsCajas();
                List <Caja> ListarMesas = new List <Caja>();

                using (FrmReportes FormReporteMovimientos = new FrmReportes())
                {
                    // creo el data source
                    dstTablasDeDatos MiDataSource = new dstTablasDeDatos();

                    // Recorro el datagridview y lleno mi tabla del dataset
                    foreach (DataGridViewRow Elemento in dgvCaja.Rows)
                    {
                        // Creo la fila de la tabla
                        dstTablasDeDatos.DtResumenMovimientosRow ArmarReporte = MiDataSource.DtResumenMovimientos.NewDtResumenMovimientosRow();

                        // La lleno
                        ArmarReporte.Fecha               = Convert.ToDateTime(Elemento.Cells["colFecha"].Value);
                        ArmarReporte.Hora                = Elemento.Cells["colHora"].Value.ToString();
                        ArmarReporte.TipoDeCuenta        = Elemento.Cells["ColTipoDeCuenta"].Value.ToString();
                        ArmarReporte.Ingresos            = Elemento.Cells["colIngreso"].Value.ToString();
                        ArmarReporte.Egresos             = Elemento.Cells["colEgreso"].Value.ToString();
                        ArmarReporte.Detalle             = Elemento.Cells["colDetalle"].Value.ToString();
                        ArmarReporte.RegistroGeneradoPor = Elemento.Cells["ColNombreUsuario"].Value.ToString();

                        // Agrego la fila al data source
                        MiDataSource.DtResumenMovimientos.AddDtResumenMovimientosRow(ArmarReporte);
                    }

                    // Creo un objeto con el reporte que voy a llenar y le asigno el datasource a SU datasource
                    RptReporteMovimientos Reporte = new RptReporteMovimientos();
                    Reporte.SetDataSource(MiDataSource);

                    string FechaDesde = dtpFechaDesde.Value.ToShortDateString();
                    string FechaHasta = dtpDechaHasta.Value.ToShortDateString();

                    if (!ckbIncluirFechaDesde.Checked)
                    {
                        FechaDesde = "Sin fecha desde";
                    }
                    if (!ckbIncluirFechaHasta.Checked)
                    {
                        FechaHasta = "Sin fecha hasta";
                    }

                    string TextoTipoDeMonto   = string.Empty;
                    string TextoNombreUsuario = string.Empty;

                    if (cmbTipoDeMonto.SelectedValue != null)
                    {
                        TipoDeMonto TipoDeMontoSeleccionado = (TipoDeMonto)cmbTipoDeMonto.SelectedItem;
                        TextoTipoDeMonto = TipoDeMontoSeleccionado.Nombre;

                        if (TipoDeMontoSeleccionado.ID_TipoDeMonto == 0)
                        {
                            TextoTipoDeMonto = TextoComboMonto;
                        }
                    }
                    else
                    {
                        TextoTipoDeMonto = "ERROR";
                    }

                    if (cmbUsuarios.SelectedValue != null)
                    {
                        Usuario UsuarioSeleccionado = (Usuario)cmbUsuarios.SelectedItem;
                        TextoNombreUsuario = UsuarioSeleccionado.Nombre;
                    }
                    else
                    {
                        TextoNombreUsuario = "ERROR";
                    }

                    Reporte.SetParameterValue("FechaDesde", FechaDesde);
                    Reporte.SetParameterValue("FechaHasta", FechaHasta);
                    Reporte.SetParameterValue("Usuario", TextoNombreUsuario);
                    Reporte.SetParameterValue("TipoDeMonto", TextoTipoDeMonto);

                    FormReporteMovimientos.S_ReporteMovimientos = Reporte;
                    FormReporteMovimientos.S_TipoDeReporte      = FrmReportes.ETipoDeReporte.RegistrosCaja;
                    FormReporteMovimientos.ShowDialog();
                }
            }
        }
Esempio n. 3
0
        private void CargarDGVCaja(ClsCajas.ETipoListado _TipoDeListado)
        {
            if (ValidarHora(false, mtbHoraComienzo) && ValidarHora(false, mtbHoraFin))
            {
                dgvCaja.Rows.Clear();

                string InformacionDelError = string.Empty;

                // Inicio preparacion de filtros ----
                int ID_Monto   = 0;
                int ID_Usuario = 0;

                if (cmbTipoDeMonto.SelectedValue != null)
                {
                    TipoDeMonto EstadoReservaSeleccionado = (TipoDeMonto)cmbTipoDeMonto.SelectedItem;
                    ID_Monto = EstadoReservaSeleccionado.ID_TipoDeMonto;
                }
                else
                {
                    cmbTipoDeMonto.SelectedValue = 0;
                }


                if (cmbUsuarios.SelectedValue != null)
                {
                    Usuario EstadoReservaSeleccionado = (Usuario)cmbUsuarios.SelectedItem;
                    ID_Usuario = EstadoReservaSeleccionado.ID_Usuario;
                }
                else
                {
                    cmbUsuarios.SelectedValue = 0;
                }

                string FechaDesde = Convert.ToString(dtpFechaDesde.Value.Date);
                string FechaHasta = Convert.ToString(dtpDechaHasta.Value.Date);

                if (!ckbIncluirFechaDesde.Checked)
                {
                    FechaDesde = string.Empty;
                }
                if (!ckbIncluirFechaHasta.Checked)
                {
                    FechaHasta = string.Empty;
                }
                // Fin preparacion de filtros ----

                ClsCajas Cajas = new ClsCajas();

                List <Caja> CargarDGVCaja = Cajas.LeerListado(_TipoDeListado, ref InformacionDelError, FechaDesde, FechaHasta, ID_Monto, ID_Usuario, mtbHoraComienzo.Text, mtbHoraFin.Text);

                if (CargarDGVCaja != null)
                {
                    double TotalIngreso = 0;
                    double TotalEgreso  = 0;

                    foreach (Caja Elemento in CargarDGVCaja)
                    {
                        int NumeroDeFila = dgvCaja.Rows.Add();

                        dgvCaja.Columns[(int)ENumColDGVCaja.ID_Caja].SortMode             = DataGridViewColumnSortMode.NotSortable;
                        dgvCaja.Columns[(int)ENumColDGVCaja.ID_Pedido].SortMode           = DataGridViewColumnSortMode.NotSortable;
                        dgvCaja.Columns[(int)ENumColDGVCaja.Fecha].SortMode               = DataGridViewColumnSortMode.NotSortable;
                        dgvCaja.Columns[(int)ENumColDGVCaja.Hora].SortMode                = DataGridViewColumnSortMode.NotSortable;
                        dgvCaja.Columns[(int)ENumColDGVCaja.TipoCuenta].SortMode          = DataGridViewColumnSortMode.NotSortable;
                        dgvCaja.Columns[(int)ENumColDGVCaja.Ingreso].SortMode             = DataGridViewColumnSortMode.NotSortable;
                        dgvCaja.Columns[(int)ENumColDGVCaja.Egreso].SortMode              = DataGridViewColumnSortMode.NotSortable;
                        dgvCaja.Columns[(int)ENumColDGVCaja.Detalle].SortMode             = DataGridViewColumnSortMode.NotSortable;
                        dgvCaja.Columns[(int)ENumColDGVCaja.RegistroGeneradoPor].SortMode = DataGridViewColumnSortMode.NotSortable;

                        dgvCaja.Rows[NumeroDeFila].Cells[(int)ENumColDGVCaja.ID_Caja].Value = Elemento.ID_Caja;

                        if (Elemento.ID_Pedido == null)
                        {
                            dgvCaja.Rows[NumeroDeFila].Cells[(int)ENumColDGVCaja.ID_Pedido].Value = string.Empty;
                        }
                        else
                        {
                            dgvCaja.Rows[NumeroDeFila].Cells[(int)ENumColDGVCaja.ID_Pedido].Value = Elemento.ID_Pedido;
                        }

                        dgvCaja.Rows[NumeroDeFila].Cells[(int)ENumColDGVCaja.Fecha].Value      = Elemento.Fecha.ToShortDateString();
                        dgvCaja.Rows[NumeroDeFila].Cells[(int)ENumColDGVCaja.Hora].Value       = Elemento.Hora.ToString(@"hh\:mm");
                        dgvCaja.Rows[NumeroDeFila].Cells[(int)ENumColDGVCaja.TipoCuenta].Value = Elemento.TipoDeMonto.Nombre;

                        switch ((ClsTiposDeMovimientos.ETipoDeMovimientos)Elemento.TipoDeMonto.ID_TipoDeMovimiento)
                        {
                        case ClsTiposDeMovimientos.ETipoDeMovimientos.Ingreso:
                        {
                            dgvCaja.Rows[NumeroDeFila].Cells[(int)ENumColDGVCaja.Ingreso].Value = Elemento.Monto;
                            dgvCaja.Rows[NumeroDeFila].Cells[(int)ENumColDGVCaja.Egreso].Value  = string.Empty;
                            TotalIngreso += Elemento.Monto;
                            break;
                        }

                        case ClsTiposDeMovimientos.ETipoDeMovimientos.Egreso:
                        {
                            dgvCaja.Rows[NumeroDeFila].Cells[(int)ENumColDGVCaja.Ingreso].Value = string.Empty;
                            dgvCaja.Rows[NumeroDeFila].Cells[(int)ENumColDGVCaja.Egreso].Value  = Elemento.Monto;
                            TotalEgreso += Elemento.Monto;
                            break;
                        }
                        }

                        dgvCaja.Rows[NumeroDeFila].Cells[(int)ENumColDGVCaja.Detalle].Value             = Elemento.Detalle;
                        dgvCaja.Rows[NumeroDeFila].Cells[(int)ENumColDGVCaja.RegistroGeneradoPor].Value = $"{Elemento.Usuario.Nombre} {Elemento.Usuario.Apellido}";
                    }
                    lblResultadoIngresos.Text   = Convert.ToString(TotalIngreso);
                    lblResultadoEgresos.Text    = Convert.ToString(TotalEgreso);
                    lblResultadoDiferencia.Text = Convert.ToString(TotalIngreso - TotalEgreso);
                }
                else if (InformacionDelError == string.Empty)
                {
                    FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Ocurrio un fallo al cargar la lista");
                }
                else
                {
                    FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Ocurrio un fallo al cargar la lista");
                    MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Esempio n. 4
0
        private void BtnAgregarRegistro_Click(object sender, EventArgs e)
        {
            txtDetalle.Text = txtDetalle.Text.Trim();

            if (ID_Registro != -1 && txtMonto.Text != string.Empty && txtMonto.Text.Substring(0, 1) != "," && txtMonto.Text.Substring(txtMonto.Text.Length - 1, 1) != ",")
            {
                using (FrmValidarUsuario FormValidarUsuario = new FrmValidarUsuario(FrmValidarUsuario.EFiltroUsuariosAutorizados.GerentesSubGerentes))
                {
                    FormValidarUsuario.ShowDialog();

                    if (FormValidarUsuario.DialogResult == DialogResult.OK)
                    {
                        if (txtDetalle.Text != string.Empty)
                        {
                            txtDetalle.Text = txtDetalle.Text.Substring(0, 1).ToUpper() + txtDetalle.Text.Remove(0, 1).ToLower();
                        }

                        string InformacionDelError = string.Empty;

                        ClsCajas Cajas         = new ClsCajas();
                        Caja     CrearRegistro = new Caja();

                        CrearRegistro.Fecha          = DateTime.Today.Date;
                        CrearRegistro.Hora           = TimeSpan.Parse(DateTime.Now.ToString(@"HH\:mm\:ss"));
                        CrearRegistro.Monto          = Convert.ToDouble(txtMonto.Text);
                        CrearRegistro.Detalle        = txtDetalle.Text;
                        CrearRegistro.ID_TipoDeMonto = ID_Registro;
                        CrearRegistro.ID_Pedido      = null;

                        if (ID_Registro == (int)ClsTiposDeMontos.ETiposDeMontos.AperturaCaja)
                        {
                            CrearRegistro.ID_EstadoCaja = (int)ClsEstadosCajas.EEstadosCajas.CajaAbierta;
                        }
                        else
                        {
                            CrearRegistro.ID_EstadoCaja = (int)ClsEstadosCajas.EEstadosCajas.Activo;
                        }

                        CrearRegistro.ID_Usuario = FormValidarUsuario.G_ID_UsuarioQueValido;

                        if (Cajas.Crear(CrearRegistro, ref InformacionDelError) != 0)
                        {
                            if (CrearRegistro.ID_TipoDeMonto == (int)ClsTiposDeMontos.ETiposDeMontos.CierreCaja)
                            {
                                List <Caja> BuscarRegistroCajaAbierta = Cajas.LeerListado(ClsCajas.ETipoListado.CajaAbierta, ref InformacionDelError);

                                if (BuscarRegistroCajaAbierta != null)
                                {
                                    foreach (Caja Elemento in BuscarRegistroCajaAbierta)
                                    {
                                        Elemento.ID_EstadoCaja = (int)ClsEstadosCajas.EEstadosCajas.Activo;

                                        Cajas.Actualizar(Elemento, ref InformacionDelError);
                                    }
                                }
                                else if (InformacionDelError == string.Empty)
                                {
                                    MessageBox.Show("Fallo al listar los montos", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                                else
                                {
                                    MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                            }

                            DialogResult = DialogResult.OK;
                            Close();
                        }
                        else if (InformacionDelError == string.Empty)
                        {
                            MessageBox.Show($"Fallo al crear el registro en caja", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
            }
            else
            {
                using (FrmInformacion FormInformacion = new FrmInformacion($"Debe cargar un registro con su monto correspondiente (verifique también que no tenga la " +
                                                                           "coma del centavo al principio o al final).", ClsColores.Blanco, 250, 300))
                {
                    FormInformacion.ShowDialog();
                }
            }
        }
        private void BtnRegistrarPago_Click(object sender, EventArgs e)
        {
            bool HuboError = false;

            string InformacionDelError = string.Empty;

            ClsCajas Cajas            = new ClsCajas();
            Caja     CrearRegistro    = new Caja();
            Caja     CrearSubRegistro = new Caja();

            // Creo el registro de la mesa
            CrearRegistro.Fecha     = DateTime.Today.Date;
            CrearRegistro.Hora      = TimeSpan.Parse(DateTime.Now.ToString(@"HH\:mm\:ss"));
            CrearRegistro.Monto     = Convert.ToDouble(lblMostratTotal.Text);
            CrearRegistro.Detalle   = string.Empty;
            CrearRegistro.ID_Pedido = ID_Pedido;

            if (EsDelivery)
            {
                CrearRegistro.ID_TipoDeMonto = (int)ClsTiposDeMontos.ETiposDeMontos.IngresoDelivery;
            }
            else
            {
                CrearRegistro.ID_TipoDeMonto = rbnIngreso.Checked ? (int)ClsTiposDeMontos.ETiposDeMontos.IngresoCierreDeMesa : (int)ClsTiposDeMontos.ETiposDeMontos.EgresoCierreDeMesa;
            }

            CrearRegistro.ID_EstadoCaja = (int)ClsEstadosCajas.EEstadosCajas.Activo;

            //buscar el usuario
            ClsPedidosXMesas PedidosXMesas = new ClsPedidosXMesas();
            PedidoXMesa      BuscarMozo    = new PedidoXMesa();

            BuscarMozo = PedidosXMesas.LeerPorNumero(ID_Pedido, ref InformacionDelError);

            if (BuscarMozo != null || ID_UsuarioQueConfirmaDelivery != -1)
            {
                if (ID_UsuarioQueConfirmaDelivery != -1)
                {
                    CrearRegistro.ID_Usuario    = ID_UsuarioQueConfirmaDelivery;
                    CrearSubRegistro.ID_Usuario = ID_UsuarioQueConfirmaDelivery;
                }
                else
                {
                    CrearRegistro.ID_Usuario    = BuscarMozo.Mesa.ID_Usuario;
                    CrearSubRegistro.ID_Usuario = BuscarMozo.Mesa.ID_Usuario;
                }

                // creo un registro de aumento/descuento si lo selecciono
                if (rbnDescuento.Checked)
                {
                    CrearSubRegistro.Fecha = DateTime.Today.Date;
                    CrearSubRegistro.Hora  = TimeSpan.Parse(DateTime.Now.ToString(@"HH\:mm\:ss"));
                    CrearSubRegistro.Monto = Convert.ToDouble(lblMostrarTotalDescuento.Text);

                    if (EsDelivery)
                    {
                        CrearSubRegistro.Detalle = $"{nudPorcentaje.Value}% con " +
                                                   $"fecha {DateTime.Today.ToShortDateString()} a las " +
                                                   $"{TimeSpan.Parse(DateTime.Now.ToString(@"HH\:mm\:ss"))}";
                        CrearSubRegistro.ID_TipoDeMonto = (int)ClsTiposDeMontos.ETiposDeMontos.DescuentoDelivery;
                    }
                    else
                    {
                        CrearSubRegistro.Detalle = $"{nudPorcentaje.Value}% a la mesa con " +
                                                   $"fecha {DateTime.Today.ToShortDateString()} a las " +
                                                   $"{TimeSpan.Parse(DateTime.Now.ToString(@"HH\:mm\:ss"))}";
                        CrearSubRegistro.ID_TipoDeMonto = (int)ClsTiposDeMontos.ETiposDeMontos.DescuentoCierreDeMesa;
                    }

                    CrearSubRegistro.ID_Pedido     = ID_Pedido;
                    CrearSubRegistro.ID_EstadoCaja = (int)ClsEstadosCajas.EEstadosCajas.Activo;
                }
                else if (rbnAumento.Checked)
                {
                    CrearSubRegistro.Fecha   = DateTime.Today.Date;
                    CrearSubRegistro.Hora    = TimeSpan.Parse(DateTime.Now.ToString(@"HH\:mm\:ss"));
                    CrearSubRegistro.Monto   = Convert.ToDouble(lblMostrarTotalAumento.Text);
                    CrearSubRegistro.Detalle = $"{nudPorcentaje.Value}% a la mesa con " +
                                               $"fecha {DateTime.Today.ToShortDateString()} a las " +
                                               $"{TimeSpan.Parse(DateTime.Now.ToString(@"HH\:mm\:ss"))}";
                    CrearSubRegistro.ID_Pedido      = ID_Pedido;
                    CrearSubRegistro.ID_TipoDeMonto = (int)ClsTiposDeMontos.ETiposDeMontos.AumentoCierreDeMesa;
                    CrearSubRegistro.ID_EstadoCaja  = (int)ClsEstadosCajas.EEstadosCajas.Activo;
                }

                if (Cajas.Crear(CrearRegistro, ref InformacionDelError) != 0)
                {
                    if (rbnDescuento.Checked || rbnAumento.Checked)
                    {
                        if (Cajas.Crear(CrearSubRegistro, ref InformacionDelError) != 0)
                        {
                            HuboError = false;
                        }
                        else if (InformacionDelError == string.Empty)
                        {
                            MessageBox.Show($"Fallo al crear el registro de aumento/descuento en caja", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            Cajas.Borrar(CrearRegistro.ID_Caja, ref InformacionDelError);
                            HuboError = true;
                        }
                        else
                        {
                            MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            Cajas.Borrar(CrearRegistro.ID_Caja, ref InformacionDelError);
                            HuboError = true;
                        }
                    }

                    if (!HuboError)
                    {
                        DialogResult = DialogResult.OK;
                        Close();
                    }
                }
                else if (InformacionDelError == string.Empty)
                {
                    MessageBox.Show($"Fallo al crear el registro en caja", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else if (InformacionDelError == string.Empty)
            {
                MessageBox.Show($"Fallo al buscar el mozo para crear el registro en caja", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 6
0
        private void BtnDeliveryNoRecibido_Click(object sender, EventArgs e)
        {
            FrmRespuesta FormRespuesta = new FrmRespuesta($"¿Esta seguro que quiere marcar el pedido del delivery como 'Fallido'? Si selecciona 'si', " +
                                                          $"se creara un registro del mismo como perdida en caja", FrmRespuesta.ETamaño.Mediano, FrmRespuesta.ETipo.Si_No);

            if (FormRespuesta.DialogResult == DialogResult.Yes)
            {
                int TotalDeFilas = dgvDelivery.Rows.Count;

                ClsPedidos Pedidos     = new ClsPedidos();
                Pedido     VerDelivery = new Pedido();

                ClsDeliveries Deliveries         = new ClsDeliveries();
                Delivery      ActualizarDelivery = null;

                ClsCajas Cajas         = new ClsCajas();
                Caja     CrearRegistro = null;

                ClsDetalles    Detalle         = new ClsDetalles();
                List <Detalle> CalcularPerdida = new List <Detalle>();

                using (FrmValidarUsuario FormValidarUsuario = new FrmValidarUsuario(FrmValidarUsuario.EFiltroUsuariosAutorizados.Todos))
                {
                    FormValidarUsuario.ShowDialog();

                    if (FormValidarUsuario.DialogResult == DialogResult.OK)
                    {
                        for (int Indice = 0; Indice < TotalDeFilas; Indice++)
                        {
                            //Pregunto si la celda es diferente a null
                            if (dgvDelivery.Rows[Indice].Cells[(int)ENumColDGVDelivery.Seleccionar].Value != null)
                            {
                                //Casteo el check del objeto a booleano y pregunto si es true
                                if ((bool)dgvDelivery.Rows[Indice].Cells[(int)ENumColDGVDelivery.Seleccionar].Value)
                                {
                                    string InformacionDelError = string.Empty;

                                    ClsDetalles    Detalles = new ClsDetalles();
                                    List <Detalle> BuscarArticuloSinCocinar = Detalles.LeerListado((int)dgvDelivery.Rows[Indice].Cells[(int)ENumColDGVDelivery.ID_Pedido].Value, (int)ClsDetalles.ETipoDeListado.PorIDPedido, ref InformacionDelError);

                                    bool FaltanCocinar = false;

                                    if (BuscarArticuloSinCocinar != null)
                                    {
                                        foreach (Detalle Elemento in BuscarArticuloSinCocinar)
                                        {
                                            if (Elemento.ID_EstadoDetalle == (int)ClsEstadoDetalle.EEstadoDetalle.NoCocinado)
                                            {
                                                FaltanCocinar = true;
                                                break;
                                            }
                                        }

                                        VerDelivery = Pedidos.LeerPorNumero((int)dgvDelivery.Rows[Indice].Cells[(int)ENumColDGVDelivery.ID_Pedido].Value, ref InformacionDelError);

                                        if (VerDelivery != null)
                                        {
                                            if (!FaltanCocinar)
                                            {
                                                double TotalPerdido = 0;

                                                CalcularPerdida = Detalle.LeerListado((int)dgvDelivery.Rows[Indice].Cells[(int)ENumColDGVDelivery.ID_Pedido].Value, ClsDetalles.ETipoDeListado.PorIDPedido, ref InformacionDelError);

                                                foreach (Detalle Elemento in CalcularPerdida)
                                                {
                                                    if (Elemento.Articulo.PrecioDelivery != null)
                                                    {
                                                        TotalPerdido += Elemento.Cantidad * (double)Elemento.Articulo.PrecioDelivery;
                                                    }
                                                }

                                                if (VerDelivery.Delivery.ID_EstadoDelivery == (int)ClsEstadosDeliveries.EEstadosDeliveries.ParaEntrega)
                                                {
                                                    ActualizarDelivery = Deliveries.LeerPorNumero(VerDelivery.Delivery.ID_Delivery, ref InformacionDelError);
                                                    ActualizarDelivery.ID_EstadoDelivery = (int)ClsEstadosDeliveries.EEstadosDeliveries.NoEntregado;
                                                    Deliveries.Actualizar(ActualizarDelivery, ref InformacionDelError);

                                                    VerDelivery.ID_EstadoPedido = (int)ClsEstadosPedidos.EEstadosPedidos.Finalizado;
                                                    VerDelivery.TiempoEspera    = null;

                                                    int TotalDelPedido = 0;

                                                    List <Detalle> CalcularTotal = Detalles.LeerListado((int)dgvDelivery.Rows[Indice].Cells[(int)ENumColDGVDelivery.ID_Pedido].Value, ClsDetalles.ETipoDeListado.PorIDPedido, ref InformacionDelError);

                                                    if (CalcularTotal != null)
                                                    {
                                                        foreach (Detalle Elemento in CalcularTotal)
                                                        {
                                                            TotalDelPedido += Convert.ToInt32(Elemento.Cantidad * Elemento.Articulo.Precio);
                                                        }
                                                        VerDelivery.TotalPedido = TotalDelPedido;
                                                    }
                                                    else if (InformacionDelError == string.Empty)
                                                    {
                                                        FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Error al intentar calcular el total del pedido");
                                                    }
                                                    else
                                                    {
                                                        FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Error al intentar calcular el total del pedido");
                                                        MessageBox.Show($"Error al intentar calcular el total del pedido {(int)dgvDelivery.Rows[Indice].Cells[(int)ENumColDGVDelivery.ID_Pedido].Value}: {InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                                    }

                                                    if (Pedidos.Actualizar(VerDelivery, ref InformacionDelError) != 0)
                                                    {
                                                        FrmPrincipal.ObtenerInstancia().S_tslResultadoOperacion = "Pedido y delivery actualizado";

                                                        CrearRegistro = new Caja();

                                                        CrearRegistro.ID_Usuario     = FormValidarUsuario.G_ID_UsuarioQueValido;
                                                        CrearRegistro.Fecha          = DateTime.Today.Date;
                                                        CrearRegistro.Hora           = TimeSpan.Parse(DateTime.Now.ToString(@"HH\:mm\:ss"));
                                                        CrearRegistro.Monto          = TotalPerdido;
                                                        CrearRegistro.Detalle        = "Perdida por delivery no entregado";
                                                        CrearRegistro.ID_Pedido      = VerDelivery.ID_Pedido;
                                                        CrearRegistro.ID_TipoDeMonto = (int)ClsTiposDeMontos.ETiposDeMontos.EgresoDelivery;
                                                        CrearRegistro.ID_EstadoCaja  = (int)ClsEstadosCajas.EEstadosCajas.Activo;

                                                        if (Cajas.Crear(CrearRegistro, ref InformacionDelError) != 0)
                                                        {
                                                            dgvDelivery.Rows.Remove(dgvDelivery.Rows[Indice]);
                                                            Indice       -= 1;
                                                            TotalDeFilas -= 1;
                                                        }
                                                        else if (InformacionDelError == string.Empty)
                                                        {
                                                            FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al crear el registro de perdida en caja");
                                                            MessageBox.Show($"Fallo al crear el registro de perdida en caja", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                                        }
                                                        else
                                                        {
                                                            FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al crear el registro de perdida en caja");
                                                            MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                                        }
                                                    }
                                                    else if (InformacionDelError != string.Empty)
                                                    {
                                                        FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al marcar el delivery como no recibido");
                                                        MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                                    }
                                                }
                                                else
                                                {
                                                    using (FrmInformacion FormInformacion = new FrmInformacion($"No puede editar o eliminar el delivery de {VerDelivery.Cliente.Nombre} {VerDelivery.Cliente.Apellido} " +
                                                                                                               $"porque ya fue confirmado su estado o fue eliminado.", ClsColores.Blanco, 250, 300))
                                                    {
                                                        FormInformacion.ShowDialog();
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                using (FrmInformacion FormInformacion = new FrmInformacion($"No puede marcar como 'No entregado' el delivery de {VerDelivery.Cliente.Nombre} {VerDelivery.Cliente.Apellido} porque falta que " +
                                                                                                           $"cocina marque los platos del pedido como finalizados (solo se puede marcar esta opcion si " +
                                                                                                           $"ya fueron cocinados los platos y nadie pago el delivery).", ClsColores.Blanco, 250, 300))
                                                {
                                                    FormInformacion.ShowDialog();
                                                }
                                            }
                                        }
                                        else if (InformacionDelError == string.Empty)
                                        {
                                            FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al marcar el delivery como no recibido");
                                            MessageBox.Show("Ocurrio un fallo al marcar el delivery como no recibido", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        }
                                        else
                                        {
                                            FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al marcar el delivery como no recibido");
                                            MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }