private void GetHabitaciones()
        {
            try
            {
                CNHabitacion habitacion = new CNHabitacion();
                var          lista      = habitacion.ListarHab();

                EHabitacionBindingSource.DataSource = lista;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error al obtener datos (Habitaciones)", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.reportViewer1.RefreshReport();
            }
        }
예제 #2
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (eRva == null)
                {
                    eRva = new EReserva();
                }

                eRva.IdHabitacion     = Convert.ToInt32(txtIdHabitacion.Text);
                eRva.IdCliente        = Convert.ToInt32(txtIdCliente.Text);
                eRva.IdTrabajador     = Convert.ToInt32(txtIdTrabajador.Text);
                eRva.TipoReserva      = cmbTipoReserva.Text;
                eRva.FechaReserva     = dtpFechaReserva.Value;
                eRva.FechaIngreso     = dtpFechaIngreso.Value;
                eRva.FechaSalida      = dtpFechaSalida.Value;
                eRva.CostoAlojamiento = Convert.ToDecimal(txtCosto.Text.Trim());
                eRva.Estado           = cmbEstado.Text;

                if (editar)
                {
                    idReserva      = dgvReservas.CurrentRow.Cells[0].Value.ToString();
                    eRva.IdReserva = Convert.ToInt32(idReserva);

                    bool res = cnRva.EditarRva(eRva);
                    if (cnRva.builder.Length == 0)
                    {
                        if (res)
                        {
                            MessageBox.Show("¡Reserva editada con éxito!", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ListarReserva();
                            Limpiar();
                            Inhabilitar();
                        }
                    }
                }
                else
                {
                    bool res = cnRva.RegistrarRva(eRva);

                    if (cnRva.builder.Length == 0)
                    {
                        if (res)
                        {
                            MessageBox.Show("¡Reserva registrada con éxito!", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ListarReserva();
                            Limpiar();
                            Inhabilitar();

                            //Ocupamos la habitación alquilada
                            CNHabitacion hb = new CNHabitacion();
                            hb.OcuparHab(eRva.IdHabitacion);
                        }
                    }
                }

                if (cnRva.builder.Length != 0)
                {
                    MessageBox.Show(cnRva.builder.ToString(), "Para continuar", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error inesperado", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }