Foxtable(狐表)用户栏目专家坐堂 → datacolchanged事件不计算了


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

主题:datacolchanged事件不计算了

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


加好友 发短信
等级:小狐 帖子:381 积分:3625 威望:0 精华:0 注册:2012/7/24 7:15:00
datacolchanged事件不计算了  发帖心情 Post By: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楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:113176 积分:576309 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2025/3/31 20:17:00 [只看该作者]

看不出什么问题。请上传实例测试

 回到顶部