Page 1 of 1

More range(s) for Stocktake form

PostPosted: Mon Jun 07, 2021 5:00 pm
by DannyC
Along similar lines as viewtopic.php?f=26&t=1139

Client has asked how hard it would be to add a range for Supplier.

I've reviewed the plugin from the thread above but it's beyond me to add a range.

Don't need a column in the lines to display the supplier, all I really need to do is just add a range filter so the user can just get items for a given supplier(s).

Re: More range(s) for Stocktake form

PostPosted: Mon Jun 07, 2021 5:58 pm
by SBarnes
It's actually a bit different to the post you mentioned as this doesn't involve a stored procedure but a method on the Stocktake object called find stock that needs to be redone, its definitely doable but I'd say allowing 2 -3 hours would be fair in case of any difficulties to get it done with following same principles and adding the lookups and buttons to the ranges grid.

I am assuming you are only going with the default supplier for products?

Re: More range(s) for Stocktake form

PostPosted: Wed Jun 09, 2021 2:01 pm
by DannyC
It's actually a bit different to the post you mentioned as this doesn't involve a stored procedure but a method on the Stocktake object called find stock

Yeah, I studied the form in Just Decompile and was aware that the Find Stock click event will need redoing. But not sure how to do it.

I am assuming you are only going with the default supplier for products?

Assume correct.

Re: More range(s) for Stocktake form  Topic is solved

PostPosted: Tue Jun 15, 2021 1:35 pm
by perry
You will need
1. add a custom column to handle selection of from/to supplier in the "Range Grid"
2. a custom SP to handle new filter (with same number of output columns + name)
3. intercept FindStockStart

assuming you know how to do step 1 and 2 :)

Below is what you need for step 3
Code: Select all
 Public Sub Setup(ByVal JiwaBusinessLogic As JiwaApplication.IJiwaBusinessLogic, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaBusinessLogicPlugin.Setup

            Dim stocktake As JiwaStockTake.StockTake = JiwaBusinessLogic

            AddHandler stocktake.FindStockStart, AddressOf FindstockStart
        End Sub

       
        Private Sub FindstockStart(sender As Object, e As CancelEventArgs, SQLCmd As SqlCommand)
            Dim stocktake As JiwaStockTake.StockTake = sender

            SQLCmd.CommandText = "your custom stored proc here"
            SQLCmd.CommandType = CommandType.StoredProcedure

            If stocktake.Client IsNot Nothing Then
                Dim ui As JiwaStockTakeUI.frmMain = stocktake.Client
                SQLCmd.Parameters.Add(New SqlParameter("@MaxRow", ui.MaxRowsNumericEditor.Value))
            Dim FromSupplier, ToSupplier as string
            FromSupplier = "" 'get this from custom grid column
            ToSupplier = "" 'get this from custom grid column
            SQLCmd.Parameters.Add(New SqlParameter("@FromSupplier", FromSupplier))
            SQLCmd.Parameters.Add(New SqlParameter("@ToSupplier", ToSupplier))
            End If

         

        End Sub


There is only 1 issue with above code that I cannot resolve. ui.MaxRowsNumericEditor.Value always reverted to "default max count" during this event, even if user changed it on UI.