Пример #1
0
        private void buttonClean_Click(object sender, EventArgs e)
        {
            txtNombre.Text     = "";
            txtApellido.Text   = "";
            TxtNroReserva.Text = "";
            Reserva reserva = this.getDataToSearch();

            ReservaHelper.search(reserva, dgvReserva);
        }
Пример #2
0
        private void button_consultar_Click(object sender, EventArgs e)
        {
            if ((dTDesde.Value >= VarGlobal.FechaHoraSistema) && (dTHasta.Value > VarGlobal.FechaHoraSistema) && (dTDesde.Value < dTHasta.Value))
            {
                if (VarGlobal.usuario.id == "guest")
                {
                    if (cmbHotel.SelectedValue.ToString() != String.Empty)
                    {
                        VarGlobal.usuario.hotel = Convert.ToInt32(cmbHotel.SelectedValue.ToString());
                        ReservaHelper.search_regimen(VarGlobal.usuario.hotel, dgvRegimen);
                        ReservaHelper.search_tipo_hab(VarGlobal.usuario.hotel, dgvTipoHabitacion);


                        if (dgvTipoHabitacion.Rows.Count <= 0)
                        {
                            MessageBox.Show("El hotel no tiene habitaciones registradas");
                            return;
                        }
                        if (dgvRegimen.Rows.Count <= 0)
                        {
                            MessageBox.Show("El hotel no tiene regimenes registrados");
                            return;
                        }
                    }
                }

                Reserva reserva = this.getdataConsulta();
                if (reserva != null)
                {
                    int disponible = ReservaHelper.check_hotel_availability(reserva);
                    if (disponible == 1)
                    {
                        MessageBox.Show("Hay disponibilidad de Habitacion");
                    }
                    else
                    {
                        MessageBox.Show("No hay disponibilidad de Habitacion. Elija otro rango de fechas u otro tipo de habitacion");
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                MessageBox.Show("Verificar las fechas Desde y Hasta. Hoy es: " + VarGlobal.FechaHoraSistema.Date.ToShortDateString());
            }
        }
        private void buttonGuardar_Click(object sender, EventArgs e)
        {
            Reserva reserva = this.getDataFromForm();

            if (dtFechaDesde.Value >= dtFechaHasta.Value)
            {
                MessageBox.Show("La fecha de ingreso debe ser menor a la de salida");
                return;
            }
            if (dtFechaDesde.Value < VarGlobal.FechaHoraSistema)
            {
                MessageBox.Show("La fecha de ingreso no puede ser menor a HOY: " + VarGlobal.FechaHoraSistema.Date.ToShortDateString());
                return;
            }

            ReservaHelper.update_reserva(reserva);
        }
Пример #4
0
 private void FormAltaReserva_Load(object sender, EventArgs e)
 {
     TypeDocument.fillComboBox(comboTypeDocument);
     this.ControlBox  = false;
     cmbHotel.Text    = "";
     this.WindowState = FormWindowState.Maximized;
     ReservaHelper.search_regimen(VarGlobal.usuario.hotel, dgvRegimen);
     ReservaHelper.search_tipo_hab(VarGlobal.usuario.hotel, dgvTipoHabitacion);
     if (VarGlobal.usuario.id == "guest")
     {
         ReservaHelper.fillHotel(cmbHotel);
     }
     else
     {
         cmbHotel.Visible = false;
         lblHotel.Visible = false;
     }
 }
        private Reserva getDataFromForm()
        {
            Reserva reserva = new Reserva();

            reserva.id_hotel  = VarGlobal.usuario.hotel;
            reserva.clienteId = ReservaHelper.search_hotel_by_reserva(Convert.ToInt32(txtIdReserva.Text));
            reserva.id        = Convert.ToInt32(txtIdReserva.Text);
            if (reserva.tipo_habitacion != Convert.ToString(dgvTipoHabitacion.CurrentRow.Cells[0].Value))
            {
                reserva.tipo_habitacion = Convert.ToString(dgvTipoHabitacion.CurrentRow.Cells[0].Value);
            }
            if (reserva.tipo_regimen != Convert.ToString(dgvRegimen.CurrentRow.Cells[0].Value))
            {
                reserva.tipo_regimen = Convert.ToString(dgvRegimen.CurrentRow.Cells[0].Value);
            }
            reserva.fecha_inicio = dtFechaDesde.Value;
            reserva.fecha_fin    = dtFechaHasta.Value;
            reserva.estadia      = Convert.ToInt32((dtFechaHasta.Value - dtFechaDesde.Value).TotalDays);

            return(reserva);
        }
        private void buttonBuscar_Click(object sender, EventArgs e)
        {
            buttonGuardar.Enabled = false;
            dtFechaDesde.Enabled  = false;
            dtFechaHasta.Enabled  = false;
            dgvRegimen.DataSource = null;
            dgvRegimen.Refresh();
            dgvTipoHabitacion.DataSource = null;
            dgvTipoHabitacion.Refresh();

            Boolean isValid = Validaciones.validAndRequiredInt32(txtIdReserva.Text, "El numero de la reserva es obligatorio y numerico");

            if (!isValid)
            {
                return;
            }
            int reservaHotel = ReservaHelper.search_hotel_by_reserva(Convert.ToInt32(txtIdReserva.Text));

            if (VarGlobal.usuario.id == "guest")
            {
                VarGlobal.usuario.hotel = reservaHotel;
            }
            else
            {
                if (reservaHotel != VarGlobal.usuario.hotel)
                {
                    MessageBox.Show("El numero de reserva no pertenece a este hotel");
                    return;
                }
            }

            if (reservaHotel == 0)
            {
                MessageBox.Show("El numero de reserva no existe");
                return;
            }


            Reserva reserva = this.getDataToSearch();

            ReservaHelper.search_reserva(reserva);

            if (reserva.fecha_inicio <= VarGlobal.FechaHoraSistema)
            {
                MessageBox.Show("Ya paso el plazo para modificar esta reserva con fecha de inicio: " + reserva.fecha_inicio.Date.ToShortDateString() + ". Hoy es: " + VarGlobal.FechaHoraSistema.Date.ToShortDateString());
                return;
            }

            ReservaHelper.search_regimen(VarGlobal.usuario.hotel, dgvRegimen);
            ReservaHelper.search_tipo_hab(VarGlobal.usuario.hotel, dgvTipoHabitacion);

            dtFechaDesde.Value = reserva.fecha_inicio;
            dtFechaHasta.Value = dtFechaDesde.Value.AddDays(reserva.estadia);


            for (int i = 0; i < dgvRegimen.RowCount; i++)
            {
                if (dgvRegimen.Rows[i].Cells[0].Value.ToString() == reserva.tipo_regimen)
                {
                    dgvRegimen.Rows[i].Selected = true;
                    this.dgvRegimen.CurrentCell = this.dgvRegimen.Rows[i].Cells[0];
                }
                else
                {
                    if (i < dgvRegimen.RowCount - 1)
                    {
                        dgvRegimen.Rows[i].Selected = false;
                    }
                }
            }
            for (int i = 0; i < dgvTipoHabitacion.RowCount; i++)
            {
                if (dgvTipoHabitacion.Rows[i].Cells[0].Value.ToString() == reserva.tipo_habitacion)
                {
                    dgvTipoHabitacion.Rows[i].Selected = true;
                    this.dgvTipoHabitacion.CurrentCell = this.dgvTipoHabitacion.Rows[i].Cells[0];
                }
                else
                {
                    if (i < dgvTipoHabitacion.RowCount - 1)
                    {
                        dgvTipoHabitacion.Rows[i].Selected = false;
                    }
                }
            }


            buttonGuardar.Enabled = true;
            dtFechaDesde.Enabled  = true;
            dtFechaHasta.Enabled  = true;
        }
Пример #7
0
        private void buttonSearch_Click(object sender, EventArgs e)
        {
            Reserva reserva = this.getDataToSearch();

            ReservaHelper.search(reserva, dgvReserva);
        }
Пример #8
0
        private void buttonReservar_Click(object sender, EventArgs e)
        {
            Boolean estaTodoOk = true;

            if (dgvTipoHabitacion.Rows.Count <= 0)
            {
                MessageBox.Show("El hotel no tiene habitaciones registradas");
                estaTodoOk = false;
                return;
            }
            if (dgvRegimen.Rows.Count <= 0)
            {
                MessageBox.Show("El hotel no tiene regimenes registrados");
                estaTodoOk = false;
                return;
            }
            if (dgvClient.Rows.Count == 0)
            {
                MessageBox.Show("Debe seleccionar algun cliente ya registrado, o registrar uno nuevo");
                estaTodoOk = false;
                return;
            }
            else
            {
                if (dgvClient.CurrentRow.Selected == false)
                {
                    MessageBox.Show("Debe seleccionar algun cliente ya registrado, o registrar uno nuevo");
                    estaTodoOk = false;
                }
            }
            if (VarGlobal.usuario.id == "guest" && cmbHotel.SelectedValue.ToString() != String.Empty)
            {
                VarGlobal.usuario.hotel = Convert.ToInt32(cmbHotel.SelectedValue.ToString());
                ReservaHelper.search_regimen(VarGlobal.usuario.hotel, dgvRegimen);
                ReservaHelper.search_tipo_hab(VarGlobal.usuario.hotel, dgvTipoHabitacion);

                //estaTodoOk = false;
            }
            else
            {
                if (VarGlobal.usuario.id == "guest")
                {
                    MessageBox.Show("Debe seleccionar algun hotel");
                    estaTodoOk = false;
                    return;
                }
            }

            if (VarGlobal.usuario.id == "guest" && cmbHotel.Text == "")
            {
                MessageBox.Show("Debe seleccionar algun hotel");
                estaTodoOk = false;
                return;
            }


            if (estaTodoOk)
            {
                Reserva reserva = this.getdataConsulta();
                if (ReservaHelper.reservar(reserva))
                {
                    this.Close();
                }
            }
        }