Option Strict Off
Imports System.Data.SqlClient
Public Class 個人帳號管理
    Dim conn As New SqlConnection
    Dim da As New SqlDataAdapter
    Dim cmd As New SqlCommand
    Dim ds As New DataSet
    Dim dr As SqlDataReader
    Private Sub Set_使用者資料()
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 姓名, 帳號, 密碼 FROM 使用者權限管理表 WHERE (姓名 = '" & gUserName & "')"
        cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
        If dr.Read() Then
            TextBox1.Text = dr("姓名").ToString
            TextBox2.Text = dr("帳號").ToString
            TextBox3.Text = dr("密碼").ToString
        End If
        conn.Close() : dr.Close()
    End Sub
    Private Sub 個人帳號管理_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        FormBorderStyle = FormBorderStyle.SizableToolWindow
        Set_使用者資料()
        TextBox1.Enabled = False : TextBox2.Enabled = False
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
            MsgBox("輸入資料有誤")
        Else
            If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
            SQL1 = "UPDATE 使用者權限管理表 SET 帳號 = '" & TextBox2.Text & "', 密碼 = '" & TextBox3.Text & "' WHERE (姓名 = '" & TextBox1.Text & "')"
            cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close() : conn.Close()
            MsgBox("修改完成")
        End If
        Set_使用者資料()
    End Sub
End Class