Page 1 of 1

Jiwa 7 - printing sales orders

PostPosted: Fri Sep 18, 2015 10:32 am
by jeromeh
Hi,

In our application referencing the Jiwa COM objects, we used to print pickslips when loading sales orders into Jiwa 6.5.

We would look for the printers by doing the following:

First we would create our database and log on, load our sales order in, etc.

MyDatabase = New JiwaODBC.database
With MyDatabase
.UseConnectionScrollCursor = True
.UseConnectionWriteData = True
.UseConnectionReadData1 = True
.UseConnectionReadData2 = True
.UseConnectionReadData3 = True
End With

.. extra log on code ..


Then later, when we were ready to print we would look through the printers via the systemprofile to find the one we wanted and printed from it.

Dim pr As New JiwaPrintReport.clsJiwaPrintReport

pr.Database = MyDatabase
pr.SystemProfile.Load(MyDatabase.IniFile)

Dim myprinter As clsLogicalPrinter = Nothing

For Each printer As clsLogicalPrinter In pr.SystemProfile.LogicalPrinters
…do printing


The issue we have is, now if Jiwa 7, we are logging on to the database using the code:

JiwaApplication.Manager.Instance.Logon(ServerName, DatabaseName, JiwaFinancials.Jiwa.JiwaODBC.database.AuthenticationModes.JiwaAuthentication, jiwaUserName, jiwaUserPassword)


Which leaves us with no MyDatabase or systemprofile, which is what we were using to find the printers.

How can we find a collection of the printers using the JiwaApplication object? Is there a new way we should be triggering a print from Jiwa 7?

Re: Jiwa 7 - printing sales orders  Topic is solved

PostPosted: Sun Sep 20, 2015 6:59 pm
by Mike.Sheen
This should point you in the right direction:

Code: Select all
    Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic(Of JiwaSales.SalesOrder.SalesOrder)(Nothing)
        salesOrder.Find(JiwaApplication.IJiwaNavigable.ReadModes.Actual, "InvoiceNo", "100537", "")

        ' Override logical printer sample
        ' ===============================
        ' Find a logical printer named "test printer"
        For Each logicalPrinter As JiwaApplication.PrintGroup.Maintenance.LogicalPrinter In JiwaApplication.Manager.Instance.Staff.PrintGroup.LogicalPrinters
            If logicalPrinter.Name = "test printer" Then
                ' Find a sales order report named "test report.rpt".
                For Each salesOrderReport As JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport In salesOrder.SalesOrderReports
                    If salesOrderReport.ReportDefinition.Report.FileName = "test report.rpt" Then
                        Dim candidateReportsToPrint As New JiwaApplication.JiwaCollection(Of JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport)
                        ' override the logical printer
                        salesOrderReport.ReportDefinition.LogicalPrinter = logicalPrinter
                        candidateReportsToPrint.Add(salesOrderReport)
                        ' Print the report
                        salesOrder.Print(candidateReportsToPrint, False)
                        Exit For
                    End If
                Next
                Exit For
            End If
        Next

        ' Use configured logical printer sample
        ' =====================================
        ' This uses the logical printer configured for the user for the report.
        ' Note you don't have to match on report name, you can also match on type (ie: Invoice, Pick sheet, Pack slip, etc)
        ' Find a sales order report named "test report.rpt".
        For Each salesOrderReport As JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport In salesOrder.SalesOrderReports
            If salesOrderReport.ReportDefinition.Report.FileName = "test report.rpt" Then
                Dim candidateReportsToPrint As New JiwaApplication.JiwaCollection(Of JiwaApplication.PrintGroup.SalesOrderReports.SalesOrderReport)
                ' override the logical printer
                salesOrderReport.ReportDefinition.LogicalPrinter = logicalPrinter
                candidateReportsToPrint.Add(salesOrderReport)
                ' Print the report
                salesOrder.Print(candidateReportsToPrint, False)
                Exit For
            End If
        Next


It's best to use the print method of the sales order, as it will log the print and save the sales order for you for audit purposes.

Re: Jiwa 7 - printing sales orders

PostPosted: Mon Sep 21, 2015 10:51 am
by jeromeh
Hi Mike,

Thank you for that, that all seems to make sense and I have managed to fit it all into our code.

Unfortunately, we now are getting the error "Cannot print a sales order until changes have been saved." when trying to execute the print on the sales order, even though we have already saved the order at this point.

I have even moved our call to salesorder.save to right before the print statement, as below, however the error is still occurring. Is there anything more we need to do to save the salesorder apart from just calling salesorder.Save()?

Code: MyJiwaSalesOrder.Save()
MyJiwaSalesOrder.Print(candidateReportsToPrint, False)

This is using Jiwa 7.0.136.

Re: Jiwa 7 - printing sales orders

PostPosted: Mon Sep 21, 2015 5:47 pm
by Mike.Sheen
jeromeh wrote:Hi Mike,

Thank you for that, that all seems to make sense and I have managed to fit it all into our code.

Unfortunately, we now are getting the error "Cannot print a sales order until changes have been saved." when trying to execute the print on the sales order, even though we have already saved the order at this point.

I have even moved our call to salesorder.save to right before the print statement, as below, however the error is still occurring. Is there anything more we need to do to save the salesorder apart from just calling salesorder.Save()?

Code: MyJiwaSalesOrder.Save()
MyJiwaSalesOrder.Print(candidateReportsToPrint, False)

This is using Jiwa 7.0.136.


After calling Save, you'll need to re-read the sales order.

So:
Code: Select all
MyJiwaSalesOrder.Save()
MyJiwaSalesOrder.Read(MyJiwaSalesOrder.RecID)
MyJiwaSalesOrder.Print(candidateReportsToPrint, False)

Re: Jiwa 7 - printing sales orders

PostPosted: Wed Sep 23, 2015 4:16 pm
by jeromeh
Hi Mike,

That was it - the sales order needed to be read after being saved. We are now printing again.