Imports UTS_Core.UTSModule.DbTableModel.Manage

Namespace UTSModule.Login
    ''' <summary>
    ''' 用户信息类
    ''' </summary>
    Public Class UserInfo
        Sub New(dataTable As DataTable)
            If dataTable Is Nothing Then Throw New Exception($"错误的登录信息!")
            If dataTable.Rows.Count = 0 Then Throw New Exception($"未查询到匹配的账号与密码!")

            InitializeFormDataTable(dataTable)

            If IsValid = False Then Throw New Exception($"账户已冻结!")
        End Sub


        Private Sub InitializeFormDataTable(dataTable As DataTable)
            UserId = CInt(dataTable.Rows(0).Item($"{UserListTable.ColNamesEnum.ID}"))
            CompanyId = CInt(dataTable.Rows(0).Item($"{UserListTable.ColNamesEnum.CompanyID}"))
            UserName = dataTable.Rows(0).Item($"{UserListTable.ColNamesEnum.UserName}").ToString
            PassWord = dataTable.Rows(0).Item($"{UserListTable.ColNamesEnum.Password}").ToString
            IsValid = CBool(dataTable.Rows(0).Item($"{UserListTable.ColNamesEnum.IsValid}"))
            Email = dataTable.Rows(0).Item($"{UserListTable.ColNamesEnum.Email}").ToString
            Mobile = dataTable.Rows(0).Item($"{UserListTable.ColNamesEnum.Mobile}").ToString
            CreateTime = dataTable.Rows(0).Item($"{UserListTable.ColNamesEnum.CreateTime}").ToString
            WeChat = dataTable.Rows(0).Item($"{UserListTable.ColNamesEnum.WeiXin}").ToString
        End Sub

        ''' <summary>账号索引</summary>
        Public Property UserId() As Integer

        ''' <summary>公司索引</summary>
        Public Property CompanyId() As Integer

        ''' <summary>获取或设置用户账号</summary>
        Public Property UserName As String

        ''' <summary>获取或设置用户密码</summary>
        Public Property PassWord As String

        ''' <summary>获取或设置用户注册日期</summary>
        Public Property CreateTime As String

        ''' <summary>获取或设置用户电话号码</summary>
        Public Property Mobile As String

        ''' <summary>获取或设置用户微信号</summary>
        Public Property WeChat As String

        ''' <summary>获取或设置用户电子邮箱</summary>
        Public Property Email As String

        ''' <summary>获取或设置用户是否有效</summary>
        Public Property IsValid As Boolean
    End Class


End Namespace