以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  求助:当月份等于1时候执行代码1 当等于2时候执行的代码2一直到12月,求简化这个代码。  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=52419)

--  作者:李孝春
--  发布时间:2014/6/15 21:39:00
--  求助:当月份等于1时候执行代码1 当等于2时候执行的代码2一直到12月,求简化这个代码。

求助:当月份等于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


--  作者:有点甜
--  发布时间: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

 


--  作者:李孝春
--  发布时间:2014/6/16 1:19:00
--  回复:(有点甜)Select Case e.DataCol.name &n...
谢谢有点甜老师