'
' DotNetNukeŽ - http://www.dotnetnuke.com
' Copyright (c) 2002-2007
' by DotNetNuke Corporation
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions 
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
' DEALINGS IN THE SOFTWARE.
'
' Michael Washington 
' January 2007
' Los Angeles, CA USA
' http://ADefWebserver.com

Imports DotNetNuke
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection
Imports DotNetNuke.Security.PortalSecurity

Partial Class MultiViewSample

    Inherits Entities.Modules.PortalModuleBase

    Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


    End Sub

#Region " Form Events "
    Protected Sub btnView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnView1.Click
        MultiView.ActiveViewIndex = 0
    End Sub

    Protected Sub btnView2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnView2.Click
        MultiView.ActiveViewIndex = 1
        lblAgeDisplay.Text = rblAge.SelectedValue
    End Sub

    Protected Sub btnView3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnView3.Click
        MultiView.ActiveViewIndex = 2
        ShowData("")
    End Sub

    Protected Sub btnDisappear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisappear.Click
        Me.btnView1.Visible = False
        Me.btnView2.Visible = False
        Me.btnView3.Visible = False
        Me.btnDisappear.Visible = False
        Me.btnappear.Visible = True
    End Sub

    Protected Sub btnappear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnappear.Click
        Me.btnView1.Visible = True
        Me.btnView2.Visible = True
        Me.btnView3.Visible = True
        Me.btnDisappear.Visible = True
        Me.btnappear.Visible = False
    End Sub

    Protected Sub btnResetAge_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnResetAge.Click
        rblAge.SelectedIndex = -1
        lblAgeDisplay.Text = rblAge.SelectedValue
    End Sub

    Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        ShowData(txtSearch.Text)
    End Sub
#End Region

    Private Sub ShowData(ByVal SearchString As String)

        Dim mySqlString As New StringBuilder()

        mySqlString.Append("SELECT FriendlyName, Description ")
        mySqlString.Append("FROM {databaseOwner}{objectQualifier}DesktopModules ")
        mySqlString.Append("WHERE Description like '%' + @SearchString + '%' ")
        mySqlString.Append("ORDER BY FriendlyName")

        Dim myParam As SqlParameter = New SqlParameter("@SearchString", SqlDbType.VarChar, 150)

        myParam.Value = SearchString

        Me.GridView1.DataSource = CType(DataProvider.Instance().ExecuteSQL(mySqlString.ToString(), myParam), IDataReader)

        Me.GridView1.DataBind()

    End Sub

    Protected Sub rblDynamicControl_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rblDynamicControl.SelectedIndexChanged
        Dim DynamicPage As String = ""
        Select Case Me.rblDynamicControl.SelectedValue
            Case 1
                DynamicPage = DotNetNuke.Common.ResolveUrl(Me.TemplateSourceDirectory & "/DynamicControls/control1.ascx")
            Case 2
                DynamicPage = DotNetNuke.Common.ResolveUrl(Me.TemplateSourceDirectory & "/DynamicControls/control2.ascx")
        End Select
        Dim objModule As Entities.Modules.PortalModuleBase = CType(Me.LoadControl(DynamicPage), DotNetNuke.Entities.Modules.PortalModuleBase)
        If Not objModule Is Nothing Then
            objModule.ModuleConfiguration = Me.ModuleConfiguration
            phDynamicPlaceHolder.Controls.Add(objModule)
        End If

    End Sub
End Class