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

            ClsDetalles    Detalle         = new ClsDetalles();
            List <Detalle> ListarArticulos = Detalle.LeerListado(ID_Pedido, ClsDetalles.ETipoDeListado.PorIDPedido, ref InformacionDelError);

            if (ListarArticulos != null)
            {
                double?TotalPedido = 0;

                foreach (Detalle Elemento in ListarArticulos)
                {
                    int NumeroDeFila = dgvArticulosPedido.Rows.Add();

                    dgvArticulosPedido.Rows[NumeroDeFila].Cells[(int)ENumColDGVArticulosPedido.ID_Articulo].Value = Elemento.Articulo.ID_Articulo;
                    dgvArticulosPedido.Rows[NumeroDeFila].Cells[(int)ENumColDGVArticulosPedido.Articulo].Value    = Elemento.Articulo.Nombre;
                    dgvArticulosPedido.Rows[NumeroDeFila].Cells[(int)ENumColDGVArticulosPedido.Cantidad].Value    = Elemento.Cantidad;

                    TotalPedido = Elemento.Pedido.TotalPedido;
                }
                lblResultadoTotal.Text = Convert.ToString(TotalPedido);
            }
            else if (InformacionDelError == string.Empty)
            {
                MessageBox.Show($"Fallo al listar los articulos", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Si el pedido no estaba cargado, lo carga, si ya estaba cargado, lo actualiza
        /// </summary>
        private void ActualizaInformacionPedido(int _ID_Pedido)
        {
            string InformacionDelError = string.Empty;

            ClsDetalles    Detalles         = new ClsDetalles();
            List <Detalle> PlatosSinCocinar = Detalles.LeerListado(_ID_Pedido, ClsDetalles.ETipoDeListado.ParaCocina, ref InformacionDelError);

            if (PlatosSinCocinar != null)
            {
                dgvPlatosPorMesa.Rows.Clear();

                string Nota = string.Empty;

                foreach (Detalle Elemento in PlatosSinCocinar)
                {
                    int NumeroDeFila = dgvPlatosPorMesa.Rows.Add();

                    dgvPlatosPorMesa.Rows[NumeroDeFila].Cells[(int)ENumColDGVPlatosPorMesa.ID_Pedido].Value = Elemento.Pedido.ID_Pedido;
                    dgvPlatosPorMesa.Rows[NumeroDeFila].Cells[(int)ENumColDGVPlatosPorMesa.Articulo].Value  = Elemento.Articulo.Nombre;
                    dgvPlatosPorMesa.Rows[NumeroDeFila].Cells[(int)ENumColDGVPlatosPorMesa.Detalle].Value   = Elemento.Articulo.Descripcion;

                    if (Elemento.ID_EstadoDetalle == (int)ClsEstadoDetalle.EEstadoDetalle.NoCocinado)
                    {
                        dgvPlatosPorMesa.Rows[NumeroDeFila].Cells[(int)ENumColDGVPlatosPorMesa.Cantidad].Value = Elemento.Cantidad;
                    }
                    else
                    {
                        dgvPlatosPorMesa.Rows[NumeroDeFila].Cells[(int)ENumColDGVPlatosPorMesa.Cantidad].Value = Elemento.CantidadAgregada;
                    }

                    Nota = Elemento.Pedido.Nota;
                }

                lblDetallesDelPedido.Text = Nota.ToUpper();

                dgvPlatosPorMesa.ClearSelection();
            }
            else if (InformacionDelError == string.Empty)
            {
                FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al cargar el pedido");
            }
            else
            {
                FrmPrincipal.ObtenerInstancia().MensajeAdvertencia("Fallo al cargar el pedido");
                MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 3
0
        private void CargarDGVVerCocina()
        {
            dgvVerCocina.Rows.Clear();

            string InformacionDelError = string.Empty;

            ClsDetalles    Detalles         = new ClsDetalles();
            List <Detalle> PlatosSinCocinar = Detalles.LeerListado(ID_Pedido, ClsDetalles.ETipoDeListado.ParaCocina, ref InformacionDelError);

            if (PlatosSinCocinar != null)
            {
                dgvVerCocina.Rows.Clear();

                string Nota = string.Empty;

                foreach (Detalle Elemento in PlatosSinCocinar)
                {
                    int NumeroDeFila = dgvVerCocina.Rows.Add();

                    dgvVerCocina.Rows[NumeroDeFila].Cells[0].Value = Elemento.Pedido.ID_Pedido;
                    dgvVerCocina.Rows[NumeroDeFila].Cells[1].Value = Elemento.Articulo.Nombre;
                    dgvVerCocina.Rows[NumeroDeFila].Cells[2].Value = Elemento.Articulo.Descripcion;

                    if (Elemento.ID_EstadoDetalle == (int)ClsEstadoDetalle.EEstadoDetalle.NoCocinado)
                    {
                        dgvVerCocina.Rows[NumeroDeFila].Cells[3].Value = Elemento.Cantidad;
                    }
                    else
                    {
                        dgvVerCocina.Rows[NumeroDeFila].Cells[3].Value = Elemento.CantidadAgregada;
                    }

                    Nota = Elemento.Pedido.Nota;
                }

                lblDetallesDelPedido.Text = Nota;
            }
            else if (InformacionDelError == string.Empty)
            {
                MessageBox.Show($"Fallo al cargar el pedido", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        /// <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;
            }
        }
        private void BtnGuardarCambios_Click(object sender, EventArgs e)
        {
            bool   DatosValidos         = true;
            string RegistroDeErrores    = string.Empty;
            int    AnchoFormInformacion = 100;

            txtNombreCategoria.Text = txtNombreCategoria.Text.Trim();

            if (txtNombreCategoria.Text.Length < 3)
            {
                DatosValidos          = false;
                RegistroDeErrores    += "El campo 'Nombre' debe tener como minimo 3 caracteres.\r\n\r\n";
                AnchoFormInformacion += 50;
            }

            if (VerificarCategoriaRepetida(txtNombreCategoria.Text, ID_Categoria))
            {
                DatosValidos          = false;
                RegistroDeErrores    += "El nombre de la categoria ya esta en uso.\r\n\r\n";
                AnchoFormInformacion += 50;
            }

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

                string InformacionDelError = string.Empty;

                ClsCategoriasArticulos CategoriasArticulos = new ClsCategoriasArticulos();
                CategoriaArticulo      ActualizarCategoria = CategoriasArticulos.LeerPorNumero(ID_Categoria, ref InformacionDelError);

                if (ActualizarCategoria != null)
                {
                    ActualizarCategoria.Nombre = txtNombreCategoria.Text;

                    if (rbnCocinaSi.Checked)
                    {
                        ActualizarCategoria.ParaCocina = (int)ClsCategoriasArticulos.EParaCocina.Si;
                    }
                    else
                    {
                        ActualizarCategoria.ParaCocina = (int)ClsCategoriasArticulos.EParaCocina.No;
                    }

                    ClsDetalles    Detalles = new ClsDetalles();
                    List <Detalle> SeEstaUsuandoLaCategoria = Detalles.LeerListado(-1, ClsDetalles.ETipoDeListado.CategoriaEnUso, ref InformacionDelError, ID_Categoria);

                    if (SeEstaUsuandoLaCategoria.Count == 0)
                    {
                        if (CategoriasArticulos.Actualizar(ActualizarCategoria, ref InformacionDelError) != 0)
                        {
                            DialogResult = DialogResult.OK;
                            Close();
                        }
                        else if (InformacionDelError != string.Empty)
                        {
                            MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        using (FrmInformacion FormInformacion = new FrmInformacion($"No se puede editar la categoria porque " +
                                                                                   $"se esta usando para algun pedido en este momento.", ClsColores.Blanco, 200, 300))
                        {
                            FormInformacion.ShowDialog();
                        }
                    }
                }
            }
            else
            {
                using (FrmInformacion FormInformacion = new FrmInformacion(RegistroDeErrores, ClsColores.Blanco, AnchoFormInformacion, 300))
                {
                    FormInformacion.ShowDialog();
                }
            }
        }
Esempio n. 6
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 CargarResumenPedido()
        {
            double Total = 0;
            string InformacionDelError = string.Empty;

            ClsDetalles    Detalles         = new ClsDetalles();
            List <Detalle> DetalleDelPedido = Detalles.LeerListado(ID_Pedido, ClsDetalles.ETipoDeListado.PorIDPedido, ref InformacionDelError);

            if (DetalleDelPedido != null)
            {
                foreach (Detalle Elemento in DetalleDelPedido)
                {
                    int NumeroDeFila = dgvArticulosPedido.Rows.Add();

                    dgvArticulosPedido.Rows[NumeroDeFila].Cells[(int)ENumColDGVResumenPedido.ID_Articulo].Value = Elemento.Articulo.ID_Articulo;
                    dgvArticulosPedido.Rows[NumeroDeFila].Cells[(int)ENumColDGVResumenPedido.Articulo].Value    = Elemento.Articulo.Nombre;
                    dgvArticulosPedido.Rows[NumeroDeFila].Cells[(int)ENumColDGVResumenPedido.Cantidad].Value    = Elemento.Cantidad;

                    if (EsDelivery)
                    {
                        double PrecioDelivery = 0;

                        if (Elemento.Articulo.PrecioDelivery != null)
                        {
                            PrecioDelivery = (double)Elemento.Articulo.PrecioDelivery;
                        }

                        dgvArticulosPedido.Rows[NumeroDeFila].Cells[(int)ENumColDGVResumenPedido.PrecioUnitario].Value = PrecioDelivery;
                        dgvArticulosPedido.Rows[NumeroDeFila].Cells[(int)ENumColDGVResumenPedido.Subtotal].Value       = PrecioDelivery * Elemento.Cantidad;
                    }
                    else
                    {
                        double Precio = 0;

                        if (Elemento.Articulo.Precio != null)
                        {
                            Precio = (double)Elemento.Articulo.Precio;
                        }

                        dgvArticulosPedido.Rows[NumeroDeFila].Cells[(int)ENumColDGVResumenPedido.PrecioUnitario].Value = Precio;
                        dgvArticulosPedido.Rows[NumeroDeFila].Cells[(int)ENumColDGVResumenPedido.Subtotal].Value       = Precio * Elemento.Cantidad;
                    }

                    Total += Convert.ToDouble(dgvArticulosPedido.Rows[NumeroDeFila].Cells[(int)ENumColDGVResumenPedido.Subtotal].Value);
                }

                lblMostratTotal.Text = Convert.ToString(Total);
            }
            else if (InformacionDelError == string.Empty)
            {
                MessageBox.Show("Fallo al cargar el detalle del pedido", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Close();
            }
            else
            {
                MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Close();
            }

            lblNumeroPedido.Text += $" {ID_Pedido}";
        }
        private void CrearDetalle(int _ID_Pedido, int _ID_Delivery)
        {
            string InformacionDelError = string.Empty;

            ClsDetalles Detalles     = new ClsDetalles();
            Detalle     CrearDetalle = new Detalle();

            ClsArticulos Articulos = new ClsArticulos();

            int TotalDeArticulos = ID_Articulos.Count;

            bool HuboError = false;

            for (int Contador = 0; Contador < TotalDeArticulos; Contador++)
            {
                CrearDetalle.ID_Pedido   = _ID_Pedido;
                CrearDetalle.ID_Articulo = ID_Articulos.First();
                CrearDetalle.ID_Chef     = ID_Chef;
                CrearDetalle.Cantidad    = CantidadPorArticulo.First();
                CrearDetalle.Nota        = null;
                CrearDetalle.Precio      = null;

                if ((int)ClsCategoriasArticulos.EParaCocina.Si == Articulos.LeerPorNumero(ID_Articulos.First(), ref InformacionDelError).CategoriaArticulo.ParaCocina)
                {
                    CrearDetalle.ID_EstadoDetalle = (int)ClsEstadoDetalle.EEstadoDetalle.NoCocinado;
                }
                else
                {
                    CrearDetalle.ID_EstadoDetalle = (int)ClsEstadoDetalle.EEstadoDetalle.YaCocinado;
                }

                CrearDetalle.CantidadAgregada     = 0;
                CrearDetalle.ID_ArticuloEntregado = (int)ClsArticulosEntregados.EArticuloEntregado.NoEntregado;

                if (Detalles.Crear(CrearDetalle, ref InformacionDelError) != 0)
                {
                    ID_Articulos.Remove(ID_Articulos.First());
                    CantidadPorArticulo.Remove(CantidadPorArticulo.First());
                }
                else if (InformacionDelError != string.Empty)
                {
                    HuboError = true;

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

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

                    List <Detalle> EliminarDetalle = Detalles.LeerListado(_ID_Pedido, ClsDetalles.ETipoDeListado.PorIDPedido, ref InformacionDelError);

                    Deliveries.Borrar(_ID_Delivery, ref InformacionDelError);
                    Pedidos.Borrar(_ID_Pedido, ref InformacionDelError);

                    if (EliminarDetalle != null)
                    {
                        foreach (Detalle Elemento in EliminarDetalle)
                        {
                            Detalles.Borrar(Elemento.ID_Detalle, ref InformacionDelError);
                        }
                    }

                    MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    break;
                }
            }

            // No hubo error en la creacion de los detalles, confirmar y cerrar.
            if (!HuboError)
            {
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Esempio n. 9
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);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 10
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);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }