How to check for printed Status during Sales Order Plugin  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

How to check for printed Status during Sales Order Plugin

Postby Ernst » Thu Dec 04, 2014 3:09 pm

Hi Guys,

Have this plug in to show a message that order no is required. However message also pops up when printing. Is there a way to stop this.
In JIWA6 it was if printing = false.
Thanks for the help.

Public Class FormPlugin
Inherits System.MarshalByRefObject
Implements JiwaApplication.IJiwaFormPlugin

Public Overrides Function InitializeLifetimeService() As Object
' returning null here will prevent the lease manager
' from deleting the Object.
Return Nothing
End Function

Public Sub SetupBeforeHandlers(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.SetupBeforeHandlers
End Sub

Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
If TypeOf JiwaForm Is JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm Then
Dim salesOrderForm As JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm = DirectCast(JiwaForm, JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)
AddHandler salesOrderForm.SalesOrder.SaveStart, AddressOf SalesOrder_SaveStart
End If
End Sub

Private Sub SalesOrder_SaveStart(sender As Object, e As System.EventArgs)
' msgbox ("in Save Start")
Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
If salesOrder.OrderNo.Trim.Length = 0 Then
' Throw New System.Exception("Sales Order - Order no may not be blank")
System.Windows.Forms.MessageBox.Show("Customer Order No Should not be blank ")
End If
' End If
End Sub
End Class
User avatar
Ernst
Kohai
Kohai
 
Posts: 216
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12

Re: How to check for printed Status during Sales Order Plugi  Topic is solved

Postby Mike.Sheen » Thu Dec 04, 2014 3:31 pm

Ernst wrote:However message also pops up when printing. Is there a way to stop this.


Hi Ernst,

The easiest way is to remove your save handler when printing is commencing and add it again after printing - that way your save handler is not invoked during printing.

ie:

Code: Select all
Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
      If TypeOf JiwaForm Is JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm Then
         Dim salesOrderForm As JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm = DirectCast(JiwaForm, JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)
         AddHandler salesOrderForm.SalesOrder.SaveStart, AddressOf SalesOrder_SaveStart
         AddHandler salesOrderForm.SalesOrder.PrintingMany, AddressOf SalesOrder_PrintingMany
         AddHandler salesOrderForm.SalesOrder.PrintedMany, AddressOf SalesOrder_PrintedMany
      End If
    End Sub
   
   Private Sub SalesOrder_PrintingMany(sender As Object, e As System.EventArgs, ByRef ReportCollection As JiwaApplication.JiwaCollection(Of JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport))
      ' We remove the handler so we don't listen to the save just because we are printing
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
      RemoveHandler salesOrder.SaveStart, AddressOf SalesOrder_SaveStart
   End Sub
   
   Private Sub SalesOrder_PrintedMany(sender As Object, e As System.EventArgs, ReportCollection As JiwaApplication.JiwaCollection(Of JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport))
      ' We add back the handler after printing
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
      AddHandler salesOrder.SaveStart, AddressOf SalesOrder_SaveStart
   End Sub
   
   Private Sub SalesOrder_SaveStart(sender As Object, e As System.EventArgs)
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
      If salesOrder.OrderNo.Trim.Length = 0 Then               
         System.Windows.Forms.MessageBox.Show("Customer Order No Should not be blank ")
      End If      
   End Sub


Attached is a working sample.
Plugin Sales Order Prompt When No Order No..xml
Sample plugin
(33.8 KiB) Downloaded 134 times


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: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: How to check for printed Status during Sales Order Plugi

Postby Ernst » Mon Dec 08, 2014 7:32 am

Great thanks.
User avatar
Ernst
Kohai
Kohai
 
Posts: 216
Joined: Tue Feb 19, 2008 3:43 pm
Topics Solved: 12


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests

cron