代码如下:DataRowAdded事件
Dim max1 As String = e.DataTable.Compute("Max(流水号)") '取得当前表最大流水号
Dim max2 As String = e.DataTable.Compute("Max(
流水号 )","分组 = '" & e.DataRow("分组") & "'And [_Identify] <> " & e.DataRow("_Identify"))'取得该分组的最大编号
If max2 > "" Then
Vars("
流水号 ") = max2 全局变量等于max2
End If
If max1>"" And max2 = "" Then
Vars("
流水号 ") = max1+1 全局变量等于max1+1
End If
If max1 = "" Then 当前表不存在流水号
Dim ls As String
Dim cmd1 As New SQLCommand
cmd1.CommandText = "Select Max(
流水号 ) From {SFMX} Where RQ = #" & Date.Today & "#"
ls = cmd1.ExecuteScalar 从后台取得当天最大流水号
If ls > "" Then
Vars("lsh") = ls
Else 如果当天不从在流水号
Vars("
流水号 ") = Format( Date.Today ,"yyyyMMdd") & Format("000")
End If
End If
生成的流水号每行加1,没有按分组生成
要求:同一个分组,流水号相同,新增的分组为最大流水号加1
管理员密码:yanzhen8160
收费明细表,流水号
要求:同一个分组,流水号相同,新增的分组为最大流水号加1
事例如下:
分组 流水号
1 20140211001
1 20140211001
1 20140211001
2 20140211002
2 20140211002
4 20140211003
4 20140211003
共3个分组,003
不管分组数是多少,只要出现几个分组,最后三位数按上一分组递增
[此贴子已经被作者于2014-2-11 23:20:04编辑过]