Beispiel #1
0
        private void ListadoUsuarios_Load(object sender, EventArgs e)
        {
            dataGridView1.DataSource = null;
            List <KeyValuePair <String, Boolean> > estados = new List <KeyValuePair <String, Boolean> >();

            estados.Add(new KeyValuePair <String, Boolean>("Habilitado", true));
            estados.Add(new KeyValuePair <String, Boolean>("Inhabilitado", false));
            comboBoxEstados.ValueMember   = "Value";
            comboBoxEstados.DisplayMember = "Key";
            comboBoxEstados.DataSource    = estados;
            comboBoxEstados.SelectedValue = "";

            RepositorioRol repositorioRol = new RepositorioRol();

            comboBoxRoles.ValueMember   = "idRol";
            comboBoxRoles.DisplayMember = "Nombre";
            comboBoxRoles.DataSource    = repositorioRol.getAll();
            comboBoxRoles.SelectedValue = "";

            RepositorioHotel repositorioHotel = new RepositorioHotel();

            comboBoxHoteles.ValueMember   = "idHotel";
            comboBoxHoteles.DisplayMember = "Nombre";
            comboBoxHoteles.DataSource    = repositorioHotel.getAll();
            comboBoxHoteles.SelectedValue = "";
        }
Beispiel #2
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);
        }
Beispiel #3
0
        private void limpiarPantalla()
        {
            //vacio todos los campos porque es el limpiar
            textBoxUsername.Text     = "";
            textBoxPassword.Text     = "";
            textBoxNombre.Text       = "";
            textBoxApellido.Text     = "";
            textBoxNroDoc.Text       = "";
            textBoxMail.Text         = "";
            textBoxTelefono.Text     = "";
            textBoxCalle.Text        = "";
            textBoxNroCalle.Text     = "";
            textBoxPiso.Text         = "";
            textBoxDepto.Text        = "";
            textBoxLocalidad.Text    = "";
            textBoxPaisOrigen.Text   = "";
            textBoxNacionalidad.Text = "";

            //cargo rol
            RepositorioRol repositorioRol = new RepositorioRol();

            dataGridRoles.DataSource = repositorioRol.getAll().OrderBy(r => r.getNombre()).ToList();
            dataGridRoles.AutoResizeColumns();
            dataGridRoles.CurrentCell = null;
            dataGridRoles.ClearSelection();

            //cargo hotel
            RepositorioHotel repositorioHotel = new RepositorioHotel();

            dataGridHoteles.DataSource = repositorioHotel.getAll().OrderBy(h => h.getNombre()).ToList();
            dataGridHoteles.AutoResizeColumns();
            dataGridHoteles.CurrentCell = null;
            dataGridHoteles.ClearSelection();

            comboBoxTipoDoc.SelectedValue = "";
            dateTime.ResetText();

            List <String> tipoDoc = new List <String>();

            tipoDoc.Add("DNI");
            tipoDoc.Add("CUIT");
            tipoDoc.Add("LE");
            tipoDoc.Add("LC");
            tipoDoc.Add("Pasaporte");

            comboBoxTipoDoc.ValueMember   = "Value";
            comboBoxTipoDoc.DisplayMember = "Key";
            comboBoxTipoDoc.DataSource    = tipoDoc;
            comboBoxTipoDoc.SelectedValue = "";
        }
        private void modificarHotel_Click(object sender, EventArgs e)
        {
            try{
                RepositorioHotel repoHotel = new RepositorioHotel();

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

                validarQuitaRegimen(hotel.getRegimenes(), regimenes);

                String    nombre                 = Utils.validateStringFields(nombreText.Text.Trim(), "Nombre");
                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");
                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");
                Direccion direccion              = new Direccion(hotel.getDireccion().getIdDireccion(), pais, ciudad, calle, numeroCalle, 0, "");
                Hotel     hotelToUpdateSave      = new Hotel(hotel.getIdHotel(), categoria, direccion, nombre, email, telefono, fechaInicioActividades, regimenes);

                if (repoHotel.yaExisteHotelMismoNombre(hotelToUpdateSave))
                {
                    MessageBox.Show("Ya existe un hotel registrado con el mismo nombre.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                repoHotel.update(hotelToUpdateSave);
                MessageBox.Show("Hotel modificado correctamente.", "Gestion de Datos TP 2018 1C - LOS_BORBOTONES", MessageBoxButtons.OK, MessageBoxIcon.Information);

                hotel = repoHotel.getById(hotel.getIdHotel());
                this.initModificacionHotel();
            }

            /*
             * catch (NoExisteIDException exceptionUpdateHotel)
             * {
             *  MessageBox.Show(exceptionUpdateHotel.Message, "Gestion de Datos TP 2018 1C - LOS_BORBOTONES", MessageBoxButtons.OK, MessageBoxIcon.Error);
             * }
             */
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Gestion de Datos TP 2018 1C - LOS_BORBOTONES", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void buttonNuevoCierre_Click(object sender, EventArgs e)
        {
            using (DropHotel cierreTemporalForm = new DropHotel(this.hotel))
            {
                var result = cierreTemporalForm.ShowDialog();

                //ME TRAIGO EL HOTEL MODIFICADO
                this.hotel.getCierresTemporales();

                RepositorioHotel repoHotel = new RepositorioHotel();
                hotel = repoHotel.getById(hotel.getIdHotel());
                //AL CERRAR LA VENTANA DESPUES DE DAR DE ALTA UN NUEVO CIERRE TEMPORAL VUELVO A CARGAR LA LISTA
                this.initModificacionHotel();
            }
        }
        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);
            }
        }
        public void Test_Repo_Hotel_CreacionInstancia_Hotel()
        {
            RepositorioHotel repositorioHotel = new RepositorioHotel();
            Hotel            hotel            = repositorioHotel.getById(13);
            Direccion        direccionHotel   = hotel.getDireccion();
            Categoria        categoriaHotel   = hotel.getCategoria();

            Assert.AreEqual("Balcarce 2520", hotel.getNombre());
            Assert.AreEqual("No Posee", hotel.getMail());
            Assert.AreEqual("No Posee", hotel.getTelefono());
            Assert.AreEqual(2017, hotel.getFechaInicioActividades().Year);
            Assert.AreEqual(1, categoriaHotel.getEstrellas());
            Assert.AreEqual(10, categoriaHotel.getRecargaEstrellas());

            Assert.AreEqual("Argentina", direccionHotel.getPais());
            Assert.AreEqual("Bs. As. Oeste", direccionHotel.getCiudad());
            Assert.AreEqual("Balcarce", direccionHotel.getCalle());
            Assert.AreEqual(2520, direccionHotel.getNumeroCalle());
            Assert.AreEqual(0, direccionHotel.getPiso());
            Assert.AreEqual("", direccionHotel.getDepartamento());
        }
        private void buscarHoteles()
        {
            String nombre    = validateStringFields(nombreText.Text.Trim());
            int?   estrellas = null;

            if (estrellasComboBox.SelectedItem != null)
            {
                estrellas = ((Categoria)estrellasComboBox.SelectedItem).getEstrellas();
            }
            ;
            String           pais             = validateStringFields(paisText.Text.Trim());
            String           ciudad           = validateStringFields(ciudadText.Text.Trim());
            RepositorioHotel repositorioHotel = new RepositorioHotel();

            this.modificarButton.Enabled = false;

            registroHoteles.DataSource = repositorioHotel.getByQuery(nombre, estrellas, ciudad, pais).OrderBy(h => h.getNombre()).ToList();
            registroHoteles.AutoResizeColumns();
            //ESTO LO TENGO QUE HACER PARA QUE NO APAREZCA SIEMPRE SELECCIONADO EL PRIMER ITEM
            registroHoteles.CurrentCell = null;
            registroHoteles.ClearSelection();
        }
        private void bajaHotel_Click(object sender, EventArgs e)
        {
            DateTime fechaDesde = calendarioDesde.Value;
            DateTime fechaHasta = calendarioHasta.Value;

            if (fechaDesde < Utils.getSystemDatetimeNow())
            {
                MessageBox.Show("No puede realizar reservas en el pasado", "Error");
                return;
            }

            if (fechaDesde > fechaHasta)
            {
                MessageBox.Show("La fecha inicio no puede ser superior a la fecha final.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (descripcionBajaText.Text.Equals(""))
                {
                    MessageBox.Show("Debe ingresar una descripción válida para el cierre temporal.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    try
                    {
                        CierreTemporal   cierreTemporal = new CierreTemporal(0, fechaDesde, fechaHasta, descripcionBajaText.Text, hotelBaja);
                        RepositorioHotel repoHotel      = new RepositorioHotel();
                        repoHotel.crearBajaTemporal(cierreTemporal);
                        MessageBox.Show("Cierre temporal creado exitosamente.", "Gestion de Datos TP 2018 1C - LOS_BORBOTONES", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.buttonLimpiarDatos_Click(sender, e);
                    }
                    //catch (RequestInvalidoException exception)
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.Message, "Gestion de Datos TP 2018 1C - LOS_BORBOTONES", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
        private void init()
        {
            calendarioDesde.Value = Utils.getSystemDatetimeNow().Date;
            calendarioHasta.Value = Utils.getSystemDatetimeNow().Date.AddDays(1);
            RepositorioTipoHabitacion repoTipoHabitacion = new RepositorioTipoHabitacion();
            RepositorioHotel          repoHotel          = new RepositorioHotel();

            comboBoxTipoHabitacion.DisplayMember = "Descripcion";
            comboBoxTipoHabitacion.ValueMember   = "Descripcion";
            comboBoxTipoHabitacion.DataSource    = repoTipoHabitacion.getAll();

            comboBoxHotel.DisplayMember = "Nombre";
            comboBoxHotel.ValueMember   = "Nombre";
            comboBoxHotel.DataSource    = repoHotel.getAll().OrderBy(h => h.getNombre()).ToList();

            comboBoxTipoHabitacion.SelectedValue = "";
            comboBoxTipoHabitacion.SelectedIndex = -1;

            if (sesion != null && sesion.getHotel() != null)
            {
                this.comboBoxHotel.Visible = false;
                this.labelHotel.Visible    = false;
            }
        }
        private void resetearDatos()
        {
            List <String> tipoDoc = new List <String>();

            tipoDoc.Add("DNI");
            tipoDoc.Add("CUIT");
            tipoDoc.Add("LE");
            tipoDoc.Add("LC");
            tipoDoc.Add("Pasaporte");

            comboBoxTipoDoc.ValueMember   = "Value";
            comboBoxTipoDoc.DisplayMember = "Key";
            comboBoxTipoDoc.DataSource    = tipoDoc;

            dateTime.ResetText();
            passwordChanged = false;

            //seteo la info
            textBoxUsername.Text          = usuario.getUsername();
            textBoxNombre.Text            = usuario.getIdentidad().getNombre();
            textBoxApellido.Text          = usuario.getIdentidad().getApellido();
            textBoxNroDoc.Text            = usuario.getIdentidad().getNumeroDocumento();
            textBoxMail.Text              = usuario.getIdentidad().getMail();
            textBoxTelefono.Text          = usuario.getIdentidad().getTelefono();
            textBoxCalle.Text             = usuario.getIdentidad().getDireccion().getCalle();
            textBoxNroCalle.Text          = usuario.getIdentidad().getDireccion().getNumeroCalle().ToString();
            textBoxPiso.Text              = usuario.getIdentidad().getDireccion().getPiso().ToString();
            textBoxDepto.Text             = usuario.getIdentidad().getDireccion().getDepartamento();
            textBoxLocalidad.Text         = usuario.getIdentidad().getDireccion().getCiudad();
            textBoxPais.Text              = usuario.getIdentidad().getDireccion().getPais();
            textBoxNacionalidad.Text      = usuario.getIdentidad().getNacionalidad();
            dateTime.Value                = usuario.getIdentidad().getFechaNacimiento();
            comboBoxTipoDoc.SelectedIndex = comboBoxTipoDoc.FindStringExact(usuario.getIdentidad().getTipoDocumento());
            checkBoxActivo.Checked        = usuario.getActivo();

            //cargo roles
            RepositorioRol repositorioRol = new RepositorioRol();

            dataGridRoles.DataSource  = repositorioRol.getAll().OrderBy(r => r.getNombre()).ToList();
            dataGridRoles.CurrentCell = null;
            dataGridRoles.AutoResizeColumns();
            dataGridRoles.ClearSelection();

            //cargo hoteles
            RepositorioHotel repositorioHotel = new RepositorioHotel();

            dataGridHoteles.DataSource  = repositorioHotel.getAll().OrderBy(h => h.getNombre()).ToList();
            dataGridHoteles.CurrentCell = null;
            dataGridHoteles.AutoResizeColumns();
            dataGridHoteles.ClearSelection();

            //MARCO LOS ROLES QUE TIENE EL USUARIO
            foreach (DataGridViewRow row in dataGridRoles.Rows)
            {
                Rol rol = (Rol)row.DataBoundItem;
                if (usuario.getRoles().Exists(r => r.getIdRol().Equals(rol.getIdRol())))
                {
                    dataGridRoles.Rows[row.Index].Selected          = true;
                    dataGridRoles.Rows[row.Index].Cells[0].Selected = true;
                }
            }

            //MARCO LOS HOTELES EN LOS QUE TRABAJA EL USUARIO
            foreach (DataGridViewRow row in dataGridHoteles.Rows)
            {
                Hotel hotel = (Hotel)row.DataBoundItem;
                //if (rol.getFuncionalidades().Exists(f => f.getDescripcion().Equals(funcionalidad.getDescripcion())))
                if (usuario.getHoteles().Exists(h => h.getIdHotel().Equals(hotel.getIdHotel())))
                {
                    dataGridHoteles.Rows[row.Index].Selected          = true;
                    dataGridHoteles.Rows[row.Index].Cells[0].Selected = true;
                }
            }
        }