Atronics wrote:One of our sites with multiple warehouses wants to see SoH available, as a total figure, in warehouses other than the one in which the PO Generation form is being created. For some items it would be preferable to ship the item from another location, rather than purchase it. How can I add this new column to the grid?
Adding a column can be done at the Setup time of the FormPlugin class. You'd also add handlers there on when the user clicks the "Go" button and probably also and the read to get the SOH for other warehouses and set that in the grid.
i.e.:
Add the column and add the handlers:
- Code: Select all
// Add the column to the grid.
poGenerationform.ProductsJiwaGrid.AddColumn("OtherSOH", new FarPoint.Win.Spread.CellType.NumberCellType(), "SOH other Warehouses", 8, false, true, true, true, 0, false, false, 0, false);
// Lock the column
poGenerationform.ProductsJiwaGrid.LockColumn(true, "OtherSOH", -1);
// Add a handler for when a form is read to populate the other SOH column
poGenerationform.PurchaseOrderGeneration.ReadEnd += PurchaseOrderGeneration_ReadEnd;
// Add a handler for when the user clicks the GetCandidatesUltraButton
poGenerationform.GetCandidatesUltraButton.Click += GetCandidatesUltraButton_Click;
Once done, setting the value is simply iterating through the grid, getting the inventory id of each item a row in the grid represents, calling a SQL query to get a sum of the quantity in other warehouses and putting that value in the grid - eg:
- Code: Select all
private void PopulateOtherSOHColumn(JiwaFinancials.Jiwa.JiwaPurchaseOrderGenerationUI.MainForm poGenerationForm)
{
for(int row = 0; row < poGenerationForm.ProductsJiwaGrid.ActiveSheet.RowCount; row++)
{
string purchaseOrderKey = poGenerationForm.ProductsJiwaGrid.get_GridText("PurchaseOrderKey", row).ToString();
string purchaseOrderLineKey = poGenerationForm.ProductsJiwaGrid.get_GridText("PurchaseOrderLineKey", row).ToString();
if(purchaseOrderKey.Trim().Length > 0 && purchaseOrderLineKey.Trim().Length > 0)
{
JiwaFinancials.Jiwa.JiwaPurchaseOrderGeneration.PurchaseOrder purchaseOrder = poGenerationForm.PurchaseOrderGeneration.PurchaseOrders[purchaseOrderKey];
JiwaFinancials.Jiwa.JiwaPurchaseOrderGeneration.Line purchaseOrderLine = purchaseOrder.Lines[purchaseOrderLineKey];
decimal SOHOtherWarehouses = GetSOHOtherWarehouses(purchaseOrderLine.Inventory.InventoryID, poGenerationForm.PurchaseOrderGeneration.LogicalWarehouseResidingIn.IN_LogicalID);
poGenerationForm.ProductsJiwaGrid.set_GridText("OtherSOH", row, SOHOtherWarehouses);
}
}
}
Attached is a plugin which does all this.