How Add a tableset CustShip.SelectedSerialNumbers a new row


(Santiago Quintero) #1

Hello, I am creating a customer shipment, from the api rest, but when selecting the series of a part, I did not find how to create a new record in the tableset, previously it was:

foreach (SelectedSerialNumbersDataSet.SelectedSerialNumbersRow drr in ssds.SelectedSerialNumbers.Rows)
if (drr.SerialNumber == Series)
drr.RowMod = “A”;
csds.SelectedSerialNumbers.Rows.Add (drr.ItemArray);

I try with the tableset in the following way, without obtaining positive results

foreach (var drr in dSelected.SelectedSerialNumbers)
if (drr.SerialNumber == ds.Tables [0] .Rows [dr.OrderLine - 1] [“SerialNum”]. ToString ())
drr.RowMod = “A”;
cs.SelectedSerialNumbers.NewRow ();
cs.SelectedSerialNumbers.Add (drr);


Beforehand thank you very much

(Chris Conn) #2

What errors are you getting. Also, more code to use for context would be helpful.

what is ds?
what is drr?

(Santiago Quintero) #3

ds: it is a dataset that has the information of the client’s order, part, quantity, warehouse …

drr: it the row of Erp.Tableset.SelectedSerialNumbersTableset

cs: Erp.Tablesets.CustShipTableset.

I need create a new row in cs.SelectedSerialNumbers and that row is drr

(Chris Conn) #4

You still didnt tell me what your error was, if I had to guess, it’s complaining when you try to add that row.

cs.SelectedSerialNumbers.NewRow (); has no effect other than adding a blank row, generally, you would assign that to a var to work on the actual row it creates like:
var newrow = cs.SelectedSerialNumbers.NewRow ();
newrow[“MyField”] = myValue;

In your case, it seems you are trying to add a row from a different table. Assuming they are identical types (cause this wont work otherwise), you will need to use cs.SelectedSerialNumbers.ImportRow(drr); Also, the NewRow() as mentioned earlier is not needed.

(Santiago Quintero) #5


this is the solution.

var drSNF = cs.SNFormat.NewRow();
drSNF[“Company”] = drSn.Company;
drSNF[“Plant”] = drSn.Plant;
drSNF[“PartNum”] = drSn.PartNum;
drSNF[“NumberOfDigits”] = drSn.NumberOfDigits;
drSNF[“SNBaseDataType”] = drSn.SNBaseDataType;
drSNF[“SNFormat”] = drSn.SNFormat;
drSNF[“LeadingZeroes”] = drSn.LeadingZeroes;
drSNF[“HasSerialNumbers”] = drSn.HasSerialNumbers;
drSNF[“SysRowID”] = drSn.SysRowID;
drSNF[“BitFlag”] = drSn.BitFlag;
drSNF[“PartPricePerCode”] = drSn.PartPricePerCode;
drSNF[“PartTrackLots”] = drSn.PartTrackLots;
drSNF[“PartTrackSerialNum”] = drSn.PartTrackSerialNum;
drSNF[“PartTrackDimension”] = drSn.PartTrackDimension;
drSNF[“PartSalesUM”] = drSn.PartSalesUM;
drSNF[“PartIUM”] = drSn.PartIUM;
drSNF[“PartSellingFactor”] = drSn.PartSellingFactor;
drSNF[“PartPartDescription”] = drSn.PartPartDescription;
drSNF[“SerialMaskMaskType”] = drSn.SerialMaskMaskType;
drSNF[“RowMod”] = “A”;