Foxtable(狐表)用户栏目专家坐堂 → 求助:当月份等于1时候执行代码1 当等于2时候执行的代码2一直到12月,求简化这个代码。


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

主题:求助:当月份等于1时候执行代码1 当等于2时候执行的代码2一直到12月,求简化这个代码。

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


加好友 发短信
等级:九尾狐 帖子:2472 积分:17346 威望:0 精华:0 注册:2013/1/31 0:03:00
求助:当月份等于1时候执行代码1 当等于2时候执行的代码2一直到12月,求简化这个代码。  发帖心情 Post By:2014/6/15 21:39:00 [只看该作者]

求助:当月份等于1时候执行代码1 当等于2时候执行的代码2一直到12月,求简化这个代码。

 

 

Select Case e.DataCol.name
    Case "月份"
        If e.DataRow.Isnull("月份") = False Then
            Dim val As Integer = e.DataRow("月份")
            If val = 1 Then
                Dim Sum As Double
                Sum = Tables("销售收入预测表").Compute("Sum(月份_1_月销售额)")
                e.DataRow("销售_含流转税销售收入") = sum
            Else
                If val = 2 Then
                    Dim Sum As Double
                    Sum = Tables("销售收入预测表").Compute("Sum(月份_2_月销售额)")
                    e.DataRow("销售_含流转税销售收入") = sum
                Else
                    If val = 3 Then
                        Dim Sum As Double
                        Sum = Tables("销售收入预测表").Compute("Sum(月份_3_月销售额)")
                        e.DataRow("销售_含流转税销售收入") = sum
                    Else
                        If val = 4 Then
                            Dim Sum As Double
                            Sum = Tables("销售收入预测表").Compute("Sum(月份_4_月销售额)")
                            e.DataRow("销售_含流转税销售收入") = sum
                        Else
                            If val = 5 Then
                                Dim Sum As Double
                                Sum = Tables("销售收入预测表").Compute("Sum(月份_5_月销售额)")
                                e.DataRow("销售_含流转税销售收入") = sum
                            Else
                                If val = 6 Then
                                    Dim Sum As Double
                                    Sum = Tables("销售收入预测表").Compute("Sum(月份_6_月销售额)")
                                    e.DataRow("销售_含流转税销售收入") = sum
                                Else
                                    If val = 7 Then
                                        Dim Sum As Double
                                        Sum = Tables("销售收入预测表").Compute("Sum(月份_7_月销售额)")
                                        e.DataRow("销售_含流转税销售收入") = sum
                                    Else
                                        If val = 8 Then
                                            Dim Sum As Double
                                            Sum = Tables("销售收入预测表").Compute("Sum(月份_8_月销售额)")
                                            e.DataRow("销售_含流转税销售收入") = sum
                                        Else
                                            If val = 9 Then
                                                Dim Sum As Double
                                                Sum = Tables("销售收入预测表").Compute("Sum(月份_9_月销售额)")
                                                e.DataRow("销售_含流转税销售收入") = sum
                                            Else
                                                If val = 10 Then
                                                    Dim Sum As Double
                                                    Sum = Tables("销售收入预测表").Compute("Sum(月份_10_月销售额)")
                                                    e.DataRow("销售_含流转税销售收入") = sum
                                                Else
                                                    If val = 11 Then
                                                        Dim Sum As Double
                                                        Sum = Tables("销售收入预测表").Compute("Sum(月份_11_月销售额)")
                                                        e.DataRow("销售_含流转税销售收入") = sum
                                                    Else
                                                        If val = 12 Then
                                                            Dim Sum As Double
                                                            Sum = Tables("销售收入预测表").Compute("Sum(月份_12_月销售额)")
                                                            e.DataRow("销售_含流转税销售收入") = sum
                                                        Else
                                                           
                                                        End If
                                                    End If
                                                End If
                                            End If
                                        End If
                                    End If
                                End If
                            End If
                        End If
                    End If
                End If
            End If
End If


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/6/15 21:42:00 [只看该作者]

Select Case e.DataCol.name
    Case "月份"
        If e.DataRow.Isnull("月份") = False Then
            Dim val As Integer = e.DataRow("月份")
            Dim Sum As Double
            Sum = Tables("销售收入预测表").Compute("Sum(月份_" & val & "_月销售额)")
            e.DataRow("销售_含流转税销售收入") = sum           
        End If
End Select

 


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


加好友 发短信
等级:九尾狐 帖子:2472 积分:17346 威望:0 精华:0 注册:2013/1/31 0:03:00
回复:(有点甜)Select Case e.DataCol.name &n...  发帖心情 Post By:2014/6/16 1:19:00 [只看该作者]

谢谢有点甜老师

 回到顶部