以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  新增项目表记录时,整体复制表中内容到项目表子表工料单价表中  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=105289)

--  作者:chengjingliang
--  发布时间:2017/8/16 12:12:00
--  新增项目表记录时,整体复制表中内容到项目表子表工料单价表中
新增项目表记录时,整体复制表中内容到项目表子表工料单价表中,怎么做?我按照之前有点甜老师指点的方法,做了另一个复制项目好长时间做不好,不知什么原因
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:成本测算170815.rar


--  作者:有点甜
--  发布时间:2017/8/16 12:32:00
--  

DataRowAdded事件,写代码,查考着改。

 

e.DataRow.save
Dim Cols1() As String = {"工料一类","工料单位","工料单价"}
Dim Cols2() As String = {"工料一类","工料单位","工料单价"}
For Each dr1 As DataRow In DataTables("单价列表").Select("")
    Dim dr2 As DataRow = DataTables("工料单价").find("工料名称= \'" & dr1("工料名称") & "\' and _Identify = " & e.DataRow("_Identify"))
    If dr2 Is Nothing Then dr2 = DataTables("工料单价").AddNew()
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
Next


--  作者:chengjingliang
--  发布时间:2017/8/16 13:31:00
--  
弹出调用目标发生异常
图片点击可在新窗口打开查看此主题相关图片如下:b(r(l8x5$jg%kkeqb@y6m.png
图片点击可在新窗口打开查看

工程项目表子表工料单价还是没有数据,没有把单价列表复制过来
图片点击可在新窗口打开查看此主题相关图片如下:~o9pw9%)et@~3_`uri57ic.png
图片点击可在新窗口打开查看

不知哪里出错了?
\'\'整体复制单价列表至工料单价表
e.DataRow.save
    Dim Cols1() As String ={"单价列表id","工料一类","工料二类","工料名称","工料单位","工料单价","备注"}
    Dim Cols2() As String ={"单价列表id","工料一类","工料二类","工料名称","工料单位","工料单价","备注"}
    For Each dr1 As DataRow In DataTables("单价列表").Select("")
 Dim dr2 As DataRow = DataTables("工料单价").find("工料名称 = \'" & dr1("工料名称") & "\' and 单价列表id = \'" & dr1("单价列表id") & "\' and _Identify = " & e.DataRow("_Identify"))

    If dr2 Is Nothing Then dr2 = DataTables("工料单价").AddNew()
        For i As Integer = 0 To Cols1.Length -1
            dr2(Cols2(i)) = dr1(Cols1(i))
        Next
    \'    dr2("项目id") = e.DataRow("_Identify")
    Next
\'End If

--  作者:有点甜
--  发布时间:2017/8/16 14:28:00
--  
e.DataRow.save
systemready = false
Dim Cols1() As String ={"单价列表id","工料一类","工料二类","工料名称","工料单位","工料单价","备注"}
Dim Cols2() As String ={"单价列表id","工料一类","工料二类","工料名称","工料单位","工料单价","备注"}
For Each dr1 As DataRow In DataTables("单价列表").Select("")
    Dim dr2 As DataRow = DataTables("工料单价").find("工料名称 = \'" & dr1("工料名称") & "\' and 单价列表id = \'" & dr1("单价列表id") & "\' and _Identify = " & e.DataRow("_Identify"))
    If dr2 Is Nothing Then dr2 = DataTables("工料单价").AddNew()
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
Next
systemready = true

--  作者:chengjingliang
--  发布时间:2017/8/16 15:11:00
--  
还是复制不了,在工程项目表内新增记录后,还是不能把单价列表复制到工料单价表内
[此贴子已经被作者于2017/8/16 15:12:25编辑过]

--  作者:有点甜
--  发布时间:2017/8/16 15:17:00
--  
e.DataRow.save
systemready = False
Dim Cols1() As String ={"单价列表id","工料一类","工料二类","工料名称","工料单位","工料单价","备注"}
Dim Cols2() As String ={"单价列表id","工料一类","工料二类","工料名称","工料单位","工料单价","备注"}
For Each dr1 As DataRow In DataTables("单价列表").Select("")
    Dim dr2 As DataRow = DataTables("工料单价").find("工料名称 = \'" & dr1("工料名称") & "\' and 单价列表id = \'" & dr1("单价列表id") & "\' and _Identify = " & e.DataRow("_Identify"))
    If dr2 Is Nothing Then dr2 = DataTables("工料单价").AddNew()
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
    dr2("项目id") = e.DataRow("_Identify")
Next
systemready = True