1.click代码如下,红色代码用了向库存明细表增加数据---没有问题。问题是本以为向库存明细表写数据会触发datacolchange代码。可是发现没执行。原因我想应该是库存明细表的SN变化了,但是那个时间其他列的值为空,就没法向下执行datacolchange代码了。咋样能达到我想要的效果?
If (MessageBox.Show("确定提交入库?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes ) Then
DataTables("非插卡入库扫描").save
Dim drs As List (of DataRow) = DataTables("U8物料数量汇总表").Select("入库单号 = '" & Vars("fckrkdhrk") & "'")
For Each dr As DataRow In drs
dr("状态") = "入库完成"
Next
Dim drrs As List (of DataRow) = DataTables("U8物料编码入库单收货统计").Select("入库单号 = '" & Vars("fckrkdhrk") & "'")
For Each drr As DataRow In drrs
drr("状态") = "入库完成"
Next
Dim nms() As String = {"生产订单号码","工单行号","物料编码","物料名称","类别说明","产品批次","订单号","订单行号","客户","备注","软件版本","SN","状态","数量","MAC","HW","入库单号","库位类别","库位编码","收货完成时间","入库完成时间","体态"}
Dim lt As List(of DataRow) = DataTables("非插卡入库扫描").Select("入库单号 = '" & Vars("fckrkdhrk") & "'")
For Each r As DataRow In lt
If r("状态") = "入库完成" Then
Dim rr As DataRow = DataTables("库存明细表").addnew
For Each nm As String In nms
rr(nm) = r(nm)
Next
End If
Next
Else
e.Cancel = True
End If`
2.库存明细表datacolchange代码如下。
If e.DataCol.name = "SN" Then
If e.DataRow("体态") = "通用态" Then----没有执行
Dim dr1 As DataRow = DataTables("库存通用态表").Find("物料编码 = '" & e.DataRow("物料编码") & "'")
If dr1 IsNot Nothing Then
dr1("库存数量") = dr1("库存数量") + 1
dr1("可用数量") = dr1("可用数量") + 1
Else
Dim dr2 As DataRow = DataTables("库存通用态表").AddNew
dr2("物料编码") = e.DataRow("物料编码")
dr2("物料名称") = e.DataRow("物料名称")
dr2("库存数量") = 1
dr2("可用数量") = 1
End If
ElseIf e.DataRow("体态") = "特殊态" Then
Dim dr3 As DataRow = DataTables("库存特殊态表").Find("物料编码 = '" & e.DataRow("物料编码") & "' and 订单号 = '" & e.DataRow("订单号") & "' and 订单行号 = '" & e.DataRow("订单行号") & "'")
If dr3 IsNot Nothing Then
dr3("库存数量") = dr3("库存数量") + 1
dr3("可用数量") = dr3("可用数量") + 1
Else
Dim dr4 As DataRow = DataTables("库存特殊态表").AddNew
dr4("物料编码") = e.DataRow("物料编码")
dr4("物料名称") = e.DataRow("物料名称")
dr4("物料名称") = e.DataRow("物料名称")
dr4("订单号") = e.DataRow("订单号")
dr4("订单行号") = e.DataRow("订单行号")
dr4("客户") = e.DataRow("客户")
dr4("库存数量") = 1
dr4("可用数量") = 1
End If
End If
End If
'