Purchase Order Form Access  Topic is solved

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

Purchase Order Form Access

Postby Ernst » Thu Jan 07, 2021 6:40 pm

Our user would like the Purchase Order Line highlighted with a colour if Not fully delivered.

Seems easy enough as we have done line/ field highlighting in sales order using code like below. But there is no .Linedisplayed on the PurchaseOrderForm, And the purchaseorderform does not appear to have .grdlines.

Is this possible with the PO form. Thx..

AddHandler salesOrderForm.LineDisplayed, AddressOf SalesOrderForm_LineDisplayed

Private Sub SalesOrderForm_LineDisplayed(ByVal sender As Object, ByVal e As System.EventArgs, ByVal SalesOrderLine As JiwaSales.SalesOrder.SalesOrderLine,ByVal RowPassed As Integer)
' Unlock delivered and demand columns for all physical items
Dim salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm = sender

For row As Integer = 0 To salesOrderForm.grdLines.ActiveSheet.RowCount - 1
Dim key As String = salesOrderForm.grdLines.GridText("Key", row)
If key = salesOrderLine.RecID Then
' Scotts Extra If to change colour etc
If salesOrderLine.DiscountedPrice = 0 Then
salesOrderForm.grdLines.ActiveSheet.Cells(row, salesOrderForm.grdLines.ActiveSheet.Columns("ExtPrice").Index).BackColor = System.Drawing.Color.Red
Else
salesOrderForm.grdLines.ActiveSheet.Cells(row, salesOrderForm.grdLines.ActiveSheet.Columns("ExtPrice").Index).BackColor = System.Drawing.Color.White
End If
If salesOrderLine.QuantityDemand > 0 Then
salesOrderForm.grdLines.ActiveSheet.Cells(row, salesOrderForm.grdLines.ActiveSheet.Columns("QuantityDemand").Index).BackColor = System.Drawing.Color.Blue
Else
salesOrderForm.grdLines.ActiveSheet.Cells(row, salesOrderForm.grdLines.ActiveSheet.Columns("QuantityDemand").Index).BackColor = System.Drawing.Color.White
End If
Exit For
End If
Next

End Sub
User avatar
Ernst
Kohai
Kohai
 
Posts: 242
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 13

Re: Purchase Order Form Access  Topic is solved

Postby DannyC » Thu Jan 07, 2021 10:34 pm

This does it

Code: Select all
    Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
      Dim purchaseOrderForm As JiwaFinancials.Jiwa.JiwaPurchaseOrdersUI.MainForm = JiwaForm
      AddHandler purchaseOrderForm.PurchaseOrder.ReadEnd, AddressOf PurchOrder_ReadEnd
    End Sub
   
   Private Sub PurchOrder_ReadEnd(ByVal sender As Object, ByVal e As System.EventArgs)
      Dim purchaseOrder As JiwaPurchaseOrders.PurchaseOrder = DirectCast(sender, JiwaPurchaseOrders.PurchaseOrder)
      Dim row As Integer = 0
      Dim poForm As JiwaFinancials.Jiwa.JiwaPurchaseOrdersUI.MainForm = purchaseOrder.Client
      For Each purchaseOrderLine As JiwaPurchaseOrders.Line In purchaseOrder.Lines
         If purchaseOrderLine.Quantity > purchaseOrderLine.Delivered Then
            poForm.LinesJiwaGrid.ActiveSheet.Cells(row, poForm.LinesJiwaGrid.ActiveSheet.Columns("Qty").Index).BackColor = System.Drawing.Color.Red
         Else
            poForm.LinesJiwaGrid.ActiveSheet.Cells(row, poForm.LinesJiwaGrid.ActiveSheet.Columns("Qty").Index).BackColor = System.Drawing.Color.White
         End If
      row = row + 1   
      Next   
   End Sub   
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Purchase Order Form Access

Postby SBarnes » Thu Jan 07, 2021 11:34 pm

Similarly if you want to look at changing the colour if user changes a value in the grid you can subscribe to the grids change event with a function with a signature like

Code: Select all
void GridLines_Change(object sender, FarPoint.Win.Spread.ChangeEventArgs e)


FarPoint.Win.Spread.ChangeEventArgs has the row and column as properties.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Purchase Order Form Access

Postby Ernst » Fri Jan 08, 2021 7:54 am

Thanks Danny.. That was a great solution. I added a "If form =" in the Setup. Not sure if it makes a difference. But seems to be the thing to do.

>>sbarnes Wasent sure where that bit of code would go. But thanks for the help.
void GridLines_Change(object sender, FarPoint.Win.Spread.ChangeEventArgs e)

PS.. How do you place a piece of code in a box?


Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
If TypeOf(JiwaForm) Is JiwaFinancials.Jiwa.JiwaPurchaseOrdersUI.PurchaseOrders Then
Dim purchaseOrderForm As JiwaFinancials.Jiwa.JiwaPurchaseOrdersUI.MainForm = JiwaForm
AddHandler purchaseOrderForm.PurchaseOrder.ReadEnd, AddressOf PurchOrder_ReadEnd
End If
End Sub

Untitled.jpg
Untitled.jpg (31.25 KiB) Viewed 1123 times
User avatar
Ernst
Kohai
Kohai
 
Posts: 242
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 13

Re: Purchase Order Form Access

Postby SBarnes » Fri Jan 08, 2021 8:08 am

To place a piece of code in a box there is a code button on the forum post tool bar and you just place the raw code between the tags.


For the grid change code you add a handler in the setup similar to

Code: Select all
AddHandler purchaseOrderForm.PurchaseOrder.ReadEnd, AddressOf PurchOrder_ReadEnd


but as

Code: Select all
AddHandler purchaseOrderForm.LinesJiwaGrid.Changed, AddressOf GridLines_Change
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests