public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { NyuukinKesikomiItiranHyou_Report rpt = new NyuukinKesikomiItiranHyou_Report(); rpt.Site = this.Site; return(rpt); }
/// <summary> /// Print Report on F12 Click /// </summary> protected override void PrintSec() { if (PrintMode != EPrintMode.DIRECT) { return; } if (ErrorCheck()) { dce = D_Collect_data(); dtReport = new DataTable(); dtReport = nkih_bl.NyuukinKesikomiItiranHyou_Report(dce); if (dtReport.Rows.Count > 0) { try { NyuukinKesikomiItiranHyou_Report Nkh_report = new NyuukinKesikomiItiranHyou_Report(); DialogResult DResult; switch (PrintMode) { case EPrintMode.DIRECT: DResult = bbl.ShowMessage("Q201"); if (DResult == DialogResult.Cancel) { return; } // 印字データをセット Nkh_report.SetDataSource(dtReport); Nkh_report.Refresh(); Nkh_report.SetParameterValue("lblStore", cboStoreAuthorizations.SelectedValue.ToString() + " " + cboStoreAuthorizations.Text); Nkh_report.SetParameterValue("lblToday", DateTime.Now.ToString("yyyy/MM/dd") + " " + DateTime.Now.ToString("HH:mm")); Nkh_report.SetParameterValue("lblWebCollectType", cboWebCollectType.Text); vr.CrystalReportViewer1.ReportSource = Nkh_report; try { // crv = vr.CrystalReportViewer1; } catch (Exception ex) { var msg = ex.Message; } //out log before print if (DResult == DialogResult.Yes) { //印刷処理プレビュー vr.CrystalReportViewer1.ShowPrintButton = true; vr.CrystalReportViewer1.ReportSource = Nkh_report; vr.ShowDialog(); } else { //int marginLeft = 360; CrystalDecisions.Shared.PageMargins margin = Nkh_report.PrintOptions.PageMargins; margin.leftMargin = DefaultMargin.Left; // mmの指定をtwip単位に変換する margin.topMargin = DefaultMargin.Top; margin.bottomMargin = DefaultMargin.Bottom; //mmToTwip(marginLeft); margin.rightMargin = DefaultMargin.Right; Nkh_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(); Nkh_report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900"; System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings); Nkh_report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true; Nkh_report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex; Nkh_report.PrintToPrinter(printerSettings, pSettings, false, PrintLayout); } catch (Exception ex) { } } break; } //プログラム実行履歴 //InsertLog(Get_L_Log_Entity()); } finally { //画面はそのまま txtCollectDateF.Focus(); } } } }