123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435 |
- Imports System.Net
- Imports System.Management
- Imports System.IO
- Imports System.Text
- Public Class LoginForm1
- ' TODO: 插入程式碼,利用提供的使用者名稱和密碼執行自訂驗證
- ' (請參閱 https://go.microsoft.com/fwlink/?LinkId=35339)。
- ' 如此便可將自訂主體附加到目前執行緒的主體,如下所示:
- ' My.User.CurrentPrincipal = CustomPrincipal
- ' 其中 CustomPrincipal 是用來執行驗證的 IPrincipal 實作。
- ' 接著,My.User 便會傳回封裝在 CustomPrincipal 物件中的識別資訊,
- ' 例如使用者名稱、顯示名稱等。
- ReadOnly ds2 As New DataSet
- ReadOnly MACKK As String 'MAC碼
- ReadOnly diskId As String '數字ID
- ReadOnly diskSerialNumber As String '硬碟序列
- ReadOnly diskModel As String '磁盘型態
- Public Property Credentials As ICredentials
- ReadOnly screenWidth = Screen.PrimaryScreen.Bounds.Width
- ReadOnly screenHeight = Screen.PrimaryScreen.Bounds.Height
- ReadOnly ds As New DataSet
- Dim FFGG As Integer
- Dim 更新關閉 As Boolean
- Dim strDirName As String
-
- Private Sub Set_清單1()
- FTP清單_dgv.DataSource = Nothing : ds2.Clear()
- FTP清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
- FTP清單_dgv.ColumnHeadersHeight = 25
- FTP清單_dgv.AllowUserToAddRows = False
- SQL_FTP資料夾路徑分配()
- da.Fill(ds2) : FTP清單_dgv.DataSource = ds2.Tables(0) : conn.Close()
- End Sub
- Private Sub Set_使用者清單()
- 簡易登入_dgv.DataSource = Nothing : ds.Clear()
- 簡易登入_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
- 簡易登入_dgv.ColumnHeadersHeight = 25
- 簡易登入_dgv.AllowUserToAddRows = False
- 簡易登入_dgv.RowTemplate.Height = 25
- SQL_簡易登入清單()
- da.Fill(ds) : 簡易登入_dgv.DataSource = ds.Tables(0) : conn.Close()
- 簡易登入_dgv.Columns(0).FillWeight = 80 : 簡易登入_dgv.Columns(1).FillWeight = 100 : 簡易登入_dgv.Columns(2).FillWeight = 80 : 簡易登入_dgv.Columns(3).FillWeight = 55
- 簡易登入_dgv.Columns(5).FillWeight = 80 : 簡易登入_dgv.Columns(4).FillWeight = 55
- For i As Integer = 0 To 簡易登入_dgv.Rows.Count - 1
- FFGG = DateDiff("d", Format(Today(), "yyyy/MM/dd"), 簡易登入_dgv.Rows(i).Cells("到期日").Value)
- If FFGG < 0 Then
- 簡易登入_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGreen
- Else
- 簡易登入_dgv.Rows(i).DefaultCellStyle.BackColor = Color.White
- End If
- Next
- End Sub
- Private Sub LoginForm1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- '-----------------------處理檔案-----------------------------------------------------------------------------------------------------------------------------------------------
- Dim FilePath As String = "B.txt"
- Try
- Using fs As IO.FileStream = New IO.FileStream(FilePath, FileMode.Append)
- Using sw As StreamWriter = New StreamWriter(fs, Encoding.Default)
- sw.Flush()
- End Using
- End Using
- Catch ex As Exception
- End Try
- Dim Str2 As String = Application.StartupPath
- If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\B.txt") Then : strDirName = My.Computer.FileSystem.SpecialDirectories.Desktop & "\B.txt"
- ElseIf File.Exists(Str2 & "\B.txt") Then : strDirName = Str2 & "\B.txt" : End If
- Dim diMyDir As New DirectoryInfo(strDirName) : diMyDir.Attributes = FileAttributes.Hidden
-
- If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\myLog.log") Then : strDirName = My.Computer.FileSystem.SpecialDirectories.Desktop & "\myLog.log"
- ElseIf File.Exists(Str2 & "\myLog.log") Then : strDirName = Str2 & "\myLog.log" : End If
- If File.Exists("B.txt") Then : Dim diMyDir1 As New DirectoryInfo(strDirName) : diMyDir1.Attributes = FileAttributes.Hidden
- ElseIf File.Exists(Str2 & "\B.txt") Then : Dim diMyDir1 As New DirectoryInfo(strDirName) : diMyDir1.Attributes = FileAttributes.Hidden
- ElseIf File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\B.txt") Then : Dim diMyDir1 As New DirectoryInfo(strDirName) : diMyDir1.Attributes = FileAttributes.Hidden : End If
-
- If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\M0114UI.csv") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop & "\M0114UI.csv") : End If
- 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
- '-----------------------控件基本設定-----------------------------------------------------------------------------------------------------------------------------------------------
- 刷卡登入_ch.Checked = True : 刷卡登入_ch.Enabled = False : 帳號_tb.Visible = False : 解鎖_bt.Visible = False : UPDATE_bt.Visible = False : 內網區域 = False
- 執行檔版本號_lb.Text = "執行檔版本號 : " & 版本
- 伺服器區域_ch.SelectedIndex = 0
- If 更新關閉 = True Then : Me.Close() : Else
- Me.ActiveControl = 使用者帳號_cb
- Set_使用者清單()
- Dim cmicWmi As New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
- For Each cmicWmiObj As ManagementObject In cmicWmi.Get
- PA10 = cmicWmiObj("Signature") : QA1 = cmicWmiObj("Signature")
- PA11 = cmicWmiObj("SerialNumber") : QA2 = cmicWmiObj("SerialNumber")
- PA12 = cmicWmiObj("Model") : QA3 = cmicWmiObj("Model")
- PA13 = cmicWmiObj("Size") : QA4 = cmicWmiObj("Size")
- PA10 = Replace(PA10, "'", "/") : QA1 = Replace(QA1, "'", "/") : PA11 = Replace(PA11, "'", "/") : QA2 = Replace(QA2, "'", "/")
- PA12 = Replace(PA12, "'", "/") : QA3 = Replace(QA3, "'", "/") : PA13 = Replace(PA13, "'", "/") : QA4 = Replace(QA4, "'", "/")
- SQL_驗證是否綁定()
- If dr.Read() Then
- PA15 = dr("客戶") : conn.Close()
- SQL_USB登入清單()
- If dr.Read() Then : PA16 = dr("帳號") : gUserName = dr("姓名") : End If : Exit For
- Else
- PA16 = ""
- End If
- Next
- '-----用有沒有帳號出現來分類-------------------------------------------
- If PA16 = "" Then
- QA1 = "00" : QA2 = "00" : QA3 = "00" : QA4 = "00"
- FTP登入()
- Else
- FTP登入()
- SQL_登入鎖定解除()
- If PA16 = "b70340" Or PA16 = "B70340" Then
- 使用者帳號_cb.Text = ""
- Else
- 使用者帳號_cb.Text = PA16 : PA16 = ""
- End If
- Me.ActiveControl = 密碼_tb
- End If
- Timer1.Enabled = True
- End If
- 使用者帳號_cb.ImeMode = 3
- Timer4.Enabled = True
- End Sub
- Private Sub FTP登入()
- SQL_FTP伺服器登入位置()
- If dr.Read() Then : Target = dr("FTP地址") : FTP帳號 = dr("FTP帳號") : FTP密碼 = dr("FTP密碼") : End If : conn.Close()
- Set_清單1()
- Dim HH As String = ""
- For i As Integer = 0 To FTP清單_dgv.Rows.Count - 1
- If i < 10 Then : HH = "0" & i : ElseIf i >= 10 Then : HH = i : End If
- If FTP清單_dgv("指定", i).Value.ToString = "AA" & HH Then : AA(i) = FTP清單_dgv("資料夾名稱", i).Value.ToString : End If
- Next
- Target1 = Target & AA(0) & "/"
- End Sub
- Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
- '-----------------------刪除自動更新項目-----------------------------------------------------------------------------------------------------------------------------------------------
- Dim Str As String = Application.StartupPath
- If File.Exists(Str + "\C.txt") Then : File.Delete(Str + "\C.txt") : End If
- Timer4.Enabled = True : Timer2.Enabled = False
- End Sub
- Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
- Dim Usbkey As Boolean = False
- Dim cmicWmi As New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
- For Each cmicWmiObj As ManagementObject In cmicWmi.Get
- If QA1 = Replace(cmicWmiObj("Signature"), "'", "/") And QA2 = Replace(cmicWmiObj("SerialNumber"), "'", "/") And
- QA3 = Replace(cmicWmiObj("Model"), "'", "/") And QA4 = Replace(cmicWmiObj("Size"), "'", "/") Then
- Usbkey = True : Exit For
- End If
- Next
- If Usbkey = False Then
- For Each cmicWmiObj As ManagementObject In cmicWmi.Get
- PA10 = cmicWmiObj("Signature") : QA1 = cmicWmiObj("Signature")
- PA11 = cmicWmiObj("SerialNumber") : QA2 = cmicWmiObj("SerialNumber")
- PA12 = cmicWmiObj("Model") : QA3 = cmicWmiObj("Model")
- PA13 = cmicWmiObj("Size") : QA4 = cmicWmiObj("Size")
- PA10 = Replace(PA10, "'", "/") : QA1 = Replace(QA1, "'", "/") : PA11 = Replace(PA11, "'", "/") : QA2 = Replace(QA2, "'", "/")
- PA12 = Replace(PA12, "'", "/") : QA3 = Replace(QA3, "'", "/") : PA13 = Replace(PA13, "'", "/") : QA4 = Replace(QA4, "'", "/")
- SQL_驗證是否綁定()
- If dr.Read() Then
- PA15 = dr("客戶") : conn.Close()
- SQL_USB登入清單()
- If dr.Read() Then : PA16 = dr("帳號") : gUserName = dr("姓名") : End If : Exit For
- Else
- PA16 = ""
- End If
- Next
- If PA16 = "" Then
- QA1 = "00" : QA2 = "00" : QA3 = "00" : QA4 = "00" ': 使用者帳號_cb.Text = "" : 密碼_tb.Text = ""
- Else
- SQL_登入鎖定解除()
- If PA16 = "b70340" Or PA16 = "B70340" Then
- 使用者帳號_cb.Text = ""
- Else
- 使用者帳號_cb.Text = PA16 : PA16 = ""
- End If
- Me.ActiveControl = 密碼_tb
- End If
- End If
- End Sub
- Private Sub 簡易登入_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 簡易登入_dgv.CellClick
- If e.RowIndex = -1 Then : Else
- 判斷重登 = True : 使用者帳號_cb.Text = 簡易登入_dgv("ID卡號", e.RowIndex).Value.ToString
- End If
- End Sub
- Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 伺服器區域_ch.SelectedIndexChanged
- '-----------------------確認登入伺服器位置-----------------------------------------------------------------------------------------------------------------------------------------
- If SQL_連線狀態模組.ConnectTest("180.177.181.162,5264") = True Then : IP印尼 = True
- 登入人IP = "180.177.181.162,5264" : 登入人IP_備用 = "106.1.48.106,4567"
- Else
- 登入人IP = "106.1.48.106,4567" : 登入人IP_備用 = "106.1.48.106,4567"
- End If
- If SQL_連線狀態模組1.Connect1Test("106.1.48.106,4567") = True Then
- IP台灣 = True
- End If
- If IP印尼 = True And IP台灣 = True Then : Me.Text = "GA-ERP-SYS line : 180 AND 106"
- ElseIf IP印尼 = True And IP台灣 = False Then : Me.Text = "GA-ERP-SYS line : 180"
- ElseIf IP印尼 = False And IP台灣 = True Then : Me.Text = "GA-ERP-SYS line : 106"
- ElseIf IP印尼 = False And IP台灣 = False Then : Me.Text = "GA-ERP-SYS line : NA" : End If
- 登入() : 確認_bt.Enabled = True : 取消_bt.Enabled = True : 刷卡登入_ch.Checked = True
- End Sub
- Private Sub 登入()
- '-----------------------寫入連線字串-----------------------------------------------------------------------------------------------------------------------------------------------
- SQL_連線字串_主SQL() : SQL_連線字串_主SQL備用()
- 驗證_tb.Text = "1" : g_conn_type = 伺服器區域_ch.Text & "伺服器"
- '-----------------------系統版本號驗證-----------------------------------------------------------------------------------------------------------------------------------------------
- SQL_系統版本號驗證()
- If dr.Read() Then : 資料庫版本號_lb.Text = "資料庫版本號 : " & dr("系統認證版本號") : 版本號 = dr("系統認證版本號") : End If : conn.Close()
- If Strings.Right(執行檔版本號_lb.Text, 10) <> Strings.Right(資料庫版本號_lb.Text, 10) Then
- 自動更新2()
- End If
- Timer2.Enabled = True
- End Sub
- Private Sub 自動更新1()
- 登入程序()
- End Sub
- Private Sub 自動更新2()
- Dim aa1 As MsgBoxResult = MsgBox("系統版本號 與 資料庫版本號 對應不上,請下載最新的執行檔。", MsgBoxStyle.OkCancel)
- If aa1 = MsgBoxResult.Ok Then
- 更新下載_ch.Checked = True
- Timer1.Enabled = False : UPDATE_bt.Visible = True : UPDATE_bt.PerformClick()
- 更新關閉 = True
- Else
- 簡易登入_dgv.Visible = False : 解鎖_bt.Visible = False : UPDATE_bt.Visible = False
- End If
- End Sub
- Private Sub 登入程序()
- If 帳號_tb.Text = "" Then
- MsgBox("請輸入帳號! 如使用刷登入,請確定該卡片有合法註冊!")
- ElseIf 帳號_tb.Text <> "" Then
- If 帳號_tb.Text = "" Then
- MsgBox("請輸入帳號!")
- ElseIf 帳號_tb.Text <> "" Then
- If 驗證_tb.Text = "1" Then
- SQL_使用者權限宣告()
- If dr.Read() Then
- 到期 = dr("到期日") : FFGG = DateDiff("d", Format(Today(), "yyyy/MM/dd"), dr("到期日")) : 剩餘天數 = FFGG
- If FFGG < 0 Then
- MsgBox("您帳號的合約日期已經到期,如要續約且恰客服人員!!!")
- Else
- 密碼驗證_tb.Text = dr("密碼").ToString : gUserName = dr("姓名").ToString : 登入客戶 = dr("主客戶").ToString
- For I As Integer = 1 To 權限數量
- CC(I) = dr.Item(I + 7)
- Next
- 登入第二層()
- End If
- End If : dr.Close()
- End If
- End If
- End If : conn.Close()
- End Sub
- Private Sub 登入第一層()
- If 帳號_tb.Text = "b70340" Or 帳號_tb.Text = "B70340" Then
- If Strings.Right(執行檔版本號_lb.Text, 10) <> Strings.Right(資料庫版本號_lb.Text, 10) Then : 自動更新1() : Else : 登入程序() : End If
- Else
- If Strings.Right(執行檔版本號_lb.Text, 10) <> Strings.Right(資料庫版本號_lb.Text, 10) Then : 自動更新2() : Else : 登入程序() : End If
- End If
- End Sub
- Private Sub 登入第二層()
- If 密碼_tb.Text = 密碼驗證_tb.Text Then
- If 密碼驗證_tb.Text = "" Then
- MsgBox("帳號或密碼錯誤,請重新輸入!")
- Else
- SQL_登入查詢()
- If dr.Read() Then
- Dim Str2 As String = Application.StartupPath
- If File.Exists("000.csv") Then : File.Delete("000.csv") : ElseIf File.Exists(Str2 & "\000.csv") Then : strDirName = Str2 & "\000.csv" : End If
- If File.Exists("myLog.log") Then : File.Delete("myLog.log") : ElseIf File.Exists(Str2 & "\myLog.log") Then : strDirName = Str2 & "\myLog.log" : End If
- If File.Exists("log.txt") Then : File.Delete("log.txt") : ElseIf File.Exists(Str2 & "\log.txt") Then : strDirName = Str2 & "\log.txt" : End If
- If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\000.csv") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop & "\000.csv") : End If
- If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\myLog.log") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop & "\myLog.log") : End If
- If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\log.txt") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop & "\log.txt") : End If
-
- If dr("CC20") = True Then : 判斷重登 = True : End If
- conn.Close() : SQL_登入鎖定() : conn.Close()
- Dim cmicWmi As New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
- For Each cmicWmiObj As ManagementObject In cmicWmi.Get
- PA10 = cmicWmiObj("Signature")
- PA11 = cmicWmiObj("SerialNumber")
- PA12 = cmicWmiObj("Model")
- PA13 = cmicWmiObj("Size")
- PA10 = Replace(PA10, "'", "/") : PA11 = Replace(PA11, "'", "/") : PA12 = Replace(PA12, "'", "/") : PA13 = Replace(PA13, "'", "/")
- SQL_驗證是否綁定()
- If dr.Read() Then
- QA1 = Replace(cmicWmiObj("Signature"), "'", "/")
- QA2 = Replace(cmicWmiObj("SerialNumber"), "'", "/")
- QA3 = Replace(cmicWmiObj("Model"), "'", "/")
- QA4 = Replace(cmicWmiObj("Size"), "'", "/")
- End If
- Next : conn.Close()
- Timer1.Enabled = False : Me.Hide() : GA_ERP_SYS.Show()
- End If
- End If
- ElseIf 密碼_tb.Text <> 密碼驗證_tb.Text Then
- MsgBox("帳號或密碼錯誤,請重新輸入!")
- End If
- End Sub
- Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 確認_bt.Click
- 登入第一層()
- End Sub
- Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 取消_bt.Click
- Me.Close()
- End Sub
- Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles 更新下載_ch.CheckedChanged
- 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
- 簡易登入_dgv.Visible = False : 解鎖_bt.Visible = False : UPDATE_bt.Visible = False
- Else
- If 簡易登入_dgv.Visible = True Then : Me.Size = New Size(980, 279) : Else : Me.Size = New Size(705, 279) : End If
- 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
- End If
- End Sub
- Private Sub UsernameTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles 帳號_tb.KeyPress
- If e.KeyChar = ChrW(13) Then : Me.確認_bt.PerformClick() : End If
- End Sub
- Private Sub PasswordTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles 密碼_tb.KeyPress
- If e.KeyChar = ChrW(13) Then : Me.確認_bt.PerformClick() : End If
- End Sub
- Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles 刷卡登入_ch.Click
- Me.ActiveControl = 使用者帳號_cb
- End Sub
- Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles 使用者帳號_cb.TextChanged
- If 使用者帳號_cb.Text = "b70340" Or 使用者帳號_cb.Text = "6666" Or 使用者帳號_cb.Text = "7777" Or 使用者帳號_cb.Text = "0013975151" Or 使用者帳號_cb.Text = "0003065795" Then
- 內網區域 = True
- End If
- 帳號_tb.Text = 使用者帳號_cb.Text
- End Sub
- Private Sub UsernameTextBox_TextChanged(sender As Object, e As EventArgs) Handles 帳號_tb.TextChanged
- If 刷卡登入_ch.Checked = False Then
- Else
- If IsNumeric(帳號_tb.Text) = True Then
- If 帳號_tb.Text.Length = 10 Then
- SQL_刷卡登入()
- If dr.Read() Then
- 帳號_tb.Text = dr("帳號").ToString : 密碼_tb.Text = dr("密碼").ToString
- Else
- 帳號_tb.Text = "" : 密碼_tb.Text = ""
- End If : conn.Close()
- Me.確認_bt.PerformClick()
- End If
- End If
- End If
- End Sub
- Private Sub 簡易_lb_Click(sender As Object, e As EventArgs) Handles 簡易_lb.Click
- 輸入密碼.ShowDialog()
- If PA = "0013975151" Then
- 簡易登入_dgv.Visible = True : 解鎖_bt.Visible = True : UPDATE_bt.Visible = True : 更新下載_ch.Checked = True : Set_使用者清單() : 內網區域 = True
- Else
- 簡易登入_dgv.Visible = False : 解鎖_bt.Visible = False : UPDATE_bt.Visible = False : 更新下載_ch.Checked = False : Set_使用者清單()
- End If
- End Sub
- Private Sub 解鎖_bt_Click(sender As Object, e As EventArgs) Handles 解鎖_bt.Click
- SQL_登入鎖定解除() : Set_使用者清單() : conn.Close() : 使用者帳號_cb.Text = ""
- End Sub
- Private Sub 藏_bt_Click(sender As Object, e As EventArgs) Handles 藏_bt.Click
- 使用者帳號_cb.Text = PA16
- End Sub
- Private Sub 登入綁定_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 登入綁定_ch.Click
- If 登入綁定_ch.Checked = False Then
- 登入綁定_ch.Checked = False : 藏_bt.Visible = False
- Else
- 登入綁定_ch.Checked = True : 藏_bt.Visible = True
- End If
- End Sub
- Private Sub 更新_bt_Click(sender As Object, e As EventArgs) Handles 更新_bt.Click
- Timer1.Enabled = False : UPDATE_bt.Visible = True
- UPDATE_bt.PerformClick()
- End Sub
- Private Sub UPDATE_bt_Click(sender As Object, e As EventArgs) Handles UPDATE_bt.Click
- Timer1.Enabled = False : FTP登入()
- Dim Strs As String = Application.StartupPath
- If File.Exists(Strs & "\C.txt") Then : strDirName = Strs & "\C.txt" : End If
- strDirName = Strs & "\C.txt"
- Try
- Using fs As IO.FileStream = New IO.FileStream(strDirName, FileMode.Append)
- Using sw As StreamWriter = New StreamWriter(fs, Encoding.Default)
- Dim str As String = Strings.Right(執行檔版本號_lb.Text, 10)
- sw.WriteLine(str) '插入一整行
- sw.Flush()
- End Using
- End Using
- Catch ex As Exception
- End Try
-
- My.Computer.Network.DownloadFile(Target & AA(0) & "/" & "SYS-UPDATE.exe", Strs + "\SYS-UPDATE.exe")
- Shell(Strs + "\SYS-UPDATE.exe", vbNormalFocus)
- Me.Close()
- End Sub
- Private Sub 使用者帳號_cb_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles 使用者帳號_cb.GotFocus
- 使用者帳號_cb.ImeMode = 2
- End Sub
- Private Sub Timer4_Tick(sender As Object, e As EventArgs) Handles Timer4.Tick
- Dim 已開啟 As Boolean
- Dim Strs As String = Application.StartupPath
- If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\SYS-UPDATE.exe") Then
- Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
- ' 判斷是否有符合的Process
- For Each process As Process In pro
- If ("SYS-UPDATE").Equals(process.ProcessName) Then
- 已開啟 = True
- End If
- Next
- If 已開啟 = False Then : Else
- If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop + "\C.txt") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop + "\C.txt") : End If
- If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop + "\SYS-UPDATE.exe") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop + "\SYS-UPDATE.exe") : End If
- Timer4.Enabled = False
- End If
- ElseIf File.Exists(Strs & "\SYS-UPDATE.exe") Then
- Dim pro() As Process = System.Diagnostics.Process.GetProcesses()
- ' 判斷是否有符合的Process
- For Each process As Process In pro
- If ("SYS-UPDATE").Equals(process.ProcessName) Then
- 已開啟 = True
- End If
- Next
- If 已開啟 = False Then : Else
- If File.Exists(Strs + "\C.txt") Then : File.Delete(Strs + "\C.txt") : End If
- If File.Exists(Strs + "\SYS-UPDATE.exe") Then : File.Delete(Strs + "\SYS-UPDATE.exe") : End If
- Timer4.Enabled = False
- End If
- End If
- End Sub
- End Class
|