以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]获取新增行内容  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=145469)

--  作者:紫色幽魂
--  发布时间:2020/1/21 12:18:00
--  [求助]获取新增行内容
我在表中新增一行填入下面的数据后会在自动生成一个编号,我要获取新增的这行的编号用最下面的代码为什么获取不到
            Dim zdr1 As DataRow = DataTables("无损_单项工程").AddNew
            zdr1("工程编号") = jsxmbh.Value
            zdr1("单项工程") = dxgc.Value
            zdr1.Save

            \'获取新增单项工程行编号
            Dim dr4 As DataRow = DataTables("无损_单项工程").Find("工程编号 = \'"& jsxmbh.Value &"\' and 单项工程 = \'"& str1 &"\'")

--  作者:有点蓝
--  发布时间:2020/1/21 13:46:00
--  
什么2段代码分别在什么事件使用的?完整代码发上来
--  作者:紫色幽魂
--  发布时间:2020/1/21 13:56:00
--  回复:(有点蓝)什么2段代码分别在什么事件使用的?完...
标色部分获取不到刚新增加的行

Dim jsxmbh As WinForm.TextBox = e.Form.Controls("TextBox1") \'工程编号
Dim dxgcbh As WinForm.TextBox = e.Form.Controls("TextBox2") \'单项工程编号
Dim jsxm As WinForm.DropDownBox = e.Form.Controls("DropBox1") \'建设项目
Dim dxgc As WinForm.DropDownBox = e.Form.Controls("DropBox2") \'单项工程
Dim jsxmdm As WinForm.TextBox = e.Form.Controls("TextBox3") \'建设项目代码
Dim jclb As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim jccs As WinForm.CheckedComboBox = e.Form.Controls("CheckedComboBox1") \'检测参数
Dim zgdw As WinForm.NumericComboBox = e.Form.Controls("NumericComboBox1") \'暂估吨位
Dim xmzt As WinForm.ComboBox = e.Form.Controls("ComboBox3") \'项目状态
Dim xmgldw As WinForm.TextBox = e.Form.Controls("TextBox4")
Dim lxfs As WinForm.TextBox = e.Form.Controls("TextBox5")
Dim jcxmz As WinForm.ComboBox = e.Form.Controls("ComboBox4")

Dim str1 As String = dxgc.Value
str1 = str1.Replace("*","[*]")
str1 = str1.Replace("%","[%]")
str1 = str1.Replace("#","[#]")

\'条件判断
If jsxm.Value Is Nothing
    MessageBox.Show("建设项目未输入","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
    Return
Else
    If jsxmbh.Value Is Nothing OrElse dxgcbh.Value Is Nothing \'编号为空
        If jsxmbh.Value Is Nothing \'新项目
            \'新增工程表行
            Dim zdr1 As DataRow = DataTables("无损_工程主表").AddNew
            zdr1("工程名称全称") = jsxm.Value
            \'获取新增行编号
            Dim dr1 As DataRow = DataTables("无损_工程主表").Find("工程名称全称 = \'"& jsxm.Value &"\'")
            If dr1 IsNot Nothing
                jsxmbh.Value = dr1("工程编号")
            End If
        End If
        If dxgcbh.Value Is Nothing
            \'获取新增单项工程行
            Dim zdr1 As DataRow = DataTables("无损_单项工程").AddNew
            zdr1("工程编号") = jsxmbh.Value
            zdr1("单项工程") = dxgc.Value
            zdr1.Save
            
            \'获取新增单项工程行编号
            Dim dr4 As DataRow = DataTables("无损_单项工程").Find("工程编号 = \'"& jsxmbh.Value &"\' and 单项工程 = \'"& str1 &"\'")
            If dr4 IsNot Nothing
                dxgcbh.Value = dr4("单项工程编号")
                dr4.Save
            End If
        End If
        If jsxmbh.Value Is Nothing OrElse dxgcbh.Value Is Nothing
            MessageBox.Show("编号为空,请联系管理员","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
            Return
        End If
    End If
    
    If jsxm.Value IsNot Nothing AndAlso jsxmbh.Value IsNot Nothing AndAlso dxgcbh.Value IsNot Nothing
        Dim dr3 As DataRow = DataTables("无损_工程产值表_2020").AddNew
        Dim dr4 As DataRow = DataTables("无损_单项工程").Find("工程编号 = \'"& jsxmbh.Value &"\' and 单项工程 = \'"& str1 &"\'")
        dr3("编号_工程名称") = jsxmbh.Value
        dr3("编号_单项工程") = dxgcbh.Value
        dr3("建设项目代码") = jsxmdm.Value
        dr3("检测类别") = jclb.Value
        dr3("检测参数") = jccs.Value
        dr3("暂估吨位") = zgdw.Value
        dr3("项目状态") = xmzt.Value
        dr3("检测项目组") = jcxmz.Value
        dr3.Save
        dr4("项目部_单位名称") = xmgldw.Value
        dr4("项目部_合并联系人和电话") = lxfs.Value
        dr4.Save
        e.Form.Close
    Else
        MessageBox.Show("请重新执行确认操作","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Return
    End If
End If

--  作者:有点蓝
--  发布时间:2020/1/21 14:03:00
--  
Dim zdr1 As DataRow = DataTables("无损_单项工程").AddNew

改为

Dim zdr1 As Row = Tables("无损_单项工程").AddNew