Work Orders, changing input serial quantities  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Work Orders, changing input serial quantities

Postby DannyC » Mon Sep 01, 2025 11:04 am

In Work Orders, I am trying to find the correct event to hook into when a user has the serial selection dialog displayed and they change the quantity on the line from the Inputs pane.
Work Order serial selection.jpg

What I am hoping to capture is when the user enters in a quantity which exceeds the Total Qty Required for the sum of the selected serial numbers.

I've search through the WorkOrder object and I have tried the following events but none of them fire when I want them to.
Code: Select all
      if (JiwaForm is JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder)
      {
         JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder workOrderForm = (JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder)JiwaForm;
         workOrderForm.WorkOrder.Allocations.Changed += My_LineAllocationsChanged;
         workOrderForm.WorkOrder.Stages.InputItemSerialSelection += My_InputItemSerialSelection;
         workOrderForm.WorkOrder.Stages.InputItemChanged += My_InputItemChanged;
      }


Is there another event I'm missing?


[As an aside, I'm sure this must've been mentioned before, to get that dialog to show it's the usual dbl-right click on the Qty column. Problem is, 19 times out of 20 I get a right-click context menu. Sometimes I get lucky and the dialog appears. I don't know if there is a magic pixel in that cell that I need to target or what the trick is but it's annoying.]
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Work Orders, changing input serial quantities

Postby Scott.Pearce » Mon Sep 01, 2025 6:27 pm

[As an aside, I'm sure this must've been mentioned before, to get that dialog to show it's the usual dbl-right click on the Qty column. Problem is, 19 times out of 20 I get a right-click context menu. Sometimes I get lucky and the dialog appears. I don't know if there is a magic pixel in that cell that I need to target or what the trick is but it's annoying.]


It's a bug. Give the grid focus first by click on some other read-only cell, then double-right-click on the Quantity Taken column.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Work Orders, changing input serial quantities

Postby Scott.Pearce » Mon Sep 01, 2025 6:36 pm

DannyC wrote:In Work Orders, I am trying to find the correct event to hook into when a user has the serial selection dialog displayed and they change the quantity on the line from the Inputs pane.


Try hooking into Manager.DialogFactory.AfterDialogStart, the event signature is:

Code: Select all
Public Event AfterDialogStart(ByVal JiwaDialog As IJiwaDialog)


Look at the JiwaDialog.Context property, and if it is "Work Order", run your logic (i.e. quantity entered check on the "Use Inventory" button click or whatever).
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Work Orders, changing input serial quantities

Postby DannyC » Tue Sep 02, 2025 5:57 pm

Try hooking into Manager.DialogFactory.AfterDialogStart

Appreciate that Scott.

Righto. So I can get to the serial selection dialog.

I can see what the line details are, and if they get changed I can fire some code.

What I've been struggling with for the past several hours is to find the decimal value displayed at "Total Qty Required: "

I can see the Jiwa code has it as
Code: Select all
ultraLabel.Text = string.Format("Total Qty Required:  {0}", this.Manager.ToMoneyDP(parentItem1.TotalQuantity, parentItem1.Inventory.DecimalPlaces));


but no matter what object and property I look at, I can't find any way to get to the ParentItem from the serial selection dialog.
My code so far fires on the Serials.Changed event which allows me to grab the individual line details of the stock consumed on the work order input. I can see what it has changed etc, so all good there at the moment.
I just need to get that Total Qty Required number.

Code: Select all
private void My_CheckWorkOrderInputQtys(JiwaFinancials.Jiwa.JiwaApplication.IJiwaDialog myJiwaDialog)
{
   if (myJiwaDialog is JiwaFinancials.Jiwa.JiwaSerialNumbersUI.frmSerialSelector &&  myJiwaDialog.Context == "WorkOrder")
   {
      System.Diagnostics.Debugger.Launch();
      JiwaFinancials.Jiwa.JiwaSerialNumbersUI.frmSerialSelector serialPicker = (JiwaFinancials.Jiwa.JiwaSerialNumbersUI.frmSerialSelector)myJiwaDialog;
      serialPicker.Serials.Changed += SerialsChanged;
   }
}
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Work Orders, changing input serial quantities

Postby Mike.Sheen » Wed Sep 03, 2025 10:43 am

As well has setting the label text, the work order form also pushes the inputItem.TotalQuantity property (InputItem in this context is the parentItem1) into the MaxQuantity property of the Serial Selection dialog.

If that's all you need, then in your code serialPicker.MaxQuantity is what you want.
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Work Orders, changing input serial quantities

Postby DannyC » Wed Sep 03, 2025 2:04 pm

So the code here should return a value?
It's returning 0.

Code: Select all
private void My_CheckWorkOrderInputQtys(JiwaFinancials.Jiwa.JiwaApplication.IJiwaDialog myJiwaDialog)
{
   if (myJiwaDialog is JiwaFinancials.Jiwa.JiwaSerialNumbersUI.frmSerialSelector &&  myJiwaDialog.Context == "WorkOrder")
   {
      System.Diagnostics.Debugger.Launch();
      JiwaFinancials.Jiwa.JiwaSerialNumbersUI.frmSerialSelector serialPicker = (JiwaFinancials.Jiwa.JiwaSerialNumbersUI.frmSerialSelector)myJiwaDialog;
      MessageBox.Show(serialPicker.MaxQuantity.Tostring());
      serialPicker.Serials.Changed += SerialsChanged;
   }
}
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Work Orders, changing input serial quantities

Postby Mike.Sheen » Wed Sep 03, 2025 2:14 pm

DannyC wrote:So the code here should return a value?
It's returning 0.


Yeah, because you're probably inspecting the property after the dialog factory has created the dialog, but before the work order form has set the property.

The work order form creates the dialog using the factory, sets a bunch of properties and then invokes ShowDialog on it.

So in the AfterDialogStart event you cannot look at the property because it's not set yet, but you could add a handler for the dialogs Shown event - and in there you can inspect that property, and others.
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Work Orders, changing input serial quantities

Postby DannyC » Wed Sep 03, 2025 4:34 pm

then in your code serialPicker.MaxQuantity is what you want


Nope, MaxQuantity is the the quantity Available.

Now that I know to get to the Shown event, would it be better if I instantiate the Parent item to be the InputItem? I actually tried but serialPicker.Parent is a control and I can't set it to to InputItem
Code: Select all
JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.InputItem inputItem = (JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.InputItem)serialPicker.Parent
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Work Orders, changing input serial quantities

Postby Mike.Sheen » Wed Sep 03, 2025 4:42 pm

DannyC wrote:
then in your code serialPicker.MaxQuantity is what you want


Nope, MaxQuantity is the the quantity Available.

Now that I know to get to the Shown event, would it be better if I instantiate the Parent item to be the InputItem? I actually tried but serialPicker.Parent is a control and I can't set it to to InputItem
Code: Select all
JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.InputItem inputItem = (JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.InputItem)serialPicker.Parent


Your serialPicker is a form, so it's a control and it's Parent property is the control parent and is not related to what we call a parent for line details.

You're right about MaxQuantity - kind of... it's Actual Used plus available:
Code: Select all
SerialSelectionObject.MaxQuantity = ActualUsed + LineDetails.QuantitySOHAvailable


I was looking In version 8 and in there we set that to be the inputItem.TotalQuantity:
Code: Select all
If SerialStockSelectionCollectionType = JiwaBillOfMaterials.WorkOrder.StageCollection.SerialStockSelectionCollectionTypes.Taken Then
    SerialSelectionObject.MaxQuantity = inputItem.TotalQuantity
Else
    SerialSelectionObject.MaxQuantity = Nothing ' With wastage there is no limit
End If


But that is of no help you.

There will be a way to get to the input item the serial dialog is displayed for, but I don't want to lead you astray without providing guidance I know to be correct, so I'd have to test it and then provide that. I don't have the resources to do that right now - I'll circle back when I can, or perhaps Scott can find some time.
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Work Orders, changing input serial quantities

Postby DannyC » Wed Sep 03, 2025 6:08 pm

There will be a way to get to the input item the serial dialog is displayed for


Cheers. I think thats my hurdle at the moment.

Basically the goal is just to stop the user from entering a quantity beyond what is needed.
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests