|
I have a situation that does not fit into the tableadapter mold that I'm looking for some opinions on. I have two datatables. One is a parent (CheckInOutDetail) and one is the child to that parent (CheckInOutUnit)on one form. The parent lists products to be shipped.the child lists the available serial numbers to be shipped (if that particular product is serialized). Initially,both tables are loadedwith the list of items to ship and available serial numbers. The user then fills in an empty column in the CheckInOutDetailDataTable with the quantities of each item listed to be shipped and they check off an empty checkboxcolumn in the checkInOutunitDataTable to indicate which of the serial numbers are to be shipped. when both are saved I want a new record for each row in these tables to be inserted to the database with the information. i've been able to achieve the first part of this (without the serial numbers) by assigning an "insert" SPROC to the update method of the first table. however, the problem with this is that the second table needs to know which record from the first table each record is associated with and since they have not yeat been created, their identity number does not yet exist. typically, using the standard "insert" method for the datatable, the tableadapter would hande this by waiting to get the returned identity on the first table before inserting rows from the second table. however, in my scenario, since the table is already losded, none of the rows are recignized as being "new" because they already exist. however, they are recognized as needing to be updated when I type a quantity in the empty column.
Any idea's how best to work around this? Should I continue using the "update" method? If so, how do I get the identities from the first table to use in the second table. Or, is there a way to manually mark certain rows as new then use the "insert" method and will that solve my problem?
here is an example: (the NULL values are what the use will fill in. CHECKINOUTDETAIL OrderHeaderIDQuantityOrderQuantityProductNumber 8NULL3 SP1 8NULL3 SP2 8NULL3SP3 8NULL2SP2 8NULL1SP1
CHECKINOUTUNIT OrderHeaderIDQuantityOrderQuantityProductNumber ProductID 8NULL1SP1 1 8NULL2SP1 1 8NULL3SP1 1 8NULL1SP2 2 8NULL2SP2 2 8NULL3SP2 2 8NULL1SP3 3 8NULL2SP3 3 8NULL3SP3 3 8NULL1SP2 2 8NULL2SP2 2 8NULL3SP2 2 8NULL1SP1 1 8NULL2SP1 1 8NULL3SP1 1
|