以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]填充  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=101265)

--  作者:苏州老街
--  发布时间:2017/5/27 13:01:00
--  [求助]填充
老师,怎样才能重置“已开票”列不再自动把数据填充到收支表中。(只填充一次)

If e.DataCol.Name = "已开票"
    If e.DataRow("已开票") = True Then
        Dim nma() As String = {"_Identify","出库单编号", "出库_税率","开票日期" ,"发票号码","出库_税金","出库_税金" } \'A表数据来源列
        Dim nmb() As String = {"ID" ,"单据编号","规格", "日期","发票号码","单价","支出" } \'B表数据接收列
        e.DataRow.save
        Dim dr As DataRow = DataTables("收支表").AddNew
        For i As Integer = 0 To nma.Length - 1
            dr(nmb(i)) = e.DataRow(nma(i))
        Next
        dr("来源") = "支出" \'入库表就改为"采购",其他表改为"其它"
        dr("单位") = "份"
        dr("数量") = "1"
        dr("客户ID") = "S001"
        dr("客户") = "园区国税"
        dr("项目名称") = "增值税"
    Else
        DataTables("收支表").deletefor("ID = \'" & e.DataRow("_Identify") & "\'")
    End If
End If

我搞了个禁止重复还是没用
If e.DataCol.Name = "发票号码" Then
    Dim dr As DataRow 
    dr = e.DataTable.Find("发票号码 = \'" & e.NewValue & "\'")
    If dr IsNot Nothing Then
        MessageBox.Show("此发票号码号已经存在!")
        e.Cancel = True
    End If
End If



--  作者:有点蓝
--  发布时间:2017/5/27 15:02:00
--  
If e.DataCol.Name = "已开票"
    If e.DataRow("已开票") = True Then
        Dim nma() As String = {"_Identify","出库单编号", "出库_税率","开票日期" ,"发票号码","出库_税金","出库_税金" } \'A表数据来源列
        Dim nmb() As String = {"ID" ,"单据编号","规格", "日期","发票号码","单价","支出" } \'B表数据接收列
        e.DataRow.save
        Dim dr As DataRow = DataTables("收支表").Find("发票号码 = \'" & e.DataRow("发票号码") & "\'")
        If dr Is Nothing Then
            Dim dr As DataRow = DataTables("收支表").AddNew
            For i As Integer = 0 To nma.Length - 1
                dr(nmb(i)) = e.DataRow(nma(i))
            Next
            dr("来源") = "支出" \'入库表就改为"采购",其他表改为"其它"
            dr("单位") = "份"
            dr("数量") = "1"
            dr("客户ID") = "S001"
            dr("客户") = "园区国税"
            dr("项目名称") = "增值税"
        End If
    Else
        DataTables("收支表").deletefor("ID = \'" & e.DataRow("_Identify") & "\'")
    End If
End If

--  作者:苏州老街
--  发布时间:2017/5/27 21:46:00
--  
 老师,下面两组代码可以合并吗?



If e.DataCol.Name = "审核"
        If e.DataRow("审核") = True Then
            Dim nma() As String = {"_Identify","出库单编号" , "出库日期","客户ID","客户","商品ID","商品名称","规格","出库_数量","出库_售价","出库_单位","出库_价税合计","出库单编号明细"} \'A表数据来源列
            Dim nmb() As String = {"ID" ,"单据编号" , "日期","客户ID","客户","商品ID","项目名称","规格","数量","单价","单位","收入","出库单编号明细" } \'B表数据接收列
            e.DataRow.save
            Dim dr1 As DataRow = DataTables("收支表").Find("出库单编号明细 = \'" & e.DataRow("出库单编号明细") & "\'")             \'找到指定返回的行
            If dr1 Is Nothing Then
                Dim dr As DataRow = DataTables("收支表").AddNew
                For i As Integer = 0 To nma.Length - 1
                    dr(nmb(i)) = e.DataRow(nma(i))
                Next
                dr("来源") = "销售" \'入库表就改为"采购",其他表改为"其它"
            End If
        Else
            DataTables("收支表").deletefor("ID = \'" & e.DataRow("_Identify") & "\'")
        End If
    End If    
    
    
   












 If e.DataCol.Name = "已开票"
        If e.DataRow("已开票") = True Then
            Dim nma() As String = {"_Identify","出库单编号", "出库_税率","开票日期" ,"发票号码","出库_税金","出库_税金" } \'A表数据来源列
            Dim nmb() As String = {"ID" ,"单据编号","规格", "日期","发票号码","单价","支出" } \'B表数据接收列
            e.DataRow.save
            Dim dr1 As DataRow = DataTables("收支表").Find("发票号码 = \'" & e.DataRow("发票号码") & "\'")             \'找到指定返回的行
            If dr1 Is Nothing Then
                Dim dr As DataRow = DataTables("收支表").AddNew
                For i As Integer = 0 To nma.Length - 1
                    dr(nmb(i)) = e.DataRow(nma(i))
                Next
                dr("来源") = "支出" \'入库表就改为"采购",其他表改为"其它"
                dr("单位") = "份"
                dr("数量") = "1"
                dr("客户ID") = "S001"
                dr("客户") = "园区国税"
                dr("项目名称") = "增值税"
            End If
        Else
            DataTables("收支表").deletefor("ID = \'" & e.DataRow("_Identify") & "\'")
        End If
    End If




老师,有点搞不清思路,"审核"列是通过按钮触发该事件"已开票"列是发票号码列触发的。如果已开是否的话不把"税金"列填充到收支表中。
[此贴子已经被作者于2017/5/27 22:30:45编辑过]

--  作者:有点色
--  发布时间:2017/5/28 10:12:00
--  

 回复3楼,没看懂你的问题。请举例说明具体问题。

 

 上传简单例子。