Foxtable(狐表)用户栏目专家坐堂 → 条件判断求和


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

主题:条件判断求和

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


加好友 发短信
等级:九尾狐 帖子:2159 积分:14971 威望:0 精华:0 注册:2017/10/12 13:00:00
条件判断求和  发帖心情 Post By:2019/7/9 15:27:00 [只看该作者]

用户已被锁定

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


加好友 发短信
等级:超级版主 帖子:107014 积分:544295 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/7/9 16:19:00 [只看该作者]

麻烦以后发帖改文字的颜色,不要设置背景色,看的眼花。

dv("需求数量") = dq.SQLCompute("sum(当日数量)", "发货日期 >= '" & dw1  & "' and 发货日期 <= '" & dw2 & "' and 材料编码 = '" & e.newvalue & "'  And 申请下达 is null")

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


加好友 发短信
等级:九尾狐 帖子:2159 积分:14971 威望:0 精华:0 注册:2017/10/12 13:00:00
  发帖心情 Post By:2019/7/9 17:00:00 [只看该作者]

用户已被锁定

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


加好友 发短信
等级:管理员 帖子:47448 积分:251054 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2019/7/9 17:12:00 [只看该作者]

算不出来,就是条件不符合,导致代码没有执行,自己调试分析一下:
http://www.foxtable.com/webhelp/topics/1485.htm


If e.DataRow("库位") = "包装箱"   Then
    MessageBox.show("我执行了1")
    Dim d As Integer = Date.Today.Year
    Dim f As Integer = Date.Today.Month
    Dim dr1 As New Date(d, f, 1)
    Dim do2 As New Date(d, f, Date.DaysInMonth(d, f)) '获取本月的最后一天
    Dim g As Integer = Date.Today.Year
    Dim n As Integer = Date.Today.Month
    Dim dw1 As New Date(g, n, 1)
    Dim dw2 As New Date(g, n, Date.DaysInMonth(g, n)) '获取本月的最后一天
    Dim dv As DataRow = e.DataRow
    Dim dq As DataTable =DataTables("销售发货明细")
    If e.DataCol.Name = "成品编码"  Then
        MessageBox.show("我执行了2")
        dv("需求数量") = dq.SQLCompute("sum(当日数量)", "发货日期 >= '" & dw1  & "' and 发货日期 <= '" & dw2 & "' and 材料编码 = '" & e.newvalue & "'  And 申请下达 = nothing")
    Else
        MessageBox.show("我什么都没干1")
    End If
Else
    MessageBox.show("我执行了3")
    If e.DataCol.Name  = "成品编码"
        MessageBox.show("我执行了4")
        Dim Filter As String = "[材料编码] = '" & e.DataRow("成品编码") & "'"
        e.DataRow("需求数量") = DataTables("材料需求明细").SQLCompute("Sum(未发数量)", Filter)
    Else
        MessageBox.show("我什么都没干2")
    End If
End If

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


加好友 发短信
等级:九尾狐 帖子:2159 积分:14971 威望:0 精华:0 注册:2017/10/12 13:00:00
  发帖心情 Post By:2019/7/9 20:44:00 [只看该作者]

用户已被锁定

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


加好友 发短信
等级:超级版主 帖子:107014 积分:544295 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/7/9 20:50:00 [只看该作者]

这个意思?

If e.DataCol.Name  = "成品编码"
    If e.DataRow("库位") = "包装箱"   Then
        Dim d As Integer = Date.Today.Year
        Dim f As Integer = Date.Today.Month
        Dim dr1 As New Date(d, f, 1)
        Dim do2 As New Date(d, f, Date.DaysInMonth(d, f)) '获取本月的最后一天
        Dim g As Integer = Date.Today.Year
        Dim n As Integer = Date.Today.Month
        Dim dw1 As New Date(g, n, 1)
        Dim dw2 As New Date(g, n, Date.DaysInMonth(g, n)) '获取本月的最后一天
        Dim dv As DataRow = e.DataRow
        Dim dq As DataTable =DataTables("销售发货明细")
        If e.DataCol.Name = "成品编码"  Then
            dv("需求数量") = dq.SQLCompute("sum(当日数量)", "发货日期 >= '" & dw1  & "' and 发货日期 <= '" & dw2 & "' and 材料编码 = '" & e.newvalue & "'  And 申请下达 is null")
        End If
    Else
        Dim Filter As String = "[材料编码] = '" & e.DataRow("成品编码") & "'"
        e.DataRow("需求数量") = DataTables("材料需求明细").SQLCompute("Sum(未发数量)", Filter)
    End If
End If

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


加好友 发短信
等级:九尾狐 帖子:2159 积分:14971 威望:0 精华:0 注册:2017/10/12 13:00:00
  发帖心情 Post By:2019/7/9 21:17:00 [只看该作者]

用户已被锁定

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


加好友 发短信
等级:超级版主 帖子:107014 积分:544295 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/7/9 21:23:00 [只看该作者]

If e.DataCol.Name  = "成品编码" orelse e.DataCol.Name  = "库位"
    If e.DataRow("库位") = "包装箱"   Then
        Dim d As Integer = Date.Today.Year
        Dim f As Integer = Date.Today.Month
        Dim dr1 As New Date(d, f, 1)
        Dim do2 As New Date(d, f, Date.DaysInMonth(d, f)) '获取本月的最后一天
        Dim g As Integer = Date.Today.Year
        Dim n As Integer = Date.Today.Month
        Dim dw1 As New Date(g, n, 1)
        Dim dw2 As New Date(g, n, Date.DaysInMonth(g, n)) '获取本月的最后一天
        Dim dv As DataRow = e.DataRow
        Dim dq As DataTable =DataTables("销售发货明细")
        If e.DataCol.Name = "成品编码"  Then
            dv("需求数量") = dq.SQLCompute("sum(当日数量)", "发货日期 >= '" & dw1  & "' and 发货日期 <= '" & dw2 & "' and 材料编码 = '" & e.DataRow("成品编码") & "'  And 申请下达 is null")
        End If
    Else
        Dim Filter As String = "[材料编码] = '" & e.DataRow("成品编码") & "'"
        e.DataRow("需求数量") = DataTables("材料需求明细").SQLCompute("Sum(未发数量)", Filter)
    End If
End If

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


加好友 发短信
等级:九尾狐 帖子:2159 积分:14971 威望:0 精华:0 注册:2017/10/12 13:00:00
  发帖心情 Post By:2019/7/9 22:28:00 [只看该作者]

用户已被锁定

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


加好友 发短信
等级:超级版主 帖子:107014 积分:544295 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/7/9 22:39:00 [只看该作者]

点击全部这个按钮有结果呀?或者说什么样的结果才是对的?

 回到顶部
总数 12 1 2 下一页