Foxtable(狐表)用户栏目专家坐堂 → 复制当前行数据代码出错


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

主题:复制当前行数据代码出错

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


加好友 发短信
等级:三尾狐 帖子:767 积分:6119 威望:0 精华:0 注册:2018/2/1 17:26:00
复制当前行数据代码出错  发帖心情 Post By:2018/6/1 10:55:00 [只看该作者]

老师你好:
  复制当前行数据代码出错,我的需求是:打开副表时,自动增加4行,并把当前行的相关数据复制到新增这个4行中。
下面这段代码如何修改:

Dim tp As WinForm.TabControl = e.sender
Select Case tp.SelectedPage.Text
    Case "批量录入"
        
        If Tables("原材料").Rows.Count = 0 Then '如果是一个空表
            Return '那么返回
        End If
        Dim idxs As String = "-1,"
        Dim dr As Row = Tables("原材料").Current
        For Each dc As Col In Tables("原材料").Cols
            For i As Integer = 1 To 4
                Dim nr As Row = Tables("原材料进场录入_Table1").AddNew
                idxs & = nr("_Identify") & ","
                nr(i) = dr(dc.Name)
            Next
        Next
        Tables("原材料进场录入_Table1").filter = "_Identify in (" & idxs.Trim(",") & ")"
End Select

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/6/1 11:17:00 [只看该作者]

改成

 

Dim tp As WinForm.TabControl = e.sender
Select Case tp.SelectedPage.Text
    Case "批量录入"
       
        If Tables("原材料").Rows.Count = 0 Then '如果是一个空表
            Return '那么返回
        End If
        Dim idxs As String = "-1,"
        Dim dr As Row = Tables("原材料").Current
        For Each dc As Col In Tables("原材料").Cols
            For i As Integer = 1 To 4
                Dim nr As Row = Tables("原材料进场录入_Table1").AddNew
                idxs & = nr("_Identify") & ","
                nr(dc.name) = dr(dc.Name)
            Next
        Next
        Tables("原材料进场录入_Table1").filter = "_Identify in (" & idxs.Trim(",") & ")"
End Select


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


加好友 发短信
等级:三尾狐 帖子:767 积分:6119 威望:0 精华:0 注册:2018/2/1 17:26:00
  发帖心情 Post By:2018/6/1 11:30:00 [只看该作者]

老师还是不对:


图片点击可在新窗口打开查看此主题相关图片如下:1527823829(1).png
图片点击可在新窗口打开查看


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/6/1 11:37:00 [只看该作者]

Dim tp As WinForm.TabControl = e.sender
Select Case tp.SelectedPage.Text
    Case "批量录入"
       
        If Tables("原材料").Rows.Count = 0 Then '如果是一个空表
            Return '那么返回
        End If
        Dim idxs As String = "-1,"
        Dim dr As Row = Tables("原材料").Current
        For i As Integer = 1 To 4
            Dim nr As Row = Tables("原材料进场录入_Table1").AddNew
            idxs & = nr("_Identify") & ","
            For Each dc As Col In Tables("原材料").Cols
                nr(dc.name) = dr(dc.Name)
            Next
        Next
        Tables("原材料进场录入_Table1").filter = "_Identify in (" & idxs.Trim(",") & ")"
End Select

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


加好友 发短信
等级:三尾狐 帖子:767 积分:6119 威望:0 精华:0 注册:2018/2/1 17:26:00
  发帖心情 Post By:2018/6/1 12:25:00 [只看该作者]

有点甜老师你好:
我还有个需求:如果当前行为新增行时,如何同时增加到“原材料进场录入_Table1”表中,如果当前行不为新增行时,就不能增加到“原材料进场录入_Table1”表中
Dim tp As WinForm.TabControl = e.sender
Select Case tp.SelectedPage.Text
    Case "批量录入"
        
        If Tables("原材料").Rows.Count = 0 Then '如果是一个空表
            Return '那么返回
        End If
        Dim idxs As String = "-1,"
        Dim dr As DataRow = Tables("原材料").Current.DataRow
        If dr.RowState = DataRowState.Detached Then
            Tables("原材料进场录入_Table1").filter = "dr.RowState = DataRowState.Detached "
        End If
        For i As Integer = 1 To 4
            Dim nr As Row = Tables("原材料进场录入_Table1").AddNew
            idxs & = nr("_Identify") & ","
            For Each dc As Col In Tables("原材料").Cols
                nr(dc.name) = dr(dc.Name)
            Next
        Next
        Tables("原材料进场录入_Table1").filter = "_Identify in (" & idxs.Trim(",") & ")"
End Select



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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/6/1 15:04:00 [只看该作者]

这个意思

 

Dim tp As WinForm.TabControl = e.sender
Select Case tp.SelectedPage.Text
    Case "批量录入"
        If Tables("原材料").Rows.Count = 0 Then '如果是一个空表
            Return '那么返回
        End If
        Dim idxs As String = "-1,"
        Dim dr As DataRow = Tables("原材料").Current.DataRow
        If dr.RowState = DataRowState.Unchanged Then
            For i As Integer = 1 To 4
                Dim nr As Row = Tables("原材料进场录入_Table1").AddNew
                idxs & = nr("_Identify") & ","
                For Each dc As Col In Tables("原材料").Cols
                    nr(dc.name) = dr(dc.Name)
                Next
            Next
            Tables("原材料进场录入_Table1").filter = "_Identify in (" & idxs.Trim(",") & ")"
        End If
End Select


 回到顶部