コード例 #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            ShiraraiItiranHyou_Report rpt = new ShiraraiItiranHyou_Report();

            rpt.Site = this.Site;
            return(rpt);
        }
コード例 #2
0
        protected override void PrintSec()
        {
            if (PrintMode != EPrintMode.DIRECT)
            {
                return;
            }

            //各項目のError Check
            if (ErrorCheck())
            {
                // レコード定義を行う
                // DataTable table = new DataTable();
                // レコード定義を行う
                dt = CheckData();
                if (dt == null)
                {
                    return;
                }
                try
                {
                    ShiraraiItiranHyou_Report Report = new ShiraraiItiranHyou_Report();
                    DialogResult DResult;
                    switch (PrintMode)
                    {
                    case EPrintMode.DIRECT:
                        DResult = bbl.ShowMessage("Q201");
                        if (DResult == DialogResult.Cancel)
                        {
                            return;
                        }
                        // 印字データをセット
                        Report.SetDataSource(dt);
                        Report.Refresh();
                        Report.SetParameterValue("PrintDate", System.DateTime.Now.ToString("yyyy/MM/dd") + " " + System.DateTime.Now.ToString("hh:mm"));
                        vr = previewForm.CrystalReportViewer1;
                        if (DResult == DialogResult.Yes)
                        {
                            //プレビュー
                            //var PreView = new Viewer();
                            previewForm.CrystalReportViewer1.ShowPrintButton = true;
                            previewForm.CrystalReportViewer1.ReportSource    = Report;
                            previewForm.ShowDialog();
                        }
                        else
                        {
                            //int marginLeft = 360;
                            CrystalDecisions.Shared.PageMargins margin = Report.PrintOptions.PageMargins;
                            margin.leftMargin   = DefaultMargin.Left;       // mmの指定をtwip単位に変換する
                            margin.topMargin    = DefaultMargin.Top;
                            margin.bottomMargin = DefaultMargin.Bottom;     //mmToTwip(marginLeft);
                            margin.rightMargin  = DefaultMargin.Right;
                            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();



                                Report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900";
                                System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                                Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                                Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                                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
                {
                    // 画面はそのまま
                    txtPurchaseDateFrom.Focus();
                }
            }
        }