Foxtable(狐表)用户栏目专家坐堂 → 空值问题


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

主题:空值问题

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


加好友 发短信
等级:九尾狐 帖子:2649 积分:19384 威望:0 精华:1 注册:2008/9/12 9:19:00
空值问题  发帖心情 Post By:2020/6/27 11:28:00 [只看该作者]

以下代码清除开单日期后,发货单号并不清空
'按开单日期的月份自动生成发货单号(FH1502001)
If e.DataCol.Name = "开单日期" Then
    If e.DataRow.IsNull("开单日期") Then
        e.DataRow("发货单号") = Nothing
    Else
        Dim d As Date = e.DataRow("开单日期")
        Dim y As Integer = d.Year
        Dim m As Integer = d.Month
        Dim Days As Integer = Date.DaysInMonth(y,m)
        Dim fd As Date = New Date(y,m,1) '获得该月的第一天
        Dim ld As Date = New Date(y,m,Days) '获得该月的最后一天
        Dim bh As String = "FH" & Format(d,"yyMM") '生成编号的前4位,2位年,2位月
        If e.DataRow("发货单号").StartsWith(bh) = False '如果编号的前4位不符
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.Compute("Max(发货单号)","开单日期 >= #" & fd & "# And 开单日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该月的最大编号
            If max > "" Then '如果存在最大编号
                'idx = CInt(max.Substring(7,3)) + 1 '获得最大编号的后三位顺序号,并加1
                idx = CInt(max.Substring(6,3)) + 1 '获得最大编号的后三位顺序号,并加1
            Else
                idx = 1 '否则顺序号等于1
            End If
            'e.DataRow("订单单号") = bh & "-" & Format(idx,"000")
            e.DataRow("发货单号") = bh & Format(idx,"000")
        End If
    End If
End If


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


加好友 发短信
等级:超级版主 帖子:107135 积分:544918 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/6/27 11:30:00 [只看该作者]

1、没有清空
If e.DataCol.Name = "开单日期" Then
msgbox(e.DataRow.IsNull("开单日期"))
    If e.DataRow.IsNull("开单日期") Then

2、有其它代码影响

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


加好友 发短信
等级:九尾狐 帖子:2649 积分:19384 威望:0 精华:1 注册:2008/9/12 9:19:00
  发帖心情 Post By:2020/6/27 12:14:00 [只看该作者]

这是DataColChanged的全部代码,年月日和开单人都能清空,发货单号不能
If e.DataCol.Name = "开单日期" Then
    If e.DataRow.IsNull("开单日期") Then
       e.DataRow("年") = Nothing
       e.DataRow("月") = Nothing
       e.DataRow("日") = Nothing
e.DataRow("发货单号") = Nothing
    Else
       e.DataRow("年") = Format(e.DataRow("开单日期"),"yyyy")
       e.DataRow("月") = Format(e.DataRow("开单日期"),"yyyyMM")
       e.DataRow("日") = Format(e.DataRow("开单日期"),"yyyyMMdd")
    End If
End If
'按开单日期的月份自动生成发货单号(FH1502001)
If e.DataCol.Name = "开单日期" Then
    If e.DataRow.IsNull("开单日期") Then
        e.DataRow("发货单号") = Nothing
    Else
        Dim d As Date = e.DataRow("开单日期")
        Dim y As Integer = d.Year
        Dim m As Integer = d.Month
        Dim Days As Integer = Date.DaysInMonth(y,m)
        Dim fd As Date = New Date(y,m,1) '获得该月的第一天
        Dim ld As Date = New Date(y,m,Days) '获得该月的最后一天
        Dim bh As String = "FH" & Format(d,"yyMM") '生成编号的前4位,2位年,2位月
        If e.DataRow("发货单号").StartsWith(bh) = False '如果编号的前4位不符
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.Compute("Max(发货单号)","开单日期 >= #" & fd & "# And 开单日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该月的最大编号
            If max > "" Then '如果存在最大编号
                'idx = CInt(max.Substring(7,3)) + 1 '获得最大编号的后三位顺序号,并加1
                idx = CInt(max.Substring(6,3)) + 1 '获得最大编号的后三位顺序号,并加1
            Else
                idx = 1 '否则顺序号等于1
            End If
            'e.DataRow("订单单号") = bh & "-" & Format(idx,"000")
            e.DataRow("发货单号") = bh & Format(idx,"000")
        End If
    End If
End If
'如果客户代码或业务员更改
Select Case  e.DataCol.Name 
    Case "客户代码","业务员"
    Dim crs As List(of DataRow) = e.DataRow.GetChildRows("销售发货明细")  '获得明细表中的所有行
    For Each cr As DataRow In crs
        cr(e.DataCol.Name) = e.DataRow(e.DataCol.Name)
    Next
End Select

'客户取值
If e.DataCol.Name = "客户代码" Then '产品ID发生改变
    Dim dr As DataRow 
    dr = DataTables("客户").Find("客户代码 = " & "'" & e.DataRow("客户代码") & "'" ) '在产品表找出该产品
    If dr IsNot Nothing '如果找到, 则设置各列内容
        e.DataRow("客户简称")= dr("客户简称")
        e.DataRow("客户全称")= dr("客户全称")
        e.DataRow("联系人")= dr("联系人")
        e.DataRow("送货地址")= dr("客户地址")
    End If
End If

'自动记录开单人和时间
If e.DataCol.Name = "开单日期" Then 
    If e.DataRow("开单日期") = Nothing Then '如果开单日期是空的
        e.DataRow("开单人") = Nothing
    Else
       'e.DataRow("开单人") = Nothing
       e.DataRow("开单人") = _UserName & " " & format(Date.Now,"g") 
    End If
End If

If e.DataCol.Name = "审核" Then
        e.DataRow("审核人") = User.Name & " " & format(Date.Now,"g")   
End If

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


加好友 发短信
等级:九尾狐 帖子:2649 积分:19384 威望:0 精华:1 注册:2008/9/12 9:19:00
  发帖心情 Post By:2020/6/27 12:45:00 [只看该作者]

明白了,发货单号是关联字段。

 回到顶部