Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

LoginForm1.vb 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. Imports System.Net
  2. Imports System.Management
  3. Imports System.IO
  4. Imports System.Text
  5. Public Class LoginForm1
  6. ' TODO: 插入程式碼,利用提供的使用者名稱和密碼執行自訂驗證
  7. ' (請參閱 https://go.microsoft.com/fwlink/?LinkId=35339)。
  8. ' 如此便可將自訂主體附加到目前執行緒的主體,如下所示:
  9. ' My.User.CurrentPrincipal = CustomPrincipal
  10. ' 其中 CustomPrincipal 是用來執行驗證的 IPrincipal 實作。
  11. ' 接著,My.User 便會傳回封裝在 CustomPrincipal 物件中的識別資訊,
  12. ' 例如使用者名稱、顯示名稱等。
  13. ReadOnly ds2 As New DataSet
  14. ReadOnly MACKK As String 'MAC碼
  15. ReadOnly diskId As String '數字ID
  16. ReadOnly diskSerialNumber As String '硬碟序列
  17. ReadOnly diskModel As String '磁盘型態
  18. Public Property Credentials As ICredentials
  19. ReadOnly screenWidth = Screen.PrimaryScreen.Bounds.Width
  20. ReadOnly screenHeight = Screen.PrimaryScreen.Bounds.Height
  21. ReadOnly ds As New DataSet
  22. Dim FFGG As Integer
  23. Dim 更新關閉 As Boolean
  24. Dim strDirName As String
  25. Private Sub Set_清單1()
  26. FTP清單_dgv.DataSource = Nothing : ds2.Clear()
  27. FTP清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  28. FTP清單_dgv.ColumnHeadersHeight = 25
  29. FTP清單_dgv.AllowUserToAddRows = False
  30. SQL_FTP資料夾路徑分配()
  31. da.Fill(ds2) : FTP清單_dgv.DataSource = ds2.Tables(0) : conn.Close()
  32. End Sub
  33. Private Sub Set_使用者清單()
  34. 簡易登入_dgv.DataSource = Nothing : ds.Clear()
  35. 簡易登入_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
  36. 簡易登入_dgv.ColumnHeadersHeight = 25
  37. 簡易登入_dgv.AllowUserToAddRows = False
  38. 簡易登入_dgv.RowTemplate.Height = 25
  39. SQL_簡易登入清單()
  40. da.Fill(ds) : 簡易登入_dgv.DataSource = ds.Tables(0) : conn.Close()
  41. 簡易登入_dgv.Columns(0).FillWeight = 80 : 簡易登入_dgv.Columns(1).FillWeight = 100 : 簡易登入_dgv.Columns(2).FillWeight = 80 : 簡易登入_dgv.Columns(3).FillWeight = 55
  42. 簡易登入_dgv.Columns(5).FillWeight = 80 : 簡易登入_dgv.Columns(4).FillWeight = 55
  43. For i As Integer = 0 To 簡易登入_dgv.Rows.Count - 1
  44. FFGG = DateDiff("d", Format(Today(), "yyyy/MM/dd"), 簡易登入_dgv.Rows(i).Cells("到期日").Value)
  45. If FFGG < 0 Then
  46. 簡易登入_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGreen
  47. Else
  48. 簡易登入_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White
  49. End If
  50. Next
  51. End Sub
  52. Private Sub LoginForm1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  53. '-----------------------處理檔案-----------------------------------------------------------------------------------------------------------------------------------------------
  54. Dim FilePath As String = "B.txt"
  55. Try
  56. Using fs As IO.FileStream = New IO.FileStream(FilePath, FileMode.Append)
  57. Using sw As StreamWriter = New StreamWriter(fs, Encoding.Default)
  58. sw.Flush()
  59. End Using
  60. End Using
  61. Catch ex As Exception
  62. End Try
  63. Dim Str2 As String = Application.StartupPath
  64. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\B.txt") Then : strDirName = My.Computer.FileSystem.SpecialDirectories.Desktop & "\B.txt"
  65. ElseIf File.Exists(Str2 & "\B.txt") Then : strDirName = Str2 & "\B.txt" : End If
  66. Dim diMyDir As New DirectoryInfo(strDirName) : diMyDir.Attributes = FileAttributes.Hidden
  67. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\myLog.log") Then : strDirName = My.Computer.FileSystem.SpecialDirectories.Desktop & "\myLog.log"
  68. ElseIf File.Exists(Str2 & "\myLog.log") Then : strDirName = Str2 & "\myLog.log" : End If
  69. If File.Exists("B.txt") Then : Dim diMyDir1 As New DirectoryInfo(strDirName) : diMyDir1.Attributes = FileAttributes.Hidden
  70. ElseIf File.Exists(Str2 & "\B.txt") Then : Dim diMyDir1 As New DirectoryInfo(strDirName) : diMyDir1.Attributes = FileAttributes.Hidden
  71. ElseIf File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\B.txt") Then : Dim diMyDir1 As New DirectoryInfo(strDirName) : diMyDir1.Attributes = FileAttributes.Hidden : End If
  72. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\M0114UI.csv") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop & "\M0114UI.csv") : End If
  73. Me.Size = New Size(466, 279)
  74. If screenWidth = 1920 And screenHeight = 1080 Then : Me.Location = New Point(727, 401)
  75. ElseIf screenWidth = 1366 And screenHeight = 768 Then : Me.Location = New Point(450, 245)
  76. ElseIf screenWidth = 1440 And screenHeight = 900 Then : Me.Location = New Point(487, 311)
  77. ElseIf screenWidth = 1280 And screenHeight = 1024 Then : Me.Location = New Point(407, 373)
  78. ElseIf screenWidth = 1600 And screenHeight = 900 Then : Me.Location = New Point(567, 311)
  79. End If
  80. '-----------------------控件基本設定-----------------------------------------------------------------------------------------------------------------------------------------------
  81. 刷卡登入_ch.Checked = True : 刷卡登入_ch.Enabled = False : 帳號_tb.Visible = False : 解鎖_bt.Visible = False : UPDATE_bt.Visible = False : 內網區域 = False
  82. 執行檔版本號_lb.Text = "執行檔版本號 : " & 版本
  83. 伺服器區域_ch.SelectedIndex = 0
  84. If 更新關閉 = True Then : Me.Close() : Else
  85. Me.ActiveControl = 使用者帳號_cb
  86. Set_使用者清單()
  87. Dim cmicWmi As New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
  88. For Each cmicWmiObj As ManagementObject In cmicWmi.Get
  89. PA10 = cmicWmiObj("Signature") : QA1 = cmicWmiObj("Signature")
  90. PA11 = cmicWmiObj("SerialNumber") : QA2 = cmicWmiObj("SerialNumber")
  91. PA12 = cmicWmiObj("Model") : QA3 = cmicWmiObj("Model")
  92. PA13 = cmicWmiObj("Size") : QA4 = cmicWmiObj("Size")
  93. PA10 = Replace(PA10, "'", "/") : QA1 = Replace(QA1, "'", "/") : PA11 = Replace(PA11, "'", "/") : QA2 = Replace(QA2, "'", "/")
  94. PA12 = Replace(PA12, "'", "/") : QA3 = Replace(QA3, "'", "/") : PA13 = Replace(PA13, "'", "/") : QA4 = Replace(QA4, "'", "/")
  95. SQL_驗證是否綁定()
  96. If dr.Read() Then
  97. PA15 = dr("客戶") : conn.Close()
  98. SQL_USB登入清單()
  99. If dr.Read() Then : PA16 = dr("帳號") : gUserName = dr("姓名") : End If : Exit For
  100. Else
  101. PA16 = ""
  102. End If
  103. Next
  104. '-----用有沒有帳號出現來分類-------------------------------------------
  105. If PA16 = "" Then
  106. QA1 = "00" : QA2 = "00" : QA3 = "00" : QA4 = "00"
  107. FTP登入()
  108. Else
  109. FTP登入()
  110. SQL_登入鎖定解除()
  111. If PA16 = "b70340" Or PA16 = "B70340" Then
  112. 使用者帳號_cb.Text = ""
  113. Else
  114. 使用者帳號_cb.Text = PA16 : PA16 = ""
  115. End If
  116. Me.ActiveControl = 密碼_tb
  117. End If
  118. Timer1.Enabled = True
  119. End If
  120. 使用者帳號_cb.ImeMode = 3
  121. Timer4.Enabled = True
  122. End Sub
  123. Private Sub FTP登入()
  124. SQL_FTP伺服器登入位置()
  125. If dr.Read() Then : Target = dr("FTP地址") : FTP帳號 = dr("FTP帳號") : FTP密碼 = dr("FTP密碼") : End If : conn.Close()
  126. Set_清單1()
  127. Dim HH As String = ""
  128. For i As Integer = 0 To FTP清單_dgv.Rows.Count - 1
  129. If i < 10 Then : HH = "0" & i : ElseIf i >= 10 Then : HH = i : End If
  130. If FTP清單_dgv("指定", i).Value.ToString = "AA" & HH Then : AA(i) = FTP清單_dgv("資料夾名稱", i).Value.ToString : End If
  131. Next
  132. Target1 = Target & AA(0) & "/"
  133. End Sub
  134. Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
  135. '-----------------------刪除自動更新項目-----------------------------------------------------------------------------------------------------------------------------------------------
  136. Dim Str As String = Application.StartupPath
  137. If File.Exists(Str + "\C.txt") Then : File.Delete(Str + "\C.txt") : End If
  138. Timer4.Enabled = True : Timer2.Enabled = False
  139. End Sub
  140. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  141. Dim Usbkey As Boolean = False
  142. Dim cmicWmi As New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
  143. For Each cmicWmiObj As ManagementObject In cmicWmi.Get
  144. If QA1 = Replace(cmicWmiObj("Signature"), "'", "/") And QA2 = Replace(cmicWmiObj("SerialNumber"), "'", "/") And
  145. QA3 = Replace(cmicWmiObj("Model"), "'", "/") And QA4 = Replace(cmicWmiObj("Size"), "'", "/") Then
  146. Usbkey = True : Exit For
  147. End If
  148. Next
  149. If Usbkey = False Then
  150. For Each cmicWmiObj As ManagementObject In cmicWmi.Get
  151. PA10 = cmicWmiObj("Signature") : QA1 = cmicWmiObj("Signature")
  152. PA11 = cmicWmiObj("SerialNumber") : QA2 = cmicWmiObj("SerialNumber")
  153. PA12 = cmicWmiObj("Model") : QA3 = cmicWmiObj("Model")
  154. PA13 = cmicWmiObj("Size") : QA4 = cmicWmiObj("Size")
  155. PA10 = Replace(PA10, "'", "/") : QA1 = Replace(QA1, "'", "/") : PA11 = Replace(PA11, "'", "/") : QA2 = Replace(QA2, "'", "/")
  156. PA12 = Replace(PA12, "'", "/") : QA3 = Replace(QA3, "'", "/") : PA13 = Replace(PA13, "'", "/") : QA4 = Replace(QA4, "'", "/")
  157. SQL_驗證是否綁定()
  158. If dr.Read() Then
  159. PA15 = dr("客戶") : conn.Close()
  160. SQL_USB登入清單()
  161. If dr.Read() Then : PA16 = dr("帳號") : gUserName = dr("姓名") : End If : Exit For
  162. Else
  163. PA16 = ""
  164. End If
  165. Next
  166. If PA16 = "" Then
  167. QA1 = "00" : QA2 = "00" : QA3 = "00" : QA4 = "00" ': 使用者帳號_cb.Text = "" : 密碼_tb.Text = ""
  168. Else
  169. SQL_登入鎖定解除()
  170. If PA16 = "b70340" Or PA16 = "B70340" Then
  171. 使用者帳號_cb.Text = ""
  172. Else
  173. 使用者帳號_cb.Text = PA16 : PA16 = ""
  174. End If
  175. Me.ActiveControl = 密碼_tb
  176. End If
  177. End If
  178. End Sub
  179. Private Sub 簡易登入_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 簡易登入_dgv.CellClick
  180. If e.RowIndex = -1 Then : Else
  181. 判斷重登 = True : 使用者帳號_cb.Text = 簡易登入_dgv("ID卡號", e.RowIndex).Value.ToString
  182. End If
  183. End Sub
  184. Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 伺服器區域_ch.SelectedIndexChanged
  185. '-----------------------確認登入伺服器位置-----------------------------------------------------------------------------------------------------------------------------------------
  186. If SQL_連線狀態模組.ConnectTest("180.177.181.162,5264") = True Then : IP印尼 = True
  187. 登入人IP = "180.177.181.162,5264" : 登入人IP_備用 = "106.1.48.106,4567"
  188. Else
  189. 登入人IP = "106.1.48.106,4567" : 登入人IP_備用 = "106.1.48.106,4567"
  190. End If
  191. If SQL_連線狀態模組1.Connect1Test("106.1.48.106,4567") = True Then
  192. IP台灣 = True
  193. End If
  194. If IP印尼 = True And IP台灣 = True Then : Me.Text = "GA-ERP-SYS line : 180 AND 106"
  195. ElseIf IP印尼 = True And IP台灣 = False Then : Me.Text = "GA-ERP-SYS line : 180"
  196. ElseIf IP印尼 = False And IP台灣 = True Then : Me.Text = "GA-ERP-SYS line : 106"
  197. ElseIf IP印尼 = False And IP台灣 = False Then : Me.Text = "GA-ERP-SYS line : NA" : End If
  198. 登入() : 確認_bt.Enabled = True : 取消_bt.Enabled = True : 刷卡登入_ch.Checked = True
  199. End Sub
  200. Private Sub 登入()
  201. '-----------------------寫入連線字串-----------------------------------------------------------------------------------------------------------------------------------------------
  202. SQL_連線字串_主SQL() : SQL_連線字串_主SQL備用()
  203. 驗證_tb.Text = "1" : g_conn_type = 伺服器區域_ch.Text & "伺服器"
  204. '-----------------------系統版本號驗證-----------------------------------------------------------------------------------------------------------------------------------------------
  205. SQL_系統版本號驗證()
  206. If dr.Read() Then : 資料庫版本號_lb.Text = "資料庫版本號 : " & dr("系統認證版本號") : 版本號 = dr("系統認證版本號") : End If : conn.Close()
  207. If Strings.Right(執行檔版本號_lb.Text, 10) <> Strings.Right(資料庫版本號_lb.Text, 10) Then
  208. 自動更新2()
  209. End If
  210. Timer2.Enabled = True
  211. End Sub
  212. Private Sub 自動更新1()
  213. 登入程序()
  214. End Sub
  215. Private Sub 自動更新2()
  216. Dim aa1 As MsgBoxResult = MsgBox("系統版本號 與 資料庫版本號 對應不上,請下載最新的執行檔。", MsgBoxStyle.OkCancel)
  217. If aa1 = MsgBoxResult.Ok Then
  218. 更新下載_ch.Checked = True
  219. Timer1.Enabled = False : UPDATE_bt.Visible = True : UPDATE_bt.PerformClick()
  220. 更新關閉 = True
  221. Else
  222. 簡易登入_dgv.Visible = False : 解鎖_bt.Visible = False : UPDATE_bt.Visible = False
  223. End If
  224. End Sub
  225. Private Sub 登入程序()
  226. If 帳號_tb.Text = "" Then
  227. MsgBox("請輸入帳號! 如使用刷登入,請確定該卡片有合法註冊!")
  228. ElseIf 帳號_tb.Text <> "" Then
  229. If 帳號_tb.Text = "" Then
  230. MsgBox("請輸入帳號!")
  231. ElseIf 帳號_tb.Text <> "" Then
  232. If 驗證_tb.Text = "1" Then
  233. SQL_使用者權限宣告()
  234. If dr.Read() Then
  235. 到期 = dr("到期日") : FFGG = DateDiff("d", Format(Today(), "yyyy/MM/dd"), dr("到期日")) : 剩餘天數 = FFGG
  236. If FFGG < 0 Then
  237. MsgBox("您帳號的合約日期已經到期,如要續約且恰客服人員!!!")
  238. Else
  239. 密碼驗證_tb.Text = dr("密碼").ToString : gUserName = dr("姓名").ToString : 登入客戶 = dr("主客戶").ToString
  240. For I As Integer = 1 To 權限數量
  241. CC(I) = dr.Item(I + 7)
  242. Next
  243. 登入第二層()
  244. End If
  245. End If : dr.Close()
  246. End If
  247. End If
  248. End If : conn.Close()
  249. End Sub
  250. Private Sub 登入第一層()
  251. If 帳號_tb.Text = "b70340" Or 帳號_tb.Text = "B70340" Then
  252. If Strings.Right(執行檔版本號_lb.Text, 10) <> Strings.Right(資料庫版本號_lb.Text, 10) Then : 自動更新1() : Else : 登入程序() : End If
  253. Else
  254. If Strings.Right(執行檔版本號_lb.Text, 10) <> Strings.Right(資料庫版本號_lb.Text, 10) Then : 自動更新2() : Else : 登入程序() : End If
  255. End If
  256. End Sub
  257. Private Sub 登入第二層()
  258. If 密碼_tb.Text = 密碼驗證_tb.Text Then
  259. If 密碼驗證_tb.Text = "" Then
  260. MsgBox("帳號或密碼錯誤,請重新輸入!")
  261. Else
  262. SQL_登入查詢()
  263. If dr.Read() Then
  264. Dim Str2 As String = Application.StartupPath
  265. If File.Exists("000.csv") Then : File.Delete("000.csv") : ElseIf File.Exists(Str2 & "\000.csv") Then : strDirName = Str2 & "\000.csv" : End If
  266. If File.Exists("myLog.log") Then : File.Delete("myLog.log") : ElseIf File.Exists(Str2 & "\myLog.log") Then : strDirName = Str2 & "\myLog.log" : End If
  267. If File.Exists("log.txt") Then : File.Delete("log.txt") : ElseIf File.Exists(Str2 & "\log.txt") Then : strDirName = Str2 & "\log.txt" : End If
  268. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\000.csv") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop & "\000.csv") : End If
  269. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\myLog.log") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop & "\myLog.log") : End If
  270. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\log.txt") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop & "\log.txt") : End If
  271. If dr("CC20") = True Then : 判斷重登 = True : End If
  272. conn.Close() : SQL_登入鎖定() : conn.Close()
  273. Dim cmicWmi As New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
  274. For Each cmicWmiObj As ManagementObject In cmicWmi.Get
  275. PA10 = cmicWmiObj("Signature")
  276. PA11 = cmicWmiObj("SerialNumber")
  277. PA12 = cmicWmiObj("Model")
  278. PA13 = cmicWmiObj("Size")
  279. PA10 = Replace(PA10, "'", "/") : PA11 = Replace(PA11, "'", "/") : PA12 = Replace(PA12, "'", "/") : PA13 = Replace(PA13, "'", "/")
  280. SQL_驗證是否綁定()
  281. If dr.Read() Then
  282. QA1 = Replace(cmicWmiObj("Signature"), "'", "/")
  283. QA2 = Replace(cmicWmiObj("SerialNumber"), "'", "/")
  284. QA3 = Replace(cmicWmiObj("Model"), "'", "/")
  285. QA4 = Replace(cmicWmiObj("Size"), "'", "/")
  286. End If
  287. Next : conn.Close()
  288. Timer1.Enabled = False : Me.Hide() : GA_ERP_SYS.Show()
  289. End If
  290. End If
  291. ElseIf 密碼_tb.Text <> 密碼驗證_tb.Text Then
  292. MsgBox("帳號或密碼錯誤,請重新輸入!")
  293. End If
  294. End Sub
  295. Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 確認_bt.Click
  296. 登入第一層()
  297. End Sub
  298. Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 取消_bt.Click
  299. Me.Close()
  300. End Sub
  301. Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles 更新下載_ch.CheckedChanged
  302. If 更新下載_ch.Checked = False Then
  303. Me.Size = New Size(466, 279)
  304. If screenWidth = 1920 And screenHeight = 1080 Then : Me.Location = New Point(727, 401)
  305. ElseIf screenWidth = 1366 And screenHeight = 768 Then : Me.Location = New Point(450, 245)
  306. ElseIf screenWidth = 1440 And screenHeight = 900 Then : Me.Location = New Point(487, 311)
  307. ElseIf screenWidth = 1280 And screenHeight = 1024 Then : Me.Location = New Point(407, 373)
  308. ElseIf screenWidth = 1600 And screenHeight = 900 Then : Me.Location = New Point(567, 311)
  309. End If
  310. 簡易登入_dgv.Visible = False : 解鎖_bt.Visible = False : UPDATE_bt.Visible = False
  311. Else
  312. If 簡易登入_dgv.Visible = True Then : Me.Size = New Size(980, 279) : Else : Me.Size = New Size(705, 279) : End If
  313. If screenWidth = 1920 And screenHeight = 1080 Then : Me.Location = New Point(608, 401)
  314. ElseIf screenWidth = 1366 And screenHeight = 768 Then : Me.Location = New Point(331, 245)
  315. ElseIf screenWidth = 1440 And screenHeight = 900 Then : Me.Location = New Point(368, 311)
  316. ElseIf screenWidth = 1280 And screenHeight = 1024 Then : Me.Location = New Point(288, 373)
  317. ElseIf screenWidth = 1600 And screenHeight = 900 Then : Me.Location = New Point(448, 311)
  318. End If
  319. End If
  320. End Sub
  321. Private Sub UsernameTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles 帳號_tb.KeyPress
  322. If e.KeyChar = ChrW(13) Then : Me.確認_bt.PerformClick() : End If
  323. End Sub
  324. Private Sub PasswordTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles 密碼_tb.KeyPress
  325. If e.KeyChar = ChrW(13) Then : Me.確認_bt.PerformClick() : End If
  326. End Sub
  327. Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles 刷卡登入_ch.Click
  328. Me.ActiveControl = 使用者帳號_cb
  329. End Sub
  330. Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 使用者帳號_cb.TextChanged
  331. If 使用者帳號_cb.Text = "b70340" Or 使用者帳號_cb.Text = "6666" Or 使用者帳號_cb.Text = "7777" Or 使用者帳號_cb.Text = "0013975151" Or 使用者帳號_cb.Text = "0003065795" Then
  332. 內網區域 = True
  333. End If
  334. 帳號_tb.Text = 使用者帳號_cb.Text
  335. End Sub
  336. Private Sub UsernameTextBox_TextChanged(sender As Object, e As EventArgs) Handles 帳號_tb.TextChanged
  337. If 刷卡登入_ch.Checked = False Then
  338. Else
  339. If IsNumeric(帳號_tb.Text) = True Then
  340. If 帳號_tb.Text.Length = 10 Then
  341. SQL_刷卡登入()
  342. If dr.Read() Then
  343. 帳號_tb.Text = dr("帳號").ToString : 密碼_tb.Text = dr("密碼").ToString
  344. Else
  345. 帳號_tb.Text = "" : 密碼_tb.Text = ""
  346. End If : conn.Close()
  347. Me.確認_bt.PerformClick()
  348. End If
  349. End If
  350. End If
  351. End Sub
  352. Private Sub 簡易_lb_Click(sender As Object, e As EventArgs) Handles 簡易_lb.Click
  353. 輸入密碼.ShowDialog()
  354. If PA = "0013975151" Then
  355. 簡易登入_dgv.Visible = True : 解鎖_bt.Visible = True : UPDATE_bt.Visible = True : 更新下載_ch.Checked = True : Set_使用者清單() : 內網區域 = True
  356. Else
  357. 簡易登入_dgv.Visible = False : 解鎖_bt.Visible = False : UPDATE_bt.Visible = False : 更新下載_ch.Checked = False : Set_使用者清單()
  358. End If
  359. End Sub
  360. Private Sub 解鎖_bt_Click(sender As Object, e As EventArgs) Handles 解鎖_bt.Click
  361. SQL_登入鎖定解除() : Set_使用者清單() : conn.Close() : 使用者帳號_cb.Text = ""
  362. End Sub
  363. Private Sub 藏_bt_Click(sender As Object, e As EventArgs) Handles 藏_bt.Click
  364. 使用者帳號_cb.Text = PA16
  365. End Sub
  366. Private Sub 登入綁定_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 登入綁定_ch.Click
  367. If 登入綁定_ch.Checked = False Then
  368. 登入綁定_ch.Checked = False : 藏_bt.Visible = False
  369. Else
  370. 登入綁定_ch.Checked = True : 藏_bt.Visible = True
  371. End If
  372. End Sub
  373. Private Sub 更新_bt_Click(sender As Object, e As EventArgs) Handles 更新_bt.Click
  374. Timer1.Enabled = False : UPDATE_bt.Visible = True
  375. UPDATE_bt.PerformClick()
  376. End Sub
  377. Private Sub UPDATE_bt_Click(sender As Object, e As EventArgs) Handles UPDATE_bt.Click
  378. Timer1.Enabled = False : FTP登入()
  379. Dim Strs As String = Application.StartupPath
  380. If File.Exists(Strs & "\C.txt") Then : strDirName = Strs & "\C.txt" : End If
  381. strDirName = Strs & "\C.txt"
  382. Try
  383. Using fs As IO.FileStream = New IO.FileStream(strDirName, FileMode.Append)
  384. Using sw As StreamWriter = New StreamWriter(fs, Encoding.Default)
  385. Dim str As String = Strings.Right(執行檔版本號_lb.Text, 10)
  386. sw.WriteLine(str) '插入一整行
  387. sw.Flush()
  388. End Using
  389. End Using
  390. Catch ex As Exception
  391. End Try
  392. My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "SYS-UPDATE.exe", Strs + "\SYS-UPDATE.exe")
  393. Shell(Strs + "\SYS-UPDATE.exe", vbNormalFocus)
  394. Me.Close()
  395. End Sub
  396. Private Sub 使用者帳號_cb_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles 使用者帳號_cb.GotFocus
  397. 使用者帳號_cb.ImeMode = 2
  398. End Sub
  399. Private Sub Timer4_Tick(sender As Object, e As EventArgs) Handles Timer4.Tick
  400. Dim 已開啟 As Boolean
  401. Dim Strs As String = Application.StartupPath
  402. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\SYS-UPDATE.exe") Then
  403. Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
  404. ' 判斷是否有符合的Process
  405. For Each process As Process In pro
  406. If ("SYS-UPDATE").Equals(process.ProcessName) Then
  407. 已開啟 = True
  408. End If
  409. Next
  410. If 已開啟 = False Then : Else
  411. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop + "\C.txt") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop + "\C.txt") : End If
  412. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop + "\SYS-UPDATE.exe") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop + "\SYS-UPDATE.exe") : End If
  413. Timer4.Enabled = False
  414. End If
  415. ElseIf File.Exists(Strs & "\SYS-UPDATE.exe") Then
  416. Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
  417. ' 判斷是否有符合的Process
  418. For Each process As Process In pro
  419. If ("SYS-UPDATE").Equals(process.ProcessName) Then
  420. 已開啟 = True
  421. End If
  422. Next
  423. If 已開啟 = False Then : Else
  424. If File.Exists(Strs + "\C.txt") Then : File.Delete(Strs + "\C.txt") : End If
  425. If File.Exists(Strs + "\SYS-UPDATE.exe") Then : File.Delete(Strs + "\SYS-UPDATE.exe") : End If
  426. Timer4.Enabled = False
  427. End If
  428. End If
  429. End Sub
  430. End Class