If DataTables("U8物料数量汇总表").DataRows.Count >0 Then
Dim rklb As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim kwlb As WinForm.ComboBox = e.Form.Controls("ComboBox3")
Dim rkdh As WinForm.TextBox = e.Form.Controls("TextBox14")
If rklb.text <> "请选择入库类别" And kwlb.text <> "请选择库位类别" Then
Dim d As Date = Date.Today
Dim y As Integer = d.Year
Dim m As Integer = d.Month
Dim r As Integer = d.day
Dim bh As String = "PKRK" & rklb.text & kwlb.text & Format(d,"yyyyMMdd") '生成编号的前6位,4位年,2位月.
Dim max As String
Dim idx As Integer
max = DataTables("U8物料数量汇总表").SQLCompute("Max(入库单号)","入库单号 like '" & bh & "%'")
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(bh.length)) + 1 '获得最大编号的后五位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
rkdh.text = bh & Format(idx,"0000")
For Each dr As DataRow In DataTables("U8物料数量汇总表").DataRows
If dr.IsNull("入库单号")= True Then
dr("入库单号") = rkdh.text ----希望循环时每行的每个入库单号都是上一行的入库单号加1,而不是固定的。
dr("库位类别") = kwlb.text
dr("实扫到数量") = 0
dr("生成入库单时间") = Date.Now
dr("状态") = "生成入库单"
dr.Save
End If
Next
Else
Dim str As String
If rklb.text = "请选择入库类别" Then
str & = "入库类别,"
End If
If kwlb.text = "请选择库位类别" Then
str & = "库位类别"
End If
If str > "" Then
MessageBox.show("请选择" & str.Trim(","),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error)
End If
End If
Else
MessageBox.show("请先导入U8物料编码收货单","U8物料编码收货单数据为空",MessageBoxButtons.OK,MessageBoxIcon.Error)
End If