OK,在原来的思路上弄好了,主要是统计方式不同,楼主看看是否合适。
代码如下
If e.Col.index =1 And e.Row.IsNull(e.Col.Name) = False Then
e.Style = "绿色"
End If
If e.Col.index =2 And e.Row.IsNull(e.Col.Name) = False Then
e.Style = "黄色"
End If
If e.Col.index =3 And e.Row.IsNull(e.Col.Name) = False Then
e.Style = "蓝色"
End If
If e.Col.index > 3 Then
If e.Row.IsNull(e.Col.Name) = False '且该列已经输入内容
Dim drs As List(Of DataRow) = e.Table.DataTable.Select("料号 = '" & e.Row("料号") & "'", "_Sortkey")
Dim syhj As Integer
Dim kchj(2) As Integer
For Each dr As DataRow In drs
kchj(0) = kchj(0) + dr("A库_绿色")
kchj(1) = kchj(1) + dr("B库_黄色")
kchj(2) = kchj(2) + dr("C库_蓝色")
For i As Integer = 4 To e.Col.Index
If i <> e.Col.Index OrElse dr("_Sortkey") <= e.Row("_Sortkey") Then
syhj = syhj + dr(e.Table.Cols(i).Name)
End If
Next
Next
If syhj <= kchj(0) Then
e.Style = "绿色"
Else
If syhj <= kchj(0) + kchj(1) Then
e.Style = "黄色"
Else
If syhj <= kchj(0) + kchj(1) + kchj(2) Then
e.Style = "蓝色"
End If
End If
End If
End If
End If