<TreeListView> Column에 Average 값 넣기
2020. 2. 13. 17:09ㆍC#
728x90
반응형
Private Sub TreeListView_GetAvg(ByRef Trv As TreeListNodeCollection)
Dim avgValue As Double
Dim row As DataRow()
Dim strQuery As String
Dim strDepth0 As String : Dim strDepth1 As String : Dim strDepth2 As String : Dim strDepth3 As String
For Each p_node As TreeListNode In Trv
strDepth0 = p_node.Text
strDepth1 = p_node.Nodes.Item(0).Text
strDepth2 = p_node.Nodes.Item(0).Nodes.Item(0).Text
strDepth3 = p_node.Nodes.Item(0).Nodes.Item(0).Nodes.Item(0).Text
strQuery = String.Format(
"[Project] = '{0}'",
strDepth0)
row = _dt.Select(strQuery)
If row.Count > 0 Then
avgValue = row.AsEnumerable().Average(Function(x) x.Field(Of String)("level"))
Else
avgValue = CDbl(0.0)
End If
p_node.SubItems.Add(avgValue)
For Each m_node As TreeListNode In p_node.Nodes
strDepth0 = m_node.ParentNode.Text
strDepth1 = m_node.Text
strQuery = String.Format(
"[Project] = '{0}' AND
[Model] = '{1}'",
strDepth0, strDepth1)
row = _dt.Select(strQuery)
If row.Count > 0 Then
avgValue = CDbl(row.AsEnumerable().Average(Function(x) x.Field(Of String)("level"))).ToString("F1")
Else
avgValue = CDbl(0.0)
End If
m_node.SubItems.Add(avgValue)
For Each s_node As TreeListNode In m_node.Nodes
strDepth0 = s_node.ParentNode.ParentNode.Text
strDepth1 = s_node.ParentNode.Text
strDepth2 = s_node.Text
strQuery = String.Format(
"[Project] = '{0}' AND
[Model] = '{1}' AND
[Step] = '{2}' ",
strDepth0, strDepth1, strDepth2)
row = _dt.Select(strQuery)
If row.Count > 0 Then
avgValue = CDbl(row.AsEnumerable().Average(Function(x) x.Field(Of String)("level"))).ToString("F1")
Else
avgValue = CDbl(0.0)
End If
s_node.SubItems.Add(avgValue)
For Each n_node As TreeListNode In s_node.Nodes
strDepth0 = n_node.ParentNode.ParentNode.ParentNode.Text
strDepth1 = n_node.ParentNode.ParentNode.Text
strDepth2 = n_node.ParentNode.Text
strDepth3 = n_node.Text
strQuery = String.Format(
"[Project] = '{0}' AND
[Model] = '{1}' AND
[Step] = '{2}' AND
[이름] = '{3}' ",
strDepth0, strDepth1, strDepth2, strDepth3)
row = _dt.Select(strQuery)
If row.Count > 0 Then
avgValue = CDbl(row.AsEnumerable().Average(Function(x) x.Field(Of String)("level")))
Else
avgValue = CDbl(0.0)
End If
' 점수 추가
n_node.SubItems.Add(avgValue)
Next '// Name
Next '// Step
Next '// Model
Next '// Project
End Sub
728x90
반응형
'C#' 카테고리의 다른 글
Chart 용어정리 (MS Chart 및 기타 차트 모두) (0) | 2020.02.17 |
---|---|
<TreeListView> TreeListView To DataTable (0) | 2020.02.13 |
C#/VB.NET 특정 로우 선택하기 (0) | 2020.01.21 |
C#/VB.NET Panel 안의 Control 반복하여 원하는 Control 찾기 (0) | 2020.01.14 |
C# DataGridView 좌측 열에 숫자 및 텍스트 넣기(rowheader) 및 컬럼 선택 시 sort 안되게 하는 법 (0) | 2020.01.09 |