以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]救命呀,getparentrow  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=55046)

--  作者:tele
--  发布时间:2014/8/9 16:10:00
--  [求助]救命呀,getparentrow

BeforeADDDateRows:

 

If  e.DataRow.GetParentRow("订单表")("订单状态") > "待确认" Then

MessageBox.Show("已确认的订单不能新增明细!")
e.Cancel = True
  End If

 

出错!

 

.NET Framework 版本:2.0.50727.5477
Foxtable 版本:2014.7.24.1
错误所在事件:订单明细表,BeforeAddDataRow
详细错误信息:
未将对象引用设置到对象的实例。

注释掉就没有问题!

 

 


--  作者:Bin
--  发布时间:2014/8/9 16:21:00
--  

BeforeADDDateRow事件是新增行之前

新增行之前,行数据还是空的,怎么会有父表行呢



--  作者:Bin
--  发布时间:2014/8/9 16:22:00
--  
而且代码不严谨,判断空值无论何时都是有必要的

dim dr as datarow = e.DataRow.GetParentRow("订单表")
if dr isnot nothing then

If  dr("订单状态") > "待确认" Then

MessageBox.Show("已确认的订单不能新增明细!")
e.Cancel = True
  End If

end if


--  作者:tele
--  发布时间:2014/8/9 16:30:00
--  
以下是引用Bin在2014-8-9 16:21:00的发言:

BeforeADDDateRow事件是新增行之前

新增行之前,行数据还是空的,怎么会有父表行呢


根据父表列的值,判断是否允许增加行,应该怎么写呢?


--  作者:tele
--  发布时间:2014/8/9 16:31:00
--  
以下是引用Bin在2014-8-9 16:22:00的发言:
而且代码不严谨,判断空值无论何时都是有必要的

dim dr as datarow = e.DataRow.GetParentRow("订单表")
if dr isnot nothing then

If  dr("订单状态") > "待确认" Then

MessageBox.Show("已确认的订单不能新增明细!")
e.Cancel = True
  End If

end if

哦~~谢谢,其实是有判断的,只是复制了一小段