⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmrolepermission.frm

📁 本公司开发得大请油田人事管理系统c/s结构
💻 FRM
📖 第 1 页 / 共 2 页
字号:
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private m_str As String
Private m_strSQL As String
Private m_oRs4Permission As New ADODB.Recordset
Private m_oRs4Temp As New ADODB.Recordset
Private m_temp4Table As New ADODB.Recordset
Private m_CheckPermission As String
Private m_temp4str As Integer
Private m_No4Form As Integer
'1为查询,2为增加,3为修改,4为删除,5为导出到excel,6为打印,7为其他,8为所有功能
Private Const C_FROM_NAME = 0
Private Const C_SEARCH = 1
Private Const C_ADD = 2
Private Const C_EDIT = 3
Private Const C_DELETE = 4
Private Const C_OUT_TO_EXCEL = 5
Private Const C_PRINT = 6
Private Const C_OTHER = 7
Private Const C_ALL_CHOOSE = 8
Private Const C_FROM_HAVE = 9
Private Const C_CHAR_NO = 10

Private Sub Combo4RoleName_Click()
    Call Combo4RoleName_LostFocus
End Sub

Private Sub Combo4RoleName_LostFocus()
    Dim int4ColCount As Integer
    Dim int4RowCount As Integer
    Dim Permistr4Temp As String
    Dim ifor As Integer
    With VSFlexGrid4RolePermission
        If Combo4RoleName.text = "" Then
            Exit Sub
        Else
            Call Check4Permission
            m_str = "select OPRROLE_NO from T_OPRROLE where OPRROLE_NAME='" & Combo4RoleName.text & "'"
            If m_temp4Table.State = adStateOpen Then m_temp4Table.Close
            m_temp4Table.Open m_str, g_oConnection4This
            If m_temp4Table.EOF = False Then
            m_temp4str = m_temp4Table.Fields(0)
            '读角色权限
                For int4RowCount = 1 To .Rows - 1
                    m_str = "select OPRROLE_PERMISSION from T_PERMISSION_CHAR_DETAIL where OPRROLE_NO = " & m_temp4str & " and PERMISSION_CHAR_NO = " & .TextMatrix(int4RowCount, 10)
                    If m_oRs4Permission.State = adStateOpen Then m_oRs4Permission.Close
                    m_oRs4Permission.CursorLocation = adUseClient
                    m_oRs4Permission.Open m_str, g_oConnection4This
                    If m_oRs4Permission.EOF = False Then
                        Permistr4Temp = m_oRs4Permission.Fields("OPRROLE_PERMISSION").Value
                        For int4ColCount = C_SEARCH To C_OTHER
                            If Mid(Permistr4Temp, int4ColCount, 1) = "1" Then .Cell(flexcpChecked, int4RowCount, int4ColCount) = 1
                        Next int4ColCount
                        If Permistr4Temp = .TextMatrix(int4RowCount, 9) Then .Cell(flexcpChecked, int4RowCount, 8) = 1
                        .RowData(int4RowCount) = C_NoChange
                    Else
                        .RowData(int4RowCount) = C_Init
                    End If
                Next int4RowCount
'            Else
'                Call Check4Permission
            End If
        End If
        .Editable = True
    End With
End Sub

Private Sub Command4AllPermission_Click()
    Dim int4ColCount As Integer
    Dim int4RowCount As Integer
    With VSFlexGrid4RolePermission
        If Combo4RoleName.text = "" Then
             MsgBox "请输入角色号!", vbOKOnly, "提示"
             Combo4RoleName.SetFocus
             Exit Sub
        End If
        If vbOK = MsgBox("确定要选定所有权限吗?", vbOKCancel, "提示") Then
            For int4RowCount = 1 To .Rows - 1
                For int4ColCount = C_SEARCH To C_OTHER
                    If Mid(.TextMatrix(int4RowCount, 9), int4ColCount, 1) = "1" Then .Cell(flexcpChecked, int4RowCount, int4ColCount) = 1
                Next int4ColCount
            If (.RowData(int4RowCount) = C_Init) Or (.RowData(int4RowCount) = C_NoChange) Then .RowData(int4RowCount) = .RowData(int4RowCount) + 1
            Next int4RowCount
            .Cell(flexcpChecked, 1, 8, .Rows - 1, 8) = 1
        Else
            Exit Sub
        End If
    End With
End Sub

Private Sub Command4Close_Click()
    Unload Me
End Sub

Private Sub Command4Save_Click()
    Dim lMaxIDNo As Long
    Dim ifor As Integer
    Dim i As Integer
    Dim ltemp4Tag As Long
    With VSFlexGrid4RolePermission
        If Combo4RoleName.text = "" Then
             MsgBox "请输入角色号!", vbOKOnly, "提示"
             Combo4RoleName.SetFocus
             Exit Sub
        End If
        '记录该窗体的权限字符串及角色
        ExcuteSQL ("begin transaction")
        m_str = "select OPRROLE_NO from T_OPRROLE where OPRROLE_NAME='" & Combo4RoleName.text & "'"
        If m_temp4Table.State = adStateOpen Then m_temp4Table.Close
        m_temp4Table.Open m_str, g_oConnection4This
        If m_temp4Table.EOF = True Then
            lMaxIDNo = GetMaxNo("T_OPRROLE", "OPRROLE_NO")
            m_str = "insert T_OPRROLE(OPRROLE_NO,OPRROLE_NAME) values (" & lMaxIDNo & ",'" & Combo4RoleName.text & "')"
            ExcuteSQL (m_str)
            ltemp4Tag = lMaxIDNo
        Else
            ltemp4Tag = m_temp4str
        End If
        For ifor = 1 To .Rows - 1
            For i = C_SEARCH To C_OTHER
                If .Cell(flexcpChecked, ifor, i) = 1 Then
                    .Cell(flexcpChecked, ifor, i) = 1
                Else
                    .Cell(flexcpChecked, ifor, i) = 0
                End If
            Next i
            g_Permission = .Cell(flexcpChecked, ifor, C_SEARCH) & .Cell(flexcpChecked, ifor, C_ADD) & .Cell(flexcpChecked, ifor, C_EDIT) & .Cell(flexcpChecked, ifor, C_DELETE) & .Cell(flexcpChecked, ifor, C_OUT_TO_EXCEL) & .Cell(flexcpChecked, ifor, C_PRINT) & .Cell(flexcpChecked, ifor, C_OTHER)
            '判断VSGrid状态并插入或更新数据
            If .RowData(ifor) = C_Insert Then
                m_strSQL = "insert into T_PERMISSION_CHAR_DETAIL(PERMISSION_CHAR_NO,OPRROLE_NO,OPRROLE_PERMISSION) values (" & .TextMatrix(ifor, 10) & "," & ltemp4Tag & ",'" & g_Permission & "')"
                If ExcuteSQL(m_strSQL) <> 0 Then
                    ExcuteSQL ("rollback transaction")
                    Exit Sub
                End If
            End If
            If .RowData(ifor) = C_Update Then
                m_strSQL = ""
                m_strSQL = m_strSQL & "update T_PERMISSION_CHAR_DETAIL set OPRROLE_PERMISSION = '" & g_Permission & "' where PERMISSION_CHAR_NO = " & .TextMatrix(ifor, 10) & "and OPRROLE_NO = " & ltemp4Tag
                If ExcuteSQL(m_strSQL) <> 0 Then
                    ExcuteSQL ("rollback transaction")
                    Exit Sub
                End If
            End If
        Next
        ExcuteSQL ("commit transaction")
        Call Check4Permission
        Combo4RoleName.text = ""
        Combo4RoleName.SetFocus
        MsgBox "保存完毕!", vbOKOnly, "成功"
        m_str = "select distinct T_OPRROLE.OPRROLE_NAME,T_OPRROLE.OPRROLE_NO from T_OPRROLE,T_PERMISSION_CHAR_DETAIL where T_OPRROLE.OPRROLE_NO = T_PERMISSION_CHAR_DETAIL.OPRROLE_NO"
        FillListBySql Combo4RoleName, "T_PERMISSION_CHAR_DETAIL", "OPRROLE_NO", "OPRROLE_NAME", m_str
    End With
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then SendKeys "{tab}"
End Sub

Private Sub Form_Load()
    Dim j As Integer
    Dim i As Integer
    Me.Width = 9540
    Me.Height = 5460
    With VSFlexGrid4RolePermission
        .FixedCols = 0
        .Rows = 0
        .Cols = 11
        .ColWidth(C_FROM_NAME) = VSFlexGrid4RolePermission.Width * 0.3
        .ColWidth(C_SEARCH) = VSFlexGrid4RolePermission.Width * 0.1
        .ColWidth(C_ADD) = VSFlexGrid4RolePermission.Width * 0.1
        .ColWidth(C_EDIT) = VSFlexGrid4RolePermission.Width * 0.1
        .ColWidth(C_DELETE) = VSFlexGrid4RolePermission.Width * 0.1
        .ColWidth(C_OUT_TO_EXCEL) = VSFlexGrid4RolePermission.Width * 0.1
        .ColWidth(C_PRINT) = VSFlexGrid4RolePermission.Width * 0.1
        .ColWidth(C_OTHER) = VSFlexGrid4RolePermission.Width * 0.1
        .ColWidth(C_ALL_CHOOSE) = VSFlexGrid4RolePermission.Width * 0.1
        '1为查询,2为增加,3为修改,4为删除,5为导出到excel,6为打印,7为其他
        .AddItem "窗体名称" & vbTab & "查询" & vbTab & "增加" & vbTab & "修改" & vbTab & "删除" & vbTab & "导出到EXCEL" & vbTab & "打印" & vbTab & "其他 " & vbTab & "所有功能"
        .FixedRows = 1
        .ExplorerBar = flexExSort
        .AllowBigSelection = False
        .AllowSelection = False
        .AutoSize 1, .Cols - 1
        .AutoResize = True
        .SelectionMode = flexSelectionByRow
        m_strSQL = "select distinct PERMISSION_CHAR_FORM_NAME, PERMISSION_CHAR_FORM_HAVE, PERMISSION_CHAR_NO from T_PERMISSION_CHAR"
        If m_oRs4Permission.State = adStateOpen Then m_oRs4Permission.Close
        m_oRs4Permission.CursorLocation = adUseClient
        m_oRs4Permission.Open m_strSQL, g_oConnection4This
        Do While m_oRs4Permission.EOF = False
            m_CheckPermission = m_oRs4Permission.Fields("PERMISSION_CHAR_FORM_HAVE").Value
            m_No4Form = m_oRs4Permission.Fields("PERMISSION_CHAR_NO").Value
            .AddItem m_oRs4Permission.Fields("PERMISSION_CHAR_FORM_NAME").Value & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & m_CheckPermission & vbTab & m_No4Form
            m_oRs4Permission.MoveNext
        Loop
        .ColHidden(C_FROM_HAVE) = True
        .ColHidden(C_CHAR_NO) = True
        .ColWidth(C_FROM_HAVE) = 2500
        .ExtendLastCol = True
        Call Check4Permission
        .Editable = False
    End With
    m_str = "select distinct T_OPRROLE.OPRROLE_NAME,T_OPRROLE.OPRROLE_NO from T_OPRROLE,T_PERMISSION_CHAR_DETAIL where T_OPRROLE.OPRROLE_NO = T_PERMISSION_CHAR_DETAIL.OPRROLE_NO"
    FillListBySql Combo4RoleName, "T_PERMISSION_CHAR_DETAIL", "OPRROLE_NO", "OPRROLE_NAME", m_str
    Call InitForm
    Unload frmSplash
End Sub

Private Sub Form_Unload(Cancel As Integer)
    MDIfrmMain.SSActiveToolBarsMain.Tools("ID_角色权限维护").Enabled = True
End Sub

Private Sub VSFlexGrid4RolePermission_Click()
    Dim int4AllCol As Integer
    Dim i As Integer
    If Combo4RoleName.text = "" Then
        MsgBox "请输入角色号!", vbOKOnly, "提示"
        Combo4RoleName.SetFocus
        Exit Sub
    End If
    With VSFlexGrid4RolePermission
        If .Col = C_ALL_CHOOSE And .Cell(flexcpChecked, .Row, C_ALL_CHOOSE) = 1 Then
            For int4AllCol = C_SEARCH To C_OTHER
                If Mid(.TextMatrix(.Row, C_FROM_HAVE), int4AllCol, 1) = "1" Then
                    .Cell(flexcpChecked, .Row, int4AllCol) = 1
                Else
                    .Cell(flexcpChecked, .Row, int4AllCol) = 0
                End If
            Next
        Else
            If .Col = C_ALL_CHOOSE And .Cell(flexcpChecked, .Row, C_ALL_CHOOSE) = 2 Then
                For int4AllCol = C_SEARCH To C_ALL_CHOOSE
                    If Mid(.TextMatrix(.Row, C_FROM_HAVE), int4AllCol, 1) = "1" Then
                        .Cell(flexcpChecked, .Row, int4AllCol) = 2
                    Else
                        .Cell(flexcpChecked, .Row, int4AllCol) = 0
                    End If
                Next
            End If
        End If
        If .Cell(flexcpChecked, .Row, .Col) = 1 And .Cell(flexcpChecked, .Row, 1) = 2 And .Col <> 1 Then
            .Cell(flexcpChecked, .Row, C_SEARCH) = 1
        End If
        If .Cell(flexcpChecked, .Row, C_SEARCH) = 2 Then
            For int4AllCol = C_SEARCH To C_OTHER
                If Mid(.TextMatrix(.Row, C_FROM_HAVE), int4AllCol, 1) = "1" Then
                    .Cell(flexcpChecked, .Row, int4AllCol) = 2
                Else
                    .Cell(flexcpChecked, .Row, int4AllCol) = 0
                End If
            Next
        End If
        If (.Cell(flexcpChecked, .Row, C_SEARCH) = 1 Or .Cell(flexcpChecked, .Row, C_SEARCH) = 0) And (.Cell(flexcpChecked, .Row, C_ADD) = 1 Or .Cell(flexcpChecked, .Row, C_ADD) = 0) And (.Cell(flexcpChecked, .Row, C_EDIT) = 1 Or .Cell(flexcpChecked, .Row, C_EDIT) = 0) And (.Cell(flexcpChecked, .Row, C_DELETE) = 1 Or .Cell(flexcpChecked, .Row, C_DELETE) = 0) And (.Cell(flexcpChecked, .Row, C_OUT_TO_EXCEL) = 1 Or .Cell(flexcpChecked, .Row, C_OUT_TO_EXCEL) = 0) And (.Cell(flexcpChecked, .Row, C_PRINT) = 1 Or .Cell(flexcpChecked, .Row, C_PRINT) = 0) And (.Cell(flexcpChecked, .Row, C_OTHER) = 1 Or .Cell(flexcpChecked, .Row, C_OTHER) = 0) Then
            If (.Cell(flexcpChecked, .Row, .Col)) = 1 Or (.Cell(flexcpChecked, .Row, .Col) = 2) Then
                .Cell(flexcpChecked, .Row, C_ALL_CHOOSE) = 1
            Else
                Exit Sub
            End If
        Else
            .Cell(flexcpChecked, .Row, C_ALL_CHOOSE) = 2
        End If
    If .RowData(.Row) = C_Init Or .RowData(.Row) = C_NoChange Then .RowData(.Row) = .RowData(.Row) + 1
    End With
End Sub

Private Sub Check4Permission()
    Dim Index4Temp As Integer
    Dim Index4Permission As String
    Dim Rows4Temp As Integer
    With VSFlexGrid4RolePermission
        For Rows4Temp = 1 To .Rows - 1
                For Index4Temp = C_SEARCH To C_OTHER
                    Index4Permission = Mid(.TextMatrix(Rows4Temp, C_FROM_HAVE), Index4Temp, 1)
                    If Index4Permission = "1" Then
                        .Cell(flexcpChecked, Rows4Temp, Index4Temp) = 2
                    Else
                        .Cell(flexcpChecked, Rows4Temp, Index4Temp) = 0
                    End If
                Next Index4Temp
                .RowData(Rows4Temp) = C_Init
        Next Rows4Temp
    .Cell(flexcpChecked, 1, 8, .Rows - 1, 8) = 2
    End With
End Sub

'通过角色名读取角色号
Private Sub read4Oprrole_No()
    Dim ifor As Integer
    m_str = ""
    m_str = m_str & "select OPRROLE_NO from T_OPRROLE where OPRROLE_NAME='" & Combo4RoleName.text & "'"
    If m_temp4Table.State = adStateOpen Then m_temp4Table.Close
    m_temp4Table.Open m_str, g_oConnection4This
    If m_temp4Table.EOF = False Then m_temp4str = m_temp4Table.Fields(0)
End Sub

Private Sub InitForm()
    Dim str4CheckPermission As String
    If g_lOprroleNo = 0 Then Exit Sub
    str4CheckPermission = CheckPermission("角色权限维护")
    If Mid(str4CheckPermission, 2, 1) = 0 Then
        Command4Save.Enabled = False
        Command4AllPermission.Enabled = False
    End If
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -