public List <Regimen> getRegimenes() { if (this.regimenes == null) { RepositorioRegimen repoRegimen = new RepositorioRegimen(); this.regimenes = repoRegimen.getByIdHotel(this.idHotel); } return(this.regimenes); }
private void initModificacionHotel() { RepositorioCategoria repoCategoria = new RepositorioCategoria(); this.estrellasComboBox.DataSource = repoCategoria.getAll().OrderBy(c => c.getEstrellas()).ToList(); this.estrellasComboBox.ValueMember = "Estrellas"; RepositorioRegimen repoRegimen = new RepositorioRegimen(); this.regimenesGrid.DataSource = repoRegimen.getAll().OrderBy(r => r.getDescripcion()).ToList(); regimenesGrid.AutoResizeColumns(); regimenesGrid.CurrentCell = null; regimenesGrid.ClearSelection(); this.regimenesGrid.Rows[0].Cells[0].Selected = false; this.regimenesGrid.Rows[0].Selected = false; this.nombreText.Text = hotel.getNombre(); this.paisText.Text = hotel.getDireccion().getPais(); this.ciudadText.Text = hotel.getDireccion().getCiudad(); this.telefonoText.Text = hotel.getTelefono(); this.estrellasComboBox.SelectedValue = hotel.getCategoria().getEstrellas(); this.calleText.Text = hotel.getDireccion().getCalle(); this.numeroCalleText.Text = hotel.getDireccion().getNumeroCalle().ToString(); this.creacionTime.Value = hotel.getFechaInicioActividades(); this.emailText.Text = hotel.getMail(); foreach (DataGridViewRow row in regimenesGrid.Rows) { Regimen regimen = (Regimen)row.DataBoundItem; if (hotel.getRegimenes().Exists(r => r.getIdRegimen().Equals(regimen.getIdRegimen()))) { this.regimenesGrid.Rows[row.Index].Cells[0].Selected = true; this.regimenesGrid.Rows[row.Index].Selected = true; } } this.dataGridCierres.DataSource = this.hotel.getCierresTemporales().OrderBy(c => c.getFechaInicio()).ToList(); //ESTO LO TENGO QUE HACER PARA QUE NO APAREZCA SIEMPRE SELECCIONADO EL PRIMER ITEM dataGridCierres.CurrentCell = null; dataGridCierres.ClearSelection(); //MEJORA DE PERFORMANCE DEL DGV this.dataGridReservas.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.EnableResizing; this.dataGridReservas.RowHeadersVisible = false; this.dataGridReservas.DataSource = this.hotel.getReservas().OrderBy(r => r.getFechaDesde()).ToList(); this.dataGridReservas.RowHeadersVisible = true; //ESTO LO TENGO QUE HACER PARA QUE NO APAREZCA SIEMPRE SELECCIONADO EL PRIMER ITEM dataGridReservas.CurrentCell = null; dataGridReservas.ClearSelection(); }
private void initModificacionHotel() { RepositorioCategoria repoCategoria = new RepositorioCategoria(); RepositorioRegimen repoRegimen = new RepositorioRegimen(); this.estrellasComboBox.DataSource = repoCategoria.getAll().OrderBy(c => c.getEstrellas()).ToList(); this.regimenesDataGrid.DataSource = repoRegimen.getAll().OrderBy(r => r.getDescripcion()).ToList(); regimenesDataGrid.AutoResizeColumns(); this.regimenesDataGrid.CurrentCell = null; this.regimenesDataGrid.ClearSelection(); this.regimenesDataGrid.Rows[0].Cells[0].Selected = false; this.regimenesDataGrid.Rows[0].Selected = false; this.nombreText.Text = ""; this.paisText.Text = ""; this.ciudadText.Text = ""; this.telefonoText.Text = ""; this.calleText.Text = ""; this.numeroCalleText.Text = ""; this.emailText.Text = ""; this.creacionTime.ResetText(); this.estrellasComboBox.SelectedItem = null; }
private void buscarHabitaciones(Regimen regimenParam) { this.reservarHabitacionButton.Enabled = false; DateTime fechaInicio = (DateTime)Utils.validateFields(calendarioDesde.Value, "Fecha Desde"); DateTime fechaFin = (DateTime)Utils.validateFields(calendarioHasta.Value, "Fecha Hasta"); if (fechaInicio < Utils.getSystemDatetimeNow()) { MessageBox.Show("No puede realizar reservas en el pasado", "Error"); return; } if (Utils.validateTimeRanges(fechaInicio, fechaFin)) { Hotel hotelSeleccionado = null; if (sesion != null && sesion.getHotel() != null) { hotelSeleccionado = sesion.getHotel(); } else { hotelSeleccionado = (Hotel)Utils.validateFields(comboBoxHotel.SelectedItem, "Hotel"); } TipoHabitacion tipoHabitacionSeleccionada = null; if (comboBoxTipoHabitacion.SelectedItem != null) { tipoHabitacionSeleccionada = (TipoHabitacion)comboBoxTipoHabitacion.SelectedItem; } Regimen regimenSeleccionado = null; regimenSeleccionado = (Regimen)comboBoxRegimen.SelectedItem; regimenSeleccionado = regimenParam; RepositorioHabitacion repoHabitacion = new RepositorioHabitacion(); List <HabitacionDisponible> habitacionesDisponibles = repoHabitacion.getHabitacionesDisponibles(fechaInicio, fechaFin, hotelSeleccionado, tipoHabitacionSeleccionada, regimenSeleccionado, null).OrderBy(hd => hd.getNumeroHabitacion()).ToList(); if (habitacionesDisponibles.Count == 0) { limpiarRegimenesDataGrid(); this.regimenesDisponiblesGrid.DataSource = null; this.habitacionesDisponiblesGrid.DataSource = null; MessageBox.Show("No se encontraron habitaciones disponibles.", "Generar Reserva", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } this.habitacionesDisponiblesGrid.DataSource = habitacionesDisponibles; this.habitacionesDisponiblesGrid.AutoResizeColumns(); this.habitacionesDisponiblesGrid.CurrentCell = null; this.habitacionesDisponiblesGrid.ClearSelection(); if (this.habitacionesDisponiblesGrid.Rows.Count > 0) { this.habitacionesDisponiblesGrid.Rows[0].Cells[0].Selected = false; this.habitacionesDisponiblesGrid.Rows[0].Selected = false; } RepositorioRegimen repoRegimen = new RepositorioRegimen(); this.regimenesDisponiblesGrid.DataSource = repoRegimen.getByIdHotel(hotelSeleccionado.getIdHotel()); this.regimenesDisponiblesGrid.AutoResizeColumns(); if (regimenSeleccionado == null) { limpiarRegimenesDataGrid(); } else { limpiarRegimenesDataGrid(); foreach (DataGridViewRow item in this.regimenesDisponiblesGrid.Rows) { Regimen regimen = item.DataBoundItem as Regimen; if (regimen.getIdRegimen() == regimenSeleccionado.getIdRegimen()) { item.Selected = true; } } } } }