Ver Mensaje Individual
  #6 (permalink)  
Antiguo 05/07/2013, 11:21
Avatar de Aquaventus
Aquaventus
 
Fecha de Ingreso: junio-2010
Ubicación: Lima-Peru , En el alba de la naturaleza
Mensajes: 2.105
Antigüedad: 13 años, 10 meses
Puntos: 267
Respuesta: Control de Usuario 3 capas!!!!

Buen día junior1920,

Perfecto, ahora solamente tienes que jalar el resultado de ese SP y compararlo .

En tu clase CLASE USUARIOAD le dices que la función Acceso_Usuario es String :

Código vb:
Ver original
  1. Public Function Acceso_Usuario(ByVal ObjUsuarioEN As UsuarioEN) As String
  2.         Try
  3.             comando.Parameters.Clear()
  4.             comando.CommandType = CommandType.StoredProcedure
  5.             comando.CommandText = "acceso_user"
  6.  
  7.             Dim _usuario As New SqlParameter("@nusuario", SqlDbType.VarChar, 35)
  8.             _usuario.Value = ObjUsuarioEN.usuario
  9.             _usuario.Direction = ParameterDirection.Input
  10.             comando.Parameters.Add(_usuario)
  11.  
  12.             Dim _clave As New SqlParameter("@nclave", SqlDbType.VarChar, 32)
  13.             _clave.Value = ObjUsuarioEN.clave
  14.             _clave.Direction = ParameterDirection.Input
  15.             comando.Parameters.Add(_clave)
  16.  
  17.             Dim _idtipou As New SqlParameter("@nidtipou", SqlDbType.Int)
  18.             _idtipou.Value = ObjUsuarioEN.idtipou
  19.             _idtipou.Direction = ParameterDirection.Input
  20.             comando.Parameters.Add(_idtipou)
  21.  
  22.             Dim _nmsg As New SqlParameter("@nmsg", SqlDbType.VarChar, 400)
  23.             _nmsg.Direction = ParameterDirection.Output
  24.             comando.Parameters.Add(_nmsg)
  25.             Dim nmensaje As String
  26.  
  27.             Dim resultado As String
  28.             resultado = comando.ExecuteScalar().ToString()
  29.             nmensaje = Convert.ToString(_nmsg.Value)
  30.             'MsgBox(nmensaje)
  31.            conn.ClearAllPools()
  32.             return resultado
  33.         Catch ex As Exception
  34.             'MsgBox(ex.Message, MsgBoxStyle.Critical, ex.Source)
  35.            return String.Empty()
  36.         Finally
  37.             comando.Parameters.Clear()
  38.             conn.Close()
  39.             conn.ClearAllPools()
  40.             conn = Nothing
  41.         End Try
  42.     End Function

Luego en tu FORMULARIO LOGIN, en base al resultado que te traiga la funcion anterior validarlo :

Código vb:
Ver original
  1. Private Sub BtnIngresar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnIngresar.Click
  2.         Try
  3.             Dim valor As String = CStr(cboxTipoUser.SelectedValue)
  4.             If (txtlogin.Text = "") Then
  5.                 MsgBox("Ingrese el nombre de Usuario", MsgBoxStyle.Information, "Mensaje")
  6.                 txtlogin.Focus()
  7.                 Exit Sub
  8.             End If
  9.             If (txtclave.Text = "") Then
  10.                 MsgBox("Ingrese la clave para el Usuario", MsgBoxStyle.Information, "Mensaje")
  11.                 txtclave.Focus()
  12.                 Exit Sub
  13.             End If
  14.             If (cboxTipoUser.SelectedIndex.Equals(-1)) Then
  15.                 MsgBox("Por Seleccione el tipo de Usuario", MsgBoxStyle.Information, "Mensaje")
  16.                 cboxTipoUser.Focus()
  17.                 Exit Sub
  18.             End If
  19.  
  20.             ObjUsuarioEN = New UsuarioEN
  21.             ObjUsuarioLN = New UsuarioLN
  22.             ObjUsuarioEN.usuario = LTrim(RTrim(txtlogin.Text))
  23.             ObjUsuarioEN.clave = LTrim(RTrim(txtclave.Text))
  24.             ObjUsuarioEN.idtipou = LTrim(RTrim(valor))
  25.             'ObjUsuarioLN.Acceso_Usuario(ObjUsuarioEN)
  26.            ''PUSE ESTO PARA VER SI FUNCA PERO NO LO HACE
  27.            'UserLogin = Convert.ToString(ObjUsuarioEN.usuario)
  28.            '
  29.            Dim resultado_final As String
  30.             resultado_final = ObjUsuarioLN.Acceso_Usuario(ObjUsuarioEN)
  31.             ''AQUI EL PROBLEMA NO SE COMO VALIDAR
  32.            If Not (String.IsEmpty(resultado_final)) Then
  33.                 If (Convert.ToInt32(resultado_final) = 1) Then              
  34.                     MenuPrincipal.Show()
  35.                     Me.Hide()
  36.                 End If
  37.             End If
  38.         Catch ex As Exception
  39.             MsgBox(ex.Message, MsgBoxStyle.Critical, ex.Source)
  40.         End Try
  41.     End Sub

Sorry si sale algún error pero no estoy desde una pc que VS, espero que logres comprender lo que hize. Saludos!.
__________________
Internet es tener todo el conocimiento global a tu disposición.
Desarrollo de Software - Ejemplos .Net