以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  此行已从表中移除并且没有任何数据。BeginEdit() 将允许在此行中创建新数据  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=151074)

--  作者:BG小白
--  发布时间:2020/6/15 2:45:00
--  此行已从表中移除并且没有任何数据。BeginEdit() 将允许在此行中创建新数据

图片点击可在新窗口打开查看此主题相关图片如下:2.png
图片点击可在新窗口打开查看

表属性数据变动代码
Select Case e.DataCol.name
    Case "SPDM","GG1DM","GG2DM"
        Dim dr As DataRow = e.DataRow
        If dr.IsNull("SPDM") = False AndAlso dr.IsNull("GG1DM") = False AndAlso dr.IsNull("GG2DM") = False Then
            If e.DataTable.Compute("Count([_Identify])","SPDM = \'" & dr("SPDM") & "\' And GG1DM = \'" & dr("GG1DM") & "\' And GG2DM =\'" & dr("GG2DM") & "\' ") > 1 Then
                MessageBox.Show("该商品已挂板","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                e.DataRow.Delete
            End If
        End If
End Select

窗口按下压键代码
If e.KeyCode = keys.Enter Then
    Dim title As WinForm.TextBox = e.Form.Controls("title")
    Dim s As String = title.Text
    If s.Length <> 11 AndAlso s.Length <> 12
        MessageBox.Show("货号输入错误","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Return
    End If
    Dim r As DataRow = DataTables("GB").AddNew
    If s.Length = 11 Then
        r("SPDM") = s.SubString(0,7)
        r("GG1DM") = s.SubString(7,2)
        r("GG2DM") = s.SubString(9,2)
        r("MDDM") = User.Name
        r.save()
    Else
        r("SPDM") = s.SubString(0,8)
        r("GG1DM") = s.SubString(8,2)
        r("GG2DM") = s.SubString(10,2)
        r("MDDM") = User.Name
        r.save()
    End If
    e.Cancel = True
    title.SelectAll
End If
应该是红色部分冲突了吧
[此贴子已经被作者于2020/6/15 2:46:12编辑过]

--  作者:有点蓝
--  发布时间:2020/6/15 8:36:00
--  
确实有冲突

        r("SPDM") = s.SubString(0,7)
        r("GG1DM") = s.SubString(7,2)
        r("GG2DM") = s.SubString(9,2)
到这里,触发datacolchanged事件,判断有重复的数据,执行【e.DataRow.Delete】,下面再赋值就出错了,因为这一行已被删除
        r("MDDM") = User.Name
        r.save()

建议如果有重复的,最后录入的比如GG2DM还原为空值即可,用户可以重新录入