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 = ""; }
private void buscar_Click(object sender, EventArgs e) { String nombreRol = textBox1.Text.Trim(); KeyValuePair <String, Boolean> estado = new KeyValuePair <String, Boolean>(); Funcionalidad funcionalidad = null; RepositorioRol repositorioRoles = new RepositorioRol(); if (comboBoxEstados.SelectedItem != null) { estado = (KeyValuePair <String, Boolean>)comboBoxEstados.SelectedItem; } if (comboBoxFuncionalidades.SelectedItem != null) { funcionalidad = (Funcionalidad)comboBoxFuncionalidades.SelectedItem; } dataGridView1.DataSource = repositorioRoles.getByQuery(nombreRol, estado, funcionalidad).OrderBy(r => r.getNombre()).ToList(); dataGridView1.AutoResizeColumns(); //ESTO LO TENGO QUE HACER PARA QUE NO APAREZCA SIEMPRE SELECCIONADO EL PRIMER ITEM dataGridView1.CurrentCell = null; dataGridView1.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 //UN ROL NULL... this.button4.Enabled = false; this.button5.Enabled = false; }
public void Test_Repo_Rol_CreacionInstancia_Rol() { RepositorioRol repositorioRol = new RepositorioRol(); Rol rol = null; rol = repositorioRol.getByNombre("Recepcionista"); Assert.AreEqual(6, rol.getFuncionalidades().Count); rol = repositorioRol.getByNombre("Guest"); Assert.AreEqual(1, rol.getFuncionalidades().Count); }
public void Test_Repo_Rol_getAll() { RepositorioRol repositorioRol = new RepositorioRol(); Assert.AreEqual(5, repositorioRol.getAll().Count); Assert.IsTrue(repositorioRol.getAll().Exists(r => r.getFuncionalidades().Exists(f => f.getDescripcion().Equals("ABMHotel")))); Assert.IsTrue(repositorioRol.getAll().Exists(r => r.getActivo().Equals(false))); Assert.IsTrue(repositorioRol.getAll().Exists(r => r.getNombre().Equals("Guest"))); }
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 button5_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("¿Está seguro que desea dar de baja el Rol?", "Baja Logica", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes) { RepositorioRol repositorioRol = new RepositorioRol(); Rol rol = (Rol)dataGridView1.CurrentRow.DataBoundItem; repositorioRol.bajaLogica(rol); //CUANDO DOY DE BAJA EL ROL VUELVO A CARGAR LA LISTA this.buscar_Click(sender, e); } }
public void Test_Repo_Rol_getByQuery() { RepositorioRol repositorioRol = new RepositorioRol(); //SIN FILTRO Assert.AreEqual(5, repositorioRol.getByQuery("", new KeyValuePair <String, Boolean>(), null).Count); //FILTRO ESTADO Assert.AreEqual(4, repositorioRol.getByQuery("", new KeyValuePair <String, Boolean>("", true), null).Count); //FILTRO NOMBRE Y ESTADO Assert.AreEqual(0, repositorioRol.getByQuery("Administrador", new KeyValuePair <String, Boolean>("", false), null).Count); //FALTA FILTRO FUNCIONALIDAD }
private void buttonGuardar_Click(object sender, EventArgs e) { String nombreRol = textBoxNombreRol.Text.Trim(); Boolean activo = checkBoxActivo.Checked; List <Funcionalidad> funcionalidades = new List <Funcionalidad>(); RepositorioRol repositorioRol = new RepositorioRol(); foreach (DataGridViewRow row in dataGridFuncionalidades.SelectedRows) { funcionalidades.Add((Funcionalidad)row.DataBoundItem); } //CAMBIO LOS ATRIBUTOS DEL ROL rol.setNombre(nombreRol); rol.setActivo(activo); rol.setFuncionalidades(funcionalidades); //LA RESPONSABILIDAD DE VALIDAR EL INPUT LA DEJO EN LA INTERFAZ??? //O MEJOR EN EL REPOSITORIO Y LAS MANEJO CON EXCEPCIONES??? if (this.validoInput(this)) { try { repositorioRol.update(rol); MessageBox.Show("Rol actualizado con éxito.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); //ME TRAIGO EL ROL ACTUALIZADO this.rol = repositorioRol.getById(rol.getIdRol()); this.inicializarResetear(); } //catch (NoExisteIDException exc) catch (Exception exc) { MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Ingrese nombre del Rol y seleccione sus Funcionalidades", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button2_Click(object sender, EventArgs e) { String nombreRol = textBoxNombreRol.Text.Trim(); Boolean activo = checkBoxActivo.Checked; List <Funcionalidad> funcionalidades = new List <Funcionalidad>(); RepositorioRol repositorioRol = new RepositorioRol(); Rol rol = null; foreach (DataGridViewRow row in dataGridFuncionalidades.SelectedRows) { funcionalidades.Add((Funcionalidad)row.DataBoundItem); } rol = new Rol(0, nombreRol, activo, funcionalidades); //LA RESPONSABILIDAD DE VALIDAR EL INPUT LA DEJO EN LA INTERFAZ??? //O MEJOR EN EL REPOSITORIO Y LAS MANEJO CON EXCEPCIONES??? if (this.validoInput(this)) { try { repositorioRol.create(rol); MessageBox.Show("Rol creado con éxito.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); this.limpiarPantalla(); } //catch (ElementoYaExisteException exc) catch (Exception exc) { MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Ingrese nombre del Rol y seleccione sus Funcionalidades.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static bool ProcesoActualizarRol(Rol rol) { return(RepositorioRol.ActualizarRol(rol)); }
public static bool ProcesoBorrarRol(string nombre) { return(RepositorioRol.BorrarRol(nombre)); }
public static bool ProcesoAgregarRol(Rol rol) { return(RepositorioRol.AgregarRol(rol)); }
public void Test_Repo_Rol_exists() { RepositorioRol repositorioRol = new RepositorioRol(); Assert.IsFalse(repositorioRol.exists(new Rol(50, "Dummy", false, null))); }
/// <summary> /// Consulta todos los empleados /// </summary> /// <returns>Lista de todos los empleados</returns> public static List <Rol> ProcesoConsultarRol() { return(RepositorioRol.ConsultarRoles()); }
public void Test_Repo_Rol_getByNameFalla() { RepositorioRol repositorioRol = new RepositorioRol(); Rol rol = repositorioRol.getByNombre("RolFicticio"); }
public void Inicializar() { _repositorio = new RepositorioRol(); }
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; } } }
public void Test_Repo_Rol_Alta_Baja_Modificacion_Rol() { //INICIALIZO VARIABLES int idRolTest = 0; RepositorioRol repositorioRol = new RepositorioRol(); List <Funcionalidad> funcionalidades = new List <Funcionalidad>(); RepositorioFuncionalidad repositorioFuncionalidad = new RepositorioFuncionalidad(); //INICIALIZO EL ROL A CREAR String nombreRol = "RolTest"; Boolean activo = false; funcionalidades.Add(repositorioFuncionalidad.getByDescripcion("ABMRol")); funcionalidades.Add(repositorioFuncionalidad.getByDescripcion("ABMUsuario")); funcionalidades.Add(repositorioFuncionalidad.getByDescripcion("ABMHotel")); funcionalidades.Add(repositorioFuncionalidad.getByDescripcion("ABMRegimenEstadia")); Rol rolTest = new Rol(0, nombreRol, activo, funcionalidades); //DOY DE ALTA EL ROL idRolTest = repositorioRol.create(rolTest); //RECUPERO EL ROL CREADO rolTest = repositorioRol.getById(idRolTest); //VALIDO //QUE AHORA HAY UN ROL MAS (SON 5 POR DEFAULT) Assert.AreEqual(6, repositorioRol.getAll().Count); //QUE TRAIGA LOS VALORES QUE CARGUE Assert.AreEqual(nombreRol, rolTest.getNombre()); Assert.AreEqual(activo, rolTest.getActivo()); Assert.AreEqual(4, rolTest.getFuncionalidades().Count); Assert.IsTrue(rolTest.getFuncionalidades().Exists(f => f.getDescripcion().Equals("ABMRol"))); Assert.IsTrue(rolTest.getFuncionalidades().Exists(f => f.getDescripcion().Equals("ABMUsuario"))); Assert.IsTrue(rolTest.getFuncionalidades().Exists(f => f.getDescripcion().Equals("ABMHotel"))); Assert.IsTrue(rolTest.getFuncionalidades().Exists(f => f.getDescripcion().Equals("ABMRegimenEstadia"))); //MODIFICACION DE ROL String nuevoNombre = "NuevoNombre"; Boolean nuevoEstado = true; funcionalidades.Clear(); funcionalidades.Add(repositorioFuncionalidad.getByDescripcion("ABMReserva")); funcionalidades.Add(repositorioFuncionalidad.getByDescripcion("ABMCliente")); funcionalidades.Add(repositorioFuncionalidad.getByDescripcion("ABMHabitacion")); rolTest.setNombre(nuevoNombre); rolTest.setActivo(nuevoEstado); rolTest.setFuncionalidades(funcionalidades); //ACTUALIZACION DEL ROL EN LA BASE repositorioRol.update(rolTest); //RECUPERO EL ROL ACTUALIZADO rolTest = repositorioRol.getById(idRolTest); //VALIDO //QUE LA CANTIDAD DE LOS ROLES SIGUE SIENDO LA MISMA Assert.AreEqual(6, repositorioRol.getAll().Count); //QUE EL NOMBRE CAMBIO Assert.AreEqual(nuevoNombre, rolTest.getNombre()); //QUE EL ESTADO CAMBIO Assert.AreEqual(nuevoEstado, rolTest.getActivo()); //QUE LAS FUNCIONALIDADES CAMBIARON Assert.AreEqual(3, rolTest.getFuncionalidades().Count); Assert.IsTrue(rolTest.getFuncionalidades().Exists(f => f.getDescripcion().Equals("ABMReserva"))); Assert.IsTrue(rolTest.getFuncionalidades().Exists(f => f.getDescripcion().Equals("ABMCliente"))); Assert.IsTrue(rolTest.getFuncionalidades().Exists(f => f.getDescripcion().Equals("ABMHabitacion"))); //TESTEO LA BAJA LOGICA repositorioRol.bajaLogica(rolTest); rolTest = repositorioRol.getById(idRolTest); Assert.AreEqual(false, rolTest.getActivo()); //ELIMINACION DE ROL PARA MANTENER CONSISTENCIA DE LA BASE Y LA COHERENCIA DE LOS TESTS repositorioRol.delete(rolTest); //VALIDO QUE LA CANTIDAD DE ROLES VUELVA A 5 Assert.AreEqual(5, repositorioRol.getAll().Count); }
public void Test_Repo_Rol_getByIdFalla() { RepositorioRol repositorioRol = new RepositorioRol(); Rol rol = repositorioRol.getById(50); }