private void CargarDatosDelivery()
        {
            string InformacionDelError = string.Empty;

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

            CargarDelivery = Pedidos.LeerPorNumero(ID_Pedido, ref InformacionDelError);

            if (CargarDelivery != null)
            {
                if (CargarDelivery.Delivery.Destino == null)
                {
                    ckbRetiraEnElLocal.Checked = true;
                    txtDireccion.Text          = "Se retira en el local";
                }
                else
                {
                    ckbRetiraEnElLocal.Checked = false;
                    txtDireccion.Text          = CargarDelivery.Delivery.Destino;
                }

                txtTelefonoCadete.Text = Convert.ToString(CargarDelivery.Delivery.Telefono);
            }
            else if (InformacionDelError == string.Empty)
            {
                MessageBox.Show("Ocurrio un fallo al cargar el delivery", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#2
0
        private void FrmAgregarNotaPedidos_Load(object sender, EventArgs e)
        {
            if (ID_Pedido != -1)
            {
                string InformacionDelError = string.Empty;

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

                LeerNota = Pedidos.LeerPorNumero(ID_Pedido, ref InformacionDelError);

                if (LeerNota != null)
                {
                    txtNotaPedido.Text = LeerNota.Nota;
                }
                else if (InformacionDelError == string.Empty)
                {
                    MessageBox.Show($"Error al leer la nota", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
示例#3
0
        private void DgvDelivery_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            DataGridView DetectarTipoCasilla = (DataGridView)sender;

            if (!(DetectarTipoCasilla.Columns[e.ColumnIndex] is DataGridViewButtonColumn) && !(DetectarTipoCasilla.Columns[e.ColumnIndex] is DataGridViewCheckBoxColumn) && e.RowIndex >= 0)
            {
                string InformacionDelError = string.Empty;

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

                InformacionDelPedido = Pedidos.LeerPorNumero((int)dgvDelivery.Rows[e.RowIndex].Cells[(int)ENumColDGVDelivery.ID_Pedido].Value, ref InformacionDelError);

                if (InformacionDelPedido != null)
                {
                    using (FrmCrearEditarDelivery FormCrearEditarDelivery = new FrmCrearEditarDelivery((int)dgvDelivery.Rows[e.RowIndex].Cells[(int)ENumColDGVDelivery.ID_Delivery].Value, (int)dgvDelivery.Rows[e.RowIndex].Cells[(int)ENumColDGVDelivery.ID_Pedido].Value, InformacionDelPedido.ID_Chef))
                    {
                        if (InformacionDelPedido.ID_EstadoPedido != (int)ClsEstadosPedidos.EEstadosPedidos.Entregado)
                        {
                            if (InformacionDelPedido.Delivery.ID_EstadoDelivery == (int)ClsEstadosDeliveries.EEstadosDeliveries.EnCocina)
                            {
                                FormCrearEditarDelivery.ShowDialog();
                                DeliveryPendientes();
                            }
                            else
                            {
                                using (FrmInformacion FormInformacion = new FrmInformacion($"No puede editar el delivery con fecha {InformacionDelPedido.Fecha.ToShortDateString()} " +
                                                                                           $"a las {InformacionDelPedido.Hora.ToString(@"hh\:mm")} del cliente {InformacionDelPedido.Cliente.Nombre} {InformacionDelPedido.Cliente.Apellido} " +
                                                                                           $"porque ya fue confirmado su estado o fue eliminado.", ClsColores.Blanco, 300, 350))
                                {
                                    FormInformacion.ShowDialog();
                                }
                            }
                        }
                        else
                        {
                            using (FrmInformacion FormInformacion = new FrmInformacion($"No puede editar el delivery con fecha {InformacionDelPedido.Fecha.ToShortDateString()} " +
                                                                                       $"a las {InformacionDelPedido.Hora.ToString(@"hh\:mm")} del cliente {InformacionDelPedido.Cliente.Nombre} {InformacionDelPedido.Cliente.Apellido} " +
                                                                                       $"porque ya fue indicado como finalizado desde cocina.", ClsColores.Blanco, 300, 350))
                            {
                                FormInformacion.ShowDialog();
                            }
                        }
                    }
                }
                else if (InformacionDelError == string.Empty)
                {
                    FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Ocurrio un fallo al buscar el pedido");
                    MessageBox.Show($"Ocurrio un fallo al buscar el pedido", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Ocurrio un fallo al buscar el pedido");
                    MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
示例#4
0
        private void DgvDelivery_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView DetectarTipoCasilla = (DataGridView)sender;

            if (DetectarTipoCasilla.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
            {
                string InformacionDelError = string.Empty;

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

                InformacionDelPedido = Pedidos.LeerPorNumero((int)dgvDelivery.Rows[e.RowIndex].Cells[(int)ENumColDGVDelivery.ID_Pedido].Value, ref InformacionDelError);

                if (InformacionDelPedido != null)
                {
                    using (FrmPedidosPorMesa FormPedidosPorMesa = new FrmPedidosPorMesa((int)dgvDelivery.Rows[e.RowIndex].Cells[(int)ENumColDGVDelivery.ID_Pedido].Value, InformacionDelPedido.ID_Chef, new FrmCrearEditarDelivery()))
                    {
                        if (InformacionDelPedido.Delivery.ID_EstadoDelivery != (int)ClsEstadosDeliveries.EEstadosDeliveries.EnCocina)
                        {
                            FormPedidosPorMesa.BloquearPorDeliveryEntregado();
                        }

                        FormPedidosPorMesa.ShowDialog();
                    }
                }
                else if (InformacionDelError == string.Empty)
                {
                    FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Ocurrio un fallo al buscar el delivery");
                    MessageBox.Show($"Ocurrio un fallo al buscar el chef", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Ocurrio un fallo al buscar el delivery");
                    MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            if (DetectarTipoCasilla.Columns[e.ColumnIndex] is DataGridViewCheckBoxColumn && e.RowIndex >= 0)
            {
                // invierto el estado del check seleccionado debido a que no se actualiza en el momento de marcarlo.
                if (dgvDelivery.Rows[e.RowIndex].Cells[(int)ENumColDGVDelivery.Seleccionar].Value != null)
                {
                    if (!(bool)dgvDelivery.Rows[e.RowIndex].Cells[(int)ENumColDGVDelivery.Seleccionar].Value && e.RowIndex != UltimaFilaSeleccionada)
                    {
                        ClsColores.MarcarFilaDGV(dgvDelivery, e.RowIndex, true);
                    }
                    else
                    {
                        ClsColores.MarcarFilaDGV(dgvDelivery, e.RowIndex, false);
                    }
                }

                UltimaFilaSeleccionada = e.RowIndex;
            }
        }
示例#5
0
        private void ActualizarNota()
        {
            if (ID_Pedido != -1)
            {
                string InformacionDelError = string.Empty;

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

                ActualizarNota = Pedidos.LeerPorNumero(ID_Pedido, ref InformacionDelError);

                if (ActualizarNota != null)
                {
                    ActualizarNota.Nota = txtNotaPedido.Text;

                    if (Pedidos.Actualizar(ActualizarNota, ref InformacionDelError) != 0)
                    {
                    }
                    else if (InformacionDelError != string.Empty)
                    {
                        MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else if (InformacionDelError == string.Empty)
                {
                    MessageBox.Show($"Error al leer el pedido", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                FormCrearEditarDelivery.S_NotaPedido = txtNotaPedido.Text;
            }
        }
        /// <summary>
        /// Imprime un ticket de pru.
        /// </summary>
        /// <param name="e">Evento que arma el ticket.</param>
        /// <param name="_InformacionDelError">Devuelve una cadena de texto con informacion para el usuario en caso de que el
        /// metodo devuelva null (debido a que ocurrio un error).</param>
        /// <param name="_ID_PedidoImprimir">ID del pedido que se esta imprimiendo.</param>
        public static void PlatosRecienCocinados(ref PrintPageEventArgs e, ref string _InformacionDelError, int _ID_PedidoImprimir)
        {
            try
            {
                string InformacionDelError = string.Empty;

                ClsInformacionesRestaurantes InformacionesRestaurantes = new ClsInformacionesRestaurantes();
                InformacionRestaurante       BuscarDatosRestaurante    = InformacionesRestaurantes.LeerPorNumero(1, ref InformacionDelError);

                Font       FuenteCuerpo              = new Font("Arial", 7, FontStyle.Regular, GraphicsUnit.Point);
                Font       FuenteTituloCuerpo        = new Font("Arial", 7, FontStyle.Bold, GraphicsUnit.Point);
                Font       FuenteEncabezadoPie       = new Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Point);
                Font       FuenteEncabezadoPieSimple = new Font("Arial", 7, FontStyle.Bold, GraphicsUnit.Point);
                Font       FuenteNombreRestaurante   = new Font("Arial", 20, FontStyle.Bold, GraphicsUnit.Point);
                SolidBrush Pincel = new SolidBrush(Color.Black);

                int AlturaFuente = (int)FuenteCuerpo.GetHeight();
                int ComienzoX    = 5;
                int ComienzoY    = 0;
                int Compensar    = 40;
                int SubCompensar = 3;

                if (BuscarDatosRestaurante != null)
                {
                    int PosicionX = 10;

                    if (BuscarDatosRestaurante.Nombre.Length >= 11 && BuscarDatosRestaurante.Nombre.Length < 16)
                    {
                        FuenteNombreRestaurante = new Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Point);
                    }
                    else if (BuscarDatosRestaurante.Nombre.Length >= 16)
                    {
                        FuenteNombreRestaurante = new Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point);
                    }

                    switch (BuscarDatosRestaurante.Nombre.Length)
                    {
                    case 3: PosicionX = 63; break;

                    case 4: PosicionX = 53; break;

                    case 5: PosicionX = 48; break;

                    case 6: PosicionX = 36; break;

                    case 7: PosicionX = 27; break;

                    case 8: PosicionX = 18; break;

                    case 9: PosicionX = 10; break;

                    case 10: PosicionX = 5; break;

                    case 11: PosicionX = 20; break;

                    case 12: PosicionX = 18; break;

                    case 13: PosicionX = 14; break;

                    case 14: PosicionX = 12; break;

                    case 15: PosicionX = 10; break;

                    case 16: PosicionX = 20; break;

                    case 17: PosicionX = 18; break;

                    case 18: PosicionX = 16; break;

                    case 19: PosicionX = 14; break;

                    case 20: PosicionX = 12; break;
                    }

                    e.Graphics.DrawString(BuscarDatosRestaurante.Nombre, FuenteNombreRestaurante, Pincel, PosicionX, ComienzoY);

                    if (BuscarDatosRestaurante != null)
                    {
                        e.Graphics.DrawString($"   {BuscarDatosRestaurante.Eslogan}", FuenteEncabezadoPie, Pincel, ComienzoX, ComienzoY + FuenteNombreRestaurante.GetHeight());
                        Compensar += AlturaFuente + SubCompensar;
                    }
                }

                e.Graphics.DrawString($"Fecha: {DateTime.Now.ToShortDateString()}  Hora: {DateTime.Now.ToString(@"HH\:mm")}", FuenteEncabezadoPieSimple, Pincel, ComienzoX, ComienzoY + Compensar);
                Compensar += AlturaFuente + SubCompensar * 2;

                string NombreEncabezado   = "Nombre";
                string CantidadEncabezado = "Cant.";

                ClsPedidos Pedidos = new ClsPedidos();
                Pedido     BuscarCliente;

                if (_ID_PedidoImprimir != -1)
                {
                    BuscarCliente = Pedidos.LeerPorNumero(_ID_PedidoImprimir, ref InformacionDelError);

                    if (BuscarCliente != null)
                    {
                        e.Graphics.DrawString($"Cliente: {BuscarCliente.Cliente.Nombre} {BuscarCliente.Cliente.Apellido}", FuenteTituloCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);
                        Compensar += AlturaFuente + SubCompensar;

                        e.Graphics.DrawString($"Telefono cliente: {Convert.ToString(BuscarCliente.Cliente.Telefono)}", FuenteTituloCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);
                        Compensar += AlturaFuente + SubCompensar;

                        if (BuscarCliente.Delivery.Destino == null)
                        {
                            e.Graphics.DrawString($"Direccion: Retira en el local", FuenteTituloCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);
                            Compensar += AlturaFuente + SubCompensar * 2;
                        }
                        else
                        {
                            e.Graphics.DrawString($"Dir.:{BuscarCliente.Delivery.Destino}", FuenteTituloCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);
                            Compensar += AlturaFuente + SubCompensar * 2;
                        }
                    }
                }

                e.Graphics.DrawString($"{CantidadEncabezado.PadRight(6)}{NombreEncabezado.PadRight(27)}", FuenteTituloCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);
                Compensar += AlturaFuente + SubCompensar;

                if (_ID_PedidoImprimir != -1)
                {
                    ClsDetalles    Detalles  = new ClsDetalles();
                    List <Detalle> Articulos = Detalles.LeerListado(_ID_PedidoImprimir, ClsDetalles.ETipoDeListado.PorIDPedido, ref InformacionDelError);

                    if (Articulos != null)
                    {
                        foreach (Detalle Elemento in Articulos)
                        {
                            string Nombre   = Elemento.Articulo.Nombre;
                            string Cantidad = Convert.ToString(Elemento.Cantidad + Elemento.CantidadAgregada);

                            e.Graphics.DrawString($"{Cantidad.PadLeft(7)}  {Nombre}", FuenteCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);
                            Compensar += AlturaFuente + SubCompensar;
                        }
                    }
                }
            }
            catch (Exception Error)
            {
                _InformacionDelError = $"OCURRIO UN ERROR INESPERADO AL INTENTAR LISTAR LA INFORMACIÓN: {Error.Message}\r\n\r\n" +
                                       $"ORIGEN DEL ERROR: {Error.StackTrace}\r\n\r\n" +
                                       $"OBJETO QUE GENERÓ EL ERROR: {Error.Data}\r\n\r\n\r\n" +
                                       $"ENVIE AL PROGRAMADOR UNA FOTO DE ESTE MENSAJE CON UNA DESCRIPCION DE LO QUE HIZO ANTES DE QUE SE GENERARÁ " +
                                       $"ESTE ERROR PARA QUE SEA ARREGLADO.";
                e.Cancel = true;
            }
        }
        /// <summary>
        /// Arma el ticket del resumen del pedido.
        /// </summary>
        /// <param name="e">Evento que arma el ticket.</param>
        /// <param name="_ID_Pedido">Numero del pedido.</param>
        /// <param name="_EsDelivery">Para determinar si debe imprimir los datos de un delivery.</param>
        /// <param name="_DatosPedido">Array que debe contener los datos alojados en el DataGridView, como
        /// nombre de los productos, cantidad, etc.</param>
        /// <param name="_Descuento">Cantidad de descuento.</param>
        /// <param name="_Recargo">Cantidad de aumento.</param>
        /// <param name="_Total">Total a pagar.</param>
        /// <param name="_TotalAumento">Total a aumentar.</param>
        /// <param name="_TotalDescuento">Total a descontar.</param>
        /// <param name="_Porcentaje">Porcentaje que se aplico.</param>
        /// <param name="_InformacionDelError">Devuelve una cadena de texto con informacion para el usuario en caso de que el
        /// metodo devuelva null (debido a que ocurrio un error).</param>
        /// <returns>El evento armado.</returns>
        public static void TicketResumenPedido(ref PrintPageEventArgs e, int _ID_Pedido, bool _EsDelivery, string[,] _DatosPedido, bool _Descuento, bool _Recargo, string _Total, string _TotalAumento, string _TotalDescuento, string _Porcentaje, ref string _InformacionDelError)
        {
            try
            {
                string InformacionDelError = string.Empty;

                ClsInformacionesRestaurantes InformacionesRestaurantes = new ClsInformacionesRestaurantes();
                InformacionRestaurante       BuscarDatosRestaurante    = InformacionesRestaurantes.LeerPorNumero(1, ref InformacionDelError);

                Font       FuenteCuerpo              = new Font("Arial", 7, FontStyle.Regular, GraphicsUnit.Point);
                Font       FuenteTituloCuerpo        = new Font("Arial", 7, FontStyle.Bold, GraphicsUnit.Point);
                Font       FuenteEncabezadoPie       = new Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Point);
                Font       FuenteEncabezadoPieSimple = new Font("Arial", 7, FontStyle.Bold, GraphicsUnit.Point);
                Font       FuenteNombreRestaurante   = new Font("Arial", 20, FontStyle.Bold, GraphicsUnit.Point);
                SolidBrush Pincel = new SolidBrush(Color.Black);

                int AlturaFuente = (int)FuenteCuerpo.GetHeight();
                int ComienzoX    = 5;
                int ComienzoY    = 0;
                int Compensar    = 40;
                int SubCompensar = 3;

                if (BuscarDatosRestaurante != null)
                {
                    int PosicionX = 10;

                    if (BuscarDatosRestaurante.Nombre.Length >= 11 && BuscarDatosRestaurante.Nombre.Length < 16)
                    {
                        FuenteNombreRestaurante = new Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Point);
                    }
                    else if (BuscarDatosRestaurante.Nombre.Length >= 16)
                    {
                        FuenteNombreRestaurante = new Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Point);
                    }

                    switch (BuscarDatosRestaurante.Nombre.Length)
                    {
                    case 3: PosicionX = 63; break;

                    case 4: PosicionX = 53; break;

                    case 5: PosicionX = 48; break;

                    case 6: PosicionX = 36; break;

                    case 7: PosicionX = 27; break;

                    case 8: PosicionX = 18; break;

                    case 9: PosicionX = 10; break;

                    case 10: PosicionX = 5; break;

                    case 11: PosicionX = 20; break;

                    case 12: PosicionX = 18; break;

                    case 13: PosicionX = 14; break;

                    case 14: PosicionX = 12; break;

                    case 15: PosicionX = 10; break;

                    case 16: PosicionX = 20; break;

                    case 17: PosicionX = 18; break;

                    case 18: PosicionX = 16; break;

                    case 19: PosicionX = 14; break;

                    case 20: PosicionX = 12; break;
                    }

                    e.Graphics.DrawString(BuscarDatosRestaurante.Nombre, FuenteNombreRestaurante, Pincel, PosicionX, ComienzoY);

                    if (BuscarDatosRestaurante.Eslogan != null)
                    {
                        e.Graphics.DrawString($"  {BuscarDatosRestaurante.Eslogan}", FuenteEncabezadoPie, Pincel, ComienzoX, ComienzoY + FuenteNombreRestaurante.GetHeight());
                        Compensar += AlturaFuente + SubCompensar;
                    }
                }

                string NombreMozo      = string.Empty;
                int    MesasAcumuladas = 0;
                string LineaUnoMesas   = string.Empty;
                string lineaDosMesas   = string.Empty;

                ClsPedidosXMesas   PedidosXMesas = new ClsPedidosXMesas();
                List <PedidoXMesa> BuscarDatos   = PedidosXMesas.LeerListado(ClsPedidosXMesas.ETipoDeListado.BuscarMesasYMozo, ref InformacionDelError, _ID_Pedido);

                if (BuscarDatos != null)
                {
                    if (BuscarDatos.Count > 0 && !_EsDelivery)
                    {
                        foreach (PedidoXMesa Elemento in BuscarDatos)
                        {
                            if (MesasAcumuladas < 7)
                            {
                                LineaUnoMesas += Elemento.Mesa.Numero + "-";
                            }
                            else
                            {
                                lineaDosMesas += Elemento.Mesa.Numero + "-";
                            }

                            NombreMozo = $"{Elemento.Mesa.Usuario.Nombre} {Elemento.Mesa.Usuario.Apellido}";

                            MesasAcumuladas++;
                        }

                        LineaUnoMesas = LineaUnoMesas.Remove(LineaUnoMesas.Length - 1, 1);

                        if (lineaDosMesas != string.Empty)
                        {
                            lineaDosMesas = lineaDosMesas.Remove(lineaDosMesas.Length - 1, 1);
                        }
                    }
                }

                e.Graphics.DrawString($"Fecha: {DateTime.Now.ToShortDateString()}  Hora: {DateTime.Now.ToString(@"HH\:mm")}", FuenteEncabezadoPieSimple, Pincel, ComienzoX, ComienzoY + Compensar);
                Compensar += AlturaFuente + SubCompensar * 2;

                if (BuscarDatosRestaurante != null)
                {
                    e.Graphics.DrawString($"Direccion: {BuscarDatosRestaurante.Direccion}", FuenteEncabezadoPieSimple, Pincel, ComienzoX, ComienzoY + Compensar);
                    Compensar += AlturaFuente + SubCompensar;

                    if (BuscarDatosRestaurante.TelefonoDos == null)
                    {
                        e.Graphics.DrawString($"Contacto: {BuscarDatosRestaurante.TelefonoUno}", FuenteEncabezadoPieSimple, Pincel, ComienzoX, ComienzoY + Compensar);
                        Compensar += AlturaFuente + SubCompensar * 2;
                    }
                    else
                    {
                        e.Graphics.DrawString($"Contactos: {BuscarDatosRestaurante.TelefonoUno} / {BuscarDatosRestaurante.TelefonoDos}", FuenteEncabezadoPieSimple, Pincel, ComienzoX, ComienzoY + Compensar);
                        Compensar += AlturaFuente + SubCompensar * 2;
                    }
                }

                if (BuscarDatos != null)
                {
                    if (BuscarDatos.Count > 0 && !_EsDelivery)
                    {
                        e.Graphics.DrawString($"Mozo: {NombreMozo}", FuenteTituloCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);
                        Compensar += AlturaFuente + SubCompensar;

                        e.Graphics.DrawString($"Mesa/s: {LineaUnoMesas}", FuenteTituloCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);

                        if (lineaDosMesas != string.Empty)
                        {
                            Compensar += AlturaFuente + SubCompensar;

                            e.Graphics.DrawString($"{lineaDosMesas}", FuenteTituloCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);
                            Compensar += AlturaFuente + SubCompensar * 2;
                        }
                        else
                        {
                            Compensar += AlturaFuente + SubCompensar * 2;
                        }
                    }
                    else
                    {
                        ClsPedidos Pedidos      = new ClsPedidos();
                        Pedido     BuscarPedido = Pedidos.LeerPorNumero(_ID_Pedido, ref InformacionDelError);

                        if (BuscarPedido != null)
                        {
                            if (BuscarPedido.ID_Delivery != null)
                            {
                                e.Graphics.DrawString($"Destino: {BuscarPedido.Delivery.Destino}", FuenteTituloCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);
                                Compensar += AlturaFuente + SubCompensar;
                                e.Graphics.DrawString($"Cliente: {BuscarPedido.Cliente.Nombre} {BuscarPedido.Cliente.Apellido}", FuenteTituloCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);
                                Compensar += AlturaFuente + SubCompensar;

                                if (BuscarPedido.Cliente.Telefono != 0)
                                {
                                    e.Graphics.DrawString($"Telefono cliente: {BuscarPedido.Cliente.Telefono} {BuscarPedido.Cliente.Apellido}", FuenteTituloCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);
                                    Compensar += AlturaFuente + SubCompensar * 2;
                                }
                                else
                                {
                                    Compensar += SubCompensar;
                                }
                            }
                        }
                    }
                }

                string NombreEncabezado   = "Nombre";
                string CantidadEncabezado = "Cant.";
                string SubtotalEncabezado = "Subtotal";

                e.Graphics.DrawString($"{CantidadEncabezado.PadRight(6)}{NombreEncabezado.PadRight(27)}{SubtotalEncabezado.PadLeft(11)}", FuenteTituloCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);
                Compensar += AlturaFuente + SubCompensar;

                for (int Indice = 0; Indice < _DatosPedido.GetLength(0); Indice++)
                {
                    e.Graphics.DrawString($"{_DatosPedido[Indice, 1].PadLeft(7)}  {_DatosPedido[Indice, 0]}", FuenteCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);
                    Compensar += AlturaFuente + SubCompensar;

                    e.Graphics.DrawString($"{string.Empty.PadLeft(48, '.')}{_DatosPedido[Indice, 2]}", FuenteCuerpo, Pincel, ComienzoX, ComienzoY + Compensar);
                    Compensar += AlturaFuente + SubCompensar;
                }

                if (_Descuento)
                {
                    e.Graphics.DrawString($"Descuento  ${_TotalDescuento} ({_Porcentaje}%)", FuenteEncabezadoPieSimple, Pincel, ComienzoX, ComienzoY + Compensar);
                    Compensar += AlturaFuente + SubCompensar;
                }
                else if (_Recargo)
                {
                    e.Graphics.DrawString($"Recargo      ${_TotalAumento} ({_Porcentaje}%)", FuenteEncabezadoPieSimple, Pincel, ComienzoX, ComienzoY + Compensar);
                    Compensar += AlturaFuente + SubCompensar;
                }

                e.Graphics.DrawString($"Total      ${Convert.ToString(Math.Round(Convert.ToDouble(_Total) + Convert.ToDouble(_TotalAumento) - Convert.ToDouble(_TotalDescuento), 2))}", FuenteEncabezadoPie, Pincel, ComienzoX, ComienzoY + Compensar);
                Compensar += AlturaFuente + SubCompensar * 3;

                e.Graphics.DrawString($" TICKET NO VALIDO COMO FACTURA", FuenteEncabezadoPieSimple, Pincel, ComienzoX, ComienzoY + Compensar);
            }
            catch (Exception Error)
            {
                _InformacionDelError = $"OCURRIO UN ERROR INESPERADO AL INTENTAR LISTAR LA INFORMACIÓN: {Error.Message}\r\n\r\n" +
                                       $"ORIGEN DEL ERROR: {Error.StackTrace}\r\n\r\n" +
                                       $"OBJETO QUE GENERÓ EL ERROR: {Error.Data}\r\n\r\n\r\n" +
                                       $"ENVIE AL PROGRAMADOR UNA FOTO DE ESTE MENSAJE CON UNA DESCRIPCION DE LO QUE HIZO ANTES DE QUE SE GENERARÁ " +
                                       $"ESTE ERROR PARA QUE SEA ARREGLADO.";
                e.Cancel = true;
            }
        }
示例#8
0
        private void BtnPedidoTerminado_Click(object sender, EventArgs e)
        {
            tmrActualizaPedidos.Stop();

            int TotalDeFilas = dgvListaPedidos.Rows.Count;

            string InformacionDelError = string.Empty;

            ClsDetalles Detalles = new ClsDetalles();

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

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

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

                        List <Detalle> ActualizarDetalle = Detalles.LeerListado((int)dgvListaPedidos.Rows[Indice].Cells[(int)ENumColDGVListaPedidos.ID_Pedido].Value, ClsDetalles.ETipoDeListado.ParaCocina, ref InformacionDelError);
                        ActualizarPedido = Pedidos.LeerPorNumero((int)dgvListaPedidos.Rows[Indice].Cells[(int)ENumColDGVListaPedidos.ID_Pedido].Value, ref InformacionDelError);

                        if (ActualizarDetalle != null && ActualizarPedido != null)
                        {
                            if (ActualizarPedido.ID_EstadoPedido == (int)ClsEstadosPedidos.EEstadosPedidos.EnProceso)
                            {
                                foreach (Detalle Elemento in ActualizarDetalle)
                                {
                                    if (Elemento.ID_EstadoDetalle == (int)ClsEstadoDetalle.EEstadoDetalle.CantidadAumentada)
                                    {
                                        Elemento.Cantidad        += Elemento.CantidadAgregada;
                                        Elemento.CantidadAgregada = 0;
                                    }

                                    Elemento.ID_EstadoDetalle = (int)ClsEstadoDetalle.EEstadoDetalle.YaCocinado;

                                    if (Detalles.Actualizar(Elemento, ref InformacionDelError) != 0)
                                    {
                                        dgvPlatosPorMesa.Rows.Clear();
                                        lblDetallesDelPedido.Text = string.Empty;
                                    }
                                    else if (InformacionDelError != string.Empty)
                                    {
                                        MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                }

                                if (ActualizarPedido.ID_Delivery == null)
                                {
                                    ActualizarPedido.TiempoEspera = null;
                                }

                                if (ActualizarPedido.ID_Delivery == null)
                                {
                                    ActualizarPedido.ID_EstadoPedido = (int)ClsEstadosPedidos.EEstadosPedidos.ParaEntrega;
                                }
                                else
                                {
                                    ActualizarPedido.ID_EstadoPedido = (int)ClsEstadosPedidos.EEstadosPedidos.Entregado;

                                    ActualizarDelivery = Delivery.LeerPorNumero(ActualizarPedido.ID_Delivery, ref InformacionDelError);

                                    if (ActualizarDelivery != null)
                                    {
                                        ActualizarDelivery.ID_EstadoDelivery = (int)ClsEstadosDeliveries.EEstadosDeliveries.ParaEntrega;

                                        if (Delivery.Actualizar(ActualizarDelivery, ref InformacionDelError) != 0)
                                        {
                                            FrmPrincipal.ObtenerInstancia().S_tslResultadoOperacion = "Delivery actualizado con exito";
                                        }
                                        else if (InformacionDelError == string.Empty)
                                        {
                                            FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al actualizar el delivery");
                                        }
                                        else
                                        {
                                            FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al actualizar el delivery");
                                            MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        }
                                    }
                                    else if (InformacionDelError == string.Empty)
                                    {
                                        FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al actualizar el delivery");
                                    }
                                    else
                                    {
                                        FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al actualizar el delivery");
                                        MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                }

                                if (Pedidos.Actualizar(ActualizarPedido, ref InformacionDelError) != 0)
                                {
                                    if (ActualizarPedido.ID_Delivery != null && ckbImprimirTicketDelivery.Checked)
                                    {
                                        ID_PedidoImprimir = ActualizarPedido.ID_Pedido;
                                        PtdImprimirTicket = new PrintDocument();

                                        if (ClsComprobarEstadoImpresora.ComprobarEstadoImpresora(PtdImprimirTicket.PrinterSettings.PrinterName))
                                        {
                                            PtdImprimirTicket.PrintPage += PrintPageEventHandler;
                                            PtdImprimirTicket.Print();
                                        }

                                        ID_PedidoImprimir = -1;
                                    }

                                    PedidosSeleccionados.RemoveAll(I => I == (int)dgvListaPedidos.Rows[Indice].Cells[(int)ENumColDGVListaPedidos.ID_Pedido].Value);

                                    lblMostrarNumeroPedido.Text = string.Empty;
                                    dgvPlatosPorMesa.Rows.Clear();
                                    dgvListaPedidos.Rows.Remove(dgvListaPedidos.Rows[Indice]);
                                    Indice       -= 1;
                                    TotalDeFilas -= 1;

                                    FrmPrincipal.ObtenerInstancia().S_tslResultadoOperacion = "Pedido actualizado";
                                }
                                else if (InformacionDelError != string.Empty)
                                {
                                    FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al actualizar el pedido");
                                    MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                            }
                            else
                            {
                                using (FrmInformacion FormInformacion = new FrmInformacion($"El pedido numero {ActualizarPedido.ID_Pedido}, no se indico como cocinado debido a " +
                                                                                           $"que fue retirado de la lista desde otra computadora y no llego a quitarse de esta al momento de indicarlo como terminado. " +
                                                                                           $"El pedido sera retirado de la lista al cerrar este mensaje (no se indicara como cocinado).", ClsColores.Blanco, 200, 400))
                                {
                                    FormInformacion.ShowDialog();
                                }

                                lblMostrarNumeroPedido.Text = string.Empty;
                                dgvPlatosPorMesa.Rows.Clear();
                                dgvListaPedidos.Rows.Remove(dgvListaPedidos.Rows[Indice]);
                                Indice       -= 1;
                                TotalDeFilas -= 1;
                            }
                        }
                        else if (InformacionDelError == string.Empty)
                        {
                            FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al actualizar el pedido");
                        }
                        else
                        {
                            FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al actualizar el pedido");
                            MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
            }
            dgvListaPedidos.ClearSelection();
            tmrActualizaPedidos.Start();
        }
        private void BtnGuardarCambios_Click(object sender, EventArgs e)
        {
            // Validar los datos.
            bool   DatosValidos         = true;
            string RegistroDeErrores    = string.Empty;
            int    AnchoFormInformacion = 100;

            if (ID_Cliente == -1)
            {
                DatosValidos          = false;
                RegistroDeErrores    += "Debe ingresar un cliente.\r\n\r\n";
                AnchoFormInformacion += 50;
            }

            if (!ckbRetiraEnElLocal.Checked && txtDireccion.Text.Length < 6)
            {
                DatosValidos          = false;
                RegistroDeErrores    += "Debe ingresar un minimo de 6 caracteres en la direccion.\r\n\r\n";
                AnchoFormInformacion += 50;
            }

            if (cmbNombreChef.SelectedItem != null)
            {
                ID_Chef = ((Usuario)cmbNombreChef.SelectedItem).ID_Usuario;
            }
            else
            {
                DatosValidos          = false;
                RegistroDeErrores    += "Debe ingresar un chef a cargo del pedido.\r\n\r\n";
                AnchoFormInformacion += 50;
            }

            if (DatosValidos)
            {
                txtDireccion.Text = txtDireccion.Text.Substring(0, 1).ToUpper() + txtDireccion.Text.Remove(0, 1).ToLower();

                string InformacionDelError = string.Empty;

                ClsDeliveries Deliveries             = new ClsDeliveries();
                Delivery      GuardarCambiosDelivery = new Delivery();

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

                GuardarCambioPedido = Pedidos.LeerPorNumero(ID_Pedido, ref InformacionDelError);

                if (GuardarCambioPedido != null && GuardarCambioPedido.ID_Delivery != null)
                {
                    GuardarCambiosDelivery = Deliveries.LeerPorNumero(GuardarCambioPedido.ID_Delivery, ref InformacionDelError);

                    if (GuardarCambiosDelivery != null)
                    {
                        GuardarCambioPedido.ID_Cliente = ID_Cliente;
                        GuardarCambioPedido.ID_Chef    = ID_Chef;
                        Pedidos.Actualizar(GuardarCambioPedido, ref InformacionDelError);

                        if (txtTelefonoCadete.Text == string.Empty)
                        {
                            GuardarCambiosDelivery.Telefono = null;
                        }
                        else
                        {
                            GuardarCambiosDelivery.Telefono = Convert.ToInt64(txtTelefonoCadete.Text);
                        }

                        if (ckbRetiraEnElLocal.Checked)
                        {
                            GuardarCambiosDelivery.Destino = null;
                        }
                        else
                        {
                            GuardarCambiosDelivery.Destino = txtDireccion.Text;
                        }

                        Deliveries.Actualizar(GuardarCambiosDelivery, ref InformacionDelError);

                        Close();
                    }
                    else if (InformacionDelError == string.Empty)
                    {
                        MessageBox.Show("Ocurrio un fallo al buscar el delivery", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else if (InformacionDelError == string.Empty)
                {
                    MessageBox.Show("Ocurrio un fallo al buscar el pedido", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                using (FrmInformacion FormInformacion = new FrmInformacion(RegistroDeErrores, ClsColores.Blanco, AnchoFormInformacion, 300))
                {
                    FormInformacion.ShowDialog();
                }
            }
        }
示例#10
0
        private void BtnDeliveryEntregado_Click(object sender, EventArgs e)
        {
            using (FrmValidarUsuario FormValidarUsuario = new FrmValidarUsuario(FrmValidarUsuario.EFiltroUsuariosAutorizados.Todos))
            {
                FormValidarUsuario.ShowDialog();

                if (FormValidarUsuario.DialogResult == DialogResult.OK)
                {
                    int TotalDeFilas = dgvDelivery.Rows.Count;

                    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;

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

                                ClsDetalles Detalles = new ClsDetalles();

                                if (VerDelivery != null)
                                {
                                    if (VerDelivery.Delivery.ID_EstadoDelivery == (int)ClsEstadosDeliveries.EEstadosDeliveries.ParaEntrega)
                                    {
                                        using (FrmResumenPedido FormResumenDePedido = new FrmResumenPedido((int)dgvDelivery.Rows[Indice].Cells[(int)ENumColDGVDelivery.ID_Pedido].Value, FormValidarUsuario.G_ID_UsuarioQueValido))
                                        {
                                            FormResumenDePedido.ShowDialog();

                                            if (FormResumenDePedido.DialogResult == DialogResult.OK)
                                            {
                                                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);
                                                }

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

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

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

                                                    ActualizarDelivery = Deliveries.LeerPorNumero(VerDelivery.Delivery.ID_Delivery, ref InformacionDelError);

                                                    ActualizarDelivery.ID_EstadoDelivery = (int)ClsEstadosDeliveries.EEstadosDeliveries.Entregado;

                                                    Deliveries.Actualizar(ActualizarDelivery, ref InformacionDelError);
                                                    dgvDelivery.Rows.Remove(dgvDelivery.Rows[Indice]);
                                                    Indice       -= 1;
                                                    TotalDeFilas -= 1;
                                                }
                                                else if (InformacionDelError != string.Empty)
                                                {
                                                    FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al finalizar el delivery");
                                                    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 (eliminado, entregado, etc) o este todavia se encuentra en cocina.", ClsColores.Blanco, 250, 300))
                                        {
                                            FormInformacion.ShowDialog();
                                        }
                                    }
                                }
                                else if (InformacionDelError == string.Empty)
                                {
                                    FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al buscar platos sin cocinar");
                                    MessageBox.Show("Ocurrio un fallo al buscar platos sin cocinar", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                                else
                                {
                                    FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al buscar platos sin cocinar");
                                    MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#11
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);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#12
0
        private void BtnEliminarElementos_Click(object sender, EventArgs e)
        {
            int TotalDeFilas = dgvDelivery.Rows.Count;

            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;

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

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

                        if (VerDelivery != null)
                        {
                            if (VerDelivery.Delivery.ID_EstadoDelivery == (int)ClsEstadosDeliveries.EEstadosDeliveries.EnCocina)
                            {
                                ClsDeliveries Delivery           = new ClsDeliveries();
                                Delivery      ActualizarDelivery = Delivery.LeerPorNumero(VerDelivery.ID_Delivery, ref InformacionDelError);

                                ActualizarDelivery.ID_EstadoDelivery = (int)ClsEstadosDeliveries.EEstadosDeliveries.Eliminado;
                                VerDelivery.ID_EstadoPedido          = (int)ClsEstadosPedidos.EEstadosPedidos.Eliminado;
                                VerDelivery.TiempoEspera             = null;

                                if (Pedidos.Actualizar(VerDelivery, ref InformacionDelError) != 0)
                                {
                                    if (Delivery.Actualizar(ActualizarDelivery, ref InformacionDelError) != 0)
                                    {
                                        FrmPrincipal.ObtenerInstancia().S_tslResultadoOperacion = "Pedido y delivery eliminado";
                                        dgvDelivery.Rows.Remove(dgvDelivery.Rows[Indice]);
                                        Indice       -= 1;
                                        TotalDeFilas -= 1;
                                    }
                                }
                                else if (InformacionDelError != string.Empty)
                                {
                                    FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al eliminar el delivery");
                                    MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                            }
                            else
                            {
                                using (FrmInformacion FormInformacion = new FrmInformacion($"No puede editar o eliminar el delivery " +
                                                                                           $"porque ya fue confirmado su estado o fue eliminado.", ClsColores.Blanco, 250, 300))
                                {
                                    FormInformacion.ShowDialog();
                                }
                            }
                        }
                        else if (InformacionDelError == string.Empty)
                        {
                            FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al eliminar el delivery");
                            MessageBox.Show("Ocurrio un fallo al eliminar el delivery", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al eliminar el delivery");
                            MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
            }
        }