Page 1 of 2

Adding column to Work Order Inputs grid

PostPosted: Thu Jul 02, 2020 6:07 pm
by DannyC
I want to display another an extra column in the work order Inputs grid to show the line total of each input line.
This code adds a column, but I can't work out how to populate it.
Code: Select all
if (JiwaForm is JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder)
{
   JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder woForm = (JiwaFinancials.Jiwa.JiwaBillOfMaterialsUI.WorkOrder.WorkOrder) JiwaForm;
   woForm.InputsJiwaGrid.AddColumn("LineTotal", new JiwaFinancials.Jiwa.JiwaApplication.JiwaManageGrid.JiwaCurrencyCellType(), "LineTotal",8,false,true,true,true,8,false,false,2,false,false);
}

I don't need the line total to be saved to the database, I just need it as a calculated column to display on screen.

Can you suggest how I could populate it?

Re: Adding column to Work Order Inputs grid

PostPosted: Mon Jul 06, 2020 5:23 pm
by Mike.Sheen
As you'd expect - add handlers for when a read is completed, when an item changes and so on and populate the desired cell with the desired value.

I little bit of complexity is involved in that the input items shown on the input items grid is related to the selected stage - but it's just a case of displaying the values when the stage might have changed.

Attached plugin for 7.2.1 demonstrates this.

Re: Adding column to Work Order Inputs grid

PostPosted: Mon Jul 06, 2020 7:12 pm
by DannyC
That's awesome Mike. I never would've nutted that one out.
One issue, although the cell is JiwaCurrencyCellType() and the decimals is set to 2, it is still displaying as a whole integer.

How can I get it to display with at least 2 decimals?

Also, I see you're using item.Inventory.LCost.
Can you use the Line Details last cost?
It looks like it'd be item.LineDetails.Value.

Re: Adding column to Work Order Inputs grid

PostPosted: Mon Jul 06, 2020 9:47 pm
by Mike.Sheen
DannyC wrote:One issue, although the cell is JiwaCurrencyCellType() and the decimals is set to 2, it is still displaying as a whole integer.

How can I get it to display with at least 2 decimals?


The most explicit way is when you set the value, use the GridDecimalPlaces method of the grid to set the decimals - this overrides all other factors for determining decimals, such as the decimal places property of the cell type and the column.

DannyC wrote:Also, I see you're using item.Inventory.LCost.
Can you use the Line Details last cost?
It looks like it'd be item.LineDetails.Value.


Yeah I had to guess what you intended it to be - Line total was ambiguous to me, so I just used a simple example. Even now I can't say for sure what you want the value to represent.

Re: Adding column to Work Order Inputs grid

PostPosted: Mon Jul 06, 2020 11:26 pm
by DannyC
use the GridDecimalPlaces method
.
Sweet. That's sorted that one.

I thought I could write a foreach loop to get each LineDetail but I'm having trouble working out the type of LineDetails. It seems to be JiwaFinancials.Jiwa.JiwaApplication.Inventory.SOH.LineDetail with a <T> but I can't work out the correct C# syntax. The compiler doesn't like
Code: Select all
foreach(JiwaFinancials.Jiwa.JiwaApplication.Inventory.SOH.LineDetail itemDetail in item.LineDetails)


EDIT: Never mind...I sussed it out with some trial and error.
This is the final bit of code which displays the line total to 4 decimals.
Code: Select all
         if (row != -1)
         {
            decimal mylinetotal = 0;
            //workOrderForm.InputsJiwaGrid.set_GridText("TotalCost", row, item.Inventory.LCost * item.Quantity);
            workOrderForm.InputsJiwaGrid.GridDecimalPlaces("TotalCost", row, 4);
            foreach(JiwaFinancials.Jiwa.JiwaApplication.Inventory.SOH.LineDetail<JiwaFinancials.Jiwa.JiwaBillOfMaterials.WorkOrder.InputItem> itemDetail in item.LineDetails)
            {
               mylinetotal = mylinetotal + (itemDetail.Quantity * itemDetail.OriginalCost);
            }
            workOrderForm.InputsJiwaGrid.set_GridText("TotalCost", row, mylinetotal);
            
         }

Re: Adding column to Work Order Inputs grid

PostPosted: Tue Jul 07, 2020 6:39 am
by SBarnes
If you want to set the decimal places for a column I usually just do this

Code: Select all
jgLines.AddColumn("Price", new JiwaFinancials.Jiwa.JiwaApplication.JiwaManageGrid.JiwaCurrencyCellType() {DecimalPlaces = 2}, "Price", 10, false, true, false,false);

Re: Adding column to Work Order Inputs grid

PostPosted: Tue Jul 07, 2020 7:50 pm
by DannyC
There's a problem with this plugin which I've taken a stab at fixing but the solution eludes me.
When a Work Order is already at a status of started and the status is edited to Forecast, the totals disappear. That's explainable because the plugin gets the sum of SOH taken.
But when the previous W/O is selected the column stays blank. In fact, it's only when you close work orders and go back in do the totals return. If an edit is done, the totals disappear & they don't come back no matter what the status of the W/O.

I've debugged the code and have found there are 2 issues.
The line
Code: Select all
string stageRecID = workOrderForm.StagesJiwaGrid.get_GridText("RecID", workOrderForm.StagesJiwaGrid.ActiveSheet.ActiveRowIndex).ToString();

is not returning a value to stageRecID.
Likewise, the following code isn't finding a value for workOrderForm.InputsJiwaGrid.get_GridText("RecID", inputRow).ToString()
Code: Select all
if (workOrderForm.InputsJiwaGrid.get_GridText("RecID", inputRow).ToString() == item.RecID)

It's like the get_GridText only works if you open a new W/O form.

Re: Adding column to Work Order Inputs grid

PostPosted: Wed Jul 08, 2020 6:58 pm
by DannyC
This is seriously doing my head in. Ive been trying to debug this for a few hours and am still no closer.
Not only does there seems to be something odd with get_GridText but I've also discovered that the condition
Code: Select all
for (int inputRow = 0; inputRow < workOrderForm.InputsJiwaGrid.ActiveSheet.RowCount; inputRow++)
is not being met so the code within that for loop never fires. It only happens when scrolling through other work orders after a work order has been edited, e.g. the status changed.

Maybe it's some peculiar behaviour with the Infragistics grid control? Be keen to find a solution.

Re: Adding column to Work Order Inputs grid

PostPosted: Wed Jul 08, 2020 7:18 pm
by SBarnes
It looks like it might be sequence of events Mike and Scott are fairly consistent so if it works like other forms the rows are being removed and they are incrementing the row count as each line gets drawn would be my guess, without seeing the plugin I can't comment further but this might help

https://help.infragistics.com/Help/Doc/ ... rt_EV.html

Re: Adding column to Work Order Inputs grid

PostPosted: Wed Jul 08, 2020 11:05 pm
by DannyC
without seeing the plugin I can't comment further

The plugin is in the fist reply post from Mike. Scroll up.

It's definitely something with
Code: Select all
workOrderForm.InputsJiwaGrid.ActiveSheet.RowCount
.
Whenever a work order is edited and saved, the RowCount is 0. Even when scrolling to another work order.