以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]代码不执行 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=96637) |
||||
-- 作者:铜豆 -- 发布时间:2017/2/24 20:26:00 -- [求助]代码不执行 Select Case e.DataCol.Name Case "日期" If e.DataRow("日期") IsNot Nothing Then Dim dr, dr1 As DataRow dr1 = DataTables("分摊目录").Find("[百度禁止分摊] = \'" & e.DataRow("姓名") & "\'") If dr1 IsNot Nothing Then e.DataRow("费用") = 1 Else e.DataRow("费用") = Nothing End If dr = DataTables("分摊目录").Find("[姓名] = \'" & e.DataRow("姓名") & "\' and [日期]=#" & e.DataRow("日期") & "#") If dr IsNot Nothing Then e.DataRow("离四") =1 Else e.DataRow("离四") =Nothing End If End If End Select 上述代码必须重置否则不执行
|
||||
-- 作者:有点蓝 -- 发布时间:2017/2/24 20:41:00 -- 如果是DataColChanged事件,只有重置,或者日期列单元格的值改变才会执行 |
||||
-- 作者:有点蓝 -- 发布时间:2017/2/24 20:42:00 -- 判断是否为空尽量使用isnull If e.DataRow.isnull("日期") = falseThen
|
||||
-- 作者:铜豆 -- 发布时间:2017/2/24 20:50:00 -- 老师我是粘贴在里面,是不执行的,日期列也是粘贴在里面,用isnull 也不执行,必须重置,奇怪了,我看了代码都没问题 |
||||
-- 作者:有点蓝 -- 发布时间:2017/2/24 21:24:00 -- 1、日期没有变 2、没有符合粘贴的日期的数据
|
||||
-- 作者:铜豆 -- 发布时间:2017/2/24 21:28:00 -- 昨天还可以今天就无法计算,想了很久,实在想不通 有时候还会出现这样的错误提示:无法在 System.DateTime 和 System.String 上执行“=”操作。
|
||||
-- 作者:有点蓝 -- 发布时间:2017/2/24 21:36:00 -- 上例子测试。 用isnull判断就不会出现这个错误提示了
|
||||
-- 作者:铜豆 -- 发布时间:2017/2/24 22:10:00 -- 老师你都帮我测试一下,感觉总体都有点问题,我的数据录入主要是粘贴上去的,谢谢老师
|
||||
-- 作者:有点蓝 -- 发布时间:2017/2/24 22:29:00 -- Select Case e.DataCol.Name Case "姓名" If e.NewValue > "" Then Dim dr, dr1 As DataRow dr1 = DataTables("分摊目录").Find("[百度禁止分摊] = \'" & e.DataRow("姓名") & "\'") If dr1 IsNot Nothing Then e.DataRow("费用") = 1 Else e.DataRow("费用") = Nothing End If If e.DataRow.IsNull("日期") = False Then dr = DataTables("分摊目录").Find("[姓名] = \'" & e.DataRow("姓名") & "\' and [日期]=#" & e.DataRow("日期") & "#") If dr IsNot Nothing Then e.DataRow("离四") =1 Else e.DataRow("离四") = Nothing End If End If Else e.DataRow("费用") = Nothing End If Case "日期" If e.DataRow.IsNull("日期") = False Then Dim dr, dr1 As DataRow dr = DataTables("分摊目录").Find("[姓名] = \'" & e.DataRow("姓名") & "\' and [日期]=#" & e.DataRow("日期") & "#") If dr IsNot Nothing Then e.DataRow("离四") =1 Else e.DataRow("离四") = Nothing End If Dim gd,gd1,gd2,gd3,gd4,gd5,gd6 As Double gd = DataTables("商务通参与邀请").Compute("Sum(费用)","[日期] = \'" & e.NewValue & "\'" ) gd1 = DataTables("商务通参与邀请").Compute("Sum(离四)","[日期] = \'" & e.NewValue & "\'" ) gd2 = DataTables("网站消费").Compute("Sum(点击)","[日期] = \'" & e.NewValue & "\'") gd3 = DataTables("网站消费").Compute("Sum(消费)","[日期] = \'" & e.NewValue & "\'") gd4 = DataTables("离线宝").Compute("Sum(非重复数量)","[开始时间] = \'" & e.NewValue & "\'") gd5 = DataTables("四零零").Compute("Sum(非重复数量)","[开始时间] = \'" & e.NewValue & "\'") If e.DataRow.Isnull("费用") Then e.DataRow("点击") = Nothing e.DataRow("消费") = Nothing Else e.DataRow("点击") = gd2/gd e.DataRow("消费") = gd3/gd End If If e.DataRow.Isnull("离四") Then e.DataRow("离线宝") = Nothing e.DataRow("电话400") = Nothing Else e.DataRow("离线宝") = gd4/gd1 e.DataRow("电话400") = gd5/gd1 End If Else e.DataRow("离线宝") =Nothing e.DataRow("电话400")= Nothing e.DataRow("点击")= Nothing e.DataRow("消费")= Nothing e.DataRow("费用")= Nothing e.DataRow("离四")= Nothing End If End Select Dim idx As Integer = Tables("商务通参与邀请").FindRow(e.DataRow) If idx = Tables("商务通参与邀请").rows.count-1 Then DataTables("商务通参与邀请").addnew End If
[此贴子已经被作者于2017/2/24 22:29:13编辑过]
|
||||
-- 作者:铜豆 -- 发布时间:2017/2/25 12:13:00 -- 数据粘贴后还是不会自动计算 ![]() ![]() 包含点击以后就不会自动计算 我测试发现,先把出日期以为的数据粘贴好,然后最后粘贴日期就能计算了,但是数据粘贴是从上到下的顺序,计算也是如此,导致数据结果不对,必须重置后才可得到正确结果,为此老师有什么好的方法吗
[此贴子已经被作者于2017/2/25 13:04:26编辑过]
|