Partial Class CharterDocumentManagement_Default
    Inherits AdminPage

    Protected Sub FoldersTree1_AddFolder() Handles FoldersTree1.AddFolder

        Try
            FolderProperties1.FolderID = Constants.Folders.NewFolder
        Catch ex As Exception


            Throw
        End Try

    End Sub

    Protected Sub FoldersTree1_FolderDeleted() Handles FoldersTree1.FolderDeleted

        Try
            Dim unassignedFolder As Integer = Global.Constants.Folders.Unassigned
            FoldersTree1.SelectedFolder = unassignedFolder
            FolderProperties1.FolderID = unassignedFolder
            Documents1.LoadDocuments(unassignedFolder)
        Catch ex As Exception


            Throw
        End Try

    End Sub

    Protected Sub FoldersTree1_FolderSelected(ByVal folderID As Integer) Handles FoldersTree1.FolderSelected

        Try
            FolderProperties1.FolderID = folderID
            Documents1.LoadDocuments(folderID)
            Documents1.LoadFolders()
            DocumentProperties1.DocumentID = Constants.Documents.NoDocument
        Catch ex As Exception


            Throw
        End Try

    End Sub

    Protected Sub FolderProperties1_FolderUpdated(ByVal folderID As Integer) Handles FolderProperties1.FolderUpdated

        Try
            FoldersTree1.Refresh()
            FoldersTree1.SelectedFolder = folderID
            FolderProperties1.FolderID = folderID
            Documents1.LoadDocuments(folderID)
            Documents1.LoadFolders()
        Catch ex As Exception


            Throw
        End Try

    End Sub

    Protected Sub Documents1_AddDocument(ByVal folderID As Integer) Handles Documents1.AddDocument

        Try
            DocumentProperties1.DocumentID = Constants.Documents.NewDocument
            DocumentProperties1.FolderID = folderID
        Catch ex As Exception


            Throw
        End Try

    End Sub

    Protected Sub Documents1_DocumentDeleted(ByVal folderID As Integer) Handles Documents1.DocumentDeleted

        Try
            Documents1.LoadDocuments(folderID)
            DocumentProperties1.DocumentID = Constants.Documents.NoDocument
        Catch ex As Exception


            Throw
        End Try

    End Sub

    Protected Sub Documents1_DocumentSelected(ByVal folderID As Integer, ByVal documentID As Integer) Handles Documents1.DocumentSelected

        Try
            DocumentProperties1.DocumentID = documentID
            DocumentProperties1.FolderID = folderID
        Catch ex As Exception


            Throw
        End Try

    End Sub

    Protected Sub DocumentProperties1_DocumentUpdated(ByVal folderID As Integer, ByVal documentID As Integer) Handles DocumentProperties1.DocumentUpdated

        Try
            Documents1.LoadDocuments(folderID)
            Documents1.SelectedDocument = documentID
            DocumentProperties1.DocumentID = documentID
            DocumentProperties1.FolderID = folderID
        Catch ex As Exception


            Throw
        End Try

    End Sub

    '#####################################################
    'THIS IS USED FOR THE SEARCH CAPABILITY BASED ON 
    'KEYWORDS/ID. -NAQIB 9/23/08  FOR ISSUE ID: 2362   
    '#####################################################
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            If Not Page.IsPostBack Then

                If Len(Request.QueryString("DcoumentID")) > 0 And Len(Request.QueryString("FolderID")) > 0 Then
                    Dim documentID As Integer = CInt(Request.QueryString("DcoumentID"))
                    Dim folderID As Integer = CInt(Request.QueryString("FolderID"))

                    FoldersTree1.SelectedFolder() = folderID
                    FoldersTree1.Refresh()

                    Documents1.PopulateControl(folderID, documentID)
                End If
            End If
        Catch ex As Exception
            ErrorText.Text = "<font color=red><strong>" & ex.Message & "</font></strong>"
        End Try
    End Sub
End Class
