以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  新增行为什么会触发表的datacolchanging事件?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=153156)

--  作者:yacity
--  发布时间:2020/8/2 11:09:00
--  新增行为什么会触发表的datacolchanging事件?
新增行为什么会触发表的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

--  作者:有点蓝
--  发布时间:2020/8/2 11:34:00
--  
"ruku"是逻辑列,新增行会触发逻辑列的datacolchanged。如果不想触发

datarowAdding事件:
systemready = False
e.DataRow("ruku") = False
systemready = True