Public Class ClassRightManagement
    Public Shared Sub Check_Set_Rights(RECORD_ID As Integer, ENTITY_ID As Integer)
        Try
            RIGHT_EDIT_R = True
            RIGHT_ADD_R = True
            RIGHT_DELETE_R = True
            RIGHT_RECORD_AND_FILE_READ_ONLY = False

            RIGHT_ADD_DOC = True
            RIGHT_VIEW_DOC = True
            RIGHT_DELETE_DOC = True
            RIGHT_READ_ONLY_DOC = False
            ' Wenn Rechte pro Record defineirt wurden!!!
            If SQL_RECORD_AND_FILE_READ_ONLY <> "" Or SQL_DOC_READ_ONLY <> "" Then
                If SQL_RECORD_AND_FILE_READ_ONLY <> "" Then
                    RIGHT_RECORD_AND_FILE_READ_ONLY = ClassHelper.Check_Record_Read_only(RECORD_ID, ENTITY_ID)
                    If RIGHT_RECORD_AND_FILE_READ_ONLY = True Then
                        RIGHT_EDIT_R = False
                        RIGHT_ADD_R = False
                        RIGHT_DELETE_R = False
                    End If
                End If
                If SQL_DOC_READ_ONLY <> "" Then
                    RIGHT_READ_ONLY_DOC = ClassHelper.Check_File_Read_only(RECORD_ID, ENTITY_ID)
                    If RIGHT_READ_ONLY_DOC = True Then
                        RIGHT_ADD_DOC = False
                        RIGHT_DELETE_DOC = False
                    Else
                        RIGHT_ADD_DOC = True
                        RIGHT_DELETE_DOC = True
                    End If
                End If
            Else
                ' Definitiond er REchte erfolgt über UserRightstabel......wenn gefüllt
                If DT_RIGHTS_GROUP.Rows.Count > 0 And DT_RIGHTS_USER.Rows.Count = 0 Then
                    For Each row As DataRow In DT_RIGHTS_GROUP.Rows
                        RIGHT_EDIT_R = CBool(DT_RIGHTS_GROUP.Rows(0).Item(0))
                        RIGHT_ADD_R = CBool(DT_RIGHTS_GROUP.Rows(0).Item(1))
                        RIGHT_DELETE_R = CBool(DT_RIGHTS_GROUP.Rows(0).Item(2))

                        RIGHT_ADD_DOC = CBool(DT_RIGHTS_GROUP.Rows(0).Item(3))
                        RIGHT_VIEW_DOC = CBool(DT_RIGHTS_GROUP.Rows(0).Item(4))
                        RIGHT_DELETE_DOC = CBool(DT_RIGHTS_GROUP.Rows(0).Item(5))
                        If RIGHT_ADD_DOC = False And RIGHT_DELETE_DOC = False Then
                            RIGHT_READ_ONLY_DOC = True
                        End If

                    Next
                Else
                    If DT_RIGHTS_USER.Rows.Count = 1 Then
                        RIGHT_EDIT_R = CBool(DT_RIGHTS_USER.Rows(0).Item("EDIT_REC"))
                        RIGHT_ADD_R = CBool(DT_RIGHTS_USER.Rows(0).Item("ADD_REC"))
                        RIGHT_DELETE_R = CBool(DT_RIGHTS_USER.Rows(0).Item("DELETE_REC"))

                        RIGHT_ADD_DOC = CBool(DT_RIGHTS_USER.Rows(0).Item("ADD_DOC"))
                        RIGHT_VIEW_DOC = CBool(DT_RIGHTS_USER.Rows(0).Item("FILES_VISIBLE"))
                        RIGHT_DELETE_DOC = CBool(DT_RIGHTS_USER.Rows(0).Item("DELETE_DOC"))
                        RIGHT_READ_ONLY_DOC = CBool(DT_RIGHTS_USER.Rows(0).Item("READ_ONLY_DOC"))
                    End If
                End If
            End If
            If LogErrorsOnly = False Then
                ClassLogger.Add(" >> RIGHT_EDIT_R: " & RIGHT_EDIT_R.ToString, False)
                ClassLogger.Add(" >> RIGHT_ADD_R: " & RIGHT_ADD_R.ToString, False)
                ClassLogger.Add(" >> RIGHT_DELETE_R: " & RIGHT_DELETE_R.ToString, False)
                ClassLogger.Add(" >> RIGHT_ADD_DOC: " & RIGHT_ADD_DOC.ToString, False)
                ClassLogger.Add(" >> RIGHT_VIEW_DOC: " & RIGHT_VIEW_DOC.ToString, False)
                ClassLogger.Add(" >> RIGHT_DELETE_DOC: " & RIGHT_DELETE_DOC.ToString, False)
                ClassLogger.Add(" >> RIGHT_READ_ONLY_DOC: " & RIGHT_READ_ONLY_DOC.ToString, False)
            End If
        Catch ex As Exception
            ClassHelper.MSGBOX_Handler("ERROR", "Unexpected Error in Check_Set_Rights", ex.Message, ex.StackTrace)
        End Try
    End Sub
End Class
