Brak opisu
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.

LoginForm1.vb 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. Imports System.Net
  2. Imports System.IO
  3. Imports System.Text
  4. Public Class LoginForm1
  5. Public Property Credentials As ICredentials
  6. Private ReadOnly ds As Object
  7. Private ReadOnly ds2 As New DataSet
  8. Private ReadOnly screenWidth = Screen.PrimaryScreen.Bounds.Width
  9. Private ReadOnly screenHeight = Screen.PrimaryScreen.Bounds.Height
  10. Dim HH As String
  11. Dim Str As String = Application.StartupPath
  12. Dim Strs As String = Application.StartupPath
  13. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  14. '-----------------------刪除自動更新項目-------------------------------------------------------------------------------------------------------------------------------------------
  15. Dim 已開啟 As Boolean = False
  16. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\SYS-UPDATE.exe") Then
  17. Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
  18. For Each process As Process In pro
  19. If ("SYS-UPDATE").Equals(process.ProcessName) Then
  20. 已開啟 = True
  21. End If
  22. Next
  23. If 已開啟 = False Then
  24. Timer1.Enabled = False
  25. If File.Exists(Str + "\SYS-UPDATE.exe") Then : File.Delete(Str + "\SYS-UPDATE.exe") : End If
  26. If File.Exists(Str + "\LIVE.txt") Then : File.Delete(Str + "\LIVE.txt") : End If : Timer1.Enabled = False
  27. End If
  28. ElseIf File.Exists(Strs & "\SYS-UPDATE.exe") Then
  29. Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
  30. For Each process As Process In pro
  31. If ("SYS-UPDATE").Equals(process.ProcessName) Then
  32. 已開啟 = True
  33. End If
  34. Next
  35. If 已開啟 = False Then
  36. Timer1.Enabled = False
  37. If File.Exists(Str + "\SYS-UPDATE.exe") Then : File.Delete(Str + "\SYS-UPDATE.exe") : End If
  38. If File.Exists(Str + "\LIVE.txt") Then : File.Delete(Str + "\LIVE.txt") : End If : Timer1.Enabled = False
  39. End If
  40. End If
  41. End Sub
  42. <Obsolete>
  43. Private Sub LoginForm1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  44. '-----------------------控件基本設定-----------------------------------------------------------------------------------------------------------------------------------------------
  45. 刷卡登入_ch.Checked = True : 刷卡登入_ch.Enabled = False
  46. 執行檔版本號_lb.Text = "執行檔版本號 : " & 版本 : TextBox4.Text = "1"
  47. 網段.ShowDialog()
  48. '-----------------------調整視窗大小-----------------------------------------------------------------------------------------------------------------------------------------------
  49. Me.Size = New Size(466, 279)
  50. If screenWidth = 1920 And screenHeight = 1080 Then : Me.Location = New Point(727, 401)
  51. ElseIf screenWidth = 1366 And screenHeight = 768 Then : Me.Location = New Point(450, 245)
  52. ElseIf screenWidth = 1440 And screenHeight = 900 Then : Me.Location = New Point(487, 311)
  53. ElseIf screenWidth = 1280 And screenHeight = 1024 Then : Me.Location = New Point(407, 373)
  54. ElseIf screenWidth = 1600 And screenHeight = 900 Then : Me.Location = New Point(567, 311)
  55. End If
  56. Timer1.Enabled = True
  57. End Sub
  58. Private Sub LoginForm1_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
  59. If 登入判斷 = True Then
  60. 伺服器區域選擇_cb.Text = "巨益線路"
  61. OK.Enabled = True : Cancel.Enabled = True : 刷卡登入_ch.Checked = True
  62. ElseIf 登入判斷 = False Then
  63. 伺服器區域選擇_cb.Text = "開發線路"
  64. OK.Enabled = True : Cancel.Enabled = True : 刷卡登入_ch.Checked = True
  65. End If
  66. End Sub
  67. <Obsolete>
  68. Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 伺服器區域選擇_cb.SelectedIndexChanged
  69. '-----------------------確認登入伺服器位置-----------------------------------------------------------------------------------------------------------------------------------------
  70. If 伺服器區域選擇_cb.Text = "巨益線路" Then
  71. If SQL_連線狀態模組.ConnectTest("192.168.10.5") = True Then
  72. 登入人IP = "192.168.10.5" : 登入()
  73. OK.Enabled = True : Cancel.Enabled = True : 刷卡登入_ch.Checked = True
  74. Else
  75. MsgBox("巨益伺服器無法連線,自動轉跳測試線路,請聯繫系統管理員!!")
  76. 伺服器區域選擇_cb.Text = "開發線路"
  77. 登入人IP = "106.1.49.218,2433" : 登入()
  78. OK.Enabled = True : Cancel.Enabled = True : 刷卡登入_ch.Checked = True
  79. End If
  80. ElseIf 伺服器區域選擇_cb.Text = "開發線路" Then
  81. 登入人IP = "106.1.49.218,2433" : 登入()
  82. OK.Enabled = True : Cancel.Enabled = True : 刷卡登入_ch.Checked = True
  83. End If
  84. UsernameTextBox.Focus()
  85. End Sub
  86. Private Sub 登入()
  87. '-----------------------寫入連線字串-----------------------------------------------------------------------------------------------------------------------------------------------
  88. If 伺服器區域選擇_cb.Text = "開發線路" Then
  89. SQL_連線字串_測試() : SQL密碼 = "Lee0911274990"
  90. Else
  91. SQL_連線字串_正式() : SQL密碼 = "0911274990"
  92. End If
  93. g_conn_type = 伺服器區域選擇_cb.Text
  94. '-----------------------系統版本號寫入-----------------------------------------------------------------------------------------------------------------------------------------------
  95. SQL_系統認證版本號()
  96. If dr.Read() Then
  97. 資料庫版本號_lb.Text = "資料庫版本號 : " & dr("系統認證版本號") : 版本號 = dr("系統認證版本號")
  98. End If : conn.Close()
  99. '-----------------------FTP資料夾登入位置宣告--------------------------------------------------------------------------------------------------------------------------------------
  100. Target = "https://gcm-smart.com/ERP/WINPROFIT/"
  101. '-----------------------自動更新--------------------------------------------------------------------------------------------------------------------------------------
  102. Dim Str As String = Application.StartupPath
  103. If Strings.Right(執行檔版本號_lb.Text, 10) <> Strings.Right(資料庫版本號_lb.Text, 10) Then
  104. 自動更新2()
  105. Else : End If
  106. End Sub
  107. Private Sub 登入程序()
  108. If UsernameTextBox.Text = "" Then
  109. MsgBox("請輸入帳號! 如使用刷登入,請確定該卡片有合法註冊!")
  110. ElseIf UsernameTextBox.Text <> "" Then
  111. If TextBox4.Text = "1" Then
  112. SQL_讀取使用者權限管理表()
  113. If dr.Read() Then
  114. TextBox1.Text = dr("密碼").ToString
  115. gUserName = dr("姓名").ToString
  116. 登入人部門 = dr("部門").ToString
  117. For I As Integer = 0 To 95
  118. CC(I) = dr.Item(I + 5)
  119. Next
  120. End If
  121. If PasswordTextBox.Text = TextBox1.Text Then
  122. If TextBox1.Text = "" Then
  123. MsgBox("帳號或密碼錯誤,請重新輸入!")
  124. Else
  125. Me.Hide()
  126. WINPROFIT_ERP_SYS.Show()
  127. OK.Enabled = False : Cancel.Enabled = False
  128. End If
  129. ElseIf PasswordTextBox.Text <> TextBox1.Text Then
  130. MsgBox("帳號或密碼錯誤,請重新輸入!")
  131. End If
  132. dr.Close()
  133. End If
  134. End If
  135. SQL_用員工編號分辨()
  136. If dr.Read() Then
  137. 員工編號 = dr("員工編號").ToString
  138. End If
  139. conn.Close()
  140. End Sub
  141. Private Sub 自動更新1()
  142. Dim Str As String = Application.StartupPath
  143. If File.Exists(Str + "\NOTAUTO.txt") Then : Else
  144. Dim aa1 As MsgBoxResult
  145. aa1 = MsgBox("系統版本號 與 資料庫版本號 對應不上,請開發人員注意是否有其他人員修改。並決定是否下載最新的執行檔?", MsgBoxStyle.OkCancel)
  146. If aa1 = MsgBoxResult.Ok Then
  147. UPDATE_bt.PerformClick()
  148. Else
  149. 登入程序()
  150. End If
  151. End If
  152. End Sub
  153. Private Sub 自動更新2()
  154. Dim Str As String = Application.StartupPath
  155. If File.Exists(Str + "\NOTAUTO.txt") Then : Else
  156. Dim aa1 As MsgBoxResult
  157. aa1 = MsgBox("系統版本號 與 資料庫版本號 對應不上,請下載最新的執行檔。", MsgBoxStyle.OkCancel)
  158. If aa1 = MsgBoxResult.Ok Then
  159. UPDATE_bt.PerformClick()
  160. End If
  161. End If
  162. End Sub
  163. Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
  164. If UsernameTextBox.Text = "b70340" Or UsernameTextBox.Text = "B70340" Then
  165. 登入程序()
  166. Else
  167. If Strings.Right(執行檔版本號_lb.Text, 10) <> Strings.Right(資料庫版本號_lb.Text, 10) Then
  168. 自動更新2()
  169. Else
  170. 登入程序()
  171. End If
  172. End If
  173. End Sub
  174. Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
  175. Me.Close()
  176. End Sub
  177. Private Sub CheckBox2_Click(sender As Object, e As EventArgs) Handles 下載檔案_ch.Click
  178. If 下載檔案_ch.Checked = False Then
  179. Me.Size = New Size(466, 279)
  180. If screenWidth = 1920 And screenHeight = 1080 Then : Me.Location = New Point(727, 401)
  181. ElseIf screenWidth = 1366 And screenHeight = 768 Then : Me.Location = New Point(450, 245)
  182. ElseIf screenWidth = 1440 And screenHeight = 900 Then : Me.Location = New Point(487, 311)
  183. ElseIf screenWidth = 1280 And screenHeight = 1024 Then : Me.Location = New Point(407, 373)
  184. ElseIf screenWidth = 1600 And screenHeight = 900 Then : Me.Location = New Point(567, 311)
  185. End If
  186. Else
  187. 輸入密碼.ShowDialog()
  188. If PA = "753582" Then
  189. Me.Size = New Size(705, 279)
  190. If screenWidth = 1920 And screenHeight = 1080 Then : Me.Location = New Point(608, 401)
  191. ElseIf screenWidth = 1366 And screenHeight = 768 Then : Me.Location = New Point(331, 245)
  192. ElseIf screenWidth = 1440 And screenHeight = 900 Then : Me.Location = New Point(368, 311)
  193. ElseIf screenWidth = 1280 And screenHeight = 1024 Then : Me.Location = New Point(288, 373)
  194. ElseIf screenWidth = 1600 And screenHeight = 900 Then : Me.Location = New Point(448, 311)
  195. End If
  196. Else
  197. If PA = "" Then : 下載檔案_ch.Checked = False : Else
  198. MsgBox("密碼錯誤!!") : 下載檔案_ch.Checked = False
  199. End If
  200. End If
  201. End If
  202. End Sub
  203. Private Sub UsernameTextBox_TextChanged(sender As Object, e As EventArgs) Handles UsernameTextBox.TextChanged
  204. If 刷卡登入_ch.Checked = False Then
  205. Else
  206. If IsNumeric(UsernameTextBox.Text) = True Then
  207. If UsernameTextBox.Text.Length = 10 Then
  208. SQL_讀取ID卡號()
  209. If dr.Read() Then
  210. UsernameTextBox.Text = dr("帳號").ToString
  211. PasswordTextBox.Text = dr("密碼").ToString
  212. conn.Close()
  213. Else
  214. UsernameTextBox.Text = "" : PasswordTextBox.Text = "" : conn.Close()
  215. End If
  216. Exit Sub : Me.OK.PerformClick()
  217. End If
  218. End If
  219. End If
  220. End Sub
  221. Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles 刷卡登入_ch.Click
  222. UsernameTextBox.Focus()
  223. End Sub
  224. Private Sub UPDATE_bt_Click(sender As Object, e As EventArgs) Handles UPDATE_bt.Click
  225. Dim Strs As String = Application.StartupPath
  226. My.Computer.Network.DownloadFile(Target & "SYS-UPDATE.exe", Strs + "\SYS-UPDATE.exe")
  227. Shell(Strs + "\SYS-UPDATE.exe", vbNormalFocus) : Me.Close()
  228. End Sub
  229. End Class