123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- Imports System.Net
- Imports System.IO
- Imports System.Text
- Public Class LoginForm1
- Public Property Credentials As ICredentials
- Private ReadOnly ds As Object
- Private ReadOnly ds2 As New DataSet
- Private ReadOnly screenWidth = Screen.PrimaryScreen.Bounds.Width
- Private ReadOnly screenHeight = Screen.PrimaryScreen.Bounds.Height
- Dim HH As String
- Dim Str As String = Application.StartupPath
- Dim Strs As String = Application.StartupPath
- Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
- '-----------------------刪除自動更新項目-------------------------------------------------------------------------------------------------------------------------------------------
- Dim 已開啟 As Boolean = False
- If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\SYS-UPDATE.exe") Then
- Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
- For Each process As Process In pro
- If ("SYS-UPDATE").Equals(process.ProcessName) Then
- 已開啟 = True
- End If
- Next
- If 已開啟 = False Then
- Timer1.Enabled = False
- If File.Exists(Str + "\SYS-UPDATE.exe") Then : File.Delete(Str + "\SYS-UPDATE.exe") : End If
- If File.Exists(Str + "\LIVE.txt") Then : File.Delete(Str + "\LIVE.txt") : End If : Timer1.Enabled = False
- End If
- ElseIf File.Exists(Strs & "\SYS-UPDATE.exe") Then
- Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
- For Each process As Process In pro
- If ("SYS-UPDATE").Equals(process.ProcessName) Then
- 已開啟 = True
- End If
- Next
- If 已開啟 = False Then
- Timer1.Enabled = False
- If File.Exists(Str + "\SYS-UPDATE.exe") Then : File.Delete(Str + "\SYS-UPDATE.exe") : End If
- If File.Exists(Str + "\LIVE.txt") Then : File.Delete(Str + "\LIVE.txt") : End If : Timer1.Enabled = False
- End If
- End If
- End Sub
- <Obsolete>
- Private Sub LoginForm1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- '-----------------------控件基本設定-----------------------------------------------------------------------------------------------------------------------------------------------
- 刷卡登入_ch.Checked = True : 刷卡登入_ch.Enabled = False
- 執行檔版本號_lb.Text = "執行檔版本號 : " & 版本 : TextBox4.Text = "1"
- 網段.ShowDialog()
- '-----------------------調整視窗大小-----------------------------------------------------------------------------------------------------------------------------------------------
- Me.Size = New Size(466, 279)
- If screenWidth = 1920 And screenHeight = 1080 Then : Me.Location = New Point(727, 401)
- ElseIf screenWidth = 1366 And screenHeight = 768 Then : Me.Location = New Point(450, 245)
- ElseIf screenWidth = 1440 And screenHeight = 900 Then : Me.Location = New Point(487, 311)
- ElseIf screenWidth = 1280 And screenHeight = 1024 Then : Me.Location = New Point(407, 373)
- ElseIf screenWidth = 1600 And screenHeight = 900 Then : Me.Location = New Point(567, 311)
- End If
- Timer1.Enabled = True
- End Sub
- Private Sub LoginForm1_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
- If 登入判斷 = True Then
- 伺服器區域選擇_cb.Text = "巨益線路"
- OK.Enabled = True : Cancel.Enabled = True : 刷卡登入_ch.Checked = True
- ElseIf 登入判斷 = False Then
- 伺服器區域選擇_cb.Text = "開發線路"
- OK.Enabled = True : Cancel.Enabled = True : 刷卡登入_ch.Checked = True
- End If
- End Sub
- <Obsolete>
- Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 伺服器區域選擇_cb.SelectedIndexChanged
- '-----------------------確認登入伺服器位置-----------------------------------------------------------------------------------------------------------------------------------------
- If 伺服器區域選擇_cb.Text = "巨益線路" Then
- If SQL_連線狀態模組.ConnectTest("192.168.10.5") = True Then
- 登入人IP = "192.168.10.5" : 登入()
- OK.Enabled = True : Cancel.Enabled = True : 刷卡登入_ch.Checked = True
- Else
- MsgBox("巨益伺服器無法連線,自動轉跳測試線路,請聯繫系統管理員!!")
- 伺服器區域選擇_cb.Text = "開發線路"
- 登入人IP = "106.1.49.218,2433" : 登入()
- OK.Enabled = True : Cancel.Enabled = True : 刷卡登入_ch.Checked = True
- End If
- ElseIf 伺服器區域選擇_cb.Text = "開發線路" Then
- 登入人IP = "106.1.49.218,2433" : 登入()
- OK.Enabled = True : Cancel.Enabled = True : 刷卡登入_ch.Checked = True
- End If
- UsernameTextBox.Focus()
- End Sub
- Private Sub 登入()
- '-----------------------寫入連線字串-----------------------------------------------------------------------------------------------------------------------------------------------
- If 伺服器區域選擇_cb.Text = "開發線路" Then
- SQL_連線字串_測試() : SQL密碼 = "Lee0911274990"
- Else
- SQL_連線字串_正式() : SQL密碼 = "0911274990"
- End If
- g_conn_type = 伺服器區域選擇_cb.Text
- '-----------------------系統版本號寫入-----------------------------------------------------------------------------------------------------------------------------------------------
- SQL_系統認證版本號()
- If dr.Read() Then
- 資料庫版本號_lb.Text = "資料庫版本號 : " & dr("系統認證版本號") : 版本號 = dr("系統認證版本號")
- End If : conn.Close()
- '-----------------------FTP資料夾登入位置宣告--------------------------------------------------------------------------------------------------------------------------------------
- Target = "https://gcm-smart.com/ERP/WINPROFIT/"
- '-----------------------自動更新--------------------------------------------------------------------------------------------------------------------------------------
- Dim Str As String = Application.StartupPath
- If Strings.Right(執行檔版本號_lb.Text, 10) <> Strings.Right(資料庫版本號_lb.Text, 10) Then
- 自動更新2()
- Else : End If
- End Sub
- Private Sub 登入程序()
- If UsernameTextBox.Text = "" Then
- MsgBox("請輸入帳號! 如使用刷登入,請確定該卡片有合法註冊!")
- ElseIf UsernameTextBox.Text <> "" Then
- If TextBox4.Text = "1" Then
- SQL_讀取使用者權限管理表()
- If dr.Read() Then
- TextBox1.Text = dr("密碼").ToString
- gUserName = dr("姓名").ToString
- 登入人部門 = dr("部門").ToString
- For I As Integer = 0 To 95
- CC(I) = dr.Item(I + 5)
- Next
- End If
- If PasswordTextBox.Text = TextBox1.Text Then
- If TextBox1.Text = "" Then
- MsgBox("帳號或密碼錯誤,請重新輸入!")
- Else
- Me.Hide()
- WINPROFIT_ERP_SYS.Show()
- OK.Enabled = False : Cancel.Enabled = False
- End If
- ElseIf PasswordTextBox.Text <> TextBox1.Text Then
- MsgBox("帳號或密碼錯誤,請重新輸入!")
- End If
- dr.Close()
- End If
- End If
- SQL_用員工編號分辨()
- If dr.Read() Then
- 員工編號 = dr("員工編號").ToString
- End If
- conn.Close()
- End Sub
- Private Sub 自動更新1()
- Dim Str As String = Application.StartupPath
- If File.Exists(Str + "\NOTAUTO.txt") Then : Else
- Dim aa1 As MsgBoxResult
- aa1 = MsgBox("系統版本號 與 資料庫版本號 對應不上,請開發人員注意是否有其他人員修改。並決定是否下載最新的執行檔?", MsgBoxStyle.OkCancel)
- If aa1 = MsgBoxResult.Ok Then
- UPDATE_bt.PerformClick()
- Else
- 登入程序()
- End If
- End If
- End Sub
- Private Sub 自動更新2()
- Dim Str As String = Application.StartupPath
- If File.Exists(Str + "\NOTAUTO.txt") Then : Else
- Dim aa1 As MsgBoxResult
- aa1 = MsgBox("系統版本號 與 資料庫版本號 對應不上,請下載最新的執行檔。", MsgBoxStyle.OkCancel)
- If aa1 = MsgBoxResult.Ok Then
- UPDATE_bt.PerformClick()
- End If
- End If
- End Sub
- Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
- If UsernameTextBox.Text = "b70340" Or UsernameTextBox.Text = "B70340" Then
- 登入程序()
- Else
- If Strings.Right(執行檔版本號_lb.Text, 10) <> Strings.Right(資料庫版本號_lb.Text, 10) Then
- 自動更新2()
- Else
- 登入程序()
- End If
- End If
- End Sub
- Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
- Me.Close()
- End Sub
- Private Sub CheckBox2_Click(sender As Object, e As EventArgs) Handles 下載檔案_ch.Click
- If 下載檔案_ch.Checked = False Then
- Me.Size = New Size(466, 279)
- If screenWidth = 1920 And screenHeight = 1080 Then : Me.Location = New Point(727, 401)
- ElseIf screenWidth = 1366 And screenHeight = 768 Then : Me.Location = New Point(450, 245)
- ElseIf screenWidth = 1440 And screenHeight = 900 Then : Me.Location = New Point(487, 311)
- ElseIf screenWidth = 1280 And screenHeight = 1024 Then : Me.Location = New Point(407, 373)
- ElseIf screenWidth = 1600 And screenHeight = 900 Then : Me.Location = New Point(567, 311)
- End If
- Else
- 輸入密碼.ShowDialog()
- If PA = "753582" Then
- Me.Size = New Size(705, 279)
- If screenWidth = 1920 And screenHeight = 1080 Then : Me.Location = New Point(608, 401)
- ElseIf screenWidth = 1366 And screenHeight = 768 Then : Me.Location = New Point(331, 245)
- ElseIf screenWidth = 1440 And screenHeight = 900 Then : Me.Location = New Point(368, 311)
- ElseIf screenWidth = 1280 And screenHeight = 1024 Then : Me.Location = New Point(288, 373)
- ElseIf screenWidth = 1600 And screenHeight = 900 Then : Me.Location = New Point(448, 311)
- End If
- Else
- If PA = "" Then : 下載檔案_ch.Checked = False : Else
- MsgBox("密碼錯誤!!") : 下載檔案_ch.Checked = False
- End If
- End If
- End If
- End Sub
- Private Sub UsernameTextBox_TextChanged(sender As Object, e As EventArgs) Handles UsernameTextBox.TextChanged
- If 刷卡登入_ch.Checked = False Then
- Else
- If IsNumeric(UsernameTextBox.Text) = True Then
- If UsernameTextBox.Text.Length = 10 Then
- SQL_讀取ID卡號()
- If dr.Read() Then
- UsernameTextBox.Text = dr("帳號").ToString
- PasswordTextBox.Text = dr("密碼").ToString
- conn.Close()
- Else
- UsernameTextBox.Text = "" : PasswordTextBox.Text = "" : conn.Close()
- End If
- Exit Sub : Me.OK.PerformClick()
- End If
- End If
- End If
- End Sub
- Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles 刷卡登入_ch.Click
- UsernameTextBox.Focus()
- End Sub
- Private Sub UPDATE_bt_Click(sender As Object, e As EventArgs) Handles UPDATE_bt.Click
- Dim Strs As String = Application.StartupPath
- My.Computer.Network.DownloadFile(Target & "SYS-UPDATE.exe", Strs + "\SYS-UPDATE.exe")
- Shell(Strs + "\SYS-UPDATE.exe", vbNormalFocus) : Me.Close()
- End Sub
- End Class
|