Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/02/2012, 09:53
sachis77
 
Fecha de Ingreso: octubre-2011
Ubicación: COLOMBIA, Medellín
Mensajes: 42
Antigüedad: 12 años, 6 meses
Puntos: 0
contador para el formulario de usuario

hola me pueden decir en este codigo donde iria el contador que no me permita repetir mas de 3 veces la contraseña . muchas gracias




Imports MySql.Data.MySqlClient

Public Class administrador

Private Sub txtadministrador_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtadministrador.KeyPress

If (e.KeyChar = Convert.ToChar(Keys.Return)) Or (e.KeyChar = Convert.ToChar(Keys.Enter)) Then

End If
' Button1_Click(Nothing, Nothing)
' End If
'End Sub

'aqui se validan los text

Select Case e.KeyChar
Case Is = Chr(13)
If txtadministrador.Text.Length = 0 Then
MessageBox.Show("codigo de usuario no valida, Repita", "ERROR")
Exit Sub
End If
txtcontraseña.Focus()
Case "a" To "z", "A" To "Z", "0" To "9", "", Chr(8)
txtadministrador.ForeColor = Color.Blue
Case Else
txtadministrador.ForeColor = Color.Red
e.Handled = True

End Select


End Sub

Private Sub txtcontraseña_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtcontraseña.KeyPress

If (e.KeyChar = Convert.ToChar(Keys.Return)) Or (e.KeyChar = Convert.ToChar(Keys.Enter)) Then

End If
' Button1_Click(Nothing, Nothing)
' End If
'End Sub

'aqui se validan los text

Select Case e.KeyChar
Case Is = Chr(13)
If txtcontraseña.Text.Length = 0 Then
MessageBox.Show("contraseña no valida, Repita", "ERROR")
Exit Sub
End If
txtadministrador.Focus()
Case "a" To "z", "A" To "Z", "0" To "9", "", Chr(8)
txtcontraseña.ForeColor = Color.Blue
Case Else
txtcontraseña.ForeColor = Color.Red
e.Handled = True

End Select

End Sub

Private Sub cmdaceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdaceptar.Click
Dim xCantidad As Long = -1
If txtadministrador.Text.Length = 0 Then
MessageBox.Show(" codigo No valido", "ERROR")
txtadministrador.Focus()
Exit Sub
End If
If txtcontraseña.Text.Length = 0 Then
MessageBox.Show("password No valido", "ERROR")
txtcontraseña.Focus()
Exit Sub
End If
miconexion = New MySqlConnection("server=localhost;user=root; password=111;database=colegio")

miconexion.Open()

micomando = New MySqlCommand("select count(*) from administrador where administrador = '" & txtadministrador.Text & "';", miconexion)
xCantidad = micomando.ExecuteScalar
miconexion.Close()

If xCantidad = 0 Then
MessageBox.Show("codigo NO EXISTE, REPITA", "ERROR")
txtadministrador.Clear()
txtadministrador.Focus()
Exit Sub
End If

miconexion = New MySqlConnection("server=localhost;user=root; password=111;database=colegio")

miconexion.Open()

micomando = New MySqlCommand("select count(*) from administrador where contrasena = '" & txtcontraseña.Text & "';", miconexion)
xCantidad = micomando.ExecuteScalar
miconexion.Close()

If xCantidad = 0 Then
MessageBox.Show("contraseña no existente, REPITA", "ERROR")
txtcontraseña.Clear()
txtcontraseña.Focus()
Exit Sub
End If
Try

miconexion.Open()
MessageBox.Show(" acceso aceptado")
miconexion.Close()


Catch mierror As MySqlException
MessageBox.Show("Error de Conexión a la Base de Datos: " & mierror.Message)
Finally
miconexion.Dispose()

End Try
Dim fAcceso As New menu
If fAcceso.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
fAcceso.Close()
Application.Run(New Form1)

End If
End Sub
Private Sub cmdcancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcancelar.Click
Application.Exit()

End Sub
End Class