编号到460以后就不能自动编号了,不知是什么位置出了问题,请指导,谢谢!!!
If e.DataCol.Name = "接单时间" Then
If 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,"yyyyMM")
If e.DataRow("订单号").StartsWith(bh) = False
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(订单号)","接单时间 >= #" & fd & "# And 接单时间 <= #" & ld & "#")
If max > "" Then
idx = CInt(max.Substring(7,4)) + 1
Else
idx = 1
End If
e.DataRow("订单号") = bh & "-" & Format(idx,"0000")
End If
End If
End If
Select e.DataCol.Name
Case "接单时间","部门"
If 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 = e.DataRow("部门") & "-" & Format(d,"yyyyMM") & "-"
If e.DataRow("管制号").StartsWith(bh) = False
Dim max As String
Dim idx As Integer
Dim flt As String
flt = "部门 = '"& e.DataRow("部门") & "' And 接单时间 >= #" & fd & "# And 接单时间 <= #" & ld & "#"
max = e.DataTable.Compute("Max(管制号)",flt)
If max > "" Then
idx = CInt(max.Substring(9,4)) + 1
Else
idx = 1
End If
e.DataRow("管制号") = bh & Format(idx,"0000")
End If
End If
End Select
If e.DataCol.Name = "交货日期" Then
If e.DataRow.IsNull("交货日期") Then
e.DataRow("延期") = Nothing
Else
e.DataRow("延期") = (Date.Today.Subtract(e.DataRow("交货日期")).Days)
End If
End If
Select Case e.DataCol.Name
Case "管制号"
If e.DataRow.IsNull("管制号") = False Then
If e.DataRow.GetChildRows("订单明细").Count = 0 Then
Dim dr As DataRow = DataTables("订单明细").AddNew(1)
dr("管制号") = e.DataRow("管制号")
dr("交货日期") = e.DataRow("交货日期")
dr("客户") = e.DataRow("客户")
End If
End If
End Select
Select Case e.DataCol.Name
Case "客户"
If e.DataRow.IsNull("客户") = False Then
If e.DataRow.GetChildRows("客户").Count = 0 Then
Dim dr As DataRow = DataTables("客户").AddNew()
dr("客户") = e.DataRow("客户")
End If
End If
End Select

此主题相关图片如下:截图1354268053.png