Foxtable(狐表)用户栏目专家坐堂 → 请教一下


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

主题:请教一下

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


加好友 发短信
等级:一尾狐 帖子:470 积分:3641 威望:0 精华:0 注册:2017/11/5 14:47:00
请教一下  发帖心情 Post By:2020/6/3 16:50:00 [只看该作者]

If Tables("农户售粮明细表").current Is Nothing Then
    Tables("农户售粮总表").current.delete
Else
    Tables("农户售粮总表").current.save
    For Each r As Row In Tables("农户售粮明细表").Rows
        r.save
    Next
    Tables("农户售粮总表").Current.save
    DataTables("农户售粮明细表").save
    If Tables("农户售粮总表").current("登记类型") = "其它" Then
        Dim Cols1() As String = {"日期","售粮单号","仓库名称","农户姓名","简码","乡镇","行政村","自然村","联系电话","售粮数量","售粮金额","实际金额","折扣","已用金额","未用金额","备注","登记人","经手人"} '农户售粮总表
        Dim Cols3() As String = {"日期","售粮单号","仓库名称","农户姓名","简码","乡镇","行政村","自然村","联系电话","售粮数量","售粮金额","实际金额","折扣","已用金额","未用金额","备注","登记人","经手人"} '粮食收购总表
        Dim Cols2() As String = {"日期","售粮单号","仓库名称","农户姓名","简码","乡镇","行政村","自然村","联系电话","类别编号","商品类别","商品编号","商品名称","规格型号","单位","单价","数量","金额","实际金额","折扣","登记人","经手人"} '农户售粮明细表
        Dim Cols4() As String = {"日期","售粮单号","仓库名称","农户姓名","简码","乡镇","行政村","自然村","联系电话","类别编号","商品类别","商品编号","商品名称","规格型号","单位","单价","数量","金额","实际金额","折扣","登记人","经手人"} '粮食收购明细表
        
        For Each dr1 As DataRow In DataTables("农户售粮总表").datarows
            Dim dr3 As DataRow = DataTables("粮食收购总表").AddNew()
            For i As Integer = 0 To Cols1.Length -1
                dr3(Cols3(i)) = dr1(Cols1(i))
            Next
        Next
        DataTables("粮食收购总表").save
        For Each dr2 As DataRow In DataTables("农户售粮明细表").datarows
            Dim dr4 As DataRow = DataTables("粮食收购明细表").AddNew()
            For i As Integer = 0 To Cols2.Length -1
                dr4(Cols4(i)) = dr2(Cols2(i))
            Next
        Next
        DataTables("粮食收购明细表").save
  
    End If
End If
Tables("农户售粮总表").AllowEdit=False
MessageBox.show("保存成功","提示")


  老师,请帮忙看一下,我这是保存农户售粮时,自动向 粮食收购 这个总表,明细表添加一笔数据,粮食收购明细表数据正确,可是红色部分这段代码是总表向总表填入一笔数据错误, 粮食收购总表 填入的数据现在是,每保存一次,是把 农户售粮总表 里的所有数据 重新添加到了,粮食收购总表里面???


 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110743 积分:563641 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/6/3 17:04:00 [只看该作者]

红色代码改为

dim r as row = Tables("农户售粮总表").Current
            Dim dr3 As DataRow = DataTables("粮食收购总表").AddNew()
            For i As Integer = 0 To Cols1.Length -1
                dr3(Cols3(i)) = r(Cols1(i))
            Next

        DataTables("粮食收购总表").save

 回到顶部