Group: Forum Members
Posts: 235,
Visits: 309
|
I have (more or less) followed your example for doing a login thus:
Private Shared Sub ShowLoginAndInitMainForm(ByVal e As ShowLoginAndInitFormEventArgs)
'-- ToDo: add any code to show a login form and authenticate the user
' e.LoginSuccessful = ?
'-- Establish locals
Dim llAuthenticated As Boolean = False
Dim loLoginForm As New LoginForm()
Dim loUsers As New UsersBO()
'-- Show the login form
If loLoginForm.ShowDialog = Windows.Forms.DialogResult.OK Then
'-- Check to see if the user entered the correct username and password
'-- Get the user from the database
loUsers.FillByUserName(loLoginForm.UserName)
'-- Check the password
If (loUsers.Count > 0) AndAlso _
(loUsers.user_password.Equals(loLoginForm.Password)) Then
'-- The user authenticated
llAuthenticated = True
End If
Having done that I want to set some properties of my main form (or pass the bo to the main form). I have no idea what the mainform is called or how to reference it.
Going the other way, your example below (presumably in a form or a bo) makes reference to a Users object but it does not make it clear where that object comes from or how it becomes a property of Me (this). At this rate I may get something useful built in a year. Guess I'm just dense.
Private Sub Customers_CheckSecurity( _
ByVal e As MicroFour.StrataFrame.Business.CheckSecurityEventArgs) _
Handles Customers.CheckSecurity
'-- Check the requested action
Select Case e.ActionRequested
Case SecurityAction.AddRecord
'-- See if the user can perform the requested action
If Me.Users.user_authlevel >= 3 Then
e.Allowed = True
Else
e.Allowed = False
End If
Case SecurityAction.DeleteRecord
'-- See if the user can perform the requested action
If Me.Users.user_authlevel >= 4 Then
e.Allowed = True
Else
e.Allowed = False
End If
Case SecurityAction.EditRecord
'-- See if the user can perform the requested action
If Me.Users.user_authlevel >= 3 Then
e.Allowed = True
Else
e.Allowed = False
End If
End Select
End Sub
|