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

            rpt.Site = this.Site;
            return(rpt);
        }
コード例 #2
0
        /// <summary>
        /// Print Report on F12 Click
        /// </summary>
        protected override void PrintSec()
        {
            if (PrintMode != EPrintMode.DIRECT)
            {
                return;
            }

            if (ErrorCheck())
            {
                sku_data = M_SKU_data();
                dms      = D_MonthlyStock_data();

                chk      = Check_ITemORMakerItem();
                dtReport = new DataTable();
                dtReport = zmibl.ZaikoMotochoulnsatsu_Report(sku_data, dms, chk);

                if (dtReport.Rows.Count > 0)
                {
                    CheckBeforeExport();
                    try
                    {
                        ZaikoMotochoulnsatsu_Report zm_report = new ZaikoMotochoulnsatsu_Report();
                        DialogResult DResult;
                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:
                            DResult = bbl.ShowMessage("Q201");
                            if (DResult == DialogResult.Cancel)
                            {
                                return;
                            }
                            // 印字データをセット
                            zm_report.SetDataSource(dtReport);
                            zm_report.Refresh();
                            zm_report.SetParameterValue("lblYearMonth", txtTargetPeriodF.Text + "  ~  " + txtTargetPeriodT.Text);
                            zm_report.SetParameterValue("lblSouko", cboSouko.SelectedValue.ToString() + " " + cboSouko.Text);
                            zm_report.SetParameterValue("lblToday", DateTime.Now.ToString("yyyy/MM/dd") + "  " + DateTime.Now.ToString("HH:mm"));
                            //zm_report.SetParameterValue("lblSKU", dtReport.Rows[0]["SKUCD"].ToString());
                            // zm_report.SetParameterValue("lblJANCD", dtReport.Rows[0]["JANCD"].ToString());
                            // zm_report.SetParameterValue("lblCSB", dtReport.Rows[0]["ColorName"].ToString() + " " + dtReport.Rows[0]["SizeName"].ToString() + " " + dtReport.Rows[0]["BrandName"].ToString());

                            vr.CrystalReportViewer1.ReportSource = zm_report;
                            //vr.ShowDialog();

                            try
                            {
                                //  crv = vr.CrystalReportViewer1;
                            }
                            catch (Exception ex)
                            {
                                var msg = ex.Message;
                            }
                            //out log before print
                            if (DResult == DialogResult.Yes)
                            {
                                //印刷処理プレビュー
                                vr = new Viewer();
                                vr.CrystalReportViewer1.ShowPrintButton = true;
                                vr.CrystalReportViewer1.ReportSource    = zm_report;

                                vr.ShowDialog();
                            }
                            else
                            {
                                //int marginLeft = 360;
                                CrystalDecisions.Shared.PageMargins margin = zm_report.PrintOptions.PageMargins;
                                margin.leftMargin   = DefaultMargin.Left;        // mmの指定をtwip単位に変換する
                                margin.topMargin    = DefaultMargin.Top;
                                margin.bottomMargin = DefaultMargin.Bottom;      //mmToTwip(marginLeft);
                                margin.rightMargin  = DefaultMargin.Right;
                                zm_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();



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

                                    zm_report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                                    zm_report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                                    zm_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
                    {
                        //画面はそのまま
                        txtTargetPeriodF.Focus();
                    }
                }
                else
                {
                    bbl.ShowMessage("E128");
                }
            }
        }