예제 #1
0
        public static Habitacion buildHabitacion(TipoHabitacion tipoHabitacion, int idHotel)
        {
            RepositorioHotel repositorioHotel = new RepositorioHotel();
            Hotel            hotel            = HotelBuilder.buildHotel();
            int id = repositorioHotel.create(hotel);

            hotel.setIdHotel(id);
            Habitacion hab = new Habitacion(0, true, 1, 1, "TEST: ZONA 1", "Desc");

            hab.setHotel(hotel);
            return(hab);
        }
        private void altaHotel_Click(object sender, EventArgs e)
        {
            try
            {
                RepositorioHotel repoHotel = new RepositorioHotel();

                List <Regimen> regimenes = new List <Regimen>();
                foreach (DataGridViewRow item in this.regimenesDataGrid.SelectedRows)
                {
                    regimenes.Add(item.DataBoundItem as Regimen);
                }

                Utils.validateListField(this.regimenesDataGrid.SelectedRows, "Regimen");

                String    pais        = Utils.validateStringFields((String)paisText.Text.Trim(), "Pais");
                String    ciudad      = Utils.validateStringFields((String)ciudadText.Text.Trim(), "Ciudad");
                String    calle       = Utils.validateStringFields((String)calleText.Text.Trim(), "Calle");
                int       numeroCalle = Utils.validateIntField((String)numeroCalleText.Text.Trim(), "NumeroCalle");
                Direccion direccion   = new Direccion(0, pais, ciudad, calle, numeroCalle, 0, "");

                Categoria categoria = (Categoria)Utils.validateFields(estrellasComboBox.SelectedItem, "Categoria");
                String    email     = Utils.validateStringFields(emailText.Text.Trim(), "Email");
                String    telefono  = Utils.validateStringFields(telefonoText.Text.Trim(), "Telefono");
                DateTime  fechaInicioActividades = (DateTime)Utils.validateFields(creacionTime.Value, "Fecha Inicio de Actividades");
                String    nombre            = Utils.validateStringFields(nombreText.Text.Trim(), "Nombre");
                Hotel     hotelToUpdateSave = new Hotel(0, categoria, direccion, nombre, email, telefono, fechaInicioActividades, regimenes);

                //VALIDAMOS QUE NO EXISTA UN HOTEL CON EL MISMO NOMBRE
                if (repoHotel.yaExisteHotelMismoNombre(hotelToUpdateSave))
                {
                    MessageBox.Show("Ya existe un hotel registrado con el mismo nombre.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                repoHotel.create(hotelToUpdateSave);
                MessageBox.Show("Hotel creado exitosamente.", "Gestion de Datos TP 2018 1C - LOS_BORBOTONES", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.initModificacionHotel();
            }
            //catch (RequestInvalidoException exception)
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Verifique los datos ingresados.", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }