Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to find a duplicate row in a datawindow ?

890 views
Skip to first unread message

ghkum...@yahoo.com

unread,
Feb 14, 2007, 11:57:40 PM2/14/07
to
How to find a duplicate row in a datawindow ? For eg: In the
order entry application for Anchor Bay Nut Company , a
application with older PB Version , have two datawindows
dw_ordmaster and dw_orddetail. In the datawindow
dw_orddetail have a column item_prod_id which is a drop down
datawindow from product table . I want to allow to select
one item_prod_id with each order_id , If the customer again
select the same item_prod_id again in the same order_id , I
want to inform the customer that duplicate product selected
and item error event is executed
Any Clue?

Asif Shoukat

unread,
Feb 15, 2007, 5:31:13 AM2/15/07
to

Hi,

you can check the duplication on item change event of
dropdowndatawindow column for all rows with loop from 1st Row to last
row

this loop will terminate immediately when a duplicate item found in
the product_id found in the same order and a boolean variable can be
used which will contain true if found duplicate

and after exitting the loop you can check that duplicate variable if
its value is true you can prompt a message to user for duplication

or

you can check duplication when you are about to save the order on pre
update with loop from 1 to all rows of the product detail datawindow.

i will preffer 2nd option coz it will save the processing.

hope it will give you some clue

Regards

Asif Shoukat
Sr. Software Engineer
NetSol Technologies Limited
www.netsoltek.com


Mitch

unread,
Feb 15, 2007, 7:18:31 AM2/15/07
to
How about just removing, or filtering out, the product id's
from the product dddw when a product is added to the order?
Why give an error msg when you can prevent the error in the
first place?

ghkum...@yahoo.com

unread,
Feb 15, 2007, 7:31:38 AM2/15/07
to
How to remove? It is a dddw and it retrieves first when the
datawindow opens.

Mitch

unread,
Feb 15, 2007, 9:10:34 AM2/15/07
to
When user adds a product id to the order, get the datawindow
child and:

1. Find the product id and deleterow.

2. Set filter to "product_id <> 'prodid1' AND product_id <>
'prodid2' ... this is better - only one retrieval

When user starts a new order re-retrieve dddw (if you
deleted the rows) or set filter to ''

Paul Horan[TeamSybase]

unread,
Feb 15, 2007, 9:51:50 AM2/15/07
to
In the ItemChanged event, just do a this.Find( 'item_prod_id = ' + data + '
and getRow() <> ' + string( row ), 1, this.rowCount() )

If that returns a value > 0, you have a duplicate, and you can flag the
error.

I usually try and prevent someone from making an error, rather than let them
and throw an error message, but this is 1 line, and it's pretty quick to
implement.

Paul Horan[TeamSybase]

<ghkum...@yahoo.com> wrote in message
news:45d3e844.27f...@sybase.com...

ArmanPorky

unread,
Feb 16, 2007, 12:17:40 AM2/16/07
to
Hi,

Personally, I prefer Paul's suggestion, it's simple and
straight forward. Also, filtering or deleting rows from a
child datawindow will definitely require a lot of coding,
why?

- If you use delete, what if the user goes back to that row
and edits that column again? You have to move that row (and
that row only) from the deleted buffer to the primary buffer
again (haven't tried though, since I'm not sure if deleted
buffer exists for child datawindows). Also, after doing
that, you have to delete that row again.

- If you use filter, you have to track all IDs that are
already selected in other rows (besides the current) and
apply that as the filter. If you code the filtering in the
dropdown user event (pbm_dwndropdown), its quite easy,
however, you have to trap also the keystrokes (say, arrow
down and arrow up). Probably better yet code this on the
itemfocuschanged and/or rowfocuschanged).

But again, it is a lot of work compared to the one liner...

HTH,

Arman

ghkum...@yahoo.com

unread,
Feb 16, 2007, 12:29:54 AM2/16/07
to
Any Sample code available ?

Mitch

unread,
Feb 16, 2007, 7:01:33 AM2/16/07
to
Look up ...
ItemChanged()
GetChild()
SetFilter()
Filter()
DeleteRow()

.... in the help file.

0 new messages