Page 1 of 1

Stocktake - add line

PostPosted: Mon Sep 18, 2017 1:12 pm
by perry
Hi,
v7.0.157

Can you please advise if it is possible to add stock take lines from code?

I'm trying add new line to stock take by stocktake.StockTakeLines.Add(item as JiwaStockTake.StockTakeLine) method
However, I get stuck at initializing a new JiwaStockTake.StockTakeLine record, "InventoryID" property is read only

What I'm trying to do is to generate the stock take without zero SOH, then allow user to append additional lines (where SOH = 0 and count > 0).




Regards,
Perry Ma

Re: Stocktake - add line  Topic is solved

PostPosted: Tue Sep 19, 2017 8:41 am
by SBarnes
Hi Perry,

Have a look FindStock on the stock take it doesn't clear the collection and just add items based on the criteria, it actually sets the the InventoryID which is actually internal to the stock take dll, which makes it the equivalent of read only for what you are trying to do but gives the stock take access to setting it when FindStock is called.

Mike or Scott may be able to tell another way but I think this is what you need to do.

Code: Select all
public void FindStock(string FromPartNo, string ToPartNo, string FromBinLocation, string ToBinLocation, string FromCat1, string ToCat1, string FromCat2, string ToCat2, string FromClassification, string ToClassification, bool GetZeroSOH, int MaxRows)

Re: Stocktake - add line

PostPosted: Tue Sep 19, 2017 1:52 pm
by perry
Hi Stuart,

Thanks for your suggestion. I saw this method and assumed it would clear existing rows.

I tested with code below and it worked perfectly. It loaded 500 lines in less than 10 secs.

Code: Select all
For Each row As DataRow In dt.Rows
    'testing
      binLocation = If(IsDBNull(row("BinLocation")), "", row("BinLocation"))
      comment = If(IsDBNull(row("Comment")), "", row("Comment"))
      partno = If(IsDBNull(row("PartNo")), "", row("PartNo"))
      If Not String.IsNullOrEmpty(partno) Then
         stock.FindStock(partno, partno, binLocation, binLocation, "", "Z", "", "Z", "", "Z", True, 1)
      End If
      
Next