日期:2014-05-20 浏览次数:21106 次
 Private dpsource As New DataView(mydataset.Tables("Dealer_product")) 'DPlist数据源
    Private dcstr As String '当前选择的dcIDs
    '过滤dplist
    Private Sub TreeView1_NodeMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseClick
        getnodevalue()
        dplist_show(getdp(dcstr))
    End Sub
  '取当前选择node的值
    Private Sub getnodevalue()
        dcstr = Chr(39) & currnode.Name.ToString & Chr(39)
        If currnode.GetNodeCount(False) > 0 Then
            For Each tmpnode As TreeNode In currnode.Nodes
                dcstr &= " , '" & tmpnode.Name.ToString & Chr(39)
            Next
        End If
        'MsgBox("currnode value:" & dcstr)
    End Sub
    '取得当前dc的DPs
    Private Function getdp(Optional ByVal _Dc_ID As String = Nothing) As String
        If _Dc_ID = Nothing Then
            Return " "
        Else
            Dim dpstr As New StringBuilder
            For Each tmpdp As DataRow In mydataset.Tables("Product_category").Select("Dc_ID in (" & _Dc_ID & ")")
                Dim findrow As DataRow() = mydataset.Tables("Product_ready").Select("Dp_ID = '" & tmpdp("Dp_ID").ToString & "'")
                If findrow.Length = 0 Then
                    dpstr.Append("'" & tmpdp("Dp_ID").ToString & "',")
                End If
            Next
            If dpstr.Length > 0 Then
                dpstr.Remove(dpstr.Length - 1, 1)
                Return dpstr.ToString
            Else
                Return Nothing
            End If
        End If
    End Function
    '过滤Dplist
    Private Sub dplist_show(Optional ByVal _Dp_ID As String = Nothing)
        If _Dp_ID = Nothing Then
            dpsource.RowFilter = "Dp_ID = '1 '"
        Else
            dpsource.RowFilter = "Dp_ID in (" & _Dp_ID & ") and use_status = '使用中'"
        End If
    End Sub