protected void Printtest()
        {
            try
            {
                A4_Test Report = new A4_Test();
                CrystalDecisions.Shared.PageMargins margin = Report.PrintOptions.PageMargins;
                margin.leftMargin   = 0; // mmの指定をtwip単位に変換する
                margin.topMargin    = 0;
                margin.bottomMargin = 0; //mmToTwip(marginLeft);
                margin.rightMargin  = 0;
                Report.PrintOptions.ApplyPageMargins(margin);
                //Report.PrintOptions.PaperSize=PaperSize.;
                Report.PrintOptions.PrinterName = @"\\dataserver\Canon LBP2900";
                Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                //Report.PrintToPrinter(0, false, 0, 0);   ///Direct Printing

                var vwr = new Viewer();
                vwr.CrystalReportViewer1.ReportSource = Report;
                vwr.ShowDialog();
            }
            catch (CrystalReportsException ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        /// <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");
                }
            }
        }
Example #3
0
        /// <summary>
        /// <Remark>PDF出力F11</Remark>
        /// <Remark>印刷する処理F12</Remark>
        /// </summary>
        protected override void PrintSec()
        {
            // レコード定義を行う
            try
            {
                //DataTable table = CheckData(1);
                //if (table == null)
                //{
                //    return;
                //}
                DialogResult            ret;
                SiharaiYoteiHyou_Report Report = new SiharaiYoteiHyou_Report();

                switch (PrintMode)
                {
                case EPrintMode.DIRECT:
                    dtResult = CheckData(1);
                    if (dtResult == null)
                    {
                        return;
                    }

                    if (StartUpKBN == "1")
                    {
                        ret = DialogResult.No;
                    }
                    else
                    {
                        //Q202 印刷します。”はい”でプレビュー、”いいえ”で直接プリンターから印刷します。
                        ret = bbl.ShowMessage("Q201");
                        if (ret == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                    Report.PrintOptions.PaperSize        = CrystalDecisions.Shared.PaperSize.PaperA4;
                    Report.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;

                    // 印字データをセット
                    Report.SetDataSource(dtResult);
                    Report.Refresh();
                    Report.SetParameterValue("StoreCD", comboStore.SelectedValue.ToString() + "  " + comboStore.Text);
                    Report.SetParameterValue("DateFrom", txtPaymentDueDateFrom.Text);
                    Report.SetParameterValue("DateTo", txtPaymentDueDateTo.Text);
                    Report.SetParameterValue("PrintDate", System.DateTime.Now.ToString("yyyy/MM/dd") + " " + System.DateTime.Now.ToString("hh:mm"));

                    if (ret == DialogResult.Yes)
                    {
                        //プレビュー
                        var previewForm = 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;

                case EPrintMode.CSV:
                    dtCSV = CheckData(2);
                    if (dtCSV == null)
                    {
                        return;
                    }
                    try
                    {
                        DialogResult DResult;
                        DResult = bbl.ShowMessage("Q203");
                        if (DResult == DialogResult.Yes)
                        {
                            ////LoacalDirectory
                            string folderPath = "C:\\CSV\\";
                            if (!Directory.Exists(folderPath))
                            {
                                Directory.CreateDirectory(folderPath);
                            }
                            SaveFileDialog savedialog = new SaveFileDialog();
                            savedialog.Filter           = "CSV|*.csv";
                            savedialog.Title            = "Save";
                            savedialog.FileName         = "支払予定表";
                            savedialog.InitialDirectory = folderPath;
                            savedialog.RestoreDirectory = true;
                            if (savedialog.ShowDialog() == DialogResult.OK)
                            {
                                if (Path.GetExtension(savedialog.FileName).Contains("csv"))
                                {
                                    CsvWriter csvwriter = new CsvWriter();
                                    csvwriter.WriteCsv(dtCSV, savedialog.FileName, Encoding.GetEncoding(932));
                                }
                                Process.Start(Path.GetDirectoryName(savedialog.FileName));
                                shyhbl.ShowMessage("I203");
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;

                case EPrintMode.PDF:

                    dtResult = CheckData(1);
                    if (dtResult == null)
                    {
                        return;
                    }

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

                    // 印字データをセット
                    Report.SetDataSource(dtResult);
                    Report.Refresh();
                    Report.SetParameterValue("StoreCD", comboStore.SelectedValue.ToString() + "  " + comboStore.Text);
                    Report.SetParameterValue("DateFrom", txtPaymentDueDateFrom.Text);
                    Report.SetParameterValue("DateTo", txtPaymentDueDateTo.Text);
                    Report.SetParameterValue("PrintDate", System.DateTime.Now.ToString("yyyy/MM/dd") + " " + System.DateTime.Now.ToString("hh:mm"));

                    bool result = OutputPDF(filePath, Report);

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

                //プログラム実行履歴
                InsertLog(Get_L_Log_Entity());

                //ClearDetail();
            }
            finally
            {
            }
        }
        protected override void PrintSec()
        {
            // レコード定義を行う

            try
            {
                if (dtDelivery == null || gdvDSKENDeliveryDetail.Rows.Count == 0)
                {
                    return;
                }
                //xsdファイルを保存します。

                //DB ---→ xsd ----→ クリスタルレポート

                //というデータの流れになります
                //dtEdi.TableName = ProID;
                //dtEdi.WriteXmlSchema("DataTable" + ProID + ".xsd");

                //①保存した.xsdはプロジェクトに追加しておきます。
                DialogResult ret;
                EDINouhinJouhouTouroku_Report Report = new EDINouhinJouhouTouroku_Report();


                //DataTableのDetailOnが1かどうかで詳細セクションを印字するかどうかの設定を
                //している(セクションエキスパート)

                switch (PrintMode)
                {
                case EPrintMode.DIRECT:

                    //Q208 印刷します。”はい”でプレビュー、”いいえ”で直接プリンターから印刷します。
                    ret = ediNHJ_bl.ShowMessage("Q208");
                    if (ret == DialogResult.Cancel)
                    {
                        return;
                    }
                    Report.PrintOptions.PaperSize        = CrystalDecisions.Shared.PaperSize.PaperA4;
                    Report.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;

                    // 印字データをセット
                    Report.SetDataSource(dtDelivery);
                    Report.Refresh();
                    Report.SetParameterValue("txtImportDate", lblImportDateTime.Text.ToString());
                    Report.SetParameterValue("txtVendor", lblVendor.Text.ToString());
                    Report.SetParameterValue("txtSKENNouhinshoNO", gdvDSKENDelivery[(int)EColNo.SKENNouhinshoNO, selectRowIndex].Value.ToString());

                    if (ret == DialogResult.Yes)
                    {
                        //プレビュー
                        var previewForm = new Viewer();
                        previewForm.CrystalReportViewer1.ShowPrintButton = true;
                        previewForm.CrystalReportViewer1.ReportSource    = Report;
                        //previewForm.CrystalReportViewer1.Zoom(1);

                        previewForm.ShowDialog();
                    }
                    else
                    {
                        int marginLeft = 360;
                        CrystalDecisions.Shared.PageMargins margin = Report.PrintOptions.PageMargins;
                        margin.leftMargin   = marginLeft;   // mmの指定をtwip単位に変換する
                        margin.topMargin    = marginLeft;
                        margin.bottomMargin = marginLeft;   //mmToTwip(marginLeft);
                        margin.rightMargin  = marginLeft;
                        Report.PrintOptions.ApplyPageMargins(margin);
                        // プリンタに印刷
                        Report.PrintToPrinter(0, false, 0, 0);
                    }
                    break;

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

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

                    bool result = OutputPDF(filePath, Report);

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

                    break;
                }
            }
            finally
            {
            }

            //更新後画面そのまま
            //detailControls[0].Focus();
        }
        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();
                }
            }
        }
        protected override void PrintSec()
        {
            if (PrintMode != EPrintMode.DIRECT)
            {
                return;
            }
            if (ErrorCheck())
            {
                dmpe = new D_MonthlyPurchase_Entity();
                dmpe = GetData();
                DataTable dt = szybl.RPC_SiiresakiZaikoYoteiHyou(dmpe);
                if (dt.Rows.Count > 0)
                {
                    // CheckBeforeExport();
                    try
                    {
                        SiiresakiZaikoYoteiHyou_Report szy_Report = new SiiresakiZaikoYoteiHyou_Report();
                        DialogResult DResult;
                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:
                            DResult = bbl.ShowMessage("Q201");
                            if (DResult == DialogResult.Cancel)
                            {
                                return;
                            }
                            szy_Report.SetDataSource(dt);
                            szy_Report.Refresh();
                            szy_Report.SetParameterValue("lblDateFrom", txtTargetDateFrom.Text);
                            szy_Report.SetParameterValue("lblDateTo", txtTargetDateTo.Text);
                            szy_Report.SetParameterValue("lblStore", cboStore.SelectedValue.ToString() + "   " + cboStore.AccessibilityObject.Name);
                            szy_Report.SetParameterValue("lblToday", dt.Rows[0]["Today"].ToString());
                            try
                            {
                            }
                            catch (Exception ex)
                            {
                                var msg = ex.Message;
                            }
                            if (DResult == DialogResult.Yes)
                            {
                                var vr = new Viewer();
                                vr.CrystalReportViewer1.ShowPrintButton = true;
                                vr.CrystalReportViewer1.ReportSource    = szy_Report;
                                vr.ShowDialog();
                            }
                            else
                            {
                                CrystalDecisions.Shared.PageMargins margin = szy_Report.PrintOptions.PageMargins;
                                margin.leftMargin   = DefaultMargin.Left;
                                margin.topMargin    = DefaultMargin.Top;
                                margin.bottomMargin = DefaultMargin.Bottom;
                                margin.rightMargin  = DefaultMargin.Right;
                                szy_Report.PrintOptions.ApplyPageMargins(margin);
                                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();
                                    szy_Report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900";
                                    System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                                    szy_Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                                    szy_Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                                    szy_Report.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                            break;
                        }
                        InsertLog(Get_L_Log_Entity());
                    }
                    finally
                    {
                        txtTargetDateTo.Focus();
                    }
                }
                else
                {
                    szybl.ShowMessage("E128");
                    txtTargetDateTo.Focus();
                }
            }
        }
Example #7
0
        protected override void PrintSec()
        {
            if (PrintMode != EPrintMode.DIRECT)
            {
                return;
            }

            if (ErrorCheck())
            {
                // レコード定義を行う
                mde = GetMonthlyDebt_Data();
                if (chkBalancePrint.Checked == true)
                {
                    chk = 1;
                }
                else
                {
                    chk = 0;
                }
                dtExport = saimukanriBL.D_MonthlyDebt_CSV_Report(mde, chk);
                if (dtExport.Rows.Count > 0)
                {
                    CheckBeforeExport();
                    try
                    {
                        SaimuKanriKyou_Report smkh_Report = new SaimuKanriKyou_Report();
                        DialogResult          DResult;
                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:
                            DResult = bbl.ShowMessage("Q201");
                            if (DResult == DialogResult.Cancel)
                            {
                                return;
                            }
                            // 印字データをセット
                            smkh_Report.SetDataSource(dtExport);
                            smkh_Report.Refresh();
                            smkh_Report.SetParameterValue("lblYearMonth", txtTargetYear.Text);
                            smkh_Report.SetParameterValue("lblStore", dtExport.Rows[0]["StoreCD"].ToString() + "  " + dtExport.Rows[0]["StoreName"].ToString());
                            smkh_Report.SetParameterValue("lblToday", dtExport.Rows[0]["Today"].ToString() + "  " + dtExport.Rows[0]["Now"].ToString());
                            crv = vr.CrystalReportViewer1;
                            crv.ReportSource = smkh_Report;
                            vr.ShowDialog();

                            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    = smkh_Report;

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



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

                                    smkh_Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                                    smkh_Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                                    smkh_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
                    {
                        //画面はそのまま
                        txtTargetYear.Focus();
                    }
                }
                else
                {
                    saimukanriBL.ShowMessage("E128");
                }
            }
        }
Example #8
0
        //public void F12()
        //{
        //    tnlbl = new TanaireList_BL();

        //    if (ErrorCheck(12))
        //    {
        //        if (tnlbl.ShowMessage(OperationMode == EOperationMode.DELETE ? "Q102" : "Q101") == DialogResult.Yes)
        //        {
        //            dse = GetDStockEntity();
        //            //if (string.IsNullOrWhiteSpace(ScSKUCD.Code))
        //            //    dtPrint = tnlbl.SelectDataForPrint(dse,"1");
        //            //else
        //            //    dtPrint = tnlbl.SelectDataForPrint(dse,"2");

        //            //PrintSec();
        //        }
        //        else
        //            PreviousCtrl.Focus();

        //    }

        //}


        protected override void PrintSec()
        {
            // レコード定義を行う
            // DataTable table = new DataTable();
            tnlbl = new TanaireList_BL();
            string    header  = string.Empty;
            DataTable dtPrint = new DataTable();

            if (ErrorCheck())
            {
                dse = GetDStockEntity();
                if (!string.IsNullOrWhiteSpace(ScSKUCD.Code))
                {
                    dtPrint = tnlbl.SelectDataForPrint(dse, "1");
                    header  = "棚入れリスト";
                }
                else
                {
                    dtPrint = tnlbl.SelectDataForPrint(dse, "2");
                    header  = "棚入れリスト(履歴)";
                }

                try
                {
                    if (dtPrint.Rows.Count <= 0 || dtPrint == null)
                    {
                        bbl.ShowMessage("E128");
                        txtStartDate.Focus();
                    }
                    else
                    {
                        //xsdファイルを保存します。

                        //①保存した.xsdはプロジェクトに追加しておきます。
                        DialogResult       ret;
                        TanaireList_Report Report = new TanaireList_Report();

                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:

                            ret = bbl.ShowMessage("Q202");
                            if (ret == DialogResult.No)
                            {
                                return;
                            }
                            //}

                            // 印字データをセット

                            Report.SetDataSource(dtPrint);
                            Report.Refresh();
                            Report.SetParameterValue("txtSouko", cboSouko.SelectedValue.ToString() + "  " + cboSouko.Text);
                            Report.SetParameterValue("txtHeader", header);

                            if (ret == DialogResult.Yes)
                            {
                                var previewForm = new Viewer();
                                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);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                            break;

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

                            // 印字データをセット
                            Report.SetDataSource(dtPrint);
                            Report.Refresh();
                            Report.SetParameterValue("txtSouko", cboSouko.SelectedValue.ToString() + "  " + cboSouko.Text);
                            Report.SetParameterValue("txtHeader", header);

                            bool result = OutputPDF(filePath, Report);

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

                            break;
                        }
                        InsertLog(Get_L_Log_Entity(dtPrint));
                    }
                    //else
                    //{
                    //    bbl.ShowMessage("E128");
                    //    txtStartDate.Focus();
                    //  }
                }
                finally
                {
                }
            }
        }
Example #9
0
        public void F12()
        {
            if (ErrorCheck())
            {
                doe = new D_Order_Entity
                {
                    StoreCD            = cboStore.SelectedValue.ToString(),
                    DestinationSoukoCD = cboWareHouse.SelectedValue.ToString(),
                };
                DateTime firstday = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                firstday.AddDays(-1).ToString("dd/MM/yyyy");

                string Text = txtTargetDateTo.Text;
                if (!string.IsNullOrWhiteSpace(Text))
                {
                    string[] p       = Text.Split('/');
                    string   y       = p[0].ToString();
                    string   m       = p[1].ToString();
                    int      yy      = Convert.ToInt32(y);
                    int      mm      = Convert.ToInt32(m);
                    DateTime lastday = new DateTime(yy, mm,
                                                    DateTime.DaysInMonth(yy, mm));

                    dpe = new D_Purchase_Entity
                    {
                        PurchaseDateFrom = firstday.ToShortDateString(),
                        PurchaseDateTo   = lastday.ToShortDateString(),
                    };
                }
                else
                {
                    dpe = new D_Purchase_Entity
                    {
                        PurchaseDateFrom = firstday.ToShortDateString(),
                        PurchaseDateTo   = null,
                    };
                }


                DataTable dt = zkybl.D_Order_Select(doe, dpe);
                //if (dt == null)
                if (dt.Rows.Count == 0)
                {
                    //if (dt == null) return;
                    zkybl.ShowMessage("E128");
                    txtTargetDateTo.Focus();
                }
                else
                {
                    dt.Columns.Add("Total");
                    dt.Rows[0]["Total"] = dt.Rows[0]["Gaku"].ToString();
                    decimal t = Convert.ToDecimal(dt.Rows[1]["Gaku"]) + Convert.ToDecimal(dt.Rows[0]["Total"]);
                    dt.Rows[1]["Total"] = t.ToString();

                    for (int i = 2; i < dt.Rows.Count; i++)
                    {
                        dt.Rows[i]["Total"] = Convert.ToDecimal(dt.Rows[i]["Gaku"]) + Convert.ToDecimal(dt.Rows[i - 1]["Total"]);
                    }

                    try
                    {
                        ZaikoYoteiHyouReport Report = new ZaikoYoteiHyouReport();
                        DialogResult         ret;
                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:
                            ret = bbl.ShowMessage("Q202");
                            if (ret == DialogResult.Cancel)
                            {
                                return;
                            }
                            // 印字データをセット
                            Report.SetDataSource(dt);
                            Report.Refresh();
                            Report.SetParameterValue("PrintDate", System.DateTime.Now.ToString("yyyy/MM/dd") + " " + System.DateTime.Now.ToString("hh:mm"));
                            Report.SetParameterValue("TargetDate", txtTargetDateFrom.Text + " ~ " + txtTargetDateTo.Text);
                            Report.SetParameterValue("txtSouko", cboWareHouse.SelectedValue.ToString() + "  " + cboWareHouse.Text);

                            if (ret == DialogResult.Yes)
                            {
                                var previewForm = 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;
                        }
                    }
                    finally
                    {
                        txtTargetDateTo.Focus();
                    }
                }
            }
        }
Example #10
0
        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();
                    }
                }
            }
        }
        protected override void PrintSec()
        {
            if (PrintMode != EPrintMode.DIRECT)
            {
                return;
            }
            if (ErrorCheck())
            {
                dpde = new D_Purchase_Details_Entity();
                dmse = new D_MonthlyStock_Entity();
                dpde = PurchaseDetailInfo();
                dmse = MonthlyStockInfo();
                if (chkRelatedPrinting.Checked == true)
                {
                    if (rdoITEM.Checked == true)
                    {
                        chk = 1;
                    }
                    else if (rdoProductCD.Checked == true)
                    {
                        chk = 2;
                    }
                }
                else
                {
                    chk = 3;
                }

                DataTable dt = zkhbl.RPC_ZaikoKanriHyou(dpde, dmse, chk);

                if (dt.Rows.Count > 0)
                {
                    // CheckBeforeExport();
                    try
                    {
                        ZaikoKanriHyou_Report zkh_Report = new ZaikoKanriHyou_Report();
                        DialogResult          DResult;
                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:
                            DResult = bbl.ShowMessage("Q201");
                            if (DResult == DialogResult.Cancel)
                            {
                                return;
                            }
                            zkh_Report.SetDataSource(dt);
                            zkh_Report.Refresh();
                            zkh_Report.SetParameterValue("lblDate", txtTargetDate.Text);
                            zkh_Report.SetParameterValue("lblSouko", cboSouko.SelectedValue.ToString() + "   " + cboSouko.AccessibilityObject.Name);
                            zkh_Report.SetParameterValue("lblToday", dt.Rows[0]["Today"].ToString() + "  " + dt.Rows[0]["Now"].ToString());
                            try
                            {
                            }
                            catch (Exception ex)
                            {
                                var msg = ex.Message;
                            }
                            //out log before print
                            if (DResult == DialogResult.Yes)
                            {
                                var vr = new Viewer();
                                vr.CrystalReportViewer1.ShowPrintButton = true;
                                vr.CrystalReportViewer1.ReportSource    = zkh_Report;
                                vr.ShowDialog();
                            }
                            else
                            {
                                CrystalDecisions.Shared.PageMargins margin = zkh_Report.PrintOptions.PageMargins;
                                margin.leftMargin   = DefaultMargin.Left;
                                margin.topMargin    = DefaultMargin.Top;
                                margin.bottomMargin = DefaultMargin.Bottom;
                                margin.rightMargin  = DefaultMargin.Right;
                                zkh_Report.PrintOptions.ApplyPageMargins(margin);
                                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();
                                    zkh_Report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900";
                                    System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                                    zkh_Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                                    zkh_Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                                    zkh_Report.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                            break;
                        }
                        InsertLog(Get_L_Log_Entity());
                    }
                    finally
                    {
                        txtTargetDate.Focus();
                    }
                }
                else
                {
                    zkhbl.ShowMessage("E128");
                    txtTargetDate.Focus();
                }
            }
        }
        protected override void PrintSec()
        {
            // レコード定義を行う
            // DataTable table = new DataTable();
            ukkthbl = new UrikakekinTairyuuHyou_BL();
            string    header = string.Empty;
            DataTable dtPrint;

            if (PrintMode != EPrintMode.DIRECT)
            {
                return;
            }
            if (ErrorCheck())
            {
                msce = new M_StoreClose_Entity();
                msce = GetStoreClose_Data();

                DateTime now      = Convert.ToDateTime(txtDate.Text.ToString() + "/01 00:00:00");
                string[] strmonth = new string[12];
                for (int i = 11; i >= 0; i--)
                {
                    strmonth[i] = now.AddMonths(-i).ToString().Substring(0, 7);
                }


                dtPrint = ukkthbl.Select_DataToExport(msce);
                //header = "棚入れリスト";

                try
                {
                    if (dtPrint == null || dtPrint.Rows.Count <= 0)
                    {
                        bbl.ShowMessage("E128");
                        txtDate.Focus();
                    }
                    else
                    {
                        string customerCD = string.Empty;
                        for (int i = 0; i < dtPrint.Rows.Count; i++)
                        {
                            if (customerCD != dtPrint.Rows[i]["CustomerCD"].ToString())
                            {
                                customerCD = dtPrint.Rows[i]["CustomerCD"].ToString();
                            }

                            DataTable dtResult = dtPrint.Select("SaleA='売上' and CustomerCD='" + customerCD + "'").CopyToDataTable();
                            if (dtResult.Rows.Count == 1)
                            {
                                dtPrint.Rows[i]["Result"] = dtResult.Rows[0]["Result"].ToString();
                            }
                        }

                        //xsdファイルを保存します。

                        //①保存した.xsdはプロジェクトに追加しておきます。
                        DialogResult ret;
                        UrikakekinTairyuuHyou_Report Report = new UrikakekinTairyuuHyou_Report();

                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:

                            ret = bbl.ShowMessage("Q202");
                            if (ret == DialogResult.No)
                            {
                                return;
                            }
                            //}

                            // 印字データをセット



                            Report.SetDataSource(dtPrint);
                            Report.Refresh();
                            Report.SetParameterValue("txtStore", cboStore.SelectedValue.ToString() + "  " + cboStore.Text);
                            Report.SetParameterValue("txtMonth11", strmonth[11].ToString());
                            Report.SetParameterValue("txtMonth10", strmonth[10].ToString());
                            Report.SetParameterValue("txtMonth9", strmonth[9].ToString());
                            Report.SetParameterValue("txtMonth8", strmonth[8].ToString());
                            Report.SetParameterValue("txtMonth7", strmonth[7].ToString());
                            Report.SetParameterValue("txtMonth6", strmonth[6].ToString());
                            Report.SetParameterValue("txtMonth5", strmonth[5].ToString());
                            Report.SetParameterValue("txtMonth4", strmonth[4].ToString());
                            Report.SetParameterValue("txtMonth3", strmonth[3].ToString());
                            Report.SetParameterValue("txtMonth2", strmonth[2].ToString());
                            Report.SetParameterValue("txtMonth1", strmonth[1].ToString());
                            Report.SetParameterValue("txtMonth0", strmonth[0].ToString());

                            if (ret == DialogResult.Yes)
                            {
                                var previewForm = new Viewer();
                                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);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                            break;

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

                            // 印字データをセット
                            Report.SetDataSource(dtPrint);
                            Report.Refresh();
                            Report.SetParameterValue("txtSouko", cboStore.SelectedValue.ToString() + "  " + cboStore.Text);
                            Report.SetParameterValue("txtHeader", header);

                            bool result = OutputPDF(filePath, Report);

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

                            break;
                        }
                        //InsertLog(Get_L_Log_Entity(dtPrint));
                    }
                }
                finally
                {
                }
            }
        }
        private void PrintDataSelect()
        {
            try
            {
                UriageMotouchou_Report umtc_Report = new UriageMotouchou_Report();
                DialogResult           DResult;
                switch (PrintMode)
                {
                case EPrintMode.DIRECT:
                    DResult = bbl.ShowMessage("Q201");
                    if (DResult == DialogResult.Cancel)
                    {
                        return;
                    }

                    umtc_Report.SetDataSource(dtReport);
                    umtc_Report.Refresh();
                    umtc_Report.SetParameterValue("YYYYMMF", txtTagetFrom.Text);
                    umtc_Report.SetParameterValue("YYYYMMT", txtTargetTo.Text);
                    umtc_Report.SetParameterValue("PrintDateTime", System.DateTime.Now.ToString("yyyy/MM/dd") + " " + System.DateTime.Now.ToString("hh:mm"));
                    umtc_Report.SetParameterValue("CustomerCD", sc_Customer.TxtCode.Text);
                    umtc_Report.SetParameterValue("CustName", sc_Customer.LabelText);
                    umtc_Report.SetParameterValue("StoreCD", cboStore.Text);
                    //crvr = vr.CrystalReportViewer1;

                    if (DResult == DialogResult.Yes)
                    {
                        var vr = new Viewer();
                        vr.CrystalReportViewer1.ShowPrintButton = true;
                        vr.CrystalReportViewer1.ReportSource    = umtc_Report;
                        vr.ShowDialog();
                    }
                    else
                    {
                        //int marginLeft = 360;
                        CrystalDecisions.Shared.PageMargins margin = umtc_Report.PrintOptions.PageMargins;
                        margin.leftMargin   = DefaultMargin.Left;          // mmの指定をtwip単位に変換する
                        margin.topMargin    = DefaultMargin.Top;
                        margin.bottomMargin = DefaultMargin.Bottom;        //mmToTwip(marginLeft);
                        margin.rightMargin  = DefaultMargin.Right;
                        umtc_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();



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

                            umtc_Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                            umtc_Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                            umtc_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
            {
                //画面はそのまま
                txtTagetFrom.Focus();
            }
        }
        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();
                //}
            }
        }
        /// <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();
                    }
                }
            }
        }
        protected override void PrintSec()

        {
            // レコード定義を行う
            // DataTable table = new DataTable();



            if (ErrorCheck())
            {
                nie = GetNyuukinData();
                DataTable table = dtlog = nih.getPrintData(nie);

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

                    DialogResult ret;
                    var          Report = new DataSet.Nyuukin_Ichihanyou();

                    switch (PrintMode)
                    {
                    case EPrintMode.DIRECT:
                        ret = bbl.ShowMessage("Q202");
                        if (ret == DialogResult.Cancel)
                        {
                            return;
                        }
                        Report.SetDataSource(table);
                        Report.Refresh();
                        Report.SetParameterValue("txtStoreName", cbo_store.SelectedValue.ToString() + "  " + nie.cbo_store);
                        Report.SetParameterValue("txtDateTime", table.Rows[0]["yyyymmdd"].ToString() + "   " + table.Rows[0]["mmss"].ToString());
                        vr = previewForm.CrystalReportViewer1;
                        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)
                        {
                            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);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        break;

                    case EPrintMode.PDF:
                        bbl.ShowMessage("I202");

                        break;
                    }
                    var dt = new DataTable();
                    dt.Columns.Add("StoreCD");
                    for (int i = 0; i < dtlog.Rows.Count; i++)
                    {
                        if (!String.IsNullOrWhiteSpace(dtlog.Rows[i]["StoreCD"].ToString()) && !dtlog.Rows[i]["StoreCD"].Equals(null))
                        {
                            dt.Rows.Add(dtlog.Rows[i]["StoreCD"].ToString());
                        }
                    }
                    dt.AcceptChanges();
                    nih.L_Log_Insert_Print(new string[] { InOperatorCD, InPcID, InProgramID }, dt);
                }
                finally
                {
                    paymentstart.Focus();
                }
            }
        }