public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { SaikenKanriHyou_Report rpt = new SaikenKanriHyou_Report(); rpt.Site = this.Site; return(rpt); }
protected override void PrintSec() { if (PrintMode != EPrintMode.DIRECT) { return; } if (ErrorCheck()) { // レコード定義を行う dtResult = CheckData(); //dmc_e = GetDataInfo(); //dtResult = skh_bl.D_MonthlyClaims_Select(dmc_e); //if (dtResult == null) //{ // return; //} if (dtResult.Rows.Count > 0) // 2020-06-19 saw { //exeRun M_StoreCheck(); try { SaikenKanriHyou_Report skh_Report = new SaikenKanriHyou_Report(); DialogResult DResult; switch (PrintMode) { case EPrintMode.DIRECT: DResult = bbl.ShowMessage("Q201"); if (DResult == DialogResult.Cancel) { return; } // 印字データをセット skh_Report.SetDataSource(dtResult); skh_Report.Refresh(); skh_Report.SetParameterValue("YYYYMM", txtTargetdate.Text); skh_Report.SetParameterValue("PrintDateTime", System.DateTime.Now.ToString("yyyy/MM/dd") + " " + System.DateTime.Now.ToString("hh:mm")); crvr = vr.CrystalReportViewer1; //out log before print if (DResult == DialogResult.Yes) { //印刷処理プレビュー vr.CrystalReportViewer1.ShowPrintButton = true; vr.CrystalReportViewer1.ReportSource = skh_Report; vr.ShowDialog(); } else { //int marginLeft = 360; CrystalDecisions.Shared.PageMargins margin = skh_Report.PrintOptions.PageMargins; margin.leftMargin = DefaultMargin.Left; // mmの指定をtwip単位に変換する margin.topMargin = DefaultMargin.Top; margin.bottomMargin = DefaultMargin.Bottom; //mmToTwip(marginLeft); margin.rightMargin = DefaultMargin.Right; skh_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(); skh_Report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900"; System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings); skh_Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true; skh_Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex; skh_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 { //画面はそのまま txtTargetdate.Focus(); } } } }