Option Strict Off
Public Class 系統權限預設表
    Dim HH As String : Dim 職稱 As String
    Dim RI As Integer = -1
    Dim SK As String = "要查找的 KEY"
    Dim Str As String = Application.StartupPath
    Dim 對話框(0) As String
    Private Sub Set_權限清單()
        Dim ds As New DataSet
        清單_dgv.DataSource = Nothing : ds.Clear()
        清單_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        清單_dgv.ColumnHeadersHeight = 25 : 清單_dgv.AllowUserToAddRows = False : 清單_dgv.RowTemplate.Height = 25

        If 小間距1_ch.Checked = False And 中間距1_ch.Checked = False And 大間距1_ch.Checked = True Then : 清單_dgv.RowTemplate.Height = 75
        ElseIf 小間距1_ch.Checked = False And 中間距1_ch.Checked = True And 大間距1_ch.Checked = False Then : 清單_dgv.RowTemplate.Height = 45
        ElseIf 小間距1_ch.Checked = True And 中間距1_ch.Checked = False And 大間距1_ch.Checked = False Then : 清單_dgv.RowTemplate.Height = 25 : End If
        SQL_系統權限預設表()
        da.Fill(ds) : 清單_dgv.DataSource = ds.Tables(0) : conn.Close()

        清單_dgv.Columns(0).FillWeight = 150 : 清單_dgv.Columns(1).FillWeight = 30
        For i As Integer = 0 To 權限數量 - 1
            清單_dgv.Columns(i + 2).Visible = False
        Next
    End Sub
    Private Sub Set_權限清單1()
        Dim ds1 As New DataSet
        清單1_dgv.DataSource = Nothing : ds1.Clear()
        清單1_dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing
        清單1_dgv.ColumnHeadersHeight = 25 : 清單1_dgv.AllowUserToAddRows = False : 清單1_dgv.RowTemplate.Height = 25
        If 小間距1_ch.Checked = False And 中間距1_ch.Checked = False And 大間距1_ch.Checked = True Then : 清單1_dgv.RowTemplate.Height = 75
        ElseIf 小間距1_ch.Checked = False And 中間距1_ch.Checked = True And 大間距1_ch.Checked = False Then : 清單1_dgv.RowTemplate.Height = 45
        ElseIf 小間距1_ch.Checked = True And 中間距1_ch.Checked = False And 大間距1_ch.Checked = False Then : 清單1_dgv.RowTemplate.Height = 25 : End If
        SQL_系統權限預設表()
        da.Fill(ds1) : 清單1_dgv.DataSource = ds1.Tables(0) : conn.Close()
        清單1_dgv.Columns(0).ReadOnly = True : 清單1_dgv.Columns(1).ReadOnly = True
        清單1_dgv.Columns(0).FillWeight = 150 : 清單1_dgv.Columns(1).FillWeight = 30
        For i As Integer = 0 To 權限數量 - 1
            清單1_dgv.Columns(i + 2).Visible = False
        Next
        For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
            Dim 驗證 As String = "" : Dim 取變數 As String : NN1 = 0
            取變數 = 清單1_dgv.Rows(i).Cells("職稱").Value
            For ii As Integer = 1 To 20
                If ii = 1 Then : 驗證 = Strings.Left(取變數, ii) : NN1 += 1 : Else
                    If Strings.Mid(取變數, ii, 1) = "/" Then : Exit For : Else : 驗證 &= Strings.Mid(取變數, ii, 1) : NN1 += 1 : End If
                End If
            Next
            清單1_dgv.Rows(i).Cells("職稱").Value = 驗證
        Next
    End Sub
    Private Sub 系統權限預設表_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.MdiParent = YS_ERP_SYS : Me.WindowState = 2 : Me.AutoScroll = True
        Set_權限清單() : Set_權限清單1() : Panel1.Visible = False
        For no As Integer = 1 To 權限數量
            Dim 選擇1 As CheckBox = CType(Me.Controls.Find("CheckBox" + no.ToString(), True)(0), CheckBox)
        Next
        清單_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 7.6)
        清單1_dgv.RowsDefaultCellStyle.Font = New System.Drawing.Font("微軟正黑體", 7.6)
    End Sub
    Private Sub 介面關閉_Closed(sender As Object, e As EventArgs) Handles MyBase.Closed
        MyModule1.虛擬桌面開啟()
    End Sub
    Private Sub 登入閒置控制_MouseMove(sender As Object, e As EventArgs) Handles MyBase.MouseMove
        timeNow = 0 : YS_ERP_SYS.Timer1.Enabled = False : YS_ERP_SYS.Timer1.Enabled = True
    End Sub
    Private Sub 登入閒置控制_KeyPress(sender As Object, e As EventArgs) Handles MyBase.KeyPress
        timeNow = 0 : YS_ERP_SYS.Timer1.Enabled = False : YS_ERP_SYS.Timer1.Enabled = True
    End Sub
    Private Sub 職稱_dgv_RowPostPaint(ByVal sender As Object, ByVal e As DataGridViewRowPostPaintEventArgs) Handles 清單1_dgv.RowPostPaint
        Dim linePen As New Pen(Color.Blue, 2)
        If e.RowIndex = 清單1_dgv.Rows.Count - 1 Then
            Exit Sub
        Else
            If 清單1_dgv(1, e.RowIndex).Value.ToString = "02" Then
                Dim startX As Integer = IIf(清單1_dgv.RowHeadersVisible, 清單1_dgv.RowHeadersWidth, 0)
                Dim startY As Integer = e.RowBounds.Top + e.RowBounds.Height - 1
                Dim endX As Integer = startX + 清單1_dgv.Columns.GetColumnsWidth(DataGridViewElementStates.Visible) - 清單1_dgv.HorizontalScrollingOffset
                e.Graphics.DrawLine(linePen, startX, startY, endX, startY)
                Exit Sub
            End If
        End If
        For i As Integer = 0 To 清單1_dgv.Rows.Count - 1
            If 清單1_dgv.Rows(i).Cells("級別").Value.ToString = "01" Then : 清單1_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGoldenrodYellow
            ElseIf 清單1_dgv.Rows(i).Cells("級別").Value.ToString = "02" Then : 清單1_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightGreen
            ElseIf 清單1_dgv.Rows(i).Cells("級別").Value.ToString = "03" Then : 清單1_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightPink
            ElseIf 清單1_dgv.Rows(i).Cells("級別").Value.ToString = "04" Then : 清單1_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightBlue
            ElseIf 清單1_dgv.Rows(i).Cells("級別").Value.ToString = "05" Then : 清單1_dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightBlue : End If
        Next
    End Sub
    Private Sub 清單1_dgv_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles 清單1_dgv.CellClick
        If e.RowIndex = -1 Then : Else
            職稱 = 清單_dgv.Rows(e.RowIndex).Cells("職稱").Value
            For no As Integer = 1 To 權限數量
                If no < 10 Then : HH = "0" & no : ElseIf no >= 10 Then : HH = no : End If
                Dim 選擇 As CheckBox = CType(Me.Controls.Find("CheckBox" + no.ToString(), True)(0), CheckBox)
                選擇.Checked = 清單_dgv.Rows(e.RowIndex).Cells("CC" & HH).Value
            Next
        End If
    End Sub
    Private Sub 修改_bt_Click(sender As Object, e As EventArgs) Handles 修改_bt.Click
        PA10 = 職稱 : PA = "系統權限預設表" : SQL_系統權限預設表修改() : PA = "使用者權限管理表" : SQL_系統權限預設表修改() : PA = "" : Set_權限清單() : MsgBox("修改完成!!")
    End Sub
    Private Sub 小間距1_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 小間距1_ch.Click
        小間距1_ch.Checked = True : 中間距1_ch.Checked = False : 大間距1_ch.Checked = False : Set_權限清單() : Set_權限清單1()
    End Sub
    Private Sub 中間距1_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 中間距1_ch.Click
        小間距1_ch.Checked = False : 中間距1_ch.Checked = True : 大間距1_ch.Checked = False : Set_權限清單() : Set_權限清單1()
    End Sub
    Private Sub 大間距1_ch_CheckedChanged(sender As Object, e As EventArgs) Handles 大間距1_ch.Click
        小間距1_ch.Checked = False : 中間距1_ch.Checked = False : 大間距1_ch.Checked = True : Set_權限清單() : Set_權限清單1()
    End Sub
End Class