代码改一下,换成这样就行了。
Select e.DataCol.Name Case = "实际交货日期","客户" If e.DataRow.IsNull("实际交货日期") OrElse e.DataRow.IsNull("客户") Then e.DataRow("送货单号码") = Nothing Else Dim d As Date = e.DataRow("实际交货日期") 'Dim y As Integer = d.Year ' Dim m As Integer = d.Month 'Dim Days As Integer = Date.DaysInMonth(y,m) ' Dim fd As Date = New Date(y,m,1) '获得该月的第一天 ' Dim ld As Date = New Date(y,m,Days) '获得该月的最后一天 Dim bh As String = Format(d,"yyyyMMdd") & "-" '生成该月编号的前缀 Dim idx As String idx = e.DataTable.Compute("Max(送货单号码)","送货单号码 like '" & bh & "*'") If idx > "" Then Dim fdr As DataRow = e.DataTable.Find("客户 = '" & e.DataRow("客户") & "' And [_identify] <> " & e.DataRow("_identify") & " And 实际交货日期 = #" & e.DataRow("实际交货日期") & "#") If fdr Is Nothing Then e.DataRow("送货单号码") = bh & Format(CInt(idx.SubString(9)) + 1, "000") Else e.DataRow("送货单号码") = fdr("送货单号码") End If Else e.DataRow("送货单号码") = bh & "001" End If End If End Select
|