Select e.DataCol.Name
Case "dnd_date", "dnd_cust_zjm"
If e.DataRow.IsNull("dnd_date") OrElse e.DataRow.IsNull("dnd_cust_zjm") Then
e.DataRow("dnd_dn") = Nothing
Else
Dim d As Date = e.DataRow("dnd_date")
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 = e.DataRow("dnd_cust_zjm") & "-" & Format(d, "yyyyMMdd") & "-" '生成编号的前缀
If e.DataRow("dnd_dn").StartsWith(bh) = False Then'如果单据编号前缀不符
Dim max As String
Dim idx As Integer
Dim flt As String
flt = "dnd_cust_zjm = '" & e.DataRow("dnd_cust_zjm") & "' And dnd_date >= #" & fd & "# And dnd_date <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")
max = e.DataTable.Compute("Max(dnd_dn)", flt) '取得该月的相同工程代码的最大单据编号
If max > "" Then '如果存在最大单据编号
idx = CInt(max.Substring(12, 4)) + 1 '获得最大单据编号的后四位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("dnd_dn") = bh & Format(idx, "0000")
End If
End If
End Select
此主题相关图片如下:问题图.png