Foxtable(狐表)用户栏目专家坐堂 → 如何实现关联主从表的数据引到关联主从表?


  共有3992人关注过本帖树形打印复制链接

主题:如何实现关联主从表的数据引到关联主从表?

帅哥哟,离线,有人找我吗?
lgz518
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1257 积分:8555 威望:0 精华:0 注册:2019/6/13 9:57:00
如何实现关联主从表的数据引到关联主从表?  发帖心情 Post By:2019/11/28 13:36:00 [显示全部帖子]

如何实现关联主从表的数据引到关联主从表?
比如:
     销售订单(销售主表和销售明细关联构成),销售退货单(销售退货主表和销售退货明细关联构成)。
     1.在销售订单列表的销售主表,选中已审核的销售订单,导入到销售退货单。
     2.批量操作,将销售订单(销售主表和销售明细关联构成)已审核,全部导入到销售退货单(销售退货主表和销售退货明细关联构成)

  请老师,指导,谢谢!

 回到顶部
帅哥哟,离线,有人找我吗?
lgz518
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1257 积分:8555 威望:0 精华:0 注册:2019/6/13 9:57:00
  发帖心情 Post By: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

 回到顶部
帅哥哟,离线,有人找我吗?
lgz518
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1257 积分:8555 威望:0 精华:0 注册:2019/6/13 9:57:00
  发帖心情 Post By:2019/11/28 16:18:00 [显示全部帖子]

这个实例

 回到顶部
帅哥哟,离线,有人找我吗?
lgz518
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1257 积分:8555 威望:0 精华:0 注册:2019/6/13 9:57:00
  发帖心情 Post By:2019/11/28 16:18:00 [显示全部帖子]


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


 回到顶部
帅哥哟,离线,有人找我吗?
lgz518
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1257 积分:8555 威望:0 精华:0 注册:2019/6/13 9:57:00
  发帖心情 Post By: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
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1257 积分:8555 威望:0 精华:0 注册:2019/6/13 9:57:00
  发帖心情 Post By:2019/11/28 19:50:00 [显示全部帖子]

1.以上代码实现,销售主表的[审核] = 1,"销售单"的[审核状态] = 1 ",代码要怎么也写,写哪里?
2.上面代码都是批量,我想双击,销售主表的单条记录,实现单一记录导入?

 回到顶部