我测试一下是可以,是不是我的代码在修改日期时,不能自动修改单号,帮我看看:
If e.DataCol.Name = "开单日期" Then
If e.DataRow.IsNull("开单日期") Then
e.DataRow("系统单号")= Nothing
Else
Dim cmd1 As New SQLCommand
Dim dt1 As DataTable
Dim dr As DataRow
cmd1.C
cmd1.CommandText = "SELECT * From {单号定义}"
dt1 = cmd1.ExecuteReader()
dr = dt1.find("表名='" & CurrentTable.Name & "'")
If dr IsNot Nothing Then
Dim s As String =dr("单号定义") & Format(e.DataRow("开单日期"),"yyMMdd")
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.C
cmd.CommandText = "SELECT * From {销售订单}"
dt = cmd.ExecuteReader()
If e.NewValue <> Nothing And e.DataRow("系统单号") = Nothing Then
Dim i1 As String = dt.Compute("Max(系统单号)","开单日期 ='" & e.DataRow("开单日期") & "'")
Dim n As Integer
If s = left(i1,8) Then
n=CInt(right(i1,4))
Else
n=0
End If
s= s & format(n+1,"0000")
e.DataRow("系统单号")=s
End If
End If
End If
End If