Imports System.IO
Public Class GRAMS_SYS
    ReadOnly ds1, ds2, ds3 As New DataSet
    Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles NewWindowToolStripMenuItem.Click
        ' 建立子表單的新執行個體。
        ' 將它變成這個 MDI 表單的子表單，然後才顯示。
        Dim ChildForm As New Form With {
            .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 m_ChildFormNumber As Integer
    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 : ds1.Clear()
        加班單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        加班單_dgv.ColumnHeadersHeight = 40
        加班單_dgv.AllowUserToAddRows = False
        SQL_加班申請明細()
        da.Fill(ds1) : 加班單_dgv.DataSource = ds1.Tables(0) : conn.Close()
    End Sub
    Private Sub Set_請假明細()
        休假單_dgv.DataSource = Nothing : ds3.Clear()
        休假單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        休假單_dgv.ColumnHeadersHeight = 40
        休假單_dgv.AllowUserToAddRows = False
        SQL_休假申請明細()
        da.Fill(ds3) : 休假單_dgv.DataSource = ds3.Tables(0) : conn.Close()
    End Sub
    Private Sub GRAMS_SYS_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        '-----------------------刪除自動更新項目-----------------------------------------------------------------------------------------------------------------------------------------------
        Dim Str As String = Application.StartupPath
        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

        Me.Text = "HSKIN醫美集團 -- 黃柏翰皮膚專科/美容醫學診所 -- 管理系統 --  系統版本  :  " & 版本 & " -- 登入人員 : " & gUserName
        '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        系統設定_tsm.Visible = CC(1) : 系統使用者權限設定_tsm.Visible = CC(2) : 系統通用變數設定_tsm.Visible = CC(3) : ID卡配置設定_tsm.Visible = CC(4) : 人員資料表_tsm.Visible = CC(5)
        '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        排班管理系統_tsm.Visible = CC(6) : 排班資料_tsm.Visible = CC(6) : 醫生班表修改_tsm.Visible = CC(17) : 人員排班條件設定_tsm.Visible = CC(17)
        '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        加班申請_審核_tsm.Visible = CC(7) : 加班申請_tsm.Visible = CC(8) : 加班核准_tsm.Visible = CC(9) : 醫師下診時間紀錄_tsm.Visible = CC(10) : 加班申請資料_tsm.Visible = CC(24)
        '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        補休申請審核_tsm.Visible = CC(11) : 補休申請_tsm.Visible = CC(12) : 補休核准_tsm.Visible = CC(13) : 國定假日設定_tsm.Visible = CC(15) : 歷史休假紀錄_tsm.Visible = CC(25)
        '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        考勤管理_tsm.Visible = CC(14) : 考勤明細表_tsm.Visible = CC(26) : 到離職管理_tsm.Visible = CC(27) : 薪資資料設定_tsm.Visible = CC(16) : 薪資表_tsm.Visible = CC(16)
        '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        業務管理系統_tsm.Visible = CC(19) : 業績獎金計算表_tsm.Visible = CC(20) : 產品銷售分析表_tsm.Visible = CC(21) : 來客資料分析表_tsm.Visible = CC(22) : 人員貢獻分析表_tsm.Visible = CC(23)
        業務銷售控制表_tsm.Visible = CC(19)
        If gUserName = "*系統管理者" Then
            業務系統資料管理_tsm.Visible = True : 交易明細表導入_tsm.Visible = True
        Else
            業務系統資料管理_tsm.Visible = False : 交易明細表導入_tsm.Visible = False
        End If
        '---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        總務管理系統_tsm.Visible = CC(29)

        Set_加班明細() : Set_請假明細()
        Dim 提醒(3) As String
        If CC(9) = True Then : 提醒(0) = "系統中還有 " & " " & 加班單_dgv.Rows.Count & " " & "筆 加班申請尚未審核" : End If
        If CC(13) = True Then : 提醒(1) = "系統中還有 " & " " & 休假單_dgv.Rows.Count & " " & "筆 請假申請尚未審核" : End If
        If CC(9) = True Or CC(13) = True Then
            MsgBox(提醒(0) & vbCrLf & vbCrLf &
                   提醒(1))
        End If
        'SYS-UPDATE.exe
    End Sub
    Private Sub GRAMS_SYS_SIZE(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
        Me.BackgroundImage = My.Resources.LOGO0101 : Me.BackgroundImageLayout = 3
    End Sub
    Private Sub GRAMS_SYS_Unload(sender As Object, e As EventArgs) Handles MyBase.Closing
        LoginForm1.Close()
    End Sub
    Private Sub 系統通用變數設定_tsm_Click(sender As Object, e As EventArgs) Handles 系統通用變數設定_tsm.Click
        PA = "" : 系統設定.Show() : 系統設定.BringToFront()
    End Sub
    Private Sub 人員資料表_tsm_Click_1(sender As Object, e As EventArgs) Handles 人員資料表_tsm.Click
        PA = "" : 人員資料表.Show() : 人員資料表.BringToFront()
    End Sub
    Private Sub 系統使用者權限設定_tsm_Click(sender As Object, e As EventArgs) Handles 系統使用者權限設定_tsm.Click
        PA = "" : 系統使用者管理.ShowDialog() : 系統使用者管理.BringToFront()
    End Sub
    Private Sub 排班資料_tsm_Click_1(sender As Object, e As EventArgs) Handles 排班資料_tsm.Click
        PA = "" : 排班資料.Show() : 排班資料.BringToFront()
    End Sub
    Private Sub 醫生班表修改_tsm_Click(sender As Object, e As EventArgs) Handles 醫生班表修改_tsm.Click
        PA = "" : 醫生班表設定.Show() : 醫生班表設定.BringToFront()
    End Sub
    Private Sub 補休申請_tsm_Click(sender As Object, e As EventArgs) Handles 補休申請_tsm.Click
        PA = "" : 休假申請.ShowDialog()
    End Sub
    Private Sub 補休核准_tsm_Click(sender As Object, e As EventArgs) Handles 補休核准_tsm.Click
        PA = "" : 休假核准.ShowDialog()
    End Sub
    Private Sub 醫師下診時間紀錄_tsm_Click(sender As Object, e As EventArgs) Handles 醫師下診時間紀錄_tsm.Click
        PA = "" : 醫師下診紀錄.ShowDialog()
    End Sub
    Private Sub 加班申請_tsm_Click(sender As Object, e As EventArgs) Handles 加班申請_tsm.Click
        PA = "" : 加班申請.ShowDialog()
    End Sub
    Private Sub 業務系統資料管理_tsm_Click(sender As Object, e As EventArgs) Handles 業務系統資料管理_tsm.Click
        PA = "" : 業務系統資料管理.Show() : 業務系統資料管理.BringToFront()
    End Sub
    Private Sub 來客資料分析表_tsm_Click(sender As Object, e As EventArgs) Handles 來客資料分析表_tsm.Click
        PA = "" : 來客資料分析表.Show() : 來客資料分析表.BringToFront()
    End Sub
    Private Sub 產品銷售分析表_tsm_Click(sender As Object, e As EventArgs) Handles 產品銷售分析表_tsm.Click
        PA = "" : 產品銷售分析表.Show() : 產品銷售分析表.BringToFront()
    End Sub
    Private Sub 人員貢獻分析表_tsm_Click(sender As Object, e As EventArgs) Handles 人員貢獻分析表_tsm.Click
        PA = "" : 人員貢獻分析表.Show() : 人員貢獻分析表.BringToFront()
    End Sub
    Private Sub 國定假日設定_tsm_Click_1(sender As Object, e As EventArgs) Handles 國定假日設定_tsm.Click
        PA = "" : 國定假日設定.ShowDialog() : 國定假日設定.BringToFront()
    End Sub
    Private Sub 歷史休假紀錄_tsm_Click(sender As Object, e As EventArgs) Handles 歷史休假紀錄_tsm.Click
        PA = "" : 休假歷史紀錄.ShowDialog() : 休假歷史紀錄.BringToFront()
    End Sub
    Private Sub 加班申請資料_tsm_Click(sender As Object, e As EventArgs) Handles 加班申請資料_tsm.Click
        PA = "" : 加班申請資料.ShowDialog() : 加班申請資料.BringToFront()
    End Sub
    Private Sub 考勤明細表_tsm_Click(sender As Object, e As EventArgs) Handles 考勤明細表_tsm.Click
        PA = "" : 考勤明細表.Show() : 考勤明細表.BringToFront()
    End Sub
    Private Sub 到離職管理_tsm_Click(sender As Object, e As EventArgs) Handles 到離職管理_tsm.Click
        PA = "" : 到離職管理.Show() : 到離職管理.BringToFront()
    End Sub
    Private Sub 到離職核准_tsm_Click(sender As Object, e As EventArgs)
    End Sub
    Private Sub 交易明細表導入_tsm_Click(sender As Object, e As EventArgs) Handles 交易明細表導入_tsm.Click
        PA = "" : 交易明細表導入.Show() : 交易明細表導入.BringToFront()
    End Sub
    Private Sub 人員排班條件設定_tsm_Click(sender As Object, e As EventArgs) Handles 人員排班條件設定_tsm.Click
        PA = "" : 人員排班條件設定.Show() : 人員排班條件設定.BringToFront()
    End Sub
    Private Sub 加班核准_tsm_Click(sender As Object, e As EventArgs) Handles 加班核准_tsm.Click
        PA = "" : 加班審核.ShowDialog()
    End Sub
    Private Sub 薪資資料設定ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 薪資資料設定_tsm.Click
        PA = "" : 薪資資料設定.ShowDialog()
    End Sub
    Private Sub 薪資表_tsm_Click(sender As Object, e As EventArgs) Handles 薪資表_tsm.Click
        PA = "" : 薪資表.Show() : 薪資表.BringToFront()
    End Sub
    Private Sub 業務銷售控制表_tsm_Click(sender As Object, e As EventArgs) Handles 業務銷售控制表_tsm.Click
        PA = "" : 業務銷售控制表.Show() : 業務銷售控制表.BringToFront()
    End Sub
    Private Sub 系統綁定電腦資訊_tsm_Click(sender As Object, e As EventArgs) Handles 系統綁定電腦資訊_tsm.Click
        PA = InputBox("請輸入系統管理員密碼!!") : If PA = "0003065795" Then : PA = "" : 系統綁定電腦資訊.ShowDialog() : 系統綁定電腦資訊.BringToFront() : End If
    End Sub
    Private Sub 專案及會議提案_tsm_Click(sender As Object, e As EventArgs) Handles 專案及會議提案_tsm.Click
        PA = "" : 專案及會議提案.Show() : 專案及會議提案.BringToFront()
    End Sub
    Private Sub 專案及會議執行_tsm_Click(sender As Object, e As EventArgs) Handles 專案及會議執行_tsm.Click
        If gUserName = "*系統管理者" Or gUserName = "黃院長" Or gUserName = "呂總監" Or gUserName = "蔡紋婷" Then
            PA = "" : 專案及會議執行.Show() : 專案及會議執行.BringToFront()
        Else : MsgBox("決議會議過程必須要有主管在場，請使用 [院長]、[總監]、[特助]其中一人的帳號登入系統後執行!!") : End If
    End Sub
    Private Sub 業績獎金計算表_tsm_Click(sender As Object, e As EventArgs) Handles 業績獎金計算表_tsm.Click
        PA = "" : 業績獎金計算表.Show() : 業績獎金計算表.BringToFront()
    End Sub
    Private Sub 個人班表_tsm_Click(sender As Object, e As EventArgs) Handles 個人班表_tsm.Click
        PA = Year(Today) : PA1 = Month(Today) : If CInt(PA1) < 10 Then : PA1 = "0" & PA1 : End If : PA2 = gUserName
        個人班表.Show() : 個人班表.BringToFront()
    End Sub
End Class
