Dim oConn As SqlConnection = Nothing
Dim oSqlCommand As SqlCommand = Nothing
Dim oSqlDataReader As SqlDataReader = Nothing
Dim oSqlParameter As SqlParameter
Dim sParentID As String = ""
Dim sPSubType As String = ""
Dim sDesc As String = ""
Dim sHtml As String = ""
Dim oTree As New obout_ASPTreeView_2_NET.Tree
Try
oConn = New SqlConnection
oConn = OpenConn(ConstString)
oSqlCommand = New SqlCommand("SPD_SYSXXD01_2", oConn)
oSqlCommand.CommandType = CommandType.StoredProcedure
oSqlParameter = oSqlCommand.Parameters.Add("@SP_BUSS_CODE", SqlDbType.VarChar, 2)
oSqlParameter.Value = Session("BussCode")
oSqlParameter = oSqlCommand.Parameters.Add("@SP_CUST_CODE", SqlDbType.VarChar, 10)
oSqlParameter.Value = Session("CusHErp")
oSqlParameter = oSqlCommand.Parameters.Add("@SP_USER_IDXX", SqlDbType.VarChar, 15)
oSqlParameter.Value = Session("LgnErp")
oSqlDataReader = oSqlCommand.ExecuteReader()
oTree.AddRootNode("eDTB (Distribution System)", "ada.gif")
oTree.FolderStyle = "icons_tree"
oTree.FolderIcons = "icons_tree"
oTree.ShowIcons = True
sHtml = ""
Do While oSqlDataReader.Read()
If Trim(CType(oSqlDataReader("PSUB_CODE"), String)) = "" Or oSqlDataReader("PSUB_CODE") Is DBNull.Value Then
sParentID = "root"
sDesc = Trim(CType(oSqlDataReader("PROG_DESC"), String))
If Trim(CType(oSqlDataReader("PROG_VALU"), String)) <> "" Then
sHtml = "" & sDesc & ""
Else
sHtml = "" & sDesc & ""
End If
oTree.Add(sParentID, "id" & CType(oSqlDataReader("PROG_TYPE"), String), sHtml, oSqlDataReader("PROG_EXPX"))
Else
sParentID = "id" & CType(oSqlDataReader("PROG_TYPE"), String)
sDesc = Trim(CType(oSqlDataReader("PSUB_NAME"), String))
sPSubType = UCase(CType(oSqlDataReader("PSUB_TYPE"), String))
If sPSubType = "ENT" Then
sPSubType = "MAF16.gif"
ElseIf sPSubType = "INQ" Then
sPSubType = "search.gif"
Else
sPSubType = "aspx.gif"
End If
If Trim(CType(oSqlDataReader("PSUB_VALU"), String)) <> "" Then
sHtml = "" & sDesc & ""
Else
sHtml = "" & sDesc & ""
End If
oTree.Add(sParentID, sParentID & "sid" & CType(oSqlDataReader("PSUB_SEQN"), String), sHtml, False, sPSubType)
End If
Loop
oTreeView.Text = oTree.HTML()
oSqlDataReader.Close()
oSqlCommand.Connection.Close()
If oConn.State = ConnectionState.Open Then oConn.Close()
Catch ex As Exception
If oConn.State = ConnectionState.Open Then oConn.Close()
Response.Write(ex.Message)
Finally
oTree = Nothing
oSqlDataReader = Nothing
If Not (oSqlParameter Is Nothing) Then oSqlParameter = Nothing
If Not (oSqlCommand Is Nothing) Then oSqlCommand.Dispose()
If Not (oConn Is Nothing) Then oConn.Dispose()
End Try
End Sub
Private Sub oTreeView_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles oTreeView.Disposed
oTreeView.Dispose()
End Sub
Tampilan: