以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  如何实现关联主从表的数据引到关联主从表?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=143559)

--  作者:lgz518
--  发布时间:2019/11/28 13:36:00
--  如何实现关联主从表的数据引到关联主从表?
如何实现关联主从表的数据引到关联主从表?
比如:
     销售订单(销售主表和销售明细关联构成),销售退货单(销售退货主表和销售退货明细关联构成)。
     1.在销售订单列表的销售主表,选中已审核的销售订单,导入到销售退货单。
     2.批量操作,将销售订单(销售主表和销售明细关联构成)已审核,全部导入到销售退货单(销售退货主表和销售退货明细关联构成)

  请老师,指导,谢谢!

--  作者:hbfnmxb
--  发布时间:2019/11/28 14:04:00
--  


--  作者:有点蓝
--  发布时间:2019/11/28 14:33:00
--  
参考:http://www.foxtable.com/webhelp/topics/1533.htm
--  作者:lgz518
--  发布时间:2019/11/28 15:39:00
--  
用蓝老师,试一下,有问题:
1.全部导入,主表可以导入,明细表只导入关联字段,没关联字段没导入:
Dim Cols1() As String = {"销售单号","销售日期","客户名称"}
Dim Cols2() As String = {"销售单号","销售日期","客户名称"}
For Each dr1 As DataRow In DataTables("销售主表").Select("[审核] = 0 ")
    Dim dr2 As DataRow = DataTables("销售退货主表").AddNew()
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
Next
Dim Cols3() As String = {"销售单号","销售日期","客户名称","产品编号","品名","单位","售价","数量"}
Dim Cols4() As String = {"销售单号","销售日期","客户名称","产品编号","品名","单位","售价","数量"}
For Each dr3 As DataRow In DataTables("销售单").Select("[审核状态] = 0 ")
    Dim dr4 As DataRow = DataTables("销售退货明细").AddNew()
    For i As Integer = 0 To Cols1.Length -1
        dr4(Cols4(i)) = dr3(Cols3(i))
    Next
Next



2.由主表单号,日期是系统录入,所以主表只导入客户,明细全部导入,结果,只有主表数据导入,明细都没有数据,就是关联字段也没有。

Dim Cols1() As String = {"客户名称"}
Dim Cols2() As String = {"客户名称"}
For Each dr1 As DataRow In DataTables("销售主表").Select("[审核] = 0 ")
    Dim dr2 As DataRow = DataTables("销售退货主表").AddNew()
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
Next
Dim Cols3() As String = {"销售单号","销售日期","客户名称","产品编号","品名","单位","售价","数量"}
Dim Cols4() As String = {"销售单号","销售日期","客户名称","产品编号","品名","单位","售价","数量"}
For Each dr3 As DataRow In DataTables("销售单").Select("[审核状态] = 0 ")
    Dim dr4 As DataRow = DataTables("销售退货明细").AddNew()
    For i As Integer = 0 To Cols1.Length -1
        dr4(Cols4(i)) = dr3(Cols3(i))
    Next
Next

--  作者:有点蓝
--  发布时间:2019/11/28 16:04:00
--  
不知道您的表结构和数据到底是怎么样的。上传实例看看
--  作者:lgz518
--  发布时间:2019/11/28 16:18:00
--  
这个实例
--  作者:lgz518
--  发布时间:2019/11/28 16:18:00
--  

这个实例
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1.table


--  作者:有点蓝
--  发布时间:2019/11/28 17:07:00
--  
Dim Cols3() As String = {"销售单号","销售日期","客户名称","产品编号","品名","单位","售价","数量"}
Dim Cols4() As String = {"销售单号","销售日期","客户名称","产品编号","品名","单位","售价","数量"}
For Each dr3 As DataRow In DataTables("销售单").Select("[审核状态] = 0")
    Dim dr4 As DataRow = DataTables("销售退货明细").AddNew()
    For r As Integer = 0 To Cols3.Length -1
        dr4(Cols4(r)) = dr3(Cols3(r))
    Next
Next



--  作者:lgz518
--  发布时间:2019/11/28 19:23:00
--  
下面代码,执行,主表数据在窗体上看到导入,而明细数据在窗体上看不到导入,只在狐表上可以看到导入,如何让他(明细表)也在窗体上可以看到导入数据?
Dim Cols1() As String = {"客户名称"}
Dim Cols2() As String = {"客户名称"}
For Each dr1 As DataRow In DataTables("销售主表").Select("[审核] = 0 ")
    Dim dr2 As DataRow = DataTables("销售退货主表").AddNew()
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
Next
Dim Cols3() As String = {"销售单号","销售日期","客户名称","产品编号","品名","单位","售价","数量"}
Dim Cols4() As String = {"销售单号","销售日期","客户名称","产品编号","品名","单位","售价","数量"}
For Each dr3 As DataRow In DataTables("销售单").Select("[审核状态] = 0 ")
    Dim dr4 As DataRow = DataTables("销售退货明细").AddNew()
    For i As Integer = 0 To Cols3.Length -1
        dr4(Cols4(i)) = dr3(Cols3(i))
    Next
Next



--  作者:lgz518
--  发布时间:2019/11/28 19:50:00
--  
1.以上代码实现,销售主表的[审核] = 1,"销售单"的[审核状态] = 1 ",代码要怎么也写,写哪里?
2.上面代码都是批量,我想双击,销售主表的单条记录,实现单一记录导入?