Programmer:Item Opening Maintenance: Difference between revisions

no edit summary
mNo edit summary
No edit summary
Line 186:
 
==Delete Item Opening entry==
When delete existing item opening entry, has to be deleted before adding / update to"ItemOpeningKey" Itemis Openingrequired.<br/>
This example uses a function to find the ItemOpeningKey.<br/>
Checking the existing record can avoid the error of '''"Sequence for Item 'FG00001', UOM 'UNIT', Location 'HQ', BatchNo ' ' is not correct."'''<br/>
Highlighted shows the function to get the list of keys and deletion of existing keys.<br/><br/>
CheckingGet "ItemOpeningKey" can be also applied to check the existing record when it can avoid the error of <br/>'''"Sequence for Item 'FG00001', UOM 'UNIT', Location 'HQ', BatchNo ' ' is not correct."'''<br/>
<syntaxhighlight lang="csharp" highlight="22,23">
public void CheckNewEntryBeforeAdding(BCE.Data.DBSetting dbSetting)
Line 248 ⟶ 249:
public List<long> GetExistItemOpeningKey(DataTable table, string itemCode, string uom, string location, string batchNo)
{
return table.AsEnumerable().Where(r => r.RowState != DataRowState.Deleted &&
r.RowState != DataRowState.Deleted &&
r.Field<string>("ItemCode") == itemCode &&
r.Field<string>("UOM") == uom &&
Line 259:
</syntaxhighlight>
 
Another function to specially handle Deleting matching Item Opening
<syntaxhighlight lang="csharp">
public void DeleteAllMatchingItemOpening(IEnumerable<DataRow> itemOpenings, string itemCode, string uom, string location, string batchNo, Action<long> deleteOpening)
{
itemOpenings.Where(r => r.RowState != DataRowState.Deleted &&
r.Field<string>("ItemCode") == itemCode &&
r.Field<string>("UOM") == uom &&
r.Field<string>("Location") == location &&
r.Field<string>("BatchNo") == batchNo
).Select(r => r.Field<long>("ItemOpeningKey"))
.ToList().ForEach(key => deleteOpening(key));
}
</syntaxhighlight>
To apply this function code;
<syntaxhighlight lang="csharp">
DeleteAllMatchingItemOpening(entities.ItemOpeningTable.AsEnumerable(), "FG00001", "UNIT", "HQ", null, entities.DeleteItemOpening);
</syntaxhighlight>
<br/>
{{SeeAlsoStock}}
{{NavigateDeveloper}}