I have worked through the code to Auto Increment the UD100 table using a Post Processing Directive. While this is not optimal (because of the potential to create a duplicate entry), I think it will work well enough as the data entry screen will be used primarily by only one user at the shipping station.
What I am looking to do now, is also auto increment the UD100A table rows that are tied to the UD100 row (starting with Line 1 - ChildKey1 - and incrementing by 1 for each new addition). I have gotten as far as duplicating the UD100 code (see below):
UD100 GetNewUD100 - Post Process BPM:
//β Ice.Tables.UD100
//β
//β Auto Increment Key1 Value for Transfer Shipment Entry, Parent Table
foreach (var ttUD100_Recs in (from ttUD100_Row in ttUD100
where ttUD100_Row. Company == Session.CompanyID
&& string.Equals(ttUD100_Row.RowMod, IceRow.ROWSTATE_ADDED, StringComparison.OrdinalIgnoreCase)
select ttUD100_Row))
{
var ttUD100Row = ttUD100_Recs;
if (ttUD100_Recs != null)
{
Ice.Tables.UD100 UD100;
var UD100_Recs = (from UD100_Row in Db.UD100
where UD100_Row.Company == Session.CompanyID
orderby UD100_Row.Key1 descending
select UD100_Row).FirstOrDefault();
{
var UD100Row = UD100_Recs;
if (UD100_Recs == null)
{
ttUD100Row.Key1 = β100001β;
}
else
{
ttUD100Row.Key1 =(System.Convert.ToInt32(UD100_Recs.Key1)+ 1).ToString();
}
}
}
}
UD100 GetNewUD100A - Post Process BPM:
//β Ice.Tables.UD100A
//β
//β Auto Increment Key1 Value for Transfer Shipment Entry, Parent Table
foreach (var ttUD100A_Recs in (from ttUD100A_Row in ttUD100A
where ttUD100A_Row. Company == Session.CompanyID
&& string.Equals(ttUD100A_Row.RowMod, IceRow.ROWSTATE_ADDED, StringComparison.OrdinalIgnoreCase)
select ttUD100A_Row))
{
var ttUD100ARow = ttUD100A_Recs;
if (ttUD100A_Recs != null)
{
Ice.Tables.UD100A UD100A;
var UD100A_Recs = (from UD100A_Row in Db.UD100A
where UD100A_Row.Company == Session.CompanyID &&
UD100A_Row.Key1 == ttUD100ARow.Key1
orderby UD100A_Row.ChildKey1 descending
select UD100A_Row).FirstOrDefault();
{
var UD100ARow = UD100A_Recs;
if (UD100A_Recs == null)
{
ttUD100ARow.Key1 = β1β;
}
else
{
ttUD100ARow.Key1 =(System.Convert.ToInt32(UD100A_Recs.Key1)+ 1).ToString();
}
}
}
}
Being kind of new to all of this, I am getting an error when I go to add the new child to the parent table:
The INSERT statement conflicted with the FOREIGN KEY constraint βFK_UD100A_UD100β. The conflict occurred in database βE10-TestDBβ, table βIce.UD100β.
The statement has been terminated.
There is probably an easy way to sync the two tables. Looking for help to trouble shoot and solve the problem.
Thanks!