都不变,改红色得,其它的,你换一下列名
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 bh As String = "SM-" & e.DataRow("厂家编号") & "" & Format(d,"yy-MM") & "" '生成编号的前缀
Dim max As String
Dim idx As Integer
Dim flt As String
flt = "采购单号 like '" & bh & "%' And [_Identify] <> " & e.DataRow("_Identify")
max = e.DataTable.Compute("Max(采购单号)",flt) '取得该月的相同厂家编号的最大采购单号
If max > "" Then '如果存在最大采购单号
idx = CInt(max.Substring(bh.Length,2)) + 1 '获得最大采购单号的后四位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("采购单号") = bh & Format(idx,"00")
End If
End Select