Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共6 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]如何实现复制单据

1楼
qtcks 发表于:2010/8/24 9:31:00
根据进销存模板要求,需要对一些单据进行复制新增。选中需要复制的有父表记录,还需复制关联表的内容。代码该如何写?
2楼
blackzhu 发表于:2010/8/24 9:49:00

Select Case e.DataCol.Name
 Case "客户","产品"
    Dim kh As String = e.DataRow("客户")
    Dim cp As String = e.DataRow("产品")
    Dim tj = "客户 = '" & kh & "' And 产品 = '" & cp & "' "
    If kh >"" Andalso cp> "" Then
        If DataTables("表B").Find(tj) Is Nothing Then
            Dim dr As DataRow = DataTables("表B").AddNew()
            dr("客户") = kh
            dr("产品") = cp
        End If
    End If
End Select

 

 

   这个代码是在A表输入客户,产品的同时,在B表新增行输入客户,产品.

3楼
狐狸爸爸 发表于:2010/8/24 9:54:00

假定表A是父表,表B是子表,代码大概如下,请自行理解调试:

 

Dim Childs As List(of DataRow) = Tables("表A").Current.DataRow.GetChildRows("表B")
Dim pr As Row = Tables("表A").AddNew
pr("关联列") = "aaa" '如果通过_Identify列关联,则不需要此行
For Each cr As DataRow In Childs
    Dim nr As Row = Tables("表A.表B").AddNew
    For Each cl As Col In Tables("表B").Cols
      If cl.Name <> "关联列" Then
        nr(cl.name) = cr(cl.Name)
      End If
   Next
Next

4楼
blackzhu 发表于:2010/8/24 10:00:00

Dim r1 As Row = Tables("父表").Current
Dim r2 As Row=  r1.Clone
For Each r3 As DataRow = r1.DataRow.GetChildRows("子表")
    Dim  r4 As Row = Tables("子表").AddNew 
    For c As Col In Tables("子表").Cols
        r4(c.Name) = r3(c.Name)
    Next
    r4("子表关联列") = r2("父表关联列")
Next

 

  试试这个,我以前保存下来的.

5楼
qtcks 发表于:2010/8/24 18:02:00

谢谢大家的帮助,晚上搞定这个。再次谢谢大家。

6楼
king 发表于:2010/10/26 11:08:00

希望给个示例看看,谢谢各位前辈。

共6 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .01953 s, 2 queries.