以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]若想要空置复制后,不显示为0的话,应该怎么改代码?  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=132428)

--  作者:fengwenliuyan
--  发布时间:2019/3/21 17:32:00
--  [求助]若想要空置复制后,不显示为0的话,应该怎么改代码?
Dim Cols1() As String = {"入库编号","品名规格","工序","单位","入库单价","客户数量","过磅数量","应收金额","出库"}
Dim Cols2() As String = {"入库编号","品名规格","工序","单位","入库单价","客户数量","过磅数量","应收金额","出库"}
For Each dr1 As DataRow In DataTables("入库明细表").Select("[出库] = true")
    Dim dr2 As DataRow = DataTables("出库明细表").AddNew()
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
    dr2("客户") = e.Form.Controls("TextBox1").text
    dr1("已出库") = True
Next

"入库明细表"的数据列,若是字符列,则可以完美复制到"出库明细表"中,包括为空的单元格内容,在"出库明细表"中会不显示0;
但是,"入库明细表"的数据列,若是整数列的话,则复制到"出库明细表"中,单元格为空的内容,在"出库明细表"中显示的却是0;
若想要空置复制后,不显示为0的话,应该怎么改代码?

--  作者:有点甜
--  发布时间:2019/3/21 18:01:00
--  
Dim Cols1() As String = {"入库编号","品名规格","工序","单位","入库单价","客户数量","过磅数量","应收金额","出库"}
Dim Cols2() As String = {"入库编号","品名规格","工序","单位","入库单价","客户数量","过磅数量","应收金额","出库"}
For Each dr1 As DataRow In DataTables("入库明细表").Select("[出库] = true")
    Dim dr2 As DataRow = DataTables("出库明细表").AddNew()
    For i As Integer = 0 To Cols1.Length -1
        If dr1.IsNull(Cols1(i)) Then
            dr2(Cols2(i)) = Nothing
        Else
            dr2(Cols2(i)) = dr1(Cols1(i))
        End If
    Next
    dr2("客户") = e.Form.Controls("TextBox1").text
    dr1("已出库") = True
Next