Bez popisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

個人帳號管理.vb 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. Option Strict Off
  2. Imports System.Data.SqlClient
  3. Public Class 個人帳號管理
  4. Dim conn As New SqlConnection
  5. Dim cmd As New SqlCommand
  6. Dim dr As SqlDataReader
  7. Dim FFGG As Integer
  8. Dim DTP As String : Dim DDFF As String
  9. Private Sub Set_使用者資料()
  10. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  11. SQL1 = "SELECT 姓名, 帳號, 密碼, 密碼日期 FROM 使用者 WHERE (姓名 = '" & gUserName & "')"
  12. cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader
  13. If dr.Read() Then
  14. TextBox1.Text = dr("姓名").ToString
  15. TextBox2.Text = dr("帳號").ToString
  16. TextBox3.Text = dr("密碼").ToString
  17. TextBox4.Text = dr("密碼日期").ToString
  18. DDFF = dr("密碼").ToString
  19. End If
  20. conn.Close() : dr.Close()
  21. End Sub
  22. Private Sub Set_日期格式轉換()
  23. DTP = Format(Today(), "yyyy/MM/dd")
  24. End Sub
  25. Private Sub 個人帳號管理_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  26. FormBorderStyle = FormBorderStyle.SizableToolWindow
  27. Set_使用者資料()
  28. TextBox1.Enabled = False : TextBox2.Enabled = False : TextBox4.Enabled = False : TextBox5.Enabled = False
  29. FFGG = DateDiff("d", TextBox4.Text, Format(Today(), "yyyy/MM/dd"))
  30. If CC(24) = False Then
  31. TextBox5.Text = "NA"
  32. Else
  33. TextBox5.Text = 密碼時限 - FFGG
  34. End If
  35. End Sub
  36. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  37. If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
  38. MsgBox("輸入資料有誤")
  39. Else
  40. Set_日期格式轉換()
  41. If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
  42. SQL1 = "UPDATE 使用者 SET 帳號 = '" & TextBox2.Text & "', 密碼 = '" & TextBox3.Text & "', 密碼日期 = '" & DTP & "' WHERE (姓名 = '" & TextBox1.Text & "')"
  43. cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close() : conn.Close()
  44. MsgBox("修改完成") : Me.Close()
  45. End If
  46. Set_使用者資料()
  47. End Sub
  48. End Class