Example #1
0
        private void desglose_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'reportes_dataSet.materiales_modulos' table. You can move, or remove it, as needed.
            this.materiales_modulosTableAdapter.Fill(this.reportes_dataSet.materiales_modulos);
            string display_n = string.Empty;

            if (constants.nombre_cotizacion != string.Empty)
            {
                display_n = " - " + constants.nombre_cotizacion;
            }
            //---------->
            if (constants.nombre_proyecto != string.Empty)
            {
                display_n = display_n + " - " + constants.nombre_proyecto;
            }
            //---------->
            if (titulo != string.Empty)
            {
                display_n = display_n + " - " + titulo;
            }
            //---------->
            reportViewer1.LocalReport.DisplayName = "Desglose" + display_n;
            reportViewer1.LocalReport.SetParameters(new ReportParameter("header", constants.getExternalImage("header")));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("cliente", constants.nombre_cotizacion == "" ? "n/a" : constants.nombre_cotizacion));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("proyecto", constants.nombre_proyecto == "" ? "n/a" : constants.nombre_proyecto));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("folio", constants.folio_abierto.ToString()));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("factor", "x" + factor));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("titulo", titulo));
            ReportPageSettings ps = reportViewer1.LocalReport.GetDefaultPageSettings();

            this.reportViewer1.ParentForm.Width = ps.PaperSize.Width;
            this.reportViewer1.RefreshReport();
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReportPrintDocument"/> class.
 /// </summary>
 /// <param name="report">The <see cref="Report"/> to print.</param>
 private ReportPrintDocument(Report report)
 {
     _rendered     = false;
     _pageSettings = report.GetDefaultPageSettings();
     _deviceInfo   = CreateEmfDeviceInfo();
     _pages        = new List <Stream>();
 }
Example #3
0
        private void print_inventarios_Load(object sender, EventArgs e)
        {
            if (peps == "Salidas")
            {
                this.Text = constants.org_name.ToUpper() + " - " + peps;
                reportViewer1.LocalReport.ReportEmbeddedResource = "cristales_pva.inventarios_salidas.rdlc";
                this.salidas_tBindingSource.DataSource           = Table;
            }
            else if (peps == "Entradas")
            {
                this.Text = constants.org_name.ToUpper() + " - " + peps;
                reportViewer1.LocalReport.ReportEmbeddedResource = "cristales_pva.inventarios_entradas.rdlc";
                this.entradas_tBindingSource.DataSource          = Table;
            }
            else
            {
                this.Text = constants.org_name.ToUpper() + " - Existencias";
                this.inventarios_tBindingSource.DataSource = Table;
            }
            reportViewer1.LocalReport.DisplayName = this.Text;
            //----------------------------------------------------------------------------------------------------------->
            reportViewer1.LocalReport.SetParameters(new ReportParameter("Image", constants.getExternalImage("header")));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("lista", lista));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("tienda", tienda));
            reportViewer1.LocalReport.SetParameters(new ReportParameter("periodo", periodo));
            reportViewer1.ZoomMode = ZoomMode.PageWidth;
            ReportPageSettings ps = reportViewer1.LocalReport.GetDefaultPageSettings();

            this.reportViewer1.ParentForm.Width = ps.PaperSize.Width;
            this.reportViewer1.RefreshReport();
        }
Example #4
0
        private void Historial_registros_Load(object sender, EventArgs e)
        {
            resetReport(new cotizaciones_local());
            this.datos_reporteTableAdapter.Fill(this.reportes_dataSet.datos_reporte);
            reportViewer1.LocalReport.SetParameters(new ReportParameter("Image", constants.getExternalImage("header")));
            ReportPageSettings ps = reportViewer1.LocalReport.GetDefaultPageSettings();

            this.reportViewer1.ParentForm.Width = ps.PaperSize.Width;
            this.reportViewer1.RefreshReport();
        }
Example #5
0
        /// <summary>
        /// Get the report settings
        /// </summary>
        /// <param name="printDoc">PrintDocument object</param>
        private void GetReportPrintSettings(ref PrintDocument printDoc)
        {
            ReportPageSettings rps = Report.LocalReport.GetDefaultPageSettings();

            _pageSettings.PaperSize = rps.PaperSize;
            _pageSettings.Margins   = rps.Margins;

            printDoc.DefaultPageSettings.Margins   = rps.Margins;
            printDoc.DefaultPageSettings.PaperSize = rps.PaperSize;
        }
Example #6
0
        public static void PrintToPrinter(this LocalReport report)
        {
            m_pageSettings = new PageSettings();
            ReportPageSettings reportPageSettings = report.GetDefaultPageSettings();

            m_pageSettings.PaperSize = reportPageSettings.PaperSize;
            m_pageSettings.Margins   = reportPageSettings.Margins;

            Export(report);
        }
Example #7
0
        private void analiticas_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'reportes_dataSet.datos_reporte' table. You can move, or remove it, as needed.
            this.datos_reporteTableAdapter.Fill(this.reportes_dataSet.datos_reporte);
            // TODO: This line of code loads data into the 'reportes_dataSet.articulos_reporte' table. You can move, or remove it, as needed.
            this.articulos_reporteTableAdapter.Fill(this.reportes_dataSet.articulos_reporte);
            ReportPageSettings ps = reportViewer1.LocalReport.GetDefaultPageSettings();

            this.reportViewer1.ParentForm.Width = ps.PaperSize.Width;
            this.reportViewer1.RefreshReport();
        }
 private AutoPrintCls(Report report)
 {
     // Set the page settings to the default defined in the report
     ReportPageSettings reportPageSettings = report.GetDefaultPageSettings();
     // The page settings object will use the default printer unless
     // PageSettings.PrinterSettings is changed.  This assumes there
     // is a default printer.
     m_pageSettings = new PageSettings();
     m_pageSettings.PaperSize = reportPageSettings.PaperSize;
     m_pageSettings.Margins = reportPageSettings.Margins;
 }
Example #9
0
        private void FrmViewChequeDetailsLoad(object sender, EventArgs e)
        {
            ReportPageSettings rptPageSettings = RptChequeDetails.LocalReport.GetDefaultPageSettings();

            if (RptChequeDetails.ParentForm.Width > rptPageSettings.PaperSize.Width)
            {
                int vPad = (RptChequeDetails.ParentForm.Width - rptPageSettings.PaperSize.Width) / 2;
                RptChequeDetails.Padding = new Padding(vPad - 20, 1, vPad - 20, 1);
            }
            this.proc_ReportTableAdapter.Fill(this.chequeMaintananceDBdsReport.Proc_Report);
            RptChequeDetails.RefreshReport();
        }
Example #10
0
        public void prt_원장조회(DataTable dt, string sDay1, string sDay2, string sCust, string sCondition)
        {
            lblMsg.Visible = true;
            Application.DoEvents();

            try
            {
                if (dt != null && dt.Rows.Count > 0)
                {
                    ////for (int kk = 0; kk < dt.Rows.Count; kk++)
                    ////{
                    ////    //if (dt매출매출항목.Rows[kk]["규격"].ToString().Length > 10)
                    ////    //{
                    ////    //    dt매출매출항목.Rows[kk]["규격"] = dt매출매출항목.Rows[kk]["규격"].ToString().Substring(0, 9) + "...";
                    ////    //}
                    ////}

                    this.reportViewer1.Reset();
                    this.reportViewer1.LocalReport.DisplayName = "원장조회" + "_" + sDay1 + "_" + sDay2;
                    this.reportViewer1.LocalReport.ReportPath  = "Reports\\rpt원장조회.rdlc";

                    ReportDataSource ds = new ReportDataSource("DataSet1", dt);
                    this.reportViewer1.LocalReport.DataSources.Add(ds);

                    ReportParameterCollection rptParams = new ReportParameterCollection();
                    rptParams.Add(new ReportParameter("p제목", "원장 조회"));
                    rptParams.Add(new ReportParameter("p검색조건", sCondition));

                    this.reportViewer1.LocalReport.SetParameters(rptParams);

                    ReportPageSettings rpg = reportViewer1.LocalReport.GetDefaultPageSettings();
                    System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
                    pg.PaperSize = rpg.PaperSize;
                    pg.Margins   = rpg.Margins;
                    pg.Landscape = false; // false = 세로, true = 가로

                    reportViewer1.SetPageSettings(pg);

                    this.reportViewer1.RefreshReport();
                    this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
                    this.reportViewer1.ZoomMode = ZoomMode.PageWidth;
                }
            }
            catch (Exception ex)
            {
                wnLog.writeLog(wnLog.LOG_ERROR, ex.Message + " - " + ex.ToString());
                MessageBox.Show("시스템에 문제가 있습니다.");
                this.Hide();
            }

            lblMsg.Visible = false;
        }
Example #11
0
        public void RefreshReport()
        {
            ReportPageSettings rptPageSettings = RptChequeDetails.LocalReport.GetDefaultPageSettings();

            if (RptChequeDetails.ParentForm.Width > rptPageSettings.PaperSize.Width)
            {
                int vPad = (RptChequeDetails.ParentForm.Width - rptPageSettings.PaperSize.Width) / 2;
                RptChequeDetails.Padding = new Padding(vPad - 20, 1, vPad - 20, 1);
            }
            RptChequeDetails.ZoomMode = ZoomMode.FullPage;
            this.proc_ReportTableAdapter.Fill(this.chequeMaintananceDBdsReport.Proc_Report);
            RptChequeDetails.RefreshReport();
        }
Example #12
0
        private ReportPrintDocument(Report report, bool isLanscape)
        {
            // Set the page settings to the default defined in the report
            ReportPageSettings reportPageSettings = report.GetDefaultPageSettings();

            // The page settings object will use the default printer unless
            // PageSettings.PrinterSettings is changed.  This assumes there
            // is a default printer.
            m_pageSettings           = new PageSettings();
            m_pageSettings.PaperSize = reportPageSettings.PaperSize;
            m_pageSettings.Margins   = reportPageSettings.Margins;
            m_pageSettings.Landscape = isLanscape;
        }
Example #13
0
        private ReportDirect(Report report)
        {
            // Set the page settings to the default defined in the report
            ReportPageSettings reportPageSettings = report.GetDefaultPageSettings();

            // The page settings object will use the default printer unless
            // PageSettings.PrinterSettings is changed. This assumes there
            // is a default printer.
            m_pageSettings = new PageSettings();
            //System.Windows.MessageBox.Show(reportPageSettings.PaperSize.PaperName);
            m_pageSettings.PaperSize = reportPageSettings.PaperSize;
            m_pageSettings.Margins   = reportPageSettings.Margins;
        }
Example #14
0
        public void prt_원자재재고현황(DataTable dt, string sDay1, string sCondition)
        {
            lblMsg.Visible = true;
            Application.DoEvents();

            try
            {
                if (dt != null && dt.Rows.Count > 0)
                {
                    if (sCondition == "원자재재고현황")
                    {
                        this.reportViewer1.Reset();
                        this.reportViewer1.LocalReport.DisplayName = "원자재재고현황";
                        this.reportViewer1.LocalReport.ReportPath  = Application.StartupPath + "\\Reports\\rpt원자재재고현황.rdlc";

                        ReportDataSource ds = new ReportDataSource("DataSet1", dt);
                        this.reportViewer1.LocalReport.DataSources.Add(ds);

                        ReportParameterCollection rptParams = new ReportParameterCollection();
                        rptParams.Add(new ReportParameter("p제목", "원자재재고현황"));
                        //rptParams.Add(new ReportParameter("p견적구분", "아래와 같이 견적합니다."));
                        rptParams.Add(new ReportParameter("p검색조건", "검색일자 : " + sDay1));

                        this.reportViewer1.LocalReport.SetParameters(rptParams);
                    }


                    ReportPageSettings rpg = reportViewer1.LocalReport.GetDefaultPageSettings();
                    System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
                    pg.PaperSize = rpg.PaperSize;
                    pg.Margins   = rpg.Margins;
                    pg.Landscape = false; // false = 세로, true = 가로

                    reportViewer1.SetPageSettings(pg);

                    this.reportViewer1.RefreshReport();
                    this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
                    this.reportViewer1.ZoomMode = ZoomMode.PageWidth;
                }
            }
            catch (Exception ex)
            {
                wnLog.writeLog(wnLog.LOG_ERROR, ex.Message + " - " + ex.ToString());
                MessageBox.Show("시스템에 문제가 있습니다.");
                this.Hide();
            }

            lblMsg.Visible = false;
        }
        public static string GetDeviceInfoFromReport(LocalReport rpt, string uiCulture, string format)
        {
            string strMargins;
            string orientation;

            //Render overwrites margins defined in RDLC; capture margins in RDLC
            ReportPageSettings pageSettings = rpt.GetDefaultPageSettings();

            strMargins = String.Concat((Convert.ToDouble(pageSettings.Margins.Top) / 40.0).ToString(), ",", (Convert.ToDouble(pageSettings.Margins.Left) / 40.0).ToString(), ",", (Convert.ToDouble(pageSettings.Margins.Bottom) / 40.0).ToString(), ",", (Convert.ToDouble(pageSettings.Margins.Right) / 40.0).ToString());

            //Capture report orientation
            orientation = pageSettings.IsLandscape ? "landscape" : "portrait";

            return(GetDeviceInfo(uiCulture, format, strMargins, orientation));
        }
Example #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="localReport"></param>
        public ReportPrintDocument(LocalReport localReport)

        {
            // Set the page settings to the default defined in the report
            ReportPageSettings reportPageSettings = localReport.GetDefaultPageSettings();

            // The page settings object will use the default printer unless
            // PageSettings.PrinterSettings is changed.  This assumes there
            // is a default printer.
            m_pageSettings           = new PageSettings();
            m_pageSettings.PaperSize = reportPageSettings.PaperSize;
            m_pageSettings.Margins   = reportPageSettings.Margins;

            RenderAllLocalReportPages(localReport);
        }
Example #17
0
        private ReportPrintDocument(Report report)
        {
            // Set the page settings to the default defined in the report
            ReportPageSettings reportPageSettings = report.GetDefaultPageSettings();

            // The page settings object will use the default printer unless
            // PageSettings.PrinterSettings is changed.  This assumes there
            // is a default printer.
            _mPageSettings = new PageSettings
            {
                Landscape = true,
                PaperSize = reportPageSettings.PaperSize,
                Margins   = reportPageSettings.Margins
            };
        }
Example #18
0
        private void Export(LocalReport report)
        {
            report.EnableExternalImages = true;
            ReportPageSettings rps = report.GetDefaultPageSettings();

            ps          = rps.PaperSize;
            ms          = rps.Margins;
            isLandscape = rps.IsLandscape;

            Width  = ps.Width;
            Height = ps.Height;
            if (rps.IsLandscape)
            {
                Width  = ps.Height;
                Height = ps.Width;
            }
            int totalPages = 1;

            Warning[] warnings;
            string    deviceInfo;

            do
            {
                this.Dispose();
                m_streams  = new List <Stream>();
                deviceInfo =
                    @"<DeviceInfo>
                <OutputFormat>EMF</OutputFormat>
                <PageWidth>" + Width / 100.00 + "in</PageWidth>" +
                    "<PageHeight>" + Height / 100.00 + "in</PageHeight>" +
                    "<MarginTop>" + ms.Top / 100.00 + "in</MarginTop>" +
                    "<MarginLeft>" + ms.Left / 100.00 + "in</MarginLeft>" +
                    "<MarginRight>" + ms.Right / 100.00 + "in</MarginRight>" +
                    "<MarginBottom>" + ms.Bottom / 100.00 + "in</MarginBottom>" +
                    "</DeviceInfo>";
                report.Render("Image", deviceInfo, CreateStream,
                              out warnings);
                foreach (Stream stream in m_streams)
                {
                    stream.Position = 0;
                }
                totalPages = m_streams.Count;
                if (totalPages > 1)
                {
                    Height += 29;
                }
            }while (totalPages > 1);
        }
Example #19
0
        public void prt_HACCP점검표(DataTable dt, DataTable dt2, string sDate, string sNum, string sCondition)
        {
            try
            {
                if (dt != null && dt.Rows.Count > 0)
                {
                    this.reportViewer1.Reset();
                    this.reportViewer1.LocalReport.DisplayName = "중요관리점(CCP) 검증 점검표" + "_" + sDate + "_" + sNum;
                    this.reportViewer1.LocalReport.ReportPath  = Application.StartupPath + "\\Reports\\rptHACCP점검표.rdlc";

                    ReportDataSource ds = new ReportDataSource("DataSet1", dt);
                    //this.reportViewer1.LocalReport.DataSources.Add(ds);
                    ds = new ReportDataSource("DataSet1", dt2);
                    this.reportViewer1.LocalReport.DataSources.Add(ds);


                    ReportParameterCollection rptParams = new ReportParameterCollection();
                    //rptParams.Add(new ReportParameter("p제목", "발주현황표"));

                    this.reportViewer1.LocalReport.SetParameters(rptParams);
                }

                ReportPageSettings rpg = reportViewer1.LocalReport.GetDefaultPageSettings();
                System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
                pg.PaperSize = rpg.PaperSize;
                pg.Margins   = rpg.Margins;
                pg.Landscape = false; // false = 세로, true = 가로

                //var setup = reportViewer1.GetPageSettings();
                //setup.PaperSize.Width = 900;
                //setup.PaperSize.Height = 600;
                //setup.Landscape = false;
                //setup.Margins.Left = 27;

                reportViewer1.SetPageSettings(pg);//pg

                this.reportViewer1.RefreshReport();
                this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
                this.reportViewer1.ZoomMode = ZoomMode.PageWidth;
            }
            catch (Exception e)
            {
                wnLog.writeLog(wnLog.LOG_ERROR, e.Message + " - " + e.ToString());
                MessageBox.Show("시스템에 문제가 있습니다.");
                this.Hide();
            }
        }
Example #20
0
        private void PrintPreview_Load(object sender, EventArgs e)
        {
            try
            {
                ReportDataSource datasource = null;
                ReportDataSource data       = null;
                ReportDataSource datatable  = null;

                con = new Connect();
                DataTable dt = new DataTable();
                dt = GetDataBill(printid);
                DataTable dsCustomers = GetData(printid);
                DataTable table       = GetDataTable(printid);
                datatable  = new ReportDataSource("DataSet3", table);
                datasource = new ReportDataSource("DataSet1", dsCustomers);
                data       = new ReportDataSource("DataSet2", dt);
                //this.reportViewer2.LocalReport.ReportPath="R_Bill.rdlc";
                this.reportViewer2.LocalReport.DataSources.Clear();
                this.reportViewer2.LocalReport.DataSources.Add(datasource);
                this.reportViewer2.LocalReport.DataSources.Add(data);
                this.reportViewer2.LocalReport.DataSources.Add(datatable);
                PageSettings pg = new PageSettings();

                pg.Landscape      = false;
                pg.Margins.Top    = 15;
                pg.Margins.Bottom = 0;
                pg.Margins.Left   = 15;
                pg.Margins.Right  = 0;
                PaperSize size = new PaperSize("A5", 583, 827);
                size.RawKind = (int)PaperKind.A5;
                pg.PaperSize = size;

                this.reportViewer2.SetPageSettings(pg);
                this.reportViewer2.RefreshReport();
                ReportPageSettings rst = reportViewer2.LocalReport.GetDefaultPageSettings();

                //if (reportViewer2.ParentForm.Width > rst.PaperSize.Width)
                //{
                //    int vPad = (reportViewer1.ParentForm.Width - rst.PaperSize.Width) / 2;
                //    reportViewer2.Padding = new Padding(vPad - 20, 1, vPad - 20, 1);
                //}
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #21
0
        private ReportPrintDocument_Landscape(Report report)
        {
            // Set the page settings to the default defined in the report
            ReportPageSettings reportPageSettings = report.GetDefaultPageSettings();

            // The page settings object will use the default printer unless
            // PageSettings.PrinterSettings is changed.  This assumes there
            // is a default printer.



            m_pageSettings                   = new PageSettings();
            m_pageSettings.PaperSize         = new System.Drawing.Printing.PaperSize("A4", 1169, 827);
            m_pageSettings.PaperSize.RawKind = (int)System.Drawing.Printing.PaperKind.A4;
            m_pageSettings.Landscape         = true;
            //   reportPageSettings.PrinterSettings(m_pageSettings);
        }
Example #22
0
        //public  int distinctTop;
        //public  int distinctButtom;
        //public  int distinctLeft;
        //public  int distinctRight;

        public ReportPrintDocument(ServerReport serverReport, int distinctLeft, int distinctRight, int distinctTop, int distinctButtom)

        {
            // Set the page settings to the default defined in the report
            ReportPageSettings reportPageSettings = serverReport.GetDefaultPageSettings();

            // The page settings object will use the default printer unless
            // PageSettings.PrinterSettings is changed.  This assumes there
            // is a default printer.
            m_pageSettings = new PageSettings();

            //m_pageSettings.PaperSize = reportPageSettings.PaperSize;
            m_pageSettings.PaperSize =
                new PaperSize("custom", reportPageSettings.PaperSize.Height, reportPageSettings.PaperSize.Width);

            //m_pageSettings.Margins = reportPageSettings.Margins;
            m_pageSettings.Margins = new Margins(distinctLeft, distinctRight, distinctTop, distinctButtom); //reportPageSettings.Margins;

            RenderAllServerReportPages(serverReport);
            // MessageBox.Show(distinctTop.ToString()+","+ distinctButtom.ToString()+","+distinctLeft.ToString()+","+distinctRight.ToString()+",");
        }
Example #23
0
        private void FillPages(bool landscape)
        {
            //PaperSize paper_size = ctlReportViewer.LocalReport.GetDefaultPageSettings().PaperSize;
            //string deviceInfo =
            //  "<DeviceInfo>" +
            //  "<OutputFormat>EMF</OutputFormat>" +
            //  ((landscape) ? "<PageWidth>297mm</PageWidth><PageHeight>210mm</PageHeight>" : "<PageWidth>210mm</PageWidth><PageHeight>297mm</PageHeight>") +
            //  "<MarginTop>0mm</MarginTop>" +
            //  "<MarginLeft>0mm</MarginLeft>" +
            //  "<MarginRight>0mm</MarginRight>" +
            //  "<MarginBottom>10mm</MarginBottom>" +
            //  "</DeviceInfo>";


            ReportPageSettings set = ctlReportViewer.LocalReport.GetDefaultPageSettings();
            //MarginsConverter conv = new MarginsConverter();
            //string temp = conv.ConvertToInvariantString(set.Margins);
            string deviceInfo =
                "<DeviceInfo>" +
                "<OutputFormat>EMF</OutputFormat>" +
                ((landscape) ? "<PageWidth>297mm</PageWidth><PageHeight>210mm</PageHeight>" : "<PageWidth>210mm</PageWidth><PageHeight>297mm</PageHeight>") +
                "<MarginTop>" + Common.PropValueDecimal2String(set.Margins.Top / 3.937) + "mm</MarginTop>" +
                "<MarginLeft>" + Common.PropValueDecimal2String(set.Margins.Left / 3.937) + "mm</MarginLeft>" +
                "<MarginRight>" + Common.PropValueDecimal2String(set.Margins.Right / 3.937) + "mm</MarginRight>" +
                "<MarginBottom>" + Common.PropValueDecimal2String(set.Margins.Bottom / 3.937) + "mm</MarginBottom>" +
                "</DeviceInfo>";

            Warning[] warnings;
            _pages = new List <Stream>();
            if (ctlReportViewer.ProcessingMode == ProcessingMode.Local)
            {
                ctlReportViewer.LocalReport.Render("Image", deviceInfo, CreateStream, out warnings);
            }
            foreach (Stream stream in _pages)
            {
                stream.Position = 0;
            }
            _printdoc.PrintPage += new PrintPageEventHandler(PrintPage);
            //_printdoc.DefaultPageSettings.Landscape = (paper_size.Width > 850);
        }
Example #24
0
        private void FormReportView_Load(object sender, EventArgs e)
        {
            this.Text = this.FormCaption;
            LocalReport l = repView.LocalReport;

            l.DisplayName = this.ReportDisplayName;

            // hide the ReportViewer toolbar.
            this.repView.ShowToolBar = false;

            this.repView.DocumentMapCollapsed = true;
            btnDocumentMap.Checked            = !this.repView.DocumentMapCollapsed;
            btnLayout.Checked   = false;
            btnFind.Enabled     = false;
            btnFindNext.Enabled = false;

            totalPages = this.repView.LocalReport.GetTotalPages() + 1;

            this.repView.CurrentPage = 1;

            displayCurrentPage();

            reportPageSettings = repView.LocalReport.GetDefaultPageSettings();
            pageSetupDialog    = new PageSetupDialog();
            pageSetupDialog.PrinterSettings = new PrinterSettings();
            pageSettings = new PageSettings(pageSetupDialog.PrinterSettings);
            pageSetupDialog.PageSettings = new PageSettings();
            pageSetupDialog.PageSettings = pageSettings;

            pageSetupDialog.PageSettings.Margins   = repView.LocalReport.GetDefaultPageSettings().Margins;
            pageSetupDialog.PageSettings.PaperSize = repView.LocalReport.GetDefaultPageSettings().PaperSize;

            setupZoomCombo();

            this.repView.RefreshReport();
        }
Example #25
0
        private void FormReportView_Load(object sender, EventArgs e)
        {
            this.Text = this.FormCaption;
            LocalReport l = repView.LocalReport;
            l.DisplayName = this.ReportDisplayName;

            // hide the ReportViewer toolbar.
            this.repView.ShowToolBar = false;

            this.repView.DocumentMapCollapsed = true;
            btnDocumentMap.Checked = !this.repView.DocumentMapCollapsed;
            btnLayout.Checked = false;
            btnFind.Enabled = false;
            btnFindNext.Enabled = false;

            totalPages = this.repView.LocalReport.GetTotalPages() + 1;

            this.repView.CurrentPage = 1;

            displayCurrentPage();

            reportPageSettings = repView.LocalReport.GetDefaultPageSettings();
            pageSetupDialog = new PageSetupDialog();
            pageSetupDialog.PrinterSettings = new PrinterSettings();
            pageSettings = new PageSettings(pageSetupDialog.PrinterSettings);
            pageSetupDialog.PageSettings = new PageSettings();
            pageSetupDialog.PageSettings = pageSettings;

            pageSetupDialog.PageSettings.Margins = repView.LocalReport.GetDefaultPageSettings().Margins;
            pageSetupDialog.PageSettings.PaperSize = repView.LocalReport.GetDefaultPageSettings().PaperSize;

            setupZoomCombo();

            this.repView.RefreshReport();
        }
Example #26
0
        public void prt_매입처원장(DataTable adoPrt2, DataGridView dgv, string strDay1, string strDay2, string strCondition)
        {
            DataTable adoPrt = GetDataTableFromDGV(dgv);


            try
            {
                if (adoPrt != null && adoPrt.Rows.Count > 0)
                {
                    this.reportViewer1.Reset();
                    this.reportViewer1.LocalReport.DisplayName = "매출처 원장";
                    this.reportViewer1.LocalReport.ReportPath  = Application.StartupPath + "\\Reports\\rpt매출처원장.rdlc";


                    adoPrt.Columns["NO"].ColumnName               = "전표분류";
                    adoPrt.Columns["BUY_DATE"].ColumnName         = "일자명칭";
                    adoPrt.Columns["BUY_CD"].ColumnName           = "전표번호";
                    adoPrt.Columns["INPUT_GUBUN"].ColumnName      = "구분명칭";
                    adoPrt.Columns["PRODUCT_NM"].ColumnName       = "상품명";
                    adoPrt.Columns["TOTAL_AMT"].ColumnName        = "박스수량";
                    adoPrt.Columns["TOTAL_PRICE"].ColumnName      = "박스단가";
                    adoPrt.Columns["TOTAL_MONEY"].ColumnName      = "금액";
                    adoPrt.Columns["TOTAL_TAX_MONEY"].ColumnName  = "부가세액";
                    adoPrt.Columns["GIVE_MONEY"].ColumnName       = "수금액";
                    adoPrt.Columns["TOTAL_GIVE_MONEY"].ColumnName = "지급액";
                    adoPrt.Columns["DC_MONEY"].ColumnName         = "할인액";
                    adoPrt.Columns["BALANCE"].ColumnName          = "잔고";

                    adoPrt.Columns.Add("서비스박스");
                    adoPrt.Columns.Add("서비스낱개");
                    adoPrt.Columns.Add("낱개단가");
                    adoPrt.Columns.Add("총수량");
                    adoPrt.Columns.Add("낱개수량");
                    adoPrt.Columns.Add("중간수량");
                    adoPrt.Columns.Add("규격");
                    adoPrt.Columns.Add("정렬구분");
                    adoPrt.Columns.Add("일자");


                    for (int i = 0; i < adoPrt.Rows.Count; i++)
                    {
                        adoPrt.Rows[i]["서비스박스"] = "0";
                        adoPrt.Rows[i]["서비스낱개"] = "0";
                        adoPrt.Rows[i]["낱개단가"]  = "0";
                        adoPrt.Rows[i]["박스단가"]  = "";
                        adoPrt.Rows[i]["총수량"]   = "0";
                        adoPrt.Rows[i]["낱개수량"]  = "0";
                        adoPrt.Rows[i]["중간수량"]  = "0";
                        adoPrt.Rows[i]["규격"]    = "0";
                        adoPrt.Rows[i]["정렬구분"]  = "0";
                        adoPrt.Rows[i]["일자"]    = "0";
                    }



                    ReportDataSource ds = new ReportDataSource("DataSet1", adoPrt);
                    //this.reportViewer1.LocalReport.DataSources.Add(ds);
                    this.reportViewer1.LocalReport.DataSources.Add(ds);


                    ReportParameterCollection rptParams = new ReportParameterCollection();
                    rptParams.Add(new ReportParameter("p제목", adoPrt2.Rows[0]["CUST_NM"].ToString() + ".거래원장"));
                    rptParams.Add(new ReportParameter("p검색기간", strDay1 + " ~ " + strDay2));
                    rptParams.Add(new ReportParameter("p담당사원", "담당사원 : " + adoPrt2.Rows[0]["CUST_MANAGER"].ToString()));
                    rptParams.Add(new ReportParameter("p거래처명", adoPrt2.Rows[0]["CUST_NM"].ToString()));
                    rptParams.Add(new ReportParameter("p거래처코드", adoPrt2.Rows[0]["CUST_CD"].ToString()));
                    rptParams.Add(new ReportParameter("p거래처사업자번호", adoPrt2.Rows[0]["SAUP_NO"].ToString()));
                    rptParams.Add(new ReportParameter("p거래처전화번호", adoPrt2.Rows[0]["CUST_COMP_PHONE"].ToString()));
                    rptParams.Add(new ReportParameter("p거래처주소", adoPrt2.Rows[0]["ADDR"].ToString()));
                    rptParams.Add(new ReportParameter("p거래처대표자명", adoPrt2.Rows[0]["OWNER"].ToString()));
                    //rptParams.Add(new ReportParameter("p제목", "발주현황표"));

                    this.reportViewer1.LocalReport.SetParameters(rptParams);
                }

                ReportPageSettings rpg = reportViewer1.LocalReport.GetDefaultPageSettings();
                System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
                pg.PaperSize = rpg.PaperSize;
                pg.Margins   = rpg.Margins;
                pg.Landscape = true; // false = 세로, true = 가로

                var setup = reportViewer1.GetPageSettings();
                setup.PaperSize.Width  = 1600;
                setup.PaperSize.Height = 1200;
                setup.Landscape        = false;
                setup.Margins.Left     = 27;

                reportViewer1.SetPageSettings(pg);//pg

                this.reportViewer1.RefreshReport();
                this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
                this.reportViewer1.ZoomMode = ZoomMode.PageWidth;
            }
            catch (Exception e)
            {
                wnLog.writeLog(wnLog.LOG_ERROR, e.Message + " - " + e.ToString());
                MessageBox.Show("시스템에 문제가 있습니다.");
                MessageBox.Show(e.Message + " - " + e.ToString());
                this.Hide();
            }
        }
Example #27
0
        public void prt_원장현황(DataTable dt, DataGridView dgv, string sDay1, string sDay2, string sCondition, string title)
        {
            lblMsg.Visible = true;
            Application.DoEvents();
            try
            {
                DataTable adoPrt = GetDataTableFromDGV(dgv);
                if (adoPrt != null && adoPrt.Rows.Count > 0)
                {
                    adoPrt.Columns.Add("제품코드");
                    adoPrt.Columns["PRODUCT_NM"].ColumnName = "제품명";
                    adoPrt.Columns.Add("원부재료코드");
                    adoPrt.Columns["LABEL_NM"].ColumnName = "원부재료명";
                    adoPrt.Columns.Add("규격");
                    adoPrt.Columns.Add("단위코드");
                    adoPrt.Columns["UNIT_NM"].ColumnName    = "단위명";
                    adoPrt.Columns["OUTPUT_LOT"].ColumnName = "제조번호";
                    adoPrt.Columns.Add("제조번호S");
                    adoPrt.Columns["INPUT_AMT"].ColumnName  = "입고량";
                    adoPrt.Columns["OUTPUT_AMT"].ColumnName = "출고량";
                    adoPrt.Columns["BALSTOCK"].ColumnName   = "HEATNO";
                    adoPrt.Columns["no"].ColumnName         = "no";
                    adoPrt.Columns.Add("출고일자");
                    adoPrt.Columns.Add("바코드");
                    adoPrt.Columns.Add("투입량");
                    adoPrt.Columns.Add("거래처코드");
                    adoPrt.Columns.Add("거래처명");
                    adoPrt.Columns["INPUT_DATE"].ColumnName = "입고일자";
                    adoPrt.Columns["INPUT_CD"].ColumnName   = "입고번호";
                    adoPrt.Columns["SEQ"].ColumnName        = "입고순번";
                    adoPrt.Columns.Add("구분코드");
                    adoPrt.Columns["INPUT_GUBUN"].ColumnName = "구분명";
                    adoPrt.Columns.Add("수량");
                    adoPrt.Columns.Add("금액");
                    adoPrt.Columns["CHUGJONG_NM"].ColumnName = "축종";
                    adoPrt.Columns["CLASS_NM"].ColumnName    = "부위";
                    adoPrt.Columns.Add("등급");
                    adoPrt.Columns["COUNTRY_NM"].ColumnName = "원산지";
                    adoPrt.Columns.Add("유형");
                    adoPrt.Columns["FROZEN_GUBUN"].ColumnName = "보관구분";
                    adoPrt.Columns["UNION_CD"].ColumnName     = "개체번호";

                    for (int i = 0; i < adoPrt.Rows.Count; i++)
                    {
                        adoPrt.Rows[i]["제품코드"]   = "0";
                        adoPrt.Rows[i]["원부재료코드"] = "0";
                        adoPrt.Rows[i]["규격"]     = "0";
                        adoPrt.Rows[i]["단위코드"]   = "0";
                        adoPrt.Rows[i]["출고일자"]   = "0";
                        adoPrt.Rows[i]["바코드"]    = "0";
                        adoPrt.Rows[i]["투입량"]    = "0";
                        adoPrt.Rows[i]["거래처코드"]  = "0";
                        adoPrt.Rows[i]["거래처명"]   = "0";
                        adoPrt.Rows[i]["구분코드"]   = "0";
                        adoPrt.Rows[i]["수량"]     = "0";
                        adoPrt.Rows[i]["금액"]     = "0";
                        adoPrt.Rows[i]["등급"]     = "0";
                        adoPrt.Rows[i]["유형"]     = "0";
                    }
                }
                if (adoPrt != null && adoPrt.Rows.Count > 0)
                {
                    string TitleTemp = sCondition;
                    if (title != null && !title.Equals(""))
                    {
                        TitleTemp = title + "." + TitleTemp;
                    }
                    if (sCondition == "원자재원장현황")
                    {
                        this.reportViewer1.Reset();
                        this.reportViewer1.LocalReport.DisplayName = "원자재원장현황";
                        this.reportViewer1.LocalReport.ReportPath  = Application.StartupPath + "\\Reports\\rpt원장현황.rdlc";

                        ReportDataSource ds = new ReportDataSource("DataSet1", adoPrt);
                        this.reportViewer1.LocalReport.DataSources.Add(ds);
                        ReportParameterCollection rptParams = new ReportParameterCollection();
                        rptParams.Add(new ReportParameter("p제목", TitleTemp));
                        //rptParams.Add(new ReportParameter("p견적구분", "아래와 같이 견적합니다."));
                        rptParams.Add(new ReportParameter("p검색조건", "검색일자 : " + sDay1 + " ~ " + sDay2));

                        this.reportViewer1.LocalReport.SetParameters(rptParams);
                    }

                    else if (sCondition == "제품원장현황")
                    {
                        this.reportViewer1.Reset();
                        this.reportViewer1.LocalReport.DisplayName = "제품원장현황";
                        this.reportViewer1.LocalReport.ReportPath  = Application.StartupPath + "\\Reports\\rpt원장현황.rdlc";

                        ReportDataSource ds = new ReportDataSource("DataSet1", adoPrt);
                        this.reportViewer1.LocalReport.DataSources.Add(ds);
                        ReportParameterCollection rptParams = new ReportParameterCollection();
                        rptParams.Add(new ReportParameter("p제목", TitleTemp));
                        //rptParams.Add(new ReportParameter("p견적구분", "아래와 같이 견적합니다."));
                        rptParams.Add(new ReportParameter("p검색조건", "검색일자 : " + sDay1 + " ~ " + sDay2));

                        this.reportViewer1.LocalReport.SetParameters(rptParams);
                    }

                    ReportPageSettings rpg = reportViewer1.LocalReport.GetDefaultPageSettings();
                    System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
                    pg.PaperSize = rpg.PaperSize;
                    pg.Margins   = rpg.Margins;
                    pg.Landscape = true; // false = 세로, true = 가로

                    //var setup = reportViewer1.GetPageSettings();
                    //setup.PaperSize.Width = 1600;
                    //setup.PaperSize.Height = 1200;
                    //setup.Landscape = false;
                    //setup.Margins.Left = 200;

                    reportViewer1.SetPageSettings(pg);//pg

                    this.reportViewer1.RefreshReport();
                    this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
                    this.reportViewer1.ZoomMode = ZoomMode.PageWidth;
                }
            }
            catch (Exception ex)
            {
                wnLog.writeLog(wnLog.LOG_ERROR, ex.Message + " - " + ex.ToString());
                MessageBox.Show("시스템에 문제가 있습니다.");
                this.Hide();
            }

            lblMsg.Visible = false;
        }
Example #28
0
        /// <summary>
        /// Print Report to specificed printer.
        /// </summary>
        /// <param name="rptViewer">The instance of Report Viewer Control.</param>
        /// <param name="printerName">The target printer name.</param>
        /// <param name="fromPage">-1 for print all</param>
        /// <param name="toPage">-1 for print all</param>
        /// <param name="noOfCopies">The Number of Copies.</param>
        /// <returns>Returns instance of RdlcPrintResult.</returns>
        public static RdlcPrintResult PrintTo(this ReportViewer rptViewer,
                                              string printerName,
                                              int fromPage     = -1, int toPage = -1,
                                              short noOfCopies = 1)
        {
            RdlcPrintResult result = new RdlcPrintResult();

            result.Success = false;

            if (string.IsNullOrWhiteSpace(printerName))
            {
                result.Message = "No printer selected.";

                RdlcMessageService.Instance.SendMessage(result.Message);

                return(result);
            }

            if (null == rptViewer.LocalReport ||
                null == rptViewer.LocalReport.DataSources ||
                rptViewer.LocalReport.DataSources.Count <= 0)
            {
                result.Message = "Report is not loaded or report has no data.";

                RdlcMessageService.Instance.SendMessage(result.Message);

                return(result);
            }

            LocalReportRenderer prt = null;

            try
            {
                LocalReport        lr       = rptViewer.LocalReport;
                ReportPageSettings settings = lr.GetDefaultPageSettings();

                if (null == settings)
                {
                    result.Message = "Cannot get page settings.";

                    RdlcMessageService.Instance.SendMessage(result.Message);

                    return(result);
                }

                #region Assign page setting

                LocalReportPageSettings pageSettings = new LocalReportPageSettings();

                if (!settings.IsLandscape)
                {
                    pageSettings.PageHeight = Convert.ToDouble(
                        (double)settings.PaperSize.Height / (double)100);
                    pageSettings.PageWidth = Convert.ToDouble(
                        (double)settings.PaperSize.Width / (double)100);
                }
                else
                {
                    pageSettings.PageHeight = Convert.ToDouble(
                        (double)settings.PaperSize.Width / (double)100);
                    pageSettings.PageWidth = Convert.ToDouble(
                        (double)settings.PaperSize.Height / (double)100);
                }
                pageSettings.MarginLeft = Convert.ToDouble(
                    (double)settings.Margins.Left / (double)100);
                pageSettings.MarginRight = Convert.ToDouble(
                    (double)settings.Margins.Right / (double)100);
                pageSettings.MarginTop = Convert.ToDouble(
                    (double)settings.Margins.Top / (double)100);
                pageSettings.MarginBottom = Convert.ToDouble(
                    (double)settings.Margins.Bottom / (double)100);

                //pageSettings.MarginLeft = 0;
                //pageSettings.MarginRight = 0;
                //pageSettings.MarginTop = 0;
                //pageSettings.MarginBottom = 0;

                pageSettings.Landscape = settings.IsLandscape;

                pageSettings.FromPage = fromPage;
                pageSettings.ToPage   = toPage;

#if WYSIWYG
                // Read Screen Resolution
                int dx, dy;
                System.Drawing.Graphics g = rptViewer.CreateGraphics();
                try
                {
                    dx = Convert.ToInt32(g.DpiX);
                    dy = Convert.ToInt32(g.DpiY);
                }
                finally
                {
                    g.Dispose();
                }
                pageSettings.DpiX = dx;
                pageSettings.DpiY = dy;

                // Create dialog and re read resolution.
                System.Windows.Forms.PrintDialog pd = new System.Windows.Forms.PrintDialog();
                pd.PrinterSettings.PrinterName = printerName;
                System.Drawing.Printing.PrinterSettings ps = pd.PrinterSettings;

                pageSettings.PrintDpiX = ps.DefaultPageSettings.PrinterResolution.X;
                pageSettings.PrintDpiY = ps.DefaultPageSettings.PrinterResolution.Y;
#endif
                #endregion

                prt = new LocalReportRenderer();
                prt.Print(lr, printerName, pageSettings, noOfCopies);

                result.Success = true;
                result.Message = "Print Success.";
                RdlcMessageService.Instance.SendMessage(result.Message);
            }
            catch (Exception ex)
            {
                result.Message = ex.ToString();
            }
            finally
            {
                if (null != prt)
                {
                    prt.Dispose();
                }
                prt = null;
            }

            return(result);
        }
Example #29
0
        /// <summary>
        /// Print RDLC File
        /// </summary>
        /// <returns></returns>
        public bool Print()
        {
            this.pageIndex = 0;

            this.pageStreams.Clear();


            ReportPageSettings rps = this.localReport.GetDefaultPageSettings();

            float pageWidth    = 0f;
            float pageHeight   = 0f;
            float marginTop    = rps.Margins.Top / 100f;
            float marginLeft   = rps.Margins.Left / 100f;
            float marginRight  = rps.Margins.Right / 100f;
            float marginBottom = rps.Margins.Bottom / 100f;

            bool landscape = false;

            if (rps.PaperSize.Width > rps.PaperSize.Height)
            {
                pageWidth  = rps.PaperSize.Width / 100f;
                pageHeight = rps.PaperSize.Height / 100f;

                landscape = false;
            }
            else
            {
                pageWidth  = rps.PaperSize.Height / 100f;
                pageHeight = rps.PaperSize.Width / 100f;

                landscape = true;
            }
            string ImageDeviceInfo = string.Format(@"<DeviceInfo>
                                                        <OutputFormat>EMF</OutputFormat>
                                                        <PageWidth>{0}in</PageWidth>
                                                        <PageHeight>{1}in</PageHeight>
                                                        <MarginTop>{2}in</MarginTop>
                                                        <MarginLeft>{3}in</MarginLeft>
                                                        <MarginRight>{4}in</MarginRight>
                                                        <MarginBottom>{5}in</MarginBottom>
                                                     </DeviceInfo>",
                                                   pageWidth, pageHeight, marginTop, marginLeft, marginRight, marginBottom);

            Warning[] warnings = null;
            try
            {
                this.localReport.Render("Image", ImageDeviceInfo, CreatePrintPageStream, out warnings);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            if (warnings != null && warnings.Length > 0)
            {
                string warnMsg = string.Empty;

                foreach (Warning warning in warnings)
                {
                    warnMsg += string.Format("WarningCode: {0} WarningMessage: {1}\r\n", warning.Code, warning.Message);
                }

                throw new Exception(warnMsg);
            }

            if (this.pageStreams == null || this.pageStreams.Count == 0)
            {
                return(false);
            }

            try
            {
                PageSetupDialog psd      = new PageSetupDialog();
                PrinterSettings printset = new PrinterSettings();

                XmlDocument doc     = new XmlDocument();
                string      xmlFile = AppDomain.CurrentDomain.BaseDirectory + "BugsBox.Pharmacy.AppClient.printSet.xml";
                doc.Load(xmlFile);
                string s = System.Environment.CurrentDirectory;

                XmlNodeList nodelist = doc.SelectNodes("/printsets/pageset");

                int          wt      = Convert.ToInt16(nodelist[0].Attributes["width"].Value);
                int          ht      = Convert.ToInt16(nodelist[1].Attributes["height"].Value);
                PaperSize    pse     = new PaperSize("Custom", wt, ht);
                PageSettings pageset = new PageSettings();

                int     Bottom = Convert.ToInt16(nodelist[2].Attributes["top"].Value);
                int     Top    = Convert.ToInt16(nodelist[3].Attributes["left"].Value);
                int     Left   = Convert.ToInt16(nodelist[4].Attributes["right"].Value);
                int     Right  = Convert.ToInt16(nodelist[5].Attributes["bottom"].Value);
                Margins margin = new Margins(Left, Right, Top, Bottom);
                pageset.Margins = margin;

                pageset.PaperSize = pse;

                printset.DefaultPageSettings.PaperSize = pse;
                psd.PrinterSettings                = printset;
                psd.PageSettings                   = pageset;
                psd.PageSettings.PaperSize         = pse;
                this.printDocument.PrinterSettings = psd.PrinterSettings;

                this.printPreview.Document = this.printDocument;
                this.printPreview.ShowDialog();
                //使用image输出到文件后,可能会改变应用程序默认路径,所以。。。。。。。。
                if (System.Environment.CurrentDirectory != s)
                {
                    System.Environment.CurrentDirectory = s;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("打印配置文件丢失,请检查!\n" + ex.Message);
            }
            return(true);
        }
Example #30
0
        /// <summary>
        /// Load Report.
        /// </summary>
        /// <param name="rptViewer">The instance of Report Viewer Control.</param>
        /// <param name="reportSource">The instance of RdlcReportModel.</param>
        public static void LoadReport(this ReportViewer rptViewer,
                                      RdlcReportModel reportSource)
        {
            RdlcMessageService.Instance.SendMessage("Begin Load Report.");

            rptViewer.ProcessingMode = ProcessingMode.Local;
            LocalReport lr = rptViewer.LocalReport;

            if (null != reportSource && null != reportSource.Definition &&
                null != reportSource.Definition.RdlcInstance &&
                null != reportSource.DataSources)
            {
                RdlcMessageService.Instance.SendMessage("Begin Load Report Definition.");

                // Load Rdlc file
                lr.LoadReportDefinition(reportSource.Definition.RdlcInstance);

                RdlcMessageService.Instance.SendMessage("Clear Report Data source.");
                // Clear all datasource before assign new one.
                lr.DataSources.Clear();

                if (reportSource.DataSources.Count > 0)
                {
                    // Set all data source.
                    foreach (var dataSource in reportSource.DataSources)
                    {
                        if (null == dataSource.Items)
                        {
                            continue;
                        }
                        RdlcMessageService.Instance
                        .SendMessage("Add New Report Data source - " + dataSource.Name);
                        lr.DataSources.Add(new ReportDataSource(
                                               dataSource.Name, dataSource.Items));
                    }
                }
                else
                {
                    RdlcMessageService.Instance
                    .SendMessage("No New Report Data source.");
                }

                if (lr.DataSources.Count > 0 &&
                    null != reportSource.Parameters && reportSource.Parameters.Count > 0)
                {
                    foreach (RdlcReportParameter para in reportSource.Parameters)
                    {
                        if (null == para || string.IsNullOrWhiteSpace(para.Name))
                        {
                            continue;
                        }
                        try
                        {
                            RdlcMessageService.Instance
                            .SendMessage("Set Report parameter - " + para.Name);

                            lr.SetValue(para.Name, para.Value);
                        }
                        catch (Exception) { }
                    }
                }
                else
                {
                    RdlcMessageService.Instance
                    .SendMessage("No Report parameter assigned.");
                }

                if (lr.DataSources.Count > 0)
                {
                    RdlcMessageService.Instance
                    .SendMessage("Set Report Page setting from Printer page setting.");

                    // Read Setting and set to report viewer
                    ReportPageSettings rdlcPageSettings = lr.GetDefaultPageSettings();
                    System.Drawing.Printing.PageSettings pageSettings = new System.Drawing.Printing.PageSettings();

                    pageSettings.PaperSize = rdlcPageSettings.PaperSize;
                    pageSettings.Landscape = rdlcPageSettings.IsLandscape;
                    pageSettings.Margins   = rdlcPageSettings.Margins;

                    rptViewer.SetPageSettings(pageSettings);
                    // refresh
                    rptViewer.LocalReport.Refresh();
                }
                else
                {
                    RdlcMessageService.Instance
                    .SendMessage("No Report data source so cannot set report page setting.");
                }
            }

            rptViewer.RefreshReport();
            // Set display mode to print layout.
            rptViewer.SetDisplayMode(DisplayMode.PrintLayout);

            if (null != reportSource && null != reportSource.Definition &&
                null != reportSource.Definition.RdlcInstance)
            {
                try
                {
                    reportSource.Definition.Dispose();
                }
                catch { }
            }
        }