Dim max As
String = DataTables("订单表").Compute("Max(订单编号)","订单编号
Like '" & Date.Today.Year & "*'")
If max > ""
Then
max
= max.SubString(5,3)
max = Date.Today.Year & "-"
& Format(cint(max) + 1,"000")
Else
max = Date.Today.Year & "-001"
End If
For Each dr As DataRow In DataTables("产品表").DataRows
If dr("选择") = True Then
dr("订单编号")
= max '赋值给产品表订单编号dr
Dim dr2 As DataRow = DataTables("订单表").AddNew()
dr2("订单编号")
= max '赋值给订单表
dr2("商品名称")
= dr("商品名称")
End If
Next
我根据上面的程序,写的下面的,内部表的时候编号根据已有的加1,可转外部sql后,就不能加1了,编号始终是0001
Dim max As String = DataTables("资金申请明细").Compute("Max(资金申请单编号)","资金申请单编号 Like '" & Date.Today.Year & "*'")
If max
> "" Then
max = max.SubString(6,4)
max = "ZJ"
& Date.Today.Year & Format(cint(max) + 1,"0000")
Else
max ="ZJ"
& Date.Today.Year & "0001"
End If
For Each dr As DataRow In DataTables("计划明细").DataRows
If dr("选择") = True Then
dr("资金申请单编号")
= max '赋值给产品表订单编号dr
Dim dr2 As DataRow = DataTables("资金申请明细").AddNew()
dr2("资金申请单编号")
= max '赋值给订单表
dr2("唯一编号") = dr("唯一编号")
dr2("所属计划") = dr("所属计划")
dr2("序号") = dr("序号")
dr2("原序号") = dr("原序号")
dr2("商品名称") = dr("商品名称")
dr2("规格型号") = dr("规格型号")
dr2("单位") = dr("单位")
dr2("数量") = dr("数量")
End If
Next
怎么回事啊 ???