以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- 代码怎么不执行呢? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=97559)
|
-- 作者:hebxtshhyj
-- 发布时间:2017/3/14 17:51:00
-- 代码怎么不执行呢?
datacolchanging中,如下代码:
Select Case e.DataCol.Name Case "销售数量_片数","销售数量_破损片" Dim dr As DataRow = e.DataRow Dim kcdr As DataRow = DataTables("商品信息表").Find("产品ID = \'" & e.DataRow("产品ID") & "\'") Dim xssl As Double = dr("销售数量_片数") + dr("销售数量_破损片")
If xssl > kcdr("库存_片数量") Then e.Cancel = True MessageBox.show("销售数量超过库存数量!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning) End If
End Select
怎么代码不执行呢?
|
-- 作者:有点蓝
-- 发布时间:2017/3/14 17:59:00
--
这2个列 "销售数量_片数","销售数量_破损片"值变化后才会触发事件
Select Case e.DataCol.Name Case "销售数量_片数","销售数量_破损片" Dim dr As DataRow = e.DataRow Dim kcdr As DataRow = DataTables("商品信息表").Find("产品ID = \'" & e.DataRow("产品ID") & "\'") Dim xssl As Double = dr("销售数量_片数") + dr("销售数量_破损片") If kcdr IsNot Nothing Then msgbox("xssl =" & xssl & ",库存_片数量=" & kcdr("库存_片数量")) \'弹出看看是不是条件不符合 If xssl > kcdr("库存_片数量") Then e.Cancel = True MessageBox.show("销售数量超过库存数量!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning) End If End If End Select
|
-- 作者:hebxtshhyj
-- 发布时间:2017/3/14 18:02:00
--
我在这两列输入了值,代码还是不执行啊。
|
-- 作者:有点蓝
-- 发布时间:2017/3/14 18:04:00
--
没有符合条件的数据吧
|
-- 作者:hebxtshhyj
-- 发布时间:2017/3/15 7:30:00
--
寻找的是父表的数据啊。可以肯定不是这个原因。
[此贴子已经被作者于2017/3/15 7:33:23编辑过]
|
-- 作者:有点蓝
-- 发布时间:2017/3/15 9:16:00
--
调试技巧:http://www.foxtable.com/webhelp/scr/1485.htm
看执行到那一句代码
|
-- 作者:有点色
-- 发布时间:2017/3/15 9:27:00
--
建议你写到DataColChanged事件吧。
如果写到ing事件,要这样改的
Select Case e.DataCol.Name Case "销售数量_片数","销售数量_破损片" Dim dr As DataRow = e.DataRow Dim kcdr As DataRow = DataTables("商品信息表").Find("产品ID = \'" & e.DataRow("产品ID") & "\'") Dim xssl As Double If e.DataCol.name = "销售数量_片数" Then xssl = e.newvalue + dr("销售数量_破损片") ElseIf e.DataCol.name = "销售数量_破损片" then xssl = dr("销售数量_片数") + e.newvalue End If If kcdr IsNot Nothing Then msgbox("xssl =" & xssl & ",库存_片数量=" & kcdr("库存_片数量")) \'弹出看看是不是条件不符合 If xssl > kcdr("库存_片数量") Then e.Cancel = True MessageBox.show("销售数量超过库存数量!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning) End If End If End Select
|