private void buttonCrearHabitacion_Click(object sender, EventArgs e)
        {
            try
            {
                int                   numero                = Utils.validateIntField(textNumero.Text, "Numero");
                int                   piso                  = Utils.validateIntField(textPiso.Text, "Piso");
                Hotel                 hotel                 = this.hotel;
                String                ubicacion             = Utils.validateStringFields((String)comboBoxUbicacion.SelectedItem, "Ubicacion");
                String                descripcion           = textDescripcion.Text.Trim();
                TipoHabitacion        tipoHabitacion        = (TipoHabitacion)Utils.validateFields(comboBoxTipoHabitacion.SelectedItem, "Tipo");
                RepositorioHabitacion repositorioHabitacion = new RepositorioHabitacion();
                bool                  activa                = checkBoxActiva.Checked;
                Habitacion            habitacion            = new Habitacion(0, activa, numero, piso, ubicacion, descripcion);
                habitacion.setHotel(hotel);
                habitacion.setTipoHabitacion(tipoHabitacion);

                if (repositorioHabitacion.yaExisteHabitacionMismoNumero(habitacion))
                {
                    MessageBox.Show("Ya existe una habitacion con ese numero.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                repositorioHabitacion.create(habitacion);
                MessageBox.Show("Habitacion creada", "Gestion de Datos TP 2018 1C - LOS_BORBOTONES", MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.limpiarDatos();
            }
            //catch (RequestInvalidoException exception)
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Gestion de Datos TP 2018 1C - LOS_BORBOTONES", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void buttonBbuscarHoteles_Click(object sender, EventArgs e)
        {
            String                numero                = validateStringFields(textNumero.Text.Trim());
            String                piso                  = validateStringFields(textPiso.Text.Trim());
            TipoHabitacion        tipoHabitacion        = (TipoHabitacion)comboBoxTipoHabitacion.SelectedItem;
            RepositorioHabitacion repositorioHabitacion = new RepositorioHabitacion();
            //bool activa = checkBoxActiva.Checked;

            KeyValuePair <String, Boolean> estado = new KeyValuePair <String, Boolean>();

            if (comboBoxEstados.SelectedItem != null)
            {
                estado = (KeyValuePair <String, Boolean>)comboBoxEstados.SelectedItem;
            }

            //MEJORA DE PERFORMANCE DEL DGV
            registroHabitaciones.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.EnableResizing;
            registroHabitaciones.RowHeadersVisible       = false;
            registroHabitaciones.DataSource = repositorioHabitacion.getByQuery(numero, piso, this.sesion.getHotel(), tipoHabitacion, estado).OrderBy(hab => hab.getNumero()).ToList();
            registroHabitaciones.AutoResizeColumns();
            registroHabitaciones.RowHeadersVisible = true;

            //ESTO LO TENGO QUE HACER PARA QUE NO APAREZCA SIEMPRE SELECCIONADO EL PRIMER ITEM
            registroHabitaciones.CurrentCell = null;
            registroHabitaciones.ClearSelection();

            //PONGO ESTO ACA PARA QUE DESPUES DE DAR DE ALTA, MODIFICAR O DAR DE BAJA
            //Y SE VUELVA A CARGAR LA LISTA, NO SE PUEDA MODIFICAR O DAR DE BAJA
            //UNA HABITACION NULL...
            this.buttonModificarHabitacion.Enabled = false;
            this.buttonBajaHabitacion.Enabled      = false;
        }
Example #3
0
 public Hotel getHotel()
 {
     if (this.hotel == null)
     {
         RepositorioHabitacion repoHabitacion = new RepositorioHabitacion();
         this.hotel = repoHabitacion.getHotelByIdHabitacion(this.idHabitacion);
     }
     return(this.hotel);
 }
Example #4
0
 public TipoHabitacion getTipoHabitacion()
 {
     if (this.tipoHabitacion == null)
     {
         RepositorioHabitacion repoHabitacion = new RepositorioHabitacion();
         this.tipoHabitacion = repoHabitacion.getTipoHabitacionByIdHabitacion(this.idHabitacion);
     }
     return(tipoHabitacion);
 }
Example #5
0
 public List <Habitacion> getHabitaciones()
 {
     if (this.habitaciones == null)
     {
         RepositorioHabitacion repoHabitacion = new RepositorioHabitacion();
         this.habitaciones = repoHabitacion.getByHotelId(this.idHotel);
     }
     return(this.habitaciones);
 }
 public List <Habitacion> getHabitaciones()
 {
     if (this.habitaciones == null)
     {
         RepositorioHabitacion repoHab = new RepositorioHabitacion();
         this.habitaciones = repoHab.getHabitacionesByReservaId(this);
     }
     return(this.habitaciones);
 }
        public ModificarHabitacion(Habitacion habitacion)
        {
            this.habitacion = habitacion;
            InitializeComponent();

            RepositorioHabitacion repoHabitacion = new RepositorioHabitacion();

            comboBoxUbicacion.DataSource = repoHabitacion.getAllUbicaciones();
            initFields();
        }
        private void buttonBajaHabitacion_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("¿Está seguro que desea dar de baja la Habitación?", "Baja Logica", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                RepositorioHabitacion repoHabitacion = new RepositorioHabitacion();
                Habitacion            habitacion     = (Habitacion)registroHabitaciones.CurrentRow.DataBoundItem;

                repoHabitacion.bajaLogica(habitacion);

                //AL CERRAR LA VENTANA DESPUES DE MODIFICAR UNA HABITACION VUELVO A CARGAR LA LISTA
                this.buttonBbuscarHoteles_Click(sender, e);
            }
        }
        public void limpiarDatos()
        {
            RepositorioTipoHabitacion repositorioTipoHab = new RepositorioTipoHabitacion();

            comboBoxTipoHabitacion.DataSource    = repositorioTipoHab.getAll();
            comboBoxTipoHabitacion.DisplayMember = "Descripcion";
            comboBoxTipoHabitacion.SelectedIndex = -1;

            RepositorioHabitacion repoHabitacion = new RepositorioHabitacion();

            comboBoxUbicacion.DataSource    = repoHabitacion.getAllUbicaciones();
            comboBoxUbicacion.SelectedIndex = -1;
            checkBoxActiva.Checked          = false;

            textNumero.Text      = "";
            textPiso.Text        = "";
            textDescripcion.Text = "";
        }
        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;
                        }
                    }
                }
            }
        }