Public Class 系統綁定電腦資訊
    Private Sub 系統綁定電腦資訊_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    End Sub
    Private Sub 系統綁定電腦資訊_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
        取得本地電腦訊息_bt.PerformClick()
    End Sub
    Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
        timeNow = 0 : YS_ERP_SYS.Timer1.Enabled = False : YS_ERP_SYS.Timer1.Enabled = True
    End Sub
    Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
        timeNow = 0 : YS_ERP_SYS.Timer1.Enabled = False : YS_ERP_SYS.Timer1.Enabled = True
    End Sub
    Private Sub 取得本地電腦訊息_bt_Click(sender As Object, e As EventArgs) Handles 取得本地電腦訊息_bt.Click
        '-----MAC碼----------------------------------------------------------------------------------------------
        Dim Wmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration")
        For Each WmiObj As Management.ManagementObject In Wmi.Get
            If CBool(WmiObj("IPEnabled")) Then
                MAC碼_tb.Text = WmiObj("MACAddress")
            End If
        Next
        '-----硬碟資料----------------------------------------------------------------------------------------------
        Dim cmicWmi As New Management.ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
        Dim diskId As String '数字ID
        Dim diskSerialNumber As String '这个我们暂且称其为序列号码
        Dim diskModel As String '序列号
        For Each cmicWmiObj As Management.ManagementObject In cmicWmi.Get
            diskId = cmicWmiObj("size")
            diskSerialNumber = cmicWmiObj("serialnumber")
            diskModel = cmicWmiObj("Model")
            硬碟ID_tb.Text = diskId
            硬碟序列_tb.Text = diskSerialNumber
            磁盘型態_tb.Text = diskModel
            Exit For
        Next
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles 電腦註冊_tb.Click
        ConnOpen()
        SQL1 = "SELECT MAC碼 FROM 系統綁定電腦資訊 
                WHERE  硬碟ID LIKE N'" & 硬碟ID_tb.Text & "' AND 硬碟序列 LIKE N'" & 硬碟序列_tb.Text & "' AND 磁盘型態 LIKE N'" & 磁盘型態_tb.Text & "'"
        CmdSet_For_dr()
        If dr.Read() Then : conn.Close() : MsgBox("該電腦以綁定過") : Else
            ConnOpen()
            SQL1 = "INSERT INTO 系統綁定電腦資訊 (MAC碼, 硬碟ID, 硬碟序列, 磁盘型態) " &
                  "VALUES (N'" & MAC碼_tb.Text & "',N'" & 硬碟ID_tb.Text & "',N'" & 硬碟序列_tb.Text & "',N'" & 磁盘型態_tb.Text & "')"
            CmdSet_For_dr() : conn.Close()
            MsgBox("新增完成")
        End If
    End Sub
End Class