private void buttonLogin_Click(object sender, EventArgs e) { if (textBox_user.Text.Length == 0 || textBox_pass.Text.Length == 0) { MessageBox.Show("Ingrese Usuario y Contraseña", "Error"); return; } try { _loginMan.login(textBox_user.Text, textBox_pass.Text); user_id = textBox_user.Text; password = Encriptacion.get_hash(textBox_pass.Text); var roles = _rolMan.GetAllPorUser(user_id, true); //solo cargo los activos foreach (string rol in roles) { comboBox_rol.Items.Add(rol); } panelRol.Enabled = true; panel_inSesion.Enabled = false; var hoteles = _hotelMan.GetAllPorUser(user_id); foreach (int hotel in hoteles) { comboBox_hotel.Items.Add(hotel); } // Sesion.iniciada = true; } catch (System.Exception exception) { MessageBox.Show(exception.Message); return; } }
public AddEditUser(Usuario user) { InitializeComponent(); button_modifDatos.Enabled = false; BindingList <Rol> all_roles = _rolMan.GetAll(); listBox_rol.DataSource = all_roles; listBox_rol.DisplayMember = "nombre_rol"; listBox_rol.SelectedItems.Clear(); BindingList <int> all_hoteles = _hotelMan.GetAll(); listBox_hots.DataSource = all_hoteles; listBox_hots.SelectedItems.Clear(); comboBox_estadoUser.Items.Add("True"); comboBox_estadoUser.Items.Add("False"); if (user != null) { current_user = user; current_user.hoteles = _hotelMan.GetAllPorUser(current_user.id_usuario); if (!current_user.hoteles.Contains(Sesion.id_hotel)) { MessageBox.Show("El Usuario seleccionado no pertenece a este hotel"); string hoteles = ""; foreach (int hotel in current_user.hoteles) { hoteles += '-' + hotel.ToString(); } MessageBox.Show("Para modificarlo, contacte al admin de los siguientes hoteles:\n" + hoteles); button_guardar.Enabled = false; return; } listBox_preHot.DataSource = current_user.hoteles; es_modificacion = true; textBox_preUser.Text = current_user.id_usuario; textBox_username.Text = current_user.id_usuario; textBox_preUser.Enabled = false; textBox_username.Enabled = false; textBox_prePass.Text = current_user.password; textBox_prePass.Enabled = false; current_user.roles = _rolMan.GetAllPorUser(textBox_preUser.Text, false); listBox_preRol.DataSource = current_user.roles; textBox_preInt.Text = Convert.ToString(current_user.intentos); textBox_preInt.Enabled = false; textBox_preEstado.Text = Convert.ToString(current_user.baja_logica); } else { panel_mod.Visible = false; } }