PB中如何判断数据窗口发生的改变

本文介绍了一种检测数据窗口中具体哪一行的哪些列发生改变的方法。通过增加计算列标记修改状态,并利用循环和条件判断来精确找出变化的具体位置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题:

一个数据窗口的数据发生了改变,但是该如何确定是哪些行的哪些列发生了改变?

 

方法:
(注:本方法仅限于对数据 修改的判断,不包含新增或删除的数据)

Step 1,在数据窗口中加入一个计算列 if(IsRowModified(),'Y','N'),命名为 ismodified , 用来判断对应的数据行是否有改变。

Step 2, 编写检验代码

If dw_ticket.ModifiedCount() = 0 Then Return

String ls_objects, ls_obj, ls_label, ls_coltype, ls_colvalue1, ls_colvalue2
Long	ll_pos, ll_getrow, ll_rows
String	ls_modified_col

dw_ticket.AcceptText()
ll_rows = dw_ticket.RowCount()

For ll_getrow = 1 To ll_rows
	If dw_ticket.GetItemString(ll_getrow,'ismodified') = 'N' Then Continue
	
	ls_modified_col = ''
	ls_objects = dw_ticket.Describe("DataWindow.Objects") + "~t"

	Do
		ll_pos = pos(ls_objects, "~t")
		ls_obj = left(ls_objects,ll_pos - 1)
		
		If (dw_ticket.describe(ls_obj+ ".type")) <> "column" Then
			ls_objects = right(ls_objects,len(ls_objects) - ll_pos) 
			Continue
		End If
		
		ls_coltype = dw_ticket.Describe(ls_obj + ".coltype")
		ls_label = dw_ticket.Describe(ls_obj + "_t.text")
		
		If ll_getrow > 0 Then
			If Pos(ls_coltype, 'char') > 0 Then
				ls_colvalue1 = dw_ticket.GetItemString(ll_getrow, ls_obj, Primary!, True)
				ls_colvalue2 = dw_ticket.GetItemString(ll_getrow, ls_obj, Primary!, False)
			ElseIf Pos(ls_coltype, 'datetime') > 0 Then
				ls_colvalue1 = String(dw_ticket.GetItemDateTime(ll_getrow, ls_obj, Primary!, True))
				ls_colvalue2 = String(dw_ticket.GetItemDateTime(ll_getrow, ls_obj, Primary!, False))
			ElseIf Pos(ls_coltype, 'timestamp') > 0 Then
				ls_colvalue1 = dw_ticket.GetItemString(ll_getrow, ls_obj, Primary!, True)
				ls_colvalue2 = dw_ticket.GetItemString(ll_getrow, ls_obj, Primary!, False)
			ElseIf Pos(ls_coltype, 'long') > 0 Then
				ls_colvalue1 = String(dw_ticket.GetItemNumber(ll_getrow, ls_obj, Primary!, True))
				ls_colvalue2 = String(dw_ticket.GetItemNumber(ll_getrow, ls_obj, Primary!, False))
			ElseIf (Pos(ls_coltype, 'number') > 0 Or Pos(ls_coltype, 'decimal') > 0) Then
				ls_colvalue1 = String(dw_ticket.GetItemDecimal(ll_getrow, ls_obj, Primary!, True))
				ls_colvalue2 = String(dw_ticket.GetItemDecimal(ll_getrow, ls_obj, Primary!, False))
			ElseIf Pos(ls_coltype, 'real') > 0 Then
				ls_colvalue1 = String(dw_ticket.GetItemDecimal(ll_getrow, ls_obj, Primary!, True))
				ls_colvalue2 = String(dw_ticket.GetItemDecimal(ll_getrow, ls_obj, Primary!, False))
			End If
			
			If ls_colvalue1 <> ls_colvalue2 Then
				ls_modified_col = ls_modified_col + ls_obj + "~t"
			End If
			
		End If
		
		ls_objects = right(ls_objects,len(ls_objects) - ll_pos) 
	Loop While (Pos(ls_objects, "~t") > 0)
	
	MessageBox("Info","The row: " + String(ll_getrow) + " is modified." + "~r~nModified Columns: " + ls_modified_col)

Next



 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值