Tuesday, 8 March 2016

Code to Open Printer Destination Dialog and select option for SSRS

Printer Destination Dialog

When  you click the button, it opens the Printer Destination Dialog for your report.

void clicked()
{
SRSPrintDestinationSettings             printSettings;
     printSettings = new SRSPrintDestinationSettings();

    super();

    if(SrsReportRunUtil::showSettingsDialog(printSettings))
    {
        SalesTable.ItemLabelPrintSettings = printSettings.pack();
    }
}

Code to Run report using the Printer setting option :

void clicked()
{
     ItemLabelController controller  = new ItemLabelController();
     Args  args = new args();
    container                   printSettingsLoc;
    if(Global::hasMenuItemAccess(menuitemOutputStr(ItemLabels),MenuItemType::Output))
    {
        args.record(SalesTable);
        controller.parmArgs(args);
        controller.parmReportName(ssrsReportStr(ItemLabelReport,Report));
        controller.parmShowDialog(false);
        if(SalesTable.ItemLabelPrintSettings)
        {
            printSettingsLoc = SalesTable.ItemLabelPrintSettings;
            controller.setPrinterSettings(printSettingsLoc);
        }
        controller.parmReportContract().parmPrintSettings().printMediumType(conPeek(printSettingsLoc,3));
        controller.parmReportContract().parmPrintSettings().overwriteFile(true);
        controller.parmReportContract().parmPrintSettings().fileName(conPeek(printSettingsLoc,20));

        controller.startOperation();
    }
}

================================================================================

Controller Class for the report :
class ItemLabelController extends SrsReportRunController
{
    container                   printerSettings;
    SRSPrintDestinationSettings printDestinationSettings;

}

protected void prePromptModifyContract()
{
    ItemLabelContract contract;
    PurchParmTable      purchParmTable;
    SalesTable          salesTable;//Bju_CIT_WMS013_ReturnRegistrationInReturnFor_11Jan
    contract = this.parmReportContract().parmRdpContract() as ItemLabelContract;
    if(this.parmArgs() && this.parmArgs().record().TableId  ==  tableNum(PurchParmTable))//Bju_CIT_WMS013_ReturnRegistrationInReturnFor_11Jan
    {
        purchParmTable = this.parmArgs().record();
        contract.parmPurchParmTable(purchParmTable.parmId);
        contract.parmTableRefId(purchParmTable.TableRefId);
    }
    //Bju_CIT_WMS013_ReturnRegistrationInReturnFor_11Jan
    if(this.parmArgs() && this.parmArgs().record().TableId  ==  tableNum(SalesTable))
    {
        salesTable = this.parmArgs().record();
        contract.parmSalesTable(salesTable.salesid);
    }
    //Bju_CIT_WMS013_ReturnRegistrationInReturnFor_11Jan
}

public void setPrinterSettings(container _settings)
{
    printerSettings = _settings;

    printDestinationSettings = new SRSPrintDestinationSettings();
    if (conlen(printerSettings) > 0)
    {
        printDestinationSettings.unpack(printerSettings);

    }
}



No comments:

Post a Comment