Imports System.Net
Imports System.IO
Public Class YS_ERP_SYS
    Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles NewWindowToolStripMenuItem.Click
        Dim ChildForm As New System.Windows.Forms.Form : ChildForm.MdiParent = Me : m_ChildFormNumber += 1
        ChildForm.Text = "視窗 " & m_ChildFormNumber : ChildForm.Show()
    End Sub
    Private Sub ExitToolsStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()
    End Sub
    Private Sub CascadeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CascadeToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.Cascade)
    End Sub
    Private Sub TileVerticalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileVerticalToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.TileVertical)
    End Sub
    Private Sub TileHorizontalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileHorizontalToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.TileHorizontal)
    End Sub
    Private Sub ArrangeIconsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ArrangeIconsToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.ArrangeIcons)
    End Sub
    Private Sub CloseAllToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CloseAllToolStripMenuItem.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
    End Sub
    Private Sub 重置()
        工人 = False : 重新計算 = True : 首次開啟 = True ': 不變形 = True
        BL = False : BL1 = False ': BL2 = False : BL3 = False : BL4 = False : BL5 = False : BL6 = False : BL7 = False : BL8 = False
        NU1 = 0 : NU2 = 0 : NU3 = 0 : NU4 = 0 : NU5 = 0
        BBL1 = "" : BBL2 = "" : BBL3 = "" : BBL4 = "" : BBL5 = "" : BBL6 = "" : PA = "" : PA1 = "" : PA2 = "" : PA3 = "" : PA4 = "" : PA5 = "" : PA6 = "" : PA7 = "" : PA8 = "" : PA9 = ""
        PA10 = "" : PA11 = "" : PA12 = "" : PA13 = "" : PA14 = "" : PA15 = "" : PA16 = "" : PA17 = "" : PA18 = "" : PA19 = "" : PA20 = "" : PA21 = "" : PA22 = "" : PA23 = "" : PA24 = ""
        PA25 = "" : PA26 = "" : PA27 = "" : PA28 = "" : PA29 = "" : PA30 = "" : PA31 = "" : PA32 = "" : PA33 = "" : PA34 = "" : PA35 = "" : PA36 = "" : PA37 = "" : PA38 = "" : PA39 = ""
        PA40 = "" : PA41 = "" : PA42 = "" : PA43 = "" : PA44 = "" : PA45 = "" : PA46 = "" : PA47 = "" : PA48 = "" : PA49 = "" : PA50 = "" : PA51 = ""
        PPAA = "" : DTP = "" : DTP1 = "" : DTP2 = "" : DTP3 = "" ': 列印用SQL = "" : 列印用SQL2 = ""
        'For i As Integer = 0 To 999 : H(i) = False : Next
    End Sub
    Private m_ChildFormNumber As Integer
    Private Sub YS_ERP_SYS_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        If 登入人級別 = "00" Then : Me.Text = Me.Text & "  --  " & g_conn_type & "  --  " & gUserName & "  --  系統版本  :" & 版本 & " -- IP : " & 登入人IP
        Else : Me.Text = Me.Text & "  --  " & g_conn_type & "  --  " & gUserName & "  --  系統版本  :" & 版本 : End If : 主頁開啟 = True
    End Sub
    Private Sub YS_ERP_SYS_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
        '-----業務管理---------------------------------------------------------------------------------------------------------------------------------------------------------------------
        業務管理系統_tsm.Visible = CC(5) : 客戶資料表_tsm.Visible = CC(19) : 洽談日報表_tsm.Visible = CC(42)
        '-----案件管理---------------------------------------------------------------------------------------------------------------------------------------------------------------------
        案件管理系統_tsm.Visible = CC(6)
        '-----工務管理---------------------------------------------------------------------------------------------------------------------------------------------------------------------
        工務管理系統_tsm.Visible = CC(8)
        '-----人事管理---------------------------------------------------------------------------------------------------------------------------------------------------------------------
        人事管理系統_tsm.Visible = CC(22) : 人員ID卡系統配置設定_tsm.Visible = CC(23)
        '-----系統管理---------------------------------------------------------------------------------------------------------------------------------------------------------------------
        資料庫系統管理_tsm.Visible = CC(1) : 系統使用者管理_tsm.Visible = CC(2) : 系統權限預設表_tsm.Visible = CC(84) : 系統組織架構設定_tsm.Visible = CC(41)
        部門權限設定_tsm.Visible = CC(87) : 系統組織結構與權限設定_tsm.Visible = CC(89) : 系統通用變數管理_tsm.Visible = CC(43) : 系統編碼規則_tsm.Visible = CC(10)
        系統對應電腦註冊_tsm.Visible = CC(44) : 系統執行檔版本管理_tsm.Visible = CC(4)

        SQL_系統閒置時間設定讀取() : If dr.Read() Then : timeExit = dr("timeExit") : timeExit2 = dr("timeExit2") : End If : conn.Close() : 重登計時()
        If gUser帳號 = LoginForm1.密碼驗證_tb.Text Then : 個人帳號管理.ShowDialog() : End If

        案件摘要表.區塊_dgv.Anchor = AnchorStyles.Top Or AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right
        案件摘要表.Label56.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
        案件摘要表.總坪數1_tb.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
    End Sub
    Private Sub YS_ERP_SYS_Closed(sender As Object, e As EventArgs) Handles MyBase.Closed
        LoginForm1.Close()
    End Sub
    Private Sub GRAMS_SYS_SIZE(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
        Me.BackgroundImage = My.Resources._2024052001 : Me.BackgroundImageLayout = 3
    End Sub
    Private Sub 重登計時()
        timeNow = 0 : timeNow2 = 0 : Timer1.Enabled = False : Timer2.Enabled = False : Timer1.Enabled = True
    End Sub
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        timeNow += 1
        If (timeNow >= timeExit) Then
            Timer1.Enabled = False : Timer2.Enabled = True : 系統登出.ShowDialog()
            If 重登確認 = True And 主頁開啟 = True Then
                Timer1.Enabled = False : Timer2.Enabled = False
                判斷重登 = True : 重登確認 = False : 主頁開啟 = False : LoginForm1.Close() : Me.Close() : Exit Sub
            ElseIf 重登確認 = True And 主頁開啟 = False Then
                Timer1.Enabled = False : Timer2.Enabled = False
                判斷重登 = True : 重登確認 = False : 主頁開啟 = False : LoginForm1.Close() : Me.Close() : Exit Sub
            ElseIf 重登確認 = False And 主頁開啟 = True Then
                timeNow = 0 : Timer1.Enabled = True : Timer2.Enabled = False : timeNow2 = 0
            ElseIf 重登確認 = False And 主頁開啟 = False Then
                timeNow = 0 : Timer1.Enabled = True : Timer2.Enabled = False : timeNow2 = 0
            End If
        End If
    End Sub
    Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
        Timer1.Enabled = False
        timeNow2 += 1
        If (timeNow2 >= timeExit2) Then
            Timer1.Enabled = False : Timer2.Enabled = False
            判斷重登 = True : 重登確認 = False : 主頁開啟 = False : LoginForm1.Close() : 系統登出.Close() : Me.Close() : Exit Sub
        End If
    End Sub
    Private Sub 個人帳號管理_tsm_Click(sender As Object, e As EventArgs) Handles 個人帳號管理_tsm.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
        重置() : 個人帳號管理.ShowDialog() : 個人帳號管理.BringToFront()
    End Sub
    Private Sub 系統使用者管理_tsm_Click(sender As Object, e As EventArgs) Handles 系統使用者管理_tsm.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
        重置() : BL = False : 系統使用者管理.Show() : 系統使用者管理.BringToFront()
    End Sub
    Private Sub 系統執行檔版本管理_tsm_Click(sender As Object, e As EventArgs) Handles 系統執行檔版本管理_tsm.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
        重置() : 系統執行檔版本管理.ShowDialog()
    End Sub
    Private Sub 系統組織架構設定_tsm_Click(sender As Object, e As EventArgs) Handles 系統組織架構設定_tsm.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
        重置() : 系統組織架構設定.Show() : 系統組織架構設定.BringToFront()
    End Sub
    Private Sub 系統權限預設表_tsm_Click(sender As Object, e As EventArgs) Handles 系統權限預設表_tsm.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
        重置() : 系統權限預設表.Show() : 系統權限預設表.BringToFront()
    End Sub
    Private Sub 系統對應電腦註冊_tsm_Click(sender As Object, e As EventArgs) Handles 系統對應電腦註冊_tsm.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
        重置() : 系統綁定電腦資訊.ShowDialog() : 系統綁定電腦資訊.BringToFront()
    End Sub
    Private Sub 公司組織結構_tsm_Click(sender As Object, e As EventArgs) Handles 公司組織結構_tsm.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
        重置() : 公司組織結構.Show() : 公司組織結構.BringToFront()
    End Sub
    Private Sub 系統組織結構與權限設定_tsm_Click(sender As Object, e As EventArgs) Handles 系統組織結構與權限設定_tsm.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
        重置() : 系統組織結構與權限設定.Show() : 系統組織結構與權限設定.BringToFront()
    End Sub
    Private Sub 部門權限設定_tsm_Click(sender As Object, e As EventArgs) Handles 部門權限設定_tsm.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
        重置() : 部門權限設定.Show() : 部門權限設定.BringToFront()
    End Sub
    Private Sub 人員ID卡系統配置設定_tsm_Click(sender As Object, e As EventArgs) Handles 人員ID卡系統配置設定_tsm.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
        重置() : 人員ID卡系統配置設定.Show() : 人員ID卡系統配置設定.BringToFront()
    End Sub
    Private Sub 系統通用變數管理_tsm_Click(sender As Object, e As EventArgs) Handles 系統通用變數管理_tsm.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
        重置() : 系統通用變數管理.Show() : 系統通用變數管理.BringToFront()
    End Sub
    Private Sub 客戶資料表_tsm_Click(sender As Object, e As EventArgs) Handles 客戶資料表_tsm.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
        重置() : 客戶資料表.Show() : 客戶資料表.BringToFront()
    End Sub
    Private Sub 案件摘要表_tsm_Click(sender As Object, e As EventArgs) Handles 案件摘要表_tsm.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
        重置() : 案件摘要表.Show() : 案件摘要表.BringToFront()
    End Sub
    Private Sub 洽談日報表_tsm_Click(sender As Object, e As EventArgs) Handles 洽談日報表_tsm.Click
        For Each ChildForm As Form In Me.MdiChildren : ChildForm.Close() : Next
        重置() : 訪談日報表.Show() : 訪談日報表.BringToFront()
    End Sub
    Private Sub TESTToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TESTToolStripMenuItem.Click
        Form1.Show() : Form1.BringToFront()
    End Sub
End Class
