Beispiel #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            RPT002_WorkPlaceAirQualityReport rpt = new RPT002_WorkPlaceAirQualityReport();

            rpt.Site = this.Site;
            return(rpt);
        }
Beispiel #2
0
        public void PrintReport()
        {
            try
            {
                if (this.WPA_ID == 0)
                {
                    return;
                }
                using (ReportDocument rpt = new RPT002_WorkPlaceAirQualityReport())
                {
                    rpt.SetParameterValue("@p_ID", WPA_ID);
                    rpt.SetDatabaseLogon(OISDataInfo.DatabaseInfomation.USERNAME, OISDataInfo.DatabaseInfomation.PASSWORD, OISDataInfo.DatabaseInfomation.DATASOURCE, OISDataInfo.DatabaseInfomation.DATABASENAME);
                    SetConnection(rpt);

                    using (PrintDialog p = new PrintDialog())
                    {
                        p.AllowPrintToFile = false;
                        p.AllowCurrentPage = true;
                        p.AllowSomePages   = true;
                        if (p.ShowDialog() == DialogResult.OK)
                        {
                            PageSettings ps = new PageSettings(p.PrinterSettings);
                            rpt.PrintToPrinter(p.PrinterSettings, ps, false);
                        }
                    }
                    CloseConnection(rpt);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        public void Export(ExportFormatType exportFormat)
        {
            try
            {
                string tmpFileName;
                string ReportNumber = "";
                if (result != null)
                {
                    ReportNumber = result.REPORTNUMBER + " " + result.CUSTOMER_NAME;
                }
                switch (exportFormat)
                {
                case ExportFormatType.PortableDocFormat:
                    tmpFileName = FilesUtil.GetTmpPdfFileName(ReportNumber);
                    break;

                case ExportFormatType.WordForWindows:
                case ExportFormatType.EditableRTF:
                    tmpFileName = FilesUtil.GetTmpDocFileName(ReportNumber);
                    break;

                case ExportFormatType.Excel:
                    tmpFileName = FilesUtil.GetTmpXlsFileName(ReportNumber);
                    break;

                default:
                    tmpFileName = FilesUtil.GetTmpPdfFileName(ReportNumber);
                    break;
                }
                using (ReportDocument rpt = new RPT002_WorkPlaceAirQualityReport())
                {
                    rpt.SetParameterValue("@p_ID", WPA_ID);
                    rpt.SetDatabaseLogon(OISDataInfo.DatabaseInfomation.USERNAME, OISDataInfo.DatabaseInfomation.PASSWORD, OISDataInfo.DatabaseInfomation.DATASOURCE, OISDataInfo.DatabaseInfomation.DATABASENAME);
                    SetConnection(rpt);

                    rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4;
                    rpt.ExportToDisk(exportFormat, tmpFileName);
                    Process.Start(tmpFileName);

                    CloseConnection(rpt);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #4
0
 public void PreviewDialog()
 {
     try
     {
         using (ReportDocument rpt = new RPT002_WorkPlaceAirQualityReport())
         {
             rpt.SetParameterValue("@p_ID", WPA_ID);
             rpt.SetDatabaseLogon(OISDataInfo.DatabaseInfomation.USERNAME, OISDataInfo.DatabaseInfomation.PASSWORD, OISDataInfo.DatabaseInfomation.DATASOURCE, OISDataInfo.DatabaseInfomation.DATABASENAME);
             SetConnection(rpt);
             using (ReportViewer dlg = new ReportViewer(rpt))
             {
                 dlg.ShowDialog(null);
             }
             CloseConnection(rpt);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }