Example #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            Keihichiranhyou rpt = new Keihichiranhyou();

            rpt.Site = this.Site;
            return(rpt);
        }
        protected override void PrintSec()
        {
            // レコード定義を行う
            // DataTable table = new DataTable();



            if (ErrorCheck())
            {
                //if (kthbl.ShowMessage(OperationMode == EOperationMode.DELETE ? "Q102" : "Q101") == DialogResult.Yes)
                //{
                dce2 = GetCostData();
                DataTable table = dtlog = kbl.getPrintData(dce2);

                try
                {
                    if (table == null)
                    {
                        return;
                    }

                    DialogResult            ret;
                    Dataset.Keihichiranhyou Report = new Dataset.Keihichiranhyou();

                    switch (PrintMode)
                    {
                    case EPrintMode.DIRECT:
                        //if (StartUpKBN == "1")
                        //{
                        //    ret = DialogResult.No;
                        //}
                        //else
                        //{
                        //Q202 印刷します。”はい”でプレビュー、”いいえ”で直接プリンターから印刷します。
                        ret = bbl.ShowMessage("Q202");
                        if (ret == DialogResult.Cancel)
                        {
                            return;
                        }
                        //}

                        // 印字データをセット
                        Report.SetDataSource(table);
                        Report.Refresh();
                        Report.SetParameterValue("txtStoreName", cboStoreName.SelectedValue.ToString() + "  " + dce2.Store);
                        Report.SetParameterValue("txtDateTime", table.Rows[0]["yyyymmdd"].ToString() + "   " + table.Rows[0]["mmss"].ToString());
                        vr = previewForm.CrystalReportViewer1;
                        AllEvent_PrintLog();
                        if (ret == DialogResult.Yes)
                        {
                            previewForm.CrystalReportViewer1.ShowPrintButton = true;
                            previewForm.CrystalReportViewer1.ReportSource    = Report;
                            previewForm.ShowDialog();
                        }
                        else             /// //Still Not Working because of Applymargin and Printer not Setting up  (PTK Will Solve)
                        {
                            //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;

                    case EPrintMode.PDF:
                        //if (bbl.ShowMessage("Q204") != DialogResult.Yes)
                        //{
                        //    return;
                        //}
                        //string filePath = "";
                        //if (!ShowSaveFileDialog(InProgramNM, out filePath))
                        //{
                        //    return;
                        //}

                        // 印字データをセット
                        //Report.SetDataSource(table);
                        // Report.Refresh();

                        //  bool result = OutputPDF(filePath, Report);

                        //PDF出力が完了しました。
                        bbl.ShowMessage("I202");

                        break;
                    }

                    //更新処理
                    //tableの請求番号だけ
                    //  mibl.D_Billing_Update(dse, dtForUpdate, InOperatorCD, InPcID);
                }
                finally
                {
                    // DeleteExclusive(dtForUpdate);
                }

                //更新後画面そのまま
                //  detailControls[1].Focus();
                //}
            }
        }