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

            rpt.Site = this.Site;
            return(rpt);
        }
        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();
                }
            }
        }