Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (((Button)sender).BackColor == limpieza || ((Button)sender).BackColor == mantenimiento)
            {
                msg = new Msg();

                msg.lblMsg.Text = "¿Desea cambiar el estado a disponible?";
                msg.Text        = $"Confirmación | Habitación {((Button)sender).Name.Remove(0, 6)}";
                DialogResult dlgres = msg.ShowDialog();
                {
                    if (dlgres == DialogResult.Yes)
                    {
                        if (CambiarEstadoHabitacion(false, "disponible", ((Button)sender).Name.Remove(0, 6)))
                        {
                            ((Button)sender).BackColor = disponible;
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }

            if (((Button)sender).BackColor == disponible || (((Button)sender).BackColor == ocupada))
            {
                ActivarTimerEspera();

                int numeroHabitacion = int.Parse(((Button)sender).Name.Remove(0, 6));//Text);
                reservacion = new Reservacion();

                reservacion.PanelCedula(false);

                if (((Button)sender).BackColor == ocupada)
                {
                    if (!reservacion.HayReserva(numeroHabitacion)) // Aparece como ocupada pero NO tiene datos de reserva almacenados
                    {
                        CambiarEstadoHabitacion(false, "disponible", numeroHabitacion.ToString());
                        ActualizarColores();
                        return;
                    }
                    reservacion.CargarReservacion(numeroHabitacion, "ocupada");
                }
                else if (((Button)sender).BackColor == disponible)
                {
                    if (reservacion.HayReserva(numeroHabitacion)) // Aparece como disponible pero aún tiene datos de reserva almacenados
                    {
                        CambiarEstadoHabitacion(true, "disponible", numeroHabitacion.ToString());
                    }

                    reservacion.CargarReservacion(numeroHabitacion, "disponible");
                }

                reservacion.ShowDialog();
            }
        }
Пример #2
0
        public void ComprobarReservas()
        {
            using (reservacion = new Reservacion())
            {
                foreach (Button b in tableLayoutPanel1.Controls)
                {
                    if (b.BackColor == ocupada)
                    {
                        if (!reservacion.HayReserva(int.Parse(b.Name.Remove(0, 6))))
                        {
                            //MessageBox.Show(b.Name.Remove(0, 6));
                            CambiarEstadoHabitacion(false, "disponible", b.Name.Remove(0, 6));
                            b.BackColor = disponible;
                            //ActualizarColores();
                        }
                    }

                    /*if (b.BackColor == disponible)
                     * {
                     *  if (reservacion.HayReserva(int.Parse(b.Name.Remove(0, 6))))
                     *  {
                     *      //MessageBox.Show(b.Name.Remove(0, 6));
                     *      CambiarEstadoHabitacion(true, "ocupada", b.Name.Remove(0, 6));
                     *      b.BackColor = ocupada;
                     *      //ActualizarColores();
                     *
                     *  }
                     * }*/
                }
            }
        }