Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共2 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:datacolchanged事件不计算了

1楼
deliangzhaoe 发表于:2025/3/31 19:27:00
表的datacolchanged事件设置了如下代码:

'本年内企业名称禁止重复
If e.DataCol.Name = "企业名称" Then
    Dim filter As String = "年度 = '" & Date.Today.year & "'"
    If e.DataRow("企业名称") = Nothing Then
        filter &= " and 企业名称 is null"
    Else
        filter &= " and 企业名称 = '" & e.DataRow("企业名称") & "'"
    End If
    Dim nr As DataRow = DataTables("安全费用提取").Find(filter,"年度 DESC",1)
    If nr IsNot Nothing Then
        e.Cancel = True '那么取消输入并提示用户
        'Dim Result As DialogResult
        'Result =
        MessageBox.Show("本年度本公司已添加了安全费用提取记录,禁止重复添加! 请删除当前行或添加其他企业!", "提示", MessageBoxButtons.OK, MessageBoxIcon.warning)
        'If Result = DialogResult.Yes Then
        'e.DataRow.Delete
        'Else
        'End If
        e.DataRow("企业名称") = Nothing
    Else
    End If
End If


Select Case e.DataCol.Name
    '自动填入上年度结余的值
    Case "企业名称"
        If e.DataRow.Isnull("企业名称")  Then
            e.DataRow("上年度结余") = Nothing
        Else
            Dim fdr As DataRow = DataTables("安全费用使用").find("年度 = '" & e.DataRow("年度") - 1 & "' and 月度 = '12' and 企业名称 = '" & e.DataRow("企业名称") & "'","本月余额",0) '填写上年度结余
            If fdr IsNot Nothing Then
                If fdr("本月余额") > "0" Then  '年底结余为负数时,清零
                    e.DataRow("上年度结余") = fdr("本月余额")
                Else
                    e.DataRow("上年度结余") = "0"
                End If
            End If
        End If
    Case "上年度营业收入" '如果更改的是列
        If e.DataRow.Isnull("行业类型") = False Then
            If e.DataRow.IsNull("上年度营业收入") AndAlso e.DataRow.IsNull("上年度结余") Then '是否为空
                e.DataRow("本年度应提取额") = Nothing '如果为空,则为空
                e.DataRow("每月提取额") = Nothing '如果为空,则为空
            End If
            
            If e.DataRow("上年度营业收入") <= 10000000 Then
                Dim drq As DataRow = DataTables("安全费用提取比例").find("行业类型 = '" & e.DataRow("行业类型") & "' and 营业收入档次1 <= " & e.DataRow("上年度营业收入") & " And 营业收入档次2 > " & e.DataRow("上年度营业收入"))  '填写上年度结余
                If drq IsNot Nothing Then
                    e.DataRow("本年度应提取额") = e.DataRow("上年度营业收入") * drq("提取比例")  '+ e.DataRow("上年度结余") '此处重复,12月余额直接计入下年1月
                    e.DataRow("每月提取额") = e.DataRow("本年度应提取额")/12
                End If
            End If
            If  e.DataRow("上年度营业收入") > 10000000 AndAlso e.DataRow("上年度营业收入") <= 100000000 Then
                Dim drq As DataRow = DataTables("安全费用提取比例").find("行业类型 = '" & e.DataRow("行业类型") & "' and 营业收入档次1 <= " & e.DataRow("上年度营业收入") & " And 营业收入档次2 > " & e.DataRow("上年度营业收入"))
                Dim drk As DataRow = DataTables("安全费用提取比例").find("行业类型 = '" & e.DataRow("行业类型") & "' and 营业收入档次2 = 10000000")
                If drq IsNot Nothing Then
                    e.DataRow("本年度应提取额") = (e.DataRow("上年度营业收入") - 10000000) * drq("提取比例") + 10000000 * drk("提取比例")  '+ e.DataRow("上年度结余") '此处重复,12月余额直接计入下年1月
                    e.DataRow("每月提取额") = e.DataRow("本年度应提取额")/12
                End If
            End If
        End If
End Select

原来使用的是阿里云,现在改成本机ACCESS,原来的时候能自动计算:本年度应提额、每月提取额,自从改成ACCESS后不自动计算了。请老师帮忙看看代码哪里有问题,应如何更改?谢谢!
2楼
有点蓝 发表于:2025/3/31 20:17:00
看不出什么问题。请上传实例测试
共2 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02344 s, 2 queries.