datarowadding中如下代码
Dim cmd As New SQLCommand
Dim dt As Date
cmd.C
cmd.CommandText = "Select GetDate()" '从远程数据库获取日期信息
dt = cmd.ExecuteScalar()
e.DataRow("日期") = dt
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 ="SG"& Format(d,"yyMM") '生成申购单号的前6位,2位字符,2位年,2位月.
If e.DataRow("申购单号").StartsWith(bh) = False '如果申购单号的前6位不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(申购单号)","日期 >= #" & fd & "# And 日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该月的最大申购单号
If max > "" Then '如果存在最大申购单号
idx = CInt(max.Substring(6,4)) + 1 '获得最大申购单号的后四位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("申购单号") = bh & Format(idx,"0000")
End If
项目事件中Initialize中添加如下代码
For Each dt As DataTable In DataTables
dt.GlobalHandler.DataRowAdded = True '使能全部表事件中的行增加事件
Next
全局表事件中datarowadded添加如下代码
e.DataTable.Save()
Syscmd.Row.Load()
不同用户在同一个表中添加项的时候,申购单号会重复,这个怎么解决?