Programmer:Item Opening Maintenance v2: Difference between revisions

m
no edit summary
(Created page with "==Technical Specification== #Quantity of the Item Opening must not be zero #*When adding a new entry to Item Opening, zero qty entry will be removed before saving to database...")
 
mNo edit summary
 
(11 intermediate revisions by the same user not shown)
Line 15:
#*The filtering will have impact on adding new record of an ItemCode that is not in the range of the filtered range.
#*:If the newly added ItemCode is not in the filter range, system throw exception message of "Item Code is not in Filter range."
#The value of '''Seq''' cannot repeat the same, when the value of below columns are all the same, or already exist in the record of Item Opening:
#*ItemCode
#*UOM
Line 21:
#*BatchNo
#:If there is any occasion when '''Seq''' is repeated for the same ItemCode, UOM, Location and BatchNo, below error message is thrown:
#:'''Sequence for Item''' 'FG00001', '''UOM''' 'UNIT', '''Location''' 'HQ', '''BatchNo''' ' ' '''is not correct'''.
#'''Seq''' will affect how the '''cost''' of '''FIFO''' and '''LIFO''' is calculated.
 
==References of AutoCount Accounting version 2.0==
{{BaseReferenceAC20}}
'''AutoCount.StockMaint.dll'''
 
<br/>
Line 133 ⟶ 138:
 
===Adding two entries of same ItemCode to Item Opening===
ThisFollowing example shows the increase of '''Seq''' when 2nd entry of Item Opening has the same '''ItemCode''', '''UOM''', '''Location''' and '''BatchNo''' from the 1st entry.
<syntaxhighlight lang="csharp" highlight="22-24,31-33,27,36">
public void NewTwoEntriesOfSameItem(AutoCount.Authentication.UserSession userSession)
{
Line 185 ⟶ 190:
 
==Delete Item Opening entry==
ThereWhen may be time whendelete existing item opening entry, has"ItemOpeningKey" to be deleted before addingis required.<br/ update to Item Opening.>
This example uses a function to find the ItemOpeningKey.<br/>
This can avoid the error of '''"Sequence for Item 'FG00001', UOM 'UNIT', Location 'HQ', BatchNo '' is not correct."'''
Highlighted shows the function to get the list of keys and deletion of existing keys.<br/><br/>
<syntaxhighlight lang="csharp">
ThisGet "ItemOpeningKey" can also be 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(AutoCount.Authentication.UserSession userSession)
{
Line 242 ⟶ 249:
</syntaxhighlight>
 
Function to find a list of keys that is/are matching.
 
<syntaxhighlight lang="csharp">
public List<long> GetExistItemOpeningKey(DataTable table, string itemCode, string uom, string location, string batchNo)
{
return table.AsEnumerable().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();
}
</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/>
{{SeeAlsoStockV2}}
{{NavigateDeveloper}}