USING Progress.Lang.*.
USING Progress.Windows.UserControl.
USING CrystalDecisions.Windows.Forms.*.
 
CLASS Adedual.Objetos.ReportViewer INHERITS UserControl   : 
 
    DEFINE PRIVATE VARIABLE components           AS System.ComponentModel.IContainer.
    DEFINE PRIVATE VARIABLE crystalReportViewer1 AS CLASS CrystalReportViewer NO-UNDO.
    DEFINE VARIABLE crwReport                    AS CrystalDecisions.CrystalReports.Engine.ReportDocument NO-UNDO.     
    DEFINE VARIABLE i           AS INTEGER NO-UNDO.
    DEFINE VARIABLE j           AS INTEGER NO-UNDO.
 
    DEFINE VARIABLE tblLogonInfo                 AS CrystalDecisions.Shared.TableLogOnInfo                NO-UNDO.
    DEFINE VARIABLE crRptTable                   AS CrystalDecisions.CrystalReports.Engine.Table          NO-UNDO.


    DEFINE PUBLIC PROPERTY ReportSource AS CHARACTER NO-UNDO 
        GET.
        SET(INPUT arg AS CHARACTER):
            ReportSource = arg.
            crystalReportViewer1:ReportSource = arg.
        END SET.
 
    CONSTRUCTOR PUBLIC ReportViewer (INPUT pReportLocation AS CHARACTER, INPUT pSendToPrinter AS INTEGER):
 
 
        SUPER().
        InitializeComponent(pReportLocation, pSendToPrinter).
        CATCH e AS Progress.Lang.Error:
            UNDO, THROW e.
        END CATCH.
 
    END CONSTRUCTOR.
   
    METHOD PRIVATE VOID InitializeComponent( INPUT pReportLocation AS CHARACTER, INPUT pSendToPrinter AS INTEGER ):
 
        THIS-OBJECT:crystalReportViewer1 = NEW CrystalDecisions.Windows.Forms.CrystalReportViewer().           
        THIS-OBJECT:SuspendLayout().

        THIS-OBJECT:crwReport = NEW CrystalDecisions.CrystalReports.Engine.ReportDocument().       
        THIS-OBJECT:crwReport:Load(pReportLocation).
        THIS-OBJECT:crystalReportViewer1:ActiveViewIndex = -1.
        THIS-OBJECT:crystalReportViewer1:BorderStyle = System.Windows.Forms.BorderStyle:FixedSingle.
        THIS-OBJECT:crystalReportViewer1:Dock = System.Windows.Forms.DockStyle:Fill.
        THIS-OBJECT:crystalReportViewer1:Location = new System.Drawing.Point(0, 0).
        THIS-OBJECT:crystalReportViewer1:Name = "crystalReportViewer1".
        THIS-OBJECT:crystalReportViewer1:SelectionFormula = "".
        THIS-OBJECT:crystalReportViewer1:Size = new System.Drawing.Size(780, 550).
        THIS-OBJECT:crystalReportViewer1:TabIndex = 0.
        THIS-OBJECT:crystalReportViewer1:ViewTimeSelectionFormula = "".         
        THIS-OBJECT:crystalReportViewer1:ReportSource= THIS-OBJECT:crwReport.
        THIS-OBJECT:crystalReportViewer1:ToolPanelView = ToolPanelViewType:NONE.
                
        IF pSendToPrinter = 2 THEN DO:
            THIS-OBJECT:crwReport:PrintOptions:PrinterName = SESSION:PRINTER-NAME.
            THIS-OBJECT:crwReport:PrintToPrinter(1, NO,0,0).
            /* THIS-OBJECT:crystalReportViewer1:PrintReport(). */
        END.
        /*  */
        /* ReportViewer */
        /*  */
        /* THIS-OBJECT:AutoScaleDimensions = NEW System.Drawing.SizeF(6, 13). */
        THIS-OBJECT:AutoSize = TRUE.        
        THIS-OBJECT:BackColor = System.Drawing.SystemColors:Desktop.        
        THIS-OBJECT:Controls:Add(THIS-OBJECT:crystalReportViewer1).        
        THIS-OBJECT:Name = "ReportViewer".
        THIS-OBJECT:Size = NEW System.Drawing.Size(300, 300).
        THIS-OBJECT:ResumeLayout(FALSE).
        CATCH e AS Progress.Lang.Error:
            UNDO, THROW e.
        END CATCH.
    END METHOD. 
 
    DESTRUCTOR PUBLIC ReportViewer ( ):
  
    END DESTRUCTOR.
 
END CLASS.
