Example #1
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);
                }
            }
        }
 private void PicBTNInformacion_Click(object sender, EventArgs e)
 {
     using (FrmInformacion FormInformacion = new FrmInformacion($"Si realiza impresiones en tickets " +
                                                                $"o impresoras en donde se encuentren datos del restaurante, estos seran tomados de lo que especifique en estos " +
                                                                $"campos.\r\n\r\nPor razones de espacio y estetica, se pide que tanto el eslogan, como los numeros de telefono, " +
                                                                $"tengan una determinada longitud.", ClsColores.Blanco, 300, 400))
     {
         FormInformacion.ShowDialog();
     }
 }
 private void PicBTNInformacion_Click(object sender, EventArgs e)
 {
     using (FrmInformacion FormInformacion = new FrmInformacion($"Para crear un pedido de delivery (el orden de la carga es indistinto), " +
                                                                $" especifique el cliente " +
                                                                $"que lo realiza usando el boton [Buscar y cargar cliente], luego la direccion de envio (debera " +
                                                                $"especificarla si no se retira en el local, en caso contrario marque el check), a continuacion " +
                                                                $"el chef que preparará el pedido, opcionalmente el telefono del cadete que enviara el pedido" +
                                                                $" y finalmente cargue el pedido seleccionando el boton [ver y/o " +
                                                                $"editar el pedido]. Una vez cargado todo, seleccione [Crear delivery].", ClsColores.Blanco, 250, 500))
     {
         FormInformacion.ShowDialog();
     }
 }
Example #4
0
        /// <summary>
        /// Muestra un color diferente (y un mensaje de advertencia la primera vez que se lo ve), para
        /// indicarle al usuario que esta por unas una funcion nueva, que podria presentar bugs.
        /// </summary>
        public static Color ColorFuncionBeta()
        {
            if (!SeAdvirtioFuncionBeta)
            {
                using (FrmInformacion FormInformacion = new FrmInformacion("Recuerde que las funciones del programa con el color de estas " +
                                                                           "letras (de fondo de un boton o de las mismas letras), indican que es una nueva funcion que se esta testeando. Si encuentra algun " +
                                                                           "error (tanto indicado por la aplicacion como uno que pueda ver pero que no se notifique), " +
                                                                           "informelo al programador para ser solucionado lo mas pronto posible.", Blanco, 250, 400))
                {
                    FormInformacion.ShowDialog();
                }

                SeAdvirtioFuncionBeta = true;

                return(Transparente);
            }

            return(FuncionBeta);
        }
 private void PicBTNInformacion_Click(object sender, EventArgs e)
 {
     using (FrmInformacion FormInformacion = new FrmInformacion($"En este cuadro de texto se muestra la ruta que indico para " +
                                                                $"crear la copia de seguridad de la base de datos. Seleccione todo el texto, luego click " +
                                                                $"derecho y seleccione la opcion 'Copiar'. Despues de eso, puede cerrar esta ventana con el " +
                                                                $"boton [Aceptar] o con la cruz de la ventana.\r\n\r\nUna vez tenga la ruta copiada, dirijase " +
                                                                $"al 'Escritorio' de su computadora (donde le aparecerá a la izquierda un listado de archivos). En " +
                                                                $"el buscador de archivos de este (parte superior), pegue la direccion que copio previamente (ruta " +
                                                                $"donde guardo la base de datos), para que este buscador lo lleve a donde creo la misma. Una vez allí, " +
                                                                $"Encontrara un archivo (con extencion .bak), que lo identificara facilmente por el nombre y la fecha " +
                                                                $"de creacion, como por ejemplo: 'Copia de seguridad del 12_11_2019 a las 12_00_00'. Ese archivo, es el " +
                                                                $"que debera arrastrar y pegarlo un una unidad de memoria externa segura (como un pendrive), con el fin " +
                                                                $"de evitar que alguien se lleve la copia de seguridad de su restaurante con todos sus datos en esta (Ya " +
                                                                $"que podria sacar la copia que dejo en la computadora)" +
                                                                $".\r\n\r\n" +
                                                                $"Se recomienda que se realize esta copia una vez al dia, al finalizar la jornada laboral, ademas de no eliminar " +
                                                                $"las copias de seguridad de dias anteriores. Si surge algun problema con la base de datos, se podra " +
                                                                $"restaurar a partir de la ultima copia de seguridad creada (si la crea uan vez al dia, se perderan " +
                                                                $"los datos de ese mismo dia, y no los de toda la semana, si la realizara semanalmente por ejemplo).", ClsColores.Blanco, 500, 700))
     {
         FormInformacion.ShowDialog();
     }
 }
        private void BtnGuardarCambios_Click(object sender, EventArgs e)
        {
            bool   DatosValidos         = true;
            string RegistroDeErrores    = string.Empty;
            int    AnchoFormInformacion = 100;

            TxtDireccion.Text = TxtDireccion.Text.Trim();

            if (TxtDireccion.Text.Length < 8)
            {
                DatosValidos          = false;
                RegistroDeErrores    += "Debe ingresar un minimo de 8 caracteres en la direccion.\r\n\r\n";
                AnchoFormInformacion += 50;
            }

            if (TxtEslogan.Text != string.Empty && (TxtEslogan.Text.Length > 24 || TxtEslogan.Text.Length < 22))
            {
                DatosValidos       = false;
                RegistroDeErrores += "La longitud del eslogan debe ser de 22 a 24 caracteres para que se imprima " +
                                     "correctamente en el ticket. Puede completar con guiones u otros simbolos hasta llegar a ese " +
                                     "rango de cantidad, o deje este campo vacio para no usar eslogan..\r\n\r\n";
                AnchoFormInformacion += 150;
            }

            if (TxtTelefonoUno.Text.Length < 7)
            {
                DatosValidos          = false;
                RegistroDeErrores    += "Debe ingresar un minimo de 7 caracteres en el telefono uno.\r\n\r\n";
                AnchoFormInformacion += 50;
            }

            if (TxtTelefonoDos.Text != string.Empty && TxtTelefonoDos.Text.Length < 7)
            {
                DatosValidos       = false;
                RegistroDeErrores += "Debe ingresar un minimo de 7 caracteres en el telefono dos, o no " +
                                     "ingresar nada si no lo quiere incluir.\r\n\r\n";
                AnchoFormInformacion += 50;
            }

            if (DatosValidos)
            {
                string InformacionDelError = string.Empty;

                ClsInformacionesRestaurantes InformacionRestaurante = new ClsInformacionesRestaurantes();
                InformacionRestaurante       ActualizarInformacion  = new InformacionRestaurante();

                ActualizarInformacion.ID_InformacionRestaurante = 1;
                ActualizarInformacion.Nombre    = txtNombre.Text.ToUpper();
                ActualizarInformacion.Direccion = TxtDireccion.Text;

                if (TxtEslogan.Text == string.Empty)
                {
                    ActualizarInformacion.Eslogan = null;
                }
                else
                {
                    TxtEslogan.Text = TxtEslogan.Text.Substring(0, 1).ToUpper() + TxtEslogan.Text.Remove(0, 1).ToLower();

                    ActualizarInformacion.Eslogan = TxtEslogan.Text;
                }

                ActualizarInformacion.TelefonoUno = Convert.ToInt64(TxtTelefonoUno.Text);

                if (TxtTelefonoDos.Text == string.Empty)
                {
                    ActualizarInformacion.TelefonoDos = null;
                }
                else
                {
                    ActualizarInformacion.TelefonoDos = Convert.ToInt64(TxtTelefonoDos.Text);
                }

                InformacionRestaurante.Actualizar(ActualizarInformacion, ref InformacionDelError);

                if (InformacionDelError == string.Empty)
                {
                    Close();
                }
                else if (InformacionDelError != string.Empty)
                {
                    MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                using (FrmInformacion FormInformacion = new FrmInformacion(RegistroDeErrores, ClsColores.Blanco, AnchoFormInformacion, 400))
                {
                    FormInformacion.ShowDialog();
                }
            }
        }
        private void BtnActualizar_Click(object sender, EventArgs e)
        {
            if (dtpVencimientoGeneral.Value.Date >= dtpVencimientoFuncionesEspecificas.Value.Date)
            {
                using (FrmValidarUsuario FormValidarUsuario = new FrmValidarUsuario(FrmValidarUsuario.EFiltroUsuariosAutorizados.Desarrolladores))
                {
                    FormValidarUsuario.ShowDialog();

                    if (FormValidarUsuario.DialogResult == DialogResult.OK)
                    {
                        string InformacionDelError = string.Empty;

                        ClsVencimientosFuncionalidades VencimientoFuncionalidades = new ClsVencimientosFuncionalidades();
                        VencimientoFuncionalidades     ActualizarFechas           = VencimientoFuncionalidades.LeerPorNumero(1, ref InformacionDelError);

                        if (ActualizarFechas != null)
                        {
                            ActualizarFechas.VencimientoGeneral   = dtpVencimientoGeneral.Value.Date;
                            ActualizarFechas.VencimientoFunciones = dtpVencimientoFuncionesEspecificas.Value.Date;

                            if (VencimientoFuncionalidades.Actualizar(ActualizarFechas, ref InformacionDelError) != 0)
                            {
                                using (FrmInformacion FormInformacion = new FrmInformacion($"Se actualizaron las fechas de vencimiento con exito:\r\n\r\n" +
                                                                                           $"Fecha de vencimiento general = {ActualizarFechas.VencimientoGeneral.ToShortDateString()}\r\n\r\n" +
                                                                                           $"Fecha de vencimiento de funciones especificas = {ActualizarFechas.VencimientoFunciones.ToShortDateString()}", ClsColores.Blanco, 200, 500))
                                {
                                    FormInformacion.ShowDialog();
                                }
                                Close();
                            }
                            else if (InformacionDelError != string.Empty)
                            {
                                MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else if (InformacionDelError == string.Empty)
                        {
                            MessageBox.Show("Fallo al leer los datos", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            MessageBox.Show($"{InformacionDelError}", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        using (FrmInformacion FormInformacion = new FrmInformacion("Usuario no autorizado, actualizacion de vencimientos cancelada.", ClsColores.Blanco, 150, 300))
                        {
                            FormInformacion.ShowDialog();
                        }
                    }
                }
            }
            else
            {
                using (FrmInformacion FormInformacion = new FrmInformacion("La fecha de vencimiento de las funciones generales no puede ser menor " +
                                                                           "a la de las funciones especificas.", ClsColores.Blanco, 150, 300))
                {
                    FormInformacion.ShowDialog();
                }
            }
        }
        private void BtnCrearDelivery_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 (ID_Articulos.Count == 0 || CantidadPorArticulo.Count == 0)
            {
                DatosValidos          = false;
                RegistroDeErrores    += "Debe ingresar un articulo.\r\n\r\n";
                AnchoFormInformacion += 50;
            }
            else if (!VerificarSiHayEnCocina())
            {
                DatosValidos          = false;
                RegistroDeErrores    += "Debe ingresar un articulo que sea para elaborar en cocina.\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      CrearDelivery = new Delivery();

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

                CrearDelivery.ID_EstadoDelivery = (int)ClsEstadosDeliveries.EEstadosDeliveries.EnCocina;

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

                if (Deliveries.Crear(CrearDelivery, ref InformacionDelError) != 0)
                {
                    CrearPedido(CrearDelivery.ID_Delivery);
                }
                else if (InformacionDelError == string.Empty)
                {
                    MessageBox.Show("Fallo al intentar crear el delivery", "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();
                }
            }
        }
        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();
                }
            }
        }
Example #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);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #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);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #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);
                        }
                    }
                }
            }
        }