Form PrintStarting and PrintEnd events  Topic is solved

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

Form PrintStarting and PrintEnd events

Postby DannyC » Wed Mar 17, 2021 7:54 pm

Sort of similar to this old post
viewtopic.php?f=26&t=506

I have a client who wants me to somehow record who and when users print some forms - in this case its the Warehouse Transfer Out and In.
Also Purchase Orders.
But my question could apply to several forms.

Basically I intent to simply add an entry to Notes, so in purchase orders, I'd add a notes to the collection. For warehouse transfers I'd just append to the Notes field.

Anyway, the PrintStarting and PrintEnd only has a parameter for the ReportDefinition. How do I get the form and/business logic object(s) so I can do the above?
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Form PrintStarting and PrintEnd events  Topic is solved

Postby SBarnes » Wed Mar 17, 2021 9:08 pm

You are approaching this from the wrong angle if you attach to click event of the ultra toolbars manager which has a signature of

Code: Select all
public virtual void UltraToolbarsManager_ToolClick(object sender, ToolClickEventArgs e)


You then need to check for ID_RecordPrint this is the snippet from Jiwa that does that

Code: Select all
 if ((e.Tool.Owner != null) && (e.Tool.Owner is PopupMenuTool))
            {
                if (((PopupMenuTool) e.Tool.Owner).Key == "ID_RecordPrint")
                {
                    this.PrintRecord(this.ReportDefinitionCollection[e.Tool.Key]);
                }


once you get there you just go after the form with something like this, which is for doing it in the sales order screen

Code: Select all
Infragistics.Win.UltraWinToolbars.UltraToolbarsManager toolbar = (Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)sender;
JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm salesform = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm)toolbar.DockWithinContainer;


The once you have the form you can get the object off it like sales order to do your notes.

You could even keep it generic if you wanted to by using the form as JiwaFinancials.Jiwa.JiwaApplication.Maintenance.UserInterface and using its BusinessLogic property and working with the interface JiwaFinancials.Jiwa.JiwaApplication.IJiwaNotes if the businesslogic property was of that type of interface
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Form PrintStarting and PrintEnd events

Postby DannyC » Wed Mar 17, 2021 10:29 pm

Sorted!
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Form PrintStarting and PrintEnd events

Postby Mike.Sheen » Thu Mar 18, 2021 2:30 pm

You could also do this by using a delegate to handle the PrintStarting or PrintEnd events and pass the Form and/or business logic as a parameter.

like so (using the cash book form as an example):

Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
   if(JiwaForm is JiwaFinancials.Jiwa.JiwaCashBookUI.frmCashBook)
   {
      JiwaFinancials.Jiwa.JiwaCashBookUI.frmCashBook cashBookForm = (JiwaFinancials.Jiwa.JiwaCashBookUI.frmCashBook)JiwaForm;               

      cashBookForm.PrintStarting += delegate(JiwaFinancials.Jiwa.JiwaApplication.PrintGroup.FormReports.ReportDefinition ReportDefinition)
      {
         myPrintStartingHandler(ReportDefinition, cashBookForm);
      };
   }
}

private void myPrintStartingHandler(JiwaFinancials.Jiwa.JiwaApplication.PrintGroup.FormReports.ReportDefinition ReportDefinition, JiwaFinancials.Jiwa.JiwaCashBookUI.frmCashBook cashBookForm)
{
}


This neat little technique is a great way to add effectively additional parameters to event handlers.

The only caveat is that using this technique you cannot remove handlers at runtime - which normally isn't a deal breaker anyway.
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: Form PrintStarting and PrintEnd events

Postby SBarnes » Thu Mar 18, 2021 4:35 pm

I didn't think of a delegate but it would work, I usually use them on Jiwa Grid event where I want to get back up to the form and the business logic object but I am yet to come across a situation where I would need to remove one so yes it definitely wouldn't be a deal breaker.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Form PrintStarting and PrintEnd events

Postby DannyC » Thu Mar 18, 2021 10:12 pm

using a delegate

A delegate! That's exactly what I was looking for.

Anyway, Stuart's idea to hook into the Click event works just as good.
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 6 guests