📄 wblusers.vb
字号:
Public Class WBLUsers
Implements IDisposable
#Region " Class Level Variables "
Private objWDAUsers As WroxDataAccess.WDAUsers
#End Region
#Region " Constructor and Destructor "
Public Sub New(ByVal Company As String, ByVal Application As String)
objWDAUsers = New WroxDataAccess.WDAUsers(Company, Application)
End Sub
Public Sub Dispose() Implements System.IDisposable.Dispose
objWDAUsers.Dispose()
objWDAUsers = Nothing
End Sub
#End Region
#Region " Public User Functions "
Public Function GetUsers() As DataSet
Try
'Call the data component to get all user
GetUsers = objWDAUsers.GetUsers
Catch ExceptionErr As Exception
Throw New System.Exception(ExceptionErr.Message, _
ExceptionErr.InnerException)
End Try
End Function
Public Function GetUser(ByVal UserID As Guid) As DataSet
Try
'Call the data component to get a specific user
GetUser = objWDAUsers.GetUser(UserID)
Catch ExceptionErr As Exception
Throw New System.Exception(ExceptionErr.Message, _
ExceptionErr.InnerException)
End Try
End Function
Public Function GetNewUserDS() As DataSet
Try
'Return the Role schema as a DataSet
GetNewUserDS = New User
Catch ExceptionErr As Exception
Throw New System.Exception(ExceptionErr.Message, _
ExceptionErr.InnerException)
End Try
End Function
Public Function AddUser(ByVal User As DataSet) As Boolean
Try
'Validate the Login Name exists
If User.Tables("User").Rows(0).Item( _
"LoginName").ToString.Trim.Length = 0 Then
Throw New System.Exception("Login Name is a required field.")
End If
'Validate the First Name exists
If User.Tables("User").Rows(0).Item( _
"FirstName").ToString.Trim.Length = 0 Then
Throw New System.Exception("First Name is a required field.")
End If
'Validate the Last Name exists
If User.Tables("User").Rows(0).Item( _
"LastName").ToString.Trim.Length = 0 Then
Throw New System.Exception("Last Name is a required field.")
End If
'Validate the password
If Not IsValidPassword(User.Tables( _
"User").Rows(0).Item("Password")) Then
Throw New System.Exception(strErrorMessage)
End If
'Validate the email
If Not IsValidEmail(User.Tables( _
"User").Rows(0).Item("Email")) Then
Throw New System.Exception(strErrorMessage)
End If
'Validate the phone number
If Not IsValidPhoneNumber(User.Tables( _
"User").Rows(0).Item("Phone")) Then
Throw New System.Exception(strErrorMessage)
End If
'Validate manager
If Not IsDBNull(User.Tables("User").Rows(0).Item("ManagerID")) Then
If Not TypeOf User.Tables("User").Rows(0).Item("ManagerID") _
Is Guid Then
If User.Tables("User").Rows(0).Item("ManagerID") = _
String.Empty Then
'Set it to a null value
User.Tables("User").Rows(0).Item("ManagerID") = _
DBNull.Value
End If
End If
End If
'Format the phone number
User.Tables("User").Rows(0).Item("Phone") = _
FormatPhoneNumber(User.Tables("User").Rows(0).Item("Phone"))
'Trim spaces
User.Tables("User").Rows(0).Item("LoginName") = _
User.Tables("User").Rows(0).Item("LoginName").ToString.Trim
User.Tables("User").Rows(0).Item("Password") = _
User.Tables("User").Rows(0).Item("Password").ToString.Trim
User.Tables("User").Rows(0).Item("FirstName") = _
User.Tables("User").Rows(0).Item("FirstName").ToString.Trim
User.Tables("User").Rows(0).Item("LastName") = _
User.Tables("User").Rows(0).Item("LastName").ToString.Trim
User.Tables("User").Rows(0).Item("Email") = _
User.Tables("User").Rows(0).Item("Email").ToString.Trim
'Call the data component to add the new group
Return objWDAUsers.AddUser(User)
Catch ExceptionErr As Exception
Throw New System.Exception(ExceptionErr.Message, _
ExceptionErr.InnerException)
End Try
End Function
Public Function GetManagers() As DataSet
Try
'Call the data component to get all user
GetManagers = objWDAUsers.GetManagers
Catch ExceptionErr As Exception
Throw New System.Exception(ExceptionErr.Message, _
ExceptionErr.InnerException)
End Try
End Function
Public Function GetManagerEmployees(ByVal ManagerID As Guid) As DataSet
Try
'Call the data component to get the manager's employees
GetManagerEmployees = objWDAUsers.GetManagerEmployees(ManagerID)
Catch ExceptionErr As Exception
Throw New System.Exception(ExceptionErr.Message, _
ExceptionErr.InnerException)
End Try
End Function
Public Function ValidateLogin(ByVal LoginName As String, _
ByVal Password As String) As DataSet
Try
'Call the data component to get a specific user
ValidateLogin = objWDAUsers.ValidateLogin(LoginName, Password)
Catch ExceptionErr As Exception
Throw New System.Exception(ExceptionErr.Message, _
ExceptionErr.InnerException)
End Try
End Function
#End Region
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -