你好!用导入数据方式 DataColChanged的自动编号生成重号?
If e.DataCol.Name = "制单日期" Then
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,"yyyyMM")
If e.DataRow("销售单号").StartsWith(bh) = False
Dim max As String
Dim idx As Integer
max = e.DataTable.SQLCompute("Max(销售单号)","制单日期 >= '" & fd & "' And 制单日期 <= '" & ld & "' And [_Identify] <> " & e.DataRow("_Identify"))
If max > "" Then
idx = CInt(max.Substring(9,5)) + 1
Else
idx = 1
End If
If e.DataRow.Isnull("销售单号")
e.DataRow("销售单号") ="DD" & bh & "-" & Format(idx,"00000")
End If
End If
End If