以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 请教一下 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=150643) |
-- 作者:outcat -- 发布时间: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("保存成功","提示") 老师,请帮忙看一下,我这是保存农户售粮时,自动向 粮食收购 这个总表,明细表添加一笔数据,粮食收购明细表数据正确,可是红色部分这段代码是总表向总表填入一笔数据错误, 粮食收购总表 填入的数据现在是,每保存一次,是把 农户售粮总表 里的所有数据 重新添加到了,粮食收购总表里面??? |
-- 作者:有点蓝 -- 发布时间: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 |