新增行为什么会触发表的datacolchanging事件?
做了一个生产记录表,本想录入生产记录后,点入库直接就可入库了,免去再到库存表输入的麻烦,可是下面代码我没有点入库啊,只不过新增了一行,它就执行代码了,这样也不对啊,如何解决?
Select Case e.DataCol.Name
Case "ruku" '复制数据到库存流水
Dim dr As DataRow=e.DataRow
If e.DataRow("ruku") = False Then
Dim nma() As String = {"shengchandate","chanpinid","shuliang"} 'A表数据来源列
Dim nmb() As String = {"rdate","chanpinid","shuliang"} 'B表数据接收列
Dim drs As DataRow = DataTables("kucun").AddNew
For i As Integer = 0 To nma.Length - 1
drs(nmb(i)) = e.DataRow(nma(i))
Next
drs("beizhu") = "制袋入库"
drs("bianhao")="ZD" & dr("_Identify")
Else
Dim Result As DialogResult
Result = MessageBox.Show("您确定要取消该产品入库吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Dim nma() As String = {"shengchandate","chanpinid","shuliang"} 'A表数据来源列
Dim nmb() As String = {"rdate","chanpinid","shuliang"} 'B表数据接收列
Dim drs As DataRow = DataTables("kucun").AddNew
For i As Integer = 0 To nma.Length - 1
drs(nmb(i)) = e.DataRow(nma(i))
Next
drs("beizhu") = "取消制袋入库"
drs("shuliang") = -drs("shuliang")
drs("bianhao")="ZD" & dr("_Identify")
Else
e.Cancel = True
End If
End If
End Select