Validating Supplier PartNo  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Validating Supplier PartNo

Postby DannyC » Wed Feb 18, 2015 3:18 pm

Hi,

I am wanting to do a sanity check on the supplier partno when it is changed. My goal is to check all other inventory items for a matching supplier part number even if different separating characters have been used, for example, a supplier partno ABC_123-47 would be a match with abc/123_47.

I have done it in 6.5.13 and am just wanting to replicate the same in Jiwa 7.
My problem at the moment is finding the current value of Supplier PartNo. Once I have that I should be able to perform some appropriate string parsing to get say ABC12347. I can then do a database lookup in SQL to see if the string exists elsewhere.

My code at the moment is this:

Code: Select all
    Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
      Dim InventoryForm As JiwaInventoryUI.InventoryMaintenanceForm = DirectCast(JiwaForm, JiwaInventoryUI.InventoryMaintenanceForm)
      AddHandler InventoryForm.grdSuppliers.LostFocus, AddressOf Check_SupplierPartNo   
   End Sub
   
      Sub Check_SupplierPartNo(Sender As Object, e As System.EventArgs)
         Dim inventory As JiwaInventory.Inventory  = DirectCast(sender, JiwaInventory.Inventory)   
            Messagebox.Show("I want the supplier PartNo here")

      End Sub   


Can you help me to get the Supplier PartNo?

Cheers

Danny
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Validating Supplier PartNo

Postby Mike.Sheen » Sun Feb 22, 2015 10:49 am

Hi Danny,

Plugin Inventory Maintenance - Check Supplier Part No.xml
Sample Plugin
(33.09 KiB) Downloaded 151 times


The attached plugin should get you pointed in the right direction. Supplier part numbers are attached to a supplier, and there can be many of these for a given region - and there can be many regions. The plugin attached iterates through each region, and within that region the associated suppliers for the item.

One question haunts me, however - how are you to determine if ABC_123-47 should be deemed identical as abc/123_47? There are potential performance considerations you should be aware of - if the pattern is known, a LIKE query against the table will be efficient enough - but I'm curious how you're going to be matching these strings, as it seems to be a less than trivial problem - personally I'd investigate using PATINDEX with a matching pattern.

Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Validating Supplier PartNo

Postby DannyC » Wed Feb 25, 2015 12:48 pm

Thanks Mike.
I nearly have this one sussed but the line
Code: Select all
      AddHandler InventoryForm.grdSuppliers.LostFocus, AddressOf Check_SupplierPartNo

is not good. The LostFocus seems to fire on GotFocus and when I am displaying a message box, as soon as I click into the supplier partno field, the messagebox pops up preventing me from actually getting into the field to change it!
I have tried a few other events on the GrdSuppliers grid but I can't find one which fires when I only am leaving the Supplier PartNo field.
Suggestions?

Cheers

Danny
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Validating Supplier PartNo  Topic is solved

Postby Mike.Sheen » Wed Feb 25, 2015 4:18 pm

DannyC wrote:I have tried a few other events on the GrdSuppliers grid but I can't find one which fires when I only am leaving the Supplier PartNo field.
Suggestions?

Cheers

Danny


I thought you'd come back with this - I saw your LostFocus handling and thought it an odd event to be listening to.

There are a few ways to do what you want:

1.Try the LeaveCell event of the grid control.

Code: Select all
AddHandler InventoryForm.grdSuppliers.LeaveCell, AddressOf grdSuppliers_LeaveCell
...
Private Sub grdSuppliers_LeaveCell(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.LeaveCellEventArgs)
End Sub


If LeaveCell for whatever reason does not suit, then:

2. Listen to the PropertyChanged event of the grid, then examine the property name - if it is "ActiveCell" then the user has changed cells on the grid.

Code: Select all
AddHandler InventoryForm.grdSuppliers.ActiveSheet.PropertyChanged, AddressOf grdSuppliers_ActiveSheet_PropertyChanged
...
Private Sub grdSuppliers_ActiveSheet_PropertyChanged(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.SheetViewPropertyChangeEventArgs)
    If e.PropertyName = "ActiveCell" Then
       
    End If
End Sub


Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 5 guests