public void CargarUsuariosModificarCombobox() { ControladorBaseDatos db = new ControladorBaseDatos(); try { List<Usuario> tipos = db.ObtenerUsuariosBd(); comboboxUsuarioModificar.Clear(); CellRendererText cell = new CellRendererText(); comboboxUsuarioModificar.PackStart(cell, false); comboboxUsuarioModificar.AddAttribute(cell, "text", 0); this.usuariosModel = new Gtk.ListStore(typeof (string)); comboboxUsuarioModificar.Model = usuariosModel; foreach (Usuario tp in tipos) { this.usuariosModel.AppendValues(tp.Userlogin); } if (tipos.Count != 0) { this.comboboxUsuarioModificar.Active = 0; } } catch (Exception ex) { Console.WriteLine("Excepcion:"+ex); } }
protected void OnComboboxUsuarioModificarChanged(object sender, EventArgs e) { ControladorBaseDatos db = new ControladorBaseDatos(); List<Usuario> tipos = db.ObtenerUsuariosBd(); for (int i = 0; i < tipos.Count; i++) { Console.WriteLine("lista"+i); if(tipos[i].Userlogin.Equals(comboboxUsuarioModificar.ActiveText)) { entryUsuarioEdit.Text = tipos[i].Userlogin; entryUsuarioEdit.QueueDraw(); entryNombreEdit.Text = tipos[i].Nombre; entryNombreEdit.QueueDraw(); entryApellidosEdit.Text = tipos[i].Apellidos; entryApellidosEdit.QueueDraw(); entryTelefonoEdit.Text = tipos[i].Telefono; entryTelefonoEdit.QueueDraw(); entryRutEdit.Text = tipos[i].Rut; entryRutEdit.QueueDraw(); entryContraseñaEdit.Text = tipos[i].Userpass; entryContraseñaEdit.QueueDraw(); comboboxTipoUsuarioMod.Clear(); CellRendererText cell = new CellRendererText(); comboboxTipoUsuarioMod.PackStart(cell, false); comboboxTipoUsuarioMod.AddAttribute(cell, "text", 0); ListStore ListaCombobox = new ListStore(typeof (string)); comboboxTipoUsuarioMod.Model = ListaCombobox; ListaCombobox.AppendValues (tipos[i].Nivel_user); if(tipos[i].Nivel_user.Equals("Cajero")) { ListaCombobox.AppendValues ("Administrador"); ListaCombobox.AppendValues ("Empleado"); } if((tipos[i].Nivel_user.Equals("Administrador"))) { ListaCombobox.AppendValues ("Cajero"); ListaCombobox.AppendValues ("Empleado"); } if((tipos[i].Nivel_user.Equals("Empleado"))) { ListaCombobox.AppendValues ("Administrador"); ListaCombobox.AppendValues ("Cajero"); } this.comboboxTipoUsuarioMod.Active = 0; // ListaCombobox.GetIterFirst(out it); } } }