簡體   English   中英

TreeView的級別

[英]Levels to TreeView

嘿我遇到TreeView問題我無法正常工作我正試圖在它上面有三個級別InspectorName,InspectionDate和AddressLine1

我正在調用存儲過程中的信息,但我看不到它的工作原理我正在獲得第一級,我很確定我的代碼可能有點不對勁。

  Sub LoadInspectionTree()
    '**Loads Property List
    ' Initialise Error Checking


    ' Dimension Local Variables
    Dim uRecSnap As ADODB.Recordset
    Dim uPar As ADODB.Parameter
    Dim uNode As TreeNode
    Dim aNode As TreeNode
    Dim iInspectorID As Integer = 0
    Dim iInspectorcnt As Integer = 0
    Dim iInspectionID As Integer = 0
    Dim iInspectionIDcnt As Integer = 0

    Dim uStackframe As New Diagnostics.StackFrame
    Try

        ' Check For Open Connection
        If uDBase Is Nothing Then
            OpenConnection()
            bConnection = True
        End If

        ' Run Stored Procedure - Load Property List (Based on Search Value)
        uCommand = New ADODB.Command
        With uCommand
            .ActiveConnection = uDBase
            .CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
            .CommandTimeout = 0
            uPar = .CreateParameter("@SearchValue", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
            .Parameters.Append(uPar)
            .Parameters("@SearchValue").Value = txtFilter.Text
            .CommandText = "Inspections_LoadRecords"
            uRecSnap = .Execute
        End With


        ' Suppress TreeView Repaint / Clear TreeView
        tgvInspections.BeginUpdate()
        tgvInspections.Nodes.Clear()
        tgvInspections.ShowNodeToolTips = True

        ' Populate List


        Do Until uRecSnap.EOF

            If iInspectorId <> uRecSnap("InspectorID").Value Then
                uNode = tgvInspections.Nodes.Add("G" & Format(uRecSnap("InspectorID").Value, "0000"), uRecSnap("InspectorName").Value)
                uNode.Tag = "G:" & Format(uRecSnap("InspectorID").Value, "0000") & ":0000"
                iInspectorId = uRecSnap("InspectorID").Value
                iInspectorcnt = iInspectorId + 1
            End If

            If (IsDBNull(uRecSnap("InspectionID").Value)) = False Then
                If iInspectionID <> uRecSnap("InspectionID").Value Then
                    uNode = tgvInspections.Nodes(iInspectorID - 1).Nodes.Add("I" & Format(uRecSnap("InspectionID").Value, "00"), uRecSnap("InspectionDate").Value)
                    uNode.Tag = "I:" & Format(uRecSnap("InspectorID").Value, "0000") & ":" & Format(uRecSnap("InspectionID").Value, "00") & ":"
                    iInspectionID = uRecSnap("InspectionID").Value
                    iInspectionIDcnt = iInspectionIDcnt + 1
                End If
            End If

            aNode = tgvInspections.Nodes(iInspectionIDcnt - 1).Nodes.Add("P" & Format(uRecSnap("InspectionID").Value, "0000"), uRecSnap("AddressLine1").Value)
            aNode.Tag = "P:" & Format(uRecSnap("InspectionID").Value, "0000") & Format(uRecSnap("InspectionID").Value, "0000")
            uRecSnap.MoveNext()

        Loop
        uRecSnap.MoveNext()



        Do Until uRecSnap.EOF

        Loop


        ' Close Connection


    Catch ex As Exception
        ' Catch Error
        If Err.Number <> 0 Then
            WriteAuditLogRecord(uStackframe.GetMethod.DeclaringType.FullName, uStackframe.GetMethod.Name.ToString, "Error", Err.Description & vbCrLf & vbCrLf & ex.StackTrace, 0)
            MsgBox("System Error Ref: " & sAuditID & vbCrLf & uStackframe.GetMethod.DeclaringType.FullName & " / " & uStackframe.GetMethod.Name.ToString & vbCrLf & Err.Description & vbCrLf & vbCrLf & ex.StackTrace & Chr(13) & sErrDescription, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Business Management System - Unexepected Error Ref: " & sAuditID)
        End If

    Finally

        If bConnection Then CloseConnection()
        uRecSnap = Nothing

    End Try
End Sub

這也是存儲過程

    ALTER PROCEDURE [dbo].[Inspections_LoadRecords]
    @SearchValue varchar(30) = NULL

AS

BEGIN
    SET NOCOUNT ON;
SELECT        InspectorName.InspectorName, InspectionHeader.InspectionID, InspectorName.InspectorID, InspectionHeader.InspectionDate, InspectionProperties.PropertyID, PropertyMaster.AddressLine1, 

FROM            InspectorName INNER JOIN
                         InspectionHeader ON InspectorName.InspectorID = InspectionHeader.InspectorID INNER JOIN
                         InspectionProperties ON InspectionHeader.InspectionID = InspectionProperties.InspectionID INNER JOIN
                         PropertyMaster ON InspectionProperties.PropertyID = PropertyMaster.PropertyID


                         Where InspectorName.InspectorID = InspectorName.InspectorID

ORDER BY InspectorName.InspectorName

END
Sub LoadInspectionTree()
    '**Loads Property List
    ' Initialise Error Checking


    ' Dimension Local Variables
    Dim uRecSnap As ADODB.Recordset
    Dim uPar As ADODB.Parameter
    Dim uNode As TreeNode
    Dim aNode As TreeNode
    Dim iInspectorID As Integer = 0
    Dim iInspectorcnt As Integer = 0
    Dim iInspectionID As Integer = 0
    Dim iInspectionIDcnt As Integer = 0

    Dim uStackframe As New Diagnostics.StackFrame
    Try

        ' Check For Open Connection
        If uDBase Is Nothing Then
            OpenConnection()
            bConnection = True
        End If

        ' Run Stored Procedure - Load Property List (Based on Search Value)
        uCommand = New ADODB.Command
        With uCommand
            .ActiveConnection = uDBase
            .CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
            .CommandTimeout = 0
            uPar = .CreateParameter("@SearchValue", ADODB.DataTypeEnum.adVarChar, ADODB.ParameterDirectionEnum.adParamInput, 30)
            .Parameters.Append(uPar)
            .Parameters("@SearchValue").Value = txtFilter.Text
            .CommandText = "Inspections_LoadRecords"
            uRecSnap = .Execute
        End With


        ' Suppress TreeView Repaint / Clear TreeView
        tgvInspections.BeginUpdate()
        tgvInspections.Nodes.Clear()
        tgvInspections.ShowNodeToolTips = True

        ' Populate List


        Do Until uRecSnap.EOF

            If iInspectorId <> uRecSnap("InspectorID").Value Then
                uNode = tgvInspections.Nodes.Add("G" & Format(uRecSnap("InspectorID").Value, "0000"), uRecSnap("InspectorName").Value)
                uNode.Tag = "G:" & Format(uRecSnap("InspectorID").Value, "0000") & ":0000"
                iInspectorId = uRecSnap("InspectorID").Value
                iInspectorcnt = iInspectorID + 1
                iInspectionID = 0
                iInspectionIDcnt = 0
            End If

            If (IsDBNull(uRecSnap("InspectionID").Value)) = False Then
                If iInspectionID <> uRecSnap("InspectionID").Value Then
                    aNode = uNode.Nodes.Add("I" & Format(uRecSnap("InspectionID").Value, "00"), uRecSnap("InspectionDate").Value)
                    aNode.Tag = "I:" & Format(uRecSnap("InspectionID").Value, "0000") & ":" & Format(uRecSnap("InspectionID").Value, "00") & "0000"
                    iInspectionID = uRecSnap("InspectionID").Value
                    iInspectionIDcnt = iInspectionIDcnt + 1
                End If
            End If

            aNode = uNode.Nodes(iInspectionIDcnt - 1).Nodes.Add("P" & Format(uRecSnap("PropertyID").Value, "0000"), uRecSnap("AddressLine1").Value)
            aNode.Tag = "P:" & Format(uRecSnap("PropertyID").Value, "0000") & Format(uRecSnap("PropertyID").Value, "0000") & "0000"
            uRecSnap.MoveNext()

        Loop




        Do Until uRecSnap.EOF

        Loop
        uRecSnap.Close()


        ' Close Connection


    Catch ex As Exception
        ' Catch Error
        If Err.Number <> 0 Then
            WriteAuditLogRecord(uStackframe.GetMethod.DeclaringType.FullName, uStackframe.GetMethod.Name.ToString, "Error", Err.Description & vbCrLf & vbCrLf & ex.StackTrace, 0)
            MsgBox("System Error Ref: " & sAuditID & vbCrLf & uStackframe.GetMethod.DeclaringType.FullName & " / " & uStackframe.GetMethod.Name.ToString & vbCrLf & Err.Description & vbCrLf & vbCrLf & ex.StackTrace & Chr(13) & sErrDescription, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Business Management System - Unexepected Error Ref: " & sAuditID)
        End If

    Finally

        If bConnection Then CloseConnection()
        uRecSnap = Nothing

    End Try
End Sub

結束地區

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM