Option Strict Off
Imports System.Net
Imports System.IO
Public Class 系統執行檔版本管理
    Private Sub 系統執行檔版本管理_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        TextBox3.Visible = False : TextBox1.Visible = False : Panel1.SendToBack()
        SQL_系統認證版本號查詢()
        If dr.Read() Then : 資料庫版本號_lb.Text = "資料庫版本號 : " & dr("內帳系統") : 版本號_tb.Text = dr("內帳系統") : End If : conn.Close()
    End Sub
    Private Sub 系統執行檔版本管理_Closed(sender As Object, e As EventArgs) Handles MyBase.Closed
        MyMod.虛擬桌面開啟()
    End Sub
    Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
        timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True
    End Sub
    Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
        timeNow = 0 : HX_PGS_ERP_SYS.Timer1.Enabled = False : HX_PGS_ERP_SYS.Timer1.Enabled = True
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "UPDATE 版本號管理 SET 內帳系統 = N'" & 版本號_tb.Text & "' WHERE (內帳系統 = N'" & Strings.Right(資料庫版本號_lb.Text, 10) & "')"
        cmd.Connection = conn : cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close()

        If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
        SQL1 = "SELECT 內帳系統 FROM 版本號管理 "
        cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
        If dr.Read() Then
            資料庫版本號_lb.Text = "資料庫版本號 : " & dr("內帳系統")
            版本號_tb.Text = dr("內帳系統")
        End If : conn.Close() : If 系統語言 = "繁體中文" Then : 通知訊息 = "修改完成!!" : Else : 通知訊息 = "Modifikasi selesai!!" : End If : 訊息類型 = "1" : 通知視窗.ShowDialog()
    End Sub
    Private Sub TextBox4_DragEnter(sender As Object, e As DragEventArgs) Handles TextBox4.DragEnter
        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
            Dim files As String()
            Try
                files = CType(e.Data.GetData(DataFormats.FileDrop), String())
                TextBox4.Text = files(files.Length - 1)
            Catch ex As Exception
                MessageBox.Show(ex.Message)
                Return
            End Try
        End If

        Dim STR2 As Integer = 0
        TextBox3.Text = TextBox4.Text
        If TextBox4.Text = "" Then
        Else
            For i As Integer = 0 To 9999
                Dim STR1 As Integer = Strings.Len(TextBox3.Text)
                If Strings.Right((TextBox3.Text), 1) <> "\" Then
                    STR1 -= 1 : STR2 += 1
                    If STR1 = 0 Then
                        TextBox3.Text = ""
                        TextBox4.Text = ""
                        i = 9999
                    Else
                        TextBox3.Text = Strings.Left((TextBox3.Text), STR1)
                    End If
                Else
                    TextBox3.Text = Strings.Right((TextBox4.Text), STR2)
                    TextBox4.Text = TextBox3.Text
                    i = 9999
                End If
            Next
        End If
    End Sub
    Private Sub TextBox4_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) Handles TextBox4.DragDrop
        Dim files As Array = e.Data.GetData(DataFormats.FileDrop)
        For Each file As String In files
            TextBox4.AppendText(file + Environment.NewLine)
        Next
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        If TextBox4.Text = "" Then
            If 系統語言 = "繁體中文" Then : 通知訊息 = "請準備檔案!!" : Else : 通知訊息 = "Mohon siapkan berkas!!" : End If : 訊息類型 = "1" : 通知視窗.ShowDialog()
        Else
            Dim clsRequest12 As FtpWebRequest = DirectCast(WebRequest.Create(Target & AA(0) & "/" & TextBox4.Text), FtpWebRequest)
            TextBox1.Text = FolderBrowserDialog1.SelectedPath & "\" & TextBox4.Text
            clsRequest12.Credentials = New NetworkCredential(FTP帳號, FTP密碼)
            clsRequest12.Method = WebRequestMethods.Ftp.UploadFile
            ' read in file...
            Dim bFile12() As Byte = File.ReadAllBytes(TextBox1.Text)

            ' upload file...
            Dim clsStream12 As Stream = clsRequest12.GetRequestStream()
            clsStream12.Write(bFile12, 0, bFile12.Length)
            clsStream12.Close()
            clsStream12.Dispose()
            TextBox4.Text = ""
        End If
    End Sub
End Class