以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [原创]代码问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=54822)

--  作者:爱相随
--  发布时间:2014/8/5 13:42:00
--  [原创]代码问题
请老师帮个忙,下面是菜单代码,我是想通过菜单点击复制部分列到另外一张表,比如选择”ZJJHB“的某一行后,点击”生成资金申请表“,然后将选择的行的代码列出的列内容复制到”ZJSQB“,然后修改补充数据后保存就形成完整的行。执行后提示红色部分代码有错:谢谢!!
If User.IsRole("录入人") Then
    For Each r As Row In Tables("ZJJHB").GetCheckedRows 
        Dim nma("ZJJHB") As String = { "KSJM","KSMC","XMBM","XMMC","JHBH","HTJE","SQDW","XMJD","YFJDK" } \'A表数据来源列
        Dim nmb("ZJSQB") As String = { "KSBM","KSMC","XMBM","XMMC","ZJJHBH","HT1","JSGLDW","HT3","HT4" } \'B表数据接收列
        Dim dr As DataRow = DataTables("ZJSQB").AddNew
        For i As Integer = 0 To nma.Length - 1
            dr(nmb(i)) = e.DataRow(nma(i))
        Next
   Next
      Else
      MessageBox.show("你没有复制数据的权限!")
End If
[此贴子已经被作者于2014-8-5 13:52:34编辑过]

--  作者:有点甜
--  发布时间:2014/8/5 14:03:00
--  
For Each r As Row In Tables("ZJJHB").GetCheckedRows
    Dim nma() As String = { "KSJM","KSMC","XMBM","XMMC","JHBH","HTJE","SQDW","XMJD","YFJDK" } \'A表数据来源列
    Dim nmb() As String = { "KSBM","KSMC","XMBM","XMMC","ZJJHBH","HT1","JSGLDW","HT3","HT4" } \'B表数据接收列
    Dim dr As DataRow = DataTables("ZJSQB").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = r(nma(i))
    Next
Next

--  作者:Bin
--  发布时间:2014/8/5 14:18:00
--  
Dim nma As String = { "KSJM","KSMC","XMBM","XMMC","JHBH","HTJE","SQDW","XMJD","YFJDK" } \'A表数据来源列
        Dim nmb  As String = { "KSBM","KSMC","XMBM","XMMC","ZJJHBH","HT1","JSGLDW","HT3","HT4" } \'B表数据接收列

--  作者:爱相随
--  发布时间:2014/8/5 14:52:00
--  
谢谢老师,还有个问题,小写转大写的代码是什么,,比如A列是小写,在B列自动转为大写金额,请老师编制一下,谢谢
[此贴子已经被作者于2014-8-5 14:52:33编辑过]

--  作者:有点甜
--  发布时间:2014/8/5 14:55:00
--  

 参考,转一下即可。

 

http://www.foxtable.com/help/topics/1345.htm

 


--  作者:爱相随
--  发布时间:2014/8/5 15:04:00
--  
老师,我在同表只需复制部分列的内容,下面代码怎么改呢??
For Each r As Row In Tables("ZJJHB").GetCheckedRows
If User.IsRole("录入人") Then
      Syscmd.Row.Clone()
      Else
      MessageBox.show("你没有复制数据的权限!")
End If
Next

--  作者:有点甜
--  发布时间:2014/8/5 15:05:00
--  
If User.IsRole("录入人") Then
    For Each r As Row In Tables("ZJJHB").GetCheckedRows
        Dim nma() As String = { "KSJM","KSMC","XMBM","XMMC","JHBH","HTJE","SQDW","XMJD","YFJDK" } \'A表数据来源列
        Dim nmb() As String = { "KSBM","KSMC","XMBM","XMMC","ZJJHBH","HT1","JSGLDW","HT3","HT4" } \'B表数据接收列
        Dim dr As DataRow = DataTables("ZJSQB").AddNew
        For i As Integer = 0 To nma.Length - 1
            dr(nmb(i)) = r(nma(i))
        Next
    Next 
Else
    MessageBox.show("你没有复制数据的权限!")
End If

--  作者:有点甜
--  发布时间:2014/8/5 15:06:00
--  

同表也一样写,表名改一下即可。


--  作者:爱相随
--  发布时间:2014/8/5 15:29:00
--  
谢谢老师,还有,如果我要记录次数,比如对同一记录复制的次数达3次时,进行提示或限制,代码怎么加呢??
--  作者:有点甜
--  发布时间:2014/8/5 15:33:00
--  
以下是引用爱相随在2014-8-5 15:29:00的发言:
谢谢老师,还有,如果我要记录次数,比如对同一记录复制的次数达3次时,进行提示或限制,代码怎么加呢??

 

加入一列次数,用于统计被复制的次数

 

If User.IsRole("录入人") Then
    For Each r As Row In Tables("ZJJHB").GetCheckedRows
        Dim nma() As String = { "KSJM","KSMC","XMBM","XMMC","JHBH","HTJE","SQDW","XMJD","YFJDK" } \'A表数据来源列
        Dim nmb() As String = { "KSBM","KSMC","XMBM","XMMC","ZJJHBH","HT1","JSGLDW","HT3","HT4" } \'B表数据接收列
        Dim dr As DataRow = DataTables("ZJSQB").AddNew
       
        If r("次数") < 3 Then
            r("次数") += 1
            For i As Integer = 0 To nma.Length - 1
                dr(nmb(i)) = r(nma(i))
            Next
        Else
            msgbox("超出次数")
        End If
    Next
Else
    MessageBox.show("你没有复制数据的权限!")
End If