问题如图: 1、审核之后库存减少,但是审核还是false状态,再次点击就报错,索引超出数组界限的错误
部分代码:
s = "select * fr om 入库条码明细 where 条码 = '" & tm & "'"
cmd.CommandText = s
dt2 = cmd.ExecuteReader
Dim dr As DataRow = dt2.DataRows(0)
s = "select * fr om 出库条码明细 where 条码 = '" & tm & "'"
cmd.CommandText = s
dt = cmd.ExecuteReader
s = "select * fr om 库存表 where 条码 = '" & tm & "'"
cmd.CommandText = s
dt1 = cmd.ExecuteReader
rkrq = dt1.DataRows(0)("入库日期")
If ckdd = "" OrElse cpx = "" OrElse cbs = "" OrElse kclx = "" OrElse cksx = "" OrElse cghth = "" OrElse tm = "" OrElse bom = "" OrElse sl <= 0 OrElse ckrq.year <= 2015 Then
e.Cancel = True '取消变动
StatusBar.Message1= "关键信息不全,请核查!"
End If
If e.NewValue = True And e.DataRow("审核") = False Then '审核出库
If dt1.DataRows.Count > 0 Then '库存中有此条码的数据
cmd.CommandText = "delete 库存表 where 仓库地点 = '" & ckdd & "' and 产品线 = '" & cpx & "'and 库存类型 = '" & kclx & "' and 仓库属性 = '" & cksx & "' and 条码 = '" & tm & "' and BOM编码 = '" & bom & "' and 产品型号 = '" & cpxh & "' and 采购合同号 = '" & cghth & "' and 入库日期 = '" & rkrq & "'"
cmd.ExecuteReader
StatusBar.Message1 = tm & "出库审核成功!库存减少"
MessageBox.Show("出库审核成功!库存减少!")
DataTables("出库录入_Table1").Save
Else
MessageBox.Show("库存1中无此条码,请重新输入")
End If
End If '
If e.NewValue = False And e.DataRow("审核") = True Then '反审入库
' If r("单据类型") = "出库" Then
If dt1.DataRows.Count <= 0 Then '库存中没有此条码的数据
If dt.DataRows.Count > 0 Then '并且出库条码明细中有数据,才能插入数据到库存中
cmd.CommandText = "insert into 库存表(id,仓库地点,产品线,库存类型,仓库属性,条码,BOM编码,产品型号,数量,采购合同号,入库日期) values (" & dr("rkid") & ",'" & ckdd & "','" & cpx & "','" & kclx & "','" & cksx & "','" & tm & "','" & bom & "','" & cpxh & "'," & sl & ",'" & cghth & "','" & rkrq & "')"
cmd.ExecuteReader
StatusBar.Message1 = tm & "反审成功!库存增加"
MessageBox.Show("反审成功,库存增加!")
DataTables("出库录入_Table1").Save
Else '库存中没有这条码并且明细中也没有
MessageBox.Show("库存2,条码都没有此条码,请核对")
End If
End If
End If
End If
此主题相关图片如下:1.png
此主题相关图片如下:2.png
此主题相关图片如下:3.png