private void buttonIngresar_Click(object sender, EventArgs e) { if (textBoxUsuario.Text != null && textBoxPassword.Text != null) { username = textBoxUsuario.Text; password = textBoxPassword.Text; int resultado = new SqlUsuarios().loguear(username, password); switch (resultado) { case 0: MessageBox.Show("Usuario inhabilitado. Por favor, contacte a su administrador de sistemas"); break; case 1: this.habilitarSeleccionDeRoles(); break; case 2: MessageBox.Show("Contraseña incorrecta. Recuerde que al tercer intento fallido su usuario sera deshabilitado"); break; case 3: MessageBox.Show("No Existe el usuario"); break; } } }
private void habilitarSeleccionDeRoles() { List <String> roles = new SqlUsuarios().getRolesUsuario(username); if (roles.Count == 0) { MessageBox.Show("No tienes ningun rol asignado"); } else if (roles.Count == 1) { new SeleccionFuncionalidades(new Usuario(username, new SqlRoles().getRol(roles[0]))).Show(); } else if (roles.Count > 1) { this.textBoxPassword.Enabled = false; this.textBoxUsuario.Enabled = false; this.labelRol.Visible = true; this.labelRol.Enabled = true; this.comboBoxRoles.Visible = true; this.comboBoxRoles.Enabled = true; this.comboBoxRoles.Items.AddRange(roles.ToArray()); this.comboBoxRoles.SelectedIndex = 0; this.buttonListo.Visible = true; this.buttonListo.Enabled = true; } }
private void button1_Click(object sender, EventArgs e) { if (!String.IsNullOrWhiteSpace(textBox1.Text) && !String.IsNullOrWhiteSpace(textBox2.Text)) { username = textBox1.Text; password = textBox2.Text; int resultado = new SqlUsuarios().IniciarSesion(username, password); switch (resultado) { case 0: MessageBox.Show("USUARIO INHABILITADO."); break; case 1: this.habilitarSeleccionDeRoles(username); this.Close(); break; case 2: MessageBox.Show("Login FALLIDO. Al tercer intento fallido se inhabilita la Cuenta!"); break; case 3: MessageBox.Show("NO EXISTE EL USUARIO"); break; } } else { MessageBox.Show("Ingrese Datos de Login"); } }