以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  动态合成表达式  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=142785)

--  作者:lfz123
--  发布时间:2019/11/6 9:41:00
--  动态合成表达式
证照号码是字符型,月份是整数型,放在一起写有点蒙,提示有错误

Dim filter As String = "证照号码 = \'" & e.DataRow("证照号码") & "\'and 月份 < = " & e.DataRow("月份")
Dim v1 As Double = e.DataTable.SQLCompute("sum(本期收入)",filter) \'本期收入

--  作者:有点蓝
--  发布时间:2019/11/6 10:26:00
--  
提示什么错误?
Dim filter As String = "证照号码 = \'" & e.DataRow("证照号码") & "\' and 月份 <= " & e.DataRow("月份")



--  作者:lfz123
--  发布时间:2019/11/6 11:01:00
--  回复:(有点蓝)提示什么错误?Dim filter As String...
现在错误提示我:有一个参数没有被指定值.年份和月份都是整数型,在月份处和本期收入处输入数据就会有这个错误提示
If e.DataCol.Name = "姓名" Then  \'测试没有问题
    If e.DataRow.IsNull("姓名") Then
        e.DataRow("证照号码") = Nothing
        e.DataRow("证照类型") = Nothing
        e.DataRow("类型") = Nothing
    Else
        Dim dr As DataRow = DataTables("人员信息").SQLfind("姓名 = \'" & e.DataRow("姓名") & "\' ")
        If dr IsNot Nothing Then
            e.DataRow("证照号码") = dr("证照号码")
            e.DataRow("证照类型") = dr("证照类型")
            e.DataRow("类型") = dr("类型")
        End If
    End If
End If

If e.DataCol.Name = "证照号码" Then \'测试没有问题
    If e.DataRow.IsNull("证照号码") Then
        e.DataRow("姓名") = Nothing
        e.DataRow("证照类型") = Nothing
        e.DataRow("类型") = Nothing
    Else
        Dim dr As DataRow = DataTables("人员信息").SQLfind("证照号码 = \'" & e.DataRow("证照号码") & "\' ")
        If dr IsNot Nothing Then
            e.DataRow("姓名") = dr("姓名")
            e.DataRow("证照类型") = dr("证照类型")
            e.DataRow("类型") = dr("类型")
        End If
    End If
End If

If e.DataCol.Name = "证照号码" OrElse e.DataCol.name = "月份" Then \'测试没有问题
    If DataTables.Contains("个人缴费信息") = False Then
        DataTables("个人缴费信息").load()
    End If
    If e.DataRow.IsNull("证照号码") OrElse e.DataRow.IsNull("月份") Then
        e.DataRow("基本养老保险费") = Nothing
        e.DataRow("基本医疗保险费") = Nothing
        e.DataRow("失业保险费") = Nothing
    Else
        Dim dr As DataRow = DataTables("个人缴费信息").SQLFind(" 年份 = " & e.DataRow("年份") & "and 月份 = " & e.DataRow("月份") & " And 证照号码 = \'" & e.DataRow("证照号码") & "\'")
        If dr IsNot Nothing Then
            e.DataRow("基本养老保险费") = dr("个人月缴纳养老保险费")
            e.DataRow("基本医疗保险费") = dr("个人月缴纳医疗保险费")
            e.DataRow("失业保险费") = dr("个人月缴纳失业保险费")
        End If
    End If
End If

\'如果发生变化的是所得税列之外的数值型列,才重新计算所得税.
If e.DataCol.Name <> "所得税" AndAlso e.DataCol.IsNumeric Then
    If e.DataRow("所得项目") = "正常工资薪金所得" Then
        Dim filter As String = "证照号码 = \'" & e.DataRow("证照号码") & "\'and 月份 <= " & e.DataRow("月份")
        Dim v1 As Double = e.DataTable.SQLCompute("sum(本期收入)",filter) \'本期收入
        Dim v2 As Double = e.DataTable.SQLCompute("sum(社保扣款小计)",filter) \'累计社保扣款
        Dim v3 As Double = e.DataTable.SQlCompute("sum(住房公积金)",filter) \'累计住房公积金
        Dim v4 As Double = e.DataTable.SQLCompute("sum(附加扣除小计)",filter) \'累计附加扣除
        Dim y As Integer = e.DataTable.SQLCompute("count(证照号码)","证照号码 = \'" & e.DataRow("证照号码") & "\'") \'累计附加扣除
        Dim v5 As Double = y * 5000 \'累计减除费用
        Dim v6 As Double = v2+v3+V4 \'累计专项扣除
        Dim v8 As Double = v1 - v6 - V5 \'累计应纳税所得额
        If v8 >  0 Then
            Dim v9 = iif((v8)>960000,(v8)*0.45-181920,IIF((v8)>660000,(v8)*0.35-85920,IIF((v8)>420000,(v8)*0.30-52920,IIF((v8)>300000,(v8)*0.25-31920,IIF((v8)>144000,(v8)*0.2-16920,IIF((v8)>36000,(v8)*0.1-2520,(v8)*0.03))))))
            Dim v10 As Double = e.DataTable.SQLCompute("sum(所得税)","证照号码 = \'" & e.DataRow("证照号码") & "\'and 月份 < " & e.DataRow("月份")) \'累计已交税金
            If v9 > v10 Then
                e.DataRow("所得税") = v9 - v10
            End If
        End If
    ElseIf e.DataRow("所得项目") = "全年一次性奖金收入" Then
        Dim v As Double = e.DataRow("本期收入")
        e.DataRow("所得税") = iif((v)>960000,(v)*0.45-181920,IIF((v)>660000,(v)*0.35-85920,IIF((v)>420000,(v)*0.30-52920,IIF((v)>300000,(v)*0.25-31920,IIF((v)>144000,(v)*0.2-16920,IIF((v)>36000,(v)*0.1-2520,(v)*0.03))))))
        If e.DataCol.Name = "本期收入" Then
            If e.DataRow.IsNull("本期收入") Then
                e.DataRow("所得税") = Nothing
            End If
        End If
        
    End If
End If
[此贴子已经被作者于2019/11/6 11:18:27编辑过]

--  作者:有点蓝
--  发布时间:2019/11/6 11:19:00
--  
确定数据库里月份是整数列?

msgbox(filter) 显示什么?

--  作者:lfz123
--  发布时间:2019/11/6 16:11:00
--  回复:(有点蓝)确定数据库里月份是整数列?msgbox(f...
蓝老师我知道了是因为有表达式列求和,我已经改好了
 Dim v2 As Double = e.DataTable.SQLCompute("sum(社保扣款小计)",filter) \'累计社保扣款