public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { UriageMotouchou_Report rpt = new UriageMotouchou_Report(); rpt.Site = this.Site; return(rpt); }
private void PrintDataSelect() { try { UriageMotouchou_Report umtc_Report = new UriageMotouchou_Report(); DialogResult DResult; switch (PrintMode) { case EPrintMode.DIRECT: DResult = bbl.ShowMessage("Q201"); if (DResult == DialogResult.Cancel) { return; } umtc_Report.SetDataSource(dtReport); umtc_Report.Refresh(); umtc_Report.SetParameterValue("YYYYMMF", txtTagetFrom.Text); umtc_Report.SetParameterValue("YYYYMMT", txtTargetTo.Text); umtc_Report.SetParameterValue("PrintDateTime", System.DateTime.Now.ToString("yyyy/MM/dd") + " " + System.DateTime.Now.ToString("hh:mm")); umtc_Report.SetParameterValue("CustomerCD", sc_Customer.TxtCode.Text); umtc_Report.SetParameterValue("CustName", sc_Customer.LabelText); umtc_Report.SetParameterValue("StoreCD", cboStore.Text); //crvr = vr.CrystalReportViewer1; if (DResult == DialogResult.Yes) { var vr = new Viewer(); vr.CrystalReportViewer1.ShowPrintButton = true; vr.CrystalReportViewer1.ReportSource = umtc_Report; vr.ShowDialog(); } else { //int marginLeft = 360; CrystalDecisions.Shared.PageMargins margin = umtc_Report.PrintOptions.PageMargins; margin.leftMargin = DefaultMargin.Left; // mmの指定をtwip単位に変換する margin.topMargin = DefaultMargin.Top; margin.bottomMargin = DefaultMargin.Bottom; //mmToTwip(marginLeft); margin.rightMargin = DefaultMargin.Right; umtc_Report.PrintOptions.ApplyPageMargins(margin); /// Error Now // プリンタに印刷 System.Drawing.Printing.PageSettings ps; try { System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument(); CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings(); System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings(); umtc_Report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900"; System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings); umtc_Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true; umtc_Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex; umtc_Report.PrintToPrinter(printerSettings, pSettings, false, PrintLayout); // Print the report. Set the startPageN and endPageN // parameters to 0 to print all pages. //Report.PrintToPrinter(1, false, 0, 0); } catch (Exception ex) { } } break; } //プログラム実行履歴 InsertLog(Get_L_Log_Entity()); } finally { //画面はそのまま txtTagetFrom.Focus(); } }