我写的代码是分别根据章节号的前两位和四位进行预警,按理说,四位预警的情况下,两位章节一定会发生预警才对,麻烦红袍哥帮忙看下,我这公司内网,没法上传附件,传代码了啊。
系统章节 = 章节号的前两位
章节号共四位
'''-----------------------------------两位章节预警-------------------------------------------------------------''
If e.DataCol.Name = "日期" Then
Dim drs As List(of DataRow)
Dim dv As Date = e.DataRow("日期")
Dim n As Integer = 0
drs = DataTables("故障报告2").Select("飞机号 = '" & e.DataRow("飞机号") & "' and 系统章节 = '" & e.DataRow("系统章节") & "'", "日期") '注意要根据日期排序
For Each dr2 As DataRow In drs
'dr2("预警") = Nothing
If dr2("日期") >= dv.AddDays(-30) And dr2("日期") < dv Then
n = n + 1
If n >=2 Then
e.DataRow("预警") = "重复性故障"
End If
Else
Exit For
End If
Next
End If
'''-----------------------------------四位章节预警-------------------------------------------------------------''
If e.DataCol.Name = "日期" Then
Dim drs As List(of DataRow)
Dim dv As Date = e.DataRow("日期")
Dim n As Integer = 0
drs = DataTables("故障报告2").Select("飞机号 = '" & e.DataRow("飞机号") & "' and 章节号 = '" & e.DataRow("章节号") & "'", "日期") '注意要根据日期排序
For Each dr2 As DataRow In drs
If dr2("日期") >= dv.AddDays(-30) And dr2("日期") < dv Then
n = n + 1
If n >=2 Then
e.DataRow("四位章节预警") = "重复性故障"
End If
Else
Exit For
End If
Next
End If
[此贴子已经被作者于2016/2/18 15:06:41编辑过]