回复大红袍能否抽时间看看附件,验证一下到底是哪里出问题了?
我增加保存行且都改为SQL查询,可是还是老效果。拜托了。
Dim d As Date = Date.Today
Dim y As Integer = d.Year
Dim m As Integer = d.Month
Dim bh As String = Format(d,"yyyyMM") '生成编号的前6位,4位年,2位月.
Dim max As String
Dim idx As Integer
max = DataTables("配货单").SQLCompute("Max(入库单号)","入库单号 like '*" & bh & "*'")
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(bh.length + 2, 3)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
For Each r As DataRow In DataTables("扫描配货明细").DataRows
Dim drs As List(of DataRow) = DataTables("配货单").SQLSelect("SN = '" & r("SN") & "'")
If drs.count >0 Then
For Each dr As DataRow In drs
dr("入库单号") = "RK" & bh & Format(idx,"000")
dr("预入库单号") = "RK" & bh & Format(idx,"000")
dr.save
Next
End If
Next
Dim rkdh As WinForm.TextBox = e.Form.Controls("TextBox1")
rkdh.text = "RK" & bh & Format(idx,"000")
DataTables("扫描配货明细统计").DataRows.Clear
For Each ndr As DataRow In DataTables("扫描配货明细").DataRows
Dim ddr3 As DataRow = DataTables("扫描配货明细统计").SQLFind("工单号 = '" & ndr("工单号") & "' and 行号 = '" & ndr("行号") & "' and 入库单号 = '" & ndr("入库单号") & "'")
If ddr3 IsNot Nothing Then
ddr3("预入库数量") = DataTables("扫描配货明细统计").SQLCompute("count(工单号)", "工单号 = '" & ndr("工单号") & "' and 行号 = '" & ndr("行号") & "' and 入库单号 = '" & ndr("入库单号") & "' ")
ddr3.save
Else
Dim ddr4 As DataRow = DataTables("扫描配货明细统计").AddNew()
ddr4("工单号") = ndr("工单号")
ddr4("行号") = ndr("行号")
ddr4("预入库数量") = 1
ddr4("入库单号") = rkdh.text
ddr4("产品态") = ndr("产品态")
ddr4("产品名称") = ndr("产品名称")
ddr4("物料编码") = ndr("物料编码")
ddr4("库位类别") = ndr("库位类别")
ddr4.save
End If
Dim ddr2 As DataRow = DataTables("工单明细").SQLFind("工单号 = '" & ndr("工单号") & "' and 行号 = '" & ndr("行号") & "' and 入库单号 = '" & ndr("入库单号") & "' ")
If ddr2 IsNot Nothing Then
ddr2("预入库数量") = DataTables("工单明细").SQLCompute("count(工单号)", "工单号 = '" & ndr("工单号") & "' and 行号 = '" & ndr("行号") & "' and 入库单号 = '" & ndr("入库单号") & "' ")
ddr2("生产结束扫描日期") = Date.now
ddr2.Save
Else
Dim ddr1 As DataRow = DataTables("工单明细").AddNew()
ddr1("工单号") = ndr("工单号")
ddr1("行号") = ndr("行号")
ddr1("预入库数量") = 1
ddr1("生产完成日期") = ndr("生产完成日期")
ddr1("预入库日期") = ndr("预计入库日期")
ddr1("入库单号") = rkdh.text
ddr1("产品态") = ndr("产品态")
ddr1("产品名称") = ndr("产品名称")
ddr1("物料编码") = ndr("物料编码")
ddr1("库位类别") = ndr("库位类别")
ddr1("生产结束扫描日期") = Date.now
ddr1.Save
End If
Next
DataTables("工单明细").Save
For Each ddr6 As DataRow In DataTables("工单明细").DataRows
Dim ddr5 As DataRow = DataTables("预入库单").SQLFind ("预入库单号 = '" & ddr6("入库单号") & "'")
If ddr5 IsNot Nothing Then
Dim sum As Integer
sum = DataTables("工单明细").SQLCompute("sum(预入库数量)","入库单号 = '" & ddr5("预入库单号") & "' ")
ddr5("总数量") = sum
ddr5.save
Else
Dim dr As DataRow = DataTables("预入库单").AddNew()
dr("预入库单号") = ddr6("入库单号")
dr("总数量") = DataTables("工单明细").SQLCompute("sum(预入库数量)","入库单号 = '" & dr("预入库单号") & "' ")
dr.save
End If
Next
Dim shhs As WinForm.Button = Forms("库存管理界面").Controls("收货核实")
Dim sum1 As Integer
sum1 = DataTables("预入库单").SQLCompute("count(预入库单号)","标志 = 'false'")
shhs.text = "收货核实(" & sum1 & ")"
Dim sum2 As Integer