Option Strict Off
Imports System.IO
Public Class 個人帳號管理
    Dim FFGG As Integer
    Dim DDFF As String
    Dim RI As Integer = -1
    Dim SK As String = "要查找的 KEY"
    Dim Str As String = Application.StartupPath
    Private ReadOnly 對話框(2) As String
    Private Sub Set_使用者資料()
        SQL_使用者資料()
        If dr.Read() Then : 姓名_rtb.Text = dr("姓名").ToString : 帳號_rtb.Text = dr("帳號").ToString : 密碼_rtb.Text = dr("密碼").ToString
            上次修改日期_rtb.Text = dr("密碼日期").ToString : DDFF = dr("密碼").ToString
        End If : conn.Close() : dr.Close()
    End Sub
    Private Sub Set_日期格式轉換()
        DTP = Format(Today(), "yyyy/MM/dd")
    End Sub
    Private Sub Set_語言()
        語言_dgv.DataSource = Nothing
        語言_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        語言_dgv.ColumnHeadersHeight = 25 : 語言_dgv.AllowUserToAddRows = False
        For i As Integer = 0 To 語言_dgv.Rows.Count - 1 : 語言_dgv.Rows.RemoveAt(0) : Next
        If File.Exists(Str + "\LANGUAGE_FILE.csv") Then
            Dim filereader = My.Computer.FileSystem.OpenTextFileReader(Str + "\LANGUAGE_FILE.csv", System.Text.Encoding.Default)
            Dim line As String = filereader.ReadLine()
            While Not (line Is Nothing)
                line = filereader.ReadLine()
                If line <> Nothing Then
                    line = line.Replace("""", "")
                    If Strings.Left(line, 4) = "G000" Or Strings.Left(line, 8) = "H601-106" Or Strings.Left(line, 8) = "H601-103" Or Strings.Left(line, 8) = "H001-178" Or
                       Strings.Left(line, 8) = "H603-100" Then
                        If 系統語言 = "繁體中文" Then
                            If Strings.Mid(line, 10, 2) = "CH" Then : 語言_dgv.Rows.Insert(0)
                                語言_dgv.Rows(0).Cells(0).Value = Strings.Left(line, 11)
                                If Strings.Mid(line, 13, 300).EndsWith(",") Then
                                    語言_dgv.Rows(0).Cells(1).Value = Strings.Mid(line, 13, 300).Substring(0, Strings.Mid(line, 13, 300).Length - 1)
                                Else : 語言_dgv.Rows(0).Cells(1).Value = Strings.Mid(line, 13, 300) : End If
                            End If
                        ElseIf 系統語言 = "English" Then
                            If Strings.Mid(line, 10, 2) = "EN" Then : 語言_dgv.Rows.Insert(0)
                                語言_dgv.Rows(0).Cells(0).Value = Strings.Left(line, 11)
                                If Strings.Mid(line, 13, 300).EndsWith(",") Then
                                    語言_dgv.Rows(0).Cells(1).Value = Strings.Mid(line, 13, 300).Substring(0, Strings.Mid(line, 13, 300).Length - 1)
                                Else : 語言_dgv.Rows(0).Cells(1).Value = Strings.Mid(line, 13, 300) : End If
                            End If
                        ElseIf 系統語言 = "Indonesian" Then
                            If Strings.Mid(line, 10, 2) = "IN" Then : 語言_dgv.Rows.Insert(0)
                                語言_dgv.Rows(0).Cells(0).Value = Strings.Left(line, 11)
                                If Strings.Mid(line, 13, 300).EndsWith(",") Then
                                    語言_dgv.Rows(0).Cells(1).Value = Strings.Mid(line, 13, 300).Substring(0, Strings.Mid(line, 13, 300).Length - 1)
                                Else : 語言_dgv.Rows(0).Cells(1).Value = Strings.Mid(line, 13, 300) : End If
                            End If
                        End If
                    End If
                End If
            End While
            filereader.Close()
        End If
    End Sub
    Private Sub Set_語言查詢()
         RI = -1 : For Each row As DataGridViewRow In 語言_dgv.Rows
            If Strings.Left(row.Cells(0).Value.ToString(), 8) = SK Then
                RI = row.Index : Exit For
            End If
        Next
    End Sub
    Private Sub 語言轉換讀取()
        Set_語言()
        SK = "H001-178" : Set_語言查詢() : 主題_lb.Text = 語言_dgv(1, RI).Value.ToString : SK = "G000-108" : Set_語言查詢() : ToolTip1.ToolTipTitle = 語言_dgv(1, RI).Value.ToString
        SK = "G000-110" : Set_語言查詢() : 對話框(0) = 語言_dgv(1, RI).Value.ToString : SK = "H601-106" : Set_語言查詢() : 帳號_lb.Text = 語言_dgv(1, RI).Value.ToString
        SK = "G000-103" : Set_語言查詢() : 密碼_lb.Text = 語言_dgv(1, RI).Value.ToString : SK = "G000-144" : Set_語言查詢() : 上次修改日期_lb.Text = 語言_dgv(1, RI).Value.ToString
        SK = "G000-145" : Set_語言查詢() : 剩餘有效日_lb.Text = 語言_dgv(1, RI).Value.ToString : SK = "G000-146" : Set_語言查詢() : 天_lb.Text = 語言_dgv(1, RI).Value.ToString
        SK = "G000-121" : Set_語言查詢() : 對話框(1) = 語言_dgv(1, RI).Value.ToString : SK = "G000-119" : Set_語言查詢() : 對話框(2) = 語言_dgv(1, RI).Value.ToString
        SK = "H601-103" : Set_語言查詢() : 姓名_lb.Text = 語言_dgv(1, RI).Value.ToString
    End Sub
    Private Sub 存檔_rbt_MouseEnter(sender As Object, e As EventArgs) Handles 存檔_rbt.MouseEnter
        ToolTip1.SetToolTip(Me.存檔_rbt, 對話框(0))
    End Sub
    Private Sub pnlTitleBar_Paint(sender As Object, e As PaintEventArgs) Handles pnlTitleBar.Paint
    End Sub
    Private Sub 個人帳號管理_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Set_使用者資料()
        姓名_rtb.Enabled = False : 帳號_rtb.Enabled = False : 上次修改日期_rtb.Enabled = False : 剩餘有效日_rtb.Enabled = False
        FFGG = DateDiff("d", 上次修改日期_rtb.Text, Format(Today(), "yyyy/MM/dd"))
        If CC(45) = False Then
            剩餘有效日_rtb.Text = "NA"
        Else
            剩餘有效日_rtb.Text = 密碼時限 - FFGG
        End If
    End Sub
    Private Sub 個人帳號管理_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
        語言轉換讀取() : Me.ActiveControl = 密碼_rtb
    End Sub
    Private Sub Cancel_bt_Click(sender As Object, e As EventArgs) Handles Cancel_bt.Click
        Me.Close()
    End Sub
    Private Sub 存檔_rbt_Click(sender As Object, e As EventArgs) Handles 存檔_rbt.Click
        Me.ActiveControl = 密碼_rtb
        If 姓名_rtb.Text = "" Or 帳號_rtb.Text = "" Or 密碼_rtb.Text = "" Or DDFF = 密碼_rtb.Text Then : MGB(對話框(1), 1) : Else
            Set_日期格式轉換() : SQL_使用者資料修改() : conn.Close() : MGB(對話框(2), 1) : Me.Close()
        End If
    End Sub

    Dim nOldWndLeft, nOldWndTop, nClickX, nClickY As Integer
    Private Sub PnlTitleBar_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlTitleBar.MouseDown
        '紀錄滑鼠點選時的視窗位置與滑鼠點選位置
        nOldWndLeft = Me.Left : nOldWndTop = Me.Top : nClickX = e.X : nClickY = e.Y
    End Sub
    Private Sub PnlTitleBar_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlTitleBar.MouseMove
        If pnlTitleBar.Capture = True Then        '如果滑鼠按著拖曳
            Me.Top = e.Y + nOldWndTop - nClickY : Me.Left = e.X + nOldWndLeft - nClickX   '設定新的視窗位置
            nOldWndLeft = Me.Left : nOldWndTop = Me.Top   '更新紀錄的視窗位置
        End If
    End Sub
    Private Sub 主題_lb_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 主題_lb.MouseDown
        '紀錄滑鼠點選時的視窗位置與滑鼠點選位置
        nOldWndLeft = Me.Left : nOldWndTop = Me.Top : nClickX = e.X : nClickY = e.Y
    End Sub
    Private Sub 主題_lb_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles 主題_lb.MouseMove
        If 主題_lb.Capture = True Then        '如果滑鼠按著拖曳
            Me.Top = e.Y + nOldWndTop - nClickY : Me.Left = e.X + nOldWndLeft - nClickX   '設定新的視窗位置
            nOldWndLeft = Me.Left : nOldWndTop = Me.Top   '更新紀錄的視窗位置
        End If
    End Sub
End Class