示例#1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            rptEstimateDPrintTotal rpt = new rptEstimateDPrintTotal();

            rpt.Site = this.Site;
            return(rpt);
        }
 public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() {
     rptEstimateDPrintTotal rpt = new rptEstimateDPrintTotal();
     rpt.Site = this.Site;
     return rpt;
 }
        public bool ReportToPdf(DataSet ds, string pgId)
        {

            #region Report Setting

            ReportClass rpt = null;
            DataSet _ds = null;
            try
            {
                switch (pgId)
                {
                    #region マスタ一覧表

                    case DataPgEvidence.PGName.Mst.Customer:
                        rpt = new rptCustomerMst();
                        rpt.SetDataSource(ds);
                        break;
                    case DataPgEvidence.PGName.Mst.Purchase:
                        rpt = new rptCustomerMst();
                        rpt.SetDataSource(ds);
                        break;
                    case DataPgEvidence.PGName.Mst.Person:
                        rpt = new rptPersonMst();
                        rpt.SetDataSource(ds);
                        break;
                    case DataPgEvidence.PGName.Mst.Commodity:
                        rpt = new rptCommodityMst();
                        rpt.SetDataSource(ds);
                        break;
                    case DataPgEvidence.PGName.Mst.Condition:
                        rpt = new rptConditionMst();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 売上入力系帳票

                    case DataPgEvidence.PGName.Estimate.EstimatePrint:
                        rpt = new rptEstimatePrint();
                        rpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
                        rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4;
                        _ds = SetDefualtRecord(ds);
                        rpt.SetDataSource(_ds);
                        break;
                    case DataPgEvidence.PGName.Order.OrderPrint:
                        rpt = new rptOrderPrint();
                        rpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
                        rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4;
                        _ds = SetDefualtRecord(ds);
                        rpt.SetDataSource(_ds);
                        break;
                    case DataPgEvidence.PGName.Sales.SalesPrint:
                        rpt = new rptSalesPrint();
                        rpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
                        rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4;
                        _ds = SetDefualtRecord(ds);
                        rpt.SetDataSource(_ds);
                        break;
                    case DataPgEvidence.PGName.Invoice.InvoicePrint:
                        rpt = new rptInvoiePrint();
                        rpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
                        rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4;
                        SetRecordNoRecord(ref ds, 0, 3);
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 売上系レポート

                    #region 見積明細書

                    case DataPgEvidence.PGName.Estimate.EstimateDPrint:
                        if (this.entitySetting != null)
                        {
                            if (this.entitySetting.total_kbn == 0)
                            {
                                rpt = new rptEstimateDPrint();
                            }
                            else
                            {
                                rpt = new rptEstimateDPrintTotal();
                            }
                        }
                        else
                        {
                            rpt = new rptEstimateDPrint();
                        }

                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 受注明細書

                    case DataPgEvidence.PGName.Order.OrderDPrint:
                        if (this.entitySetting != null)
                        {
                            if (this.entitySetting.total_kbn == 0)
                            {
                                rpt = new rptOrderDPrint();
                            }
                            else
                            {
                                rpt = new rptOrderDPrintTotal();
                            }
                        }
                        else
                        {
                            rpt = new rptOrderDPrint();
                        }

                        rpt.SetDataSource(ds);
                        //rpt.SetParameterValue(0, "where app");
                        break;

                    #endregion

                    #region 売上明細書

                    case DataPgEvidence.PGName.Sales.SalesDPrint:
                        if (this.entitySetting != null)
                        {
                            if (this.entitySetting.total_kbn == 0)
                            {
                                rpt = new rptSalesDPrint();
                            }
                            else
                            {
                                rpt = new rptSalesDPrintTotal();
                            }
                        }
                        else
                        {
                            rpt = new rptSalesDPrint();
                        }

                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 売上日(月)報

                    case DataPgEvidence.PGName.Sales.SalesDayPrint:
                    case DataPgEvidence.PGName.Sales.SalesMonthPrint:
                        rpt = new rptSalesDayPrint();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 売上推移表

                    case DataPgEvidence.PGName.Sales.SalesChangePrint:
                        rpt = new rptSalesChangePrint();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 入金明細書

                    case DataPgEvidence.PGName.Receipt.ReceiptDPrint:
                        if (this.entitySetting != null)
                        {
                            if (this.entitySetting.total_kbn == 0)
                            {
                                rpt = new rptReceiptDPrint();
                            }
                            else
                            {
                                rpt = new rptReceiptDPrintTotal();
                            }
                        }
                        else
                        {
                            rpt = new rptReceiptDPrint();
                        }

                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 入金日(月)報

                    case DataPgEvidence.PGName.Receipt.ReceiptDayPrint:
                    case DataPgEvidence.PGName.Receipt.ReceiptMonthPrint:
                        rpt = new rptReceiptDayPrint();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 回収予定表

                    case DataPgEvidence.PGName.Plan.CollectPlanPrint:
                        rpt = new rptCollectPlanPrint();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 売掛残高一覧表

                    case DataPgEvidence.PGName.SalesManagement.SalesBalancePrint:
                        rpt = new rptSalesBalancePrint();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 請求残高一覧表

                    case DataPgEvidence.PGName.SalesManagement.InvoiceBalancePrint:
                        rpt = new rptInvoiceBalancePrint();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #endregion

                    #region 仕入入力系帳票

                    case DataPgEvidence.PGName.PurchaseOrder.PurchaseOrderPrint:
                        rpt = new rptPurchaseOrderPrint();
                        rpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
                        rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4;
                        _ds = SetDefualtRecord(ds);
                        rpt.SetDataSource(_ds);
                        break;

                    case DataPgEvidence.PGName.Payment.PaymentPrint:
                        rpt = new rptPaymentPrint();
                        rpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
                        rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4;
                        SetRecordNoRecord(ref ds, 0, 3);
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 仕入系レポート

                    #region 発注明細書

                    case DataPgEvidence.PGName.PurchaseOrder.PurchaseOrderDPrint:
                        if (this.entitySetting != null)
                        {
                            if (this.entitySetting.total_kbn == 0)
                            {
                                rpt = new rptPurchaseOrderDPrint();
                            }
                            else
                            {
                                rpt = new rptPurchaseOrderDPrintTotal();
                            }
                        }
                        else
                        {
                            rpt = new rptPurchaseOrderDPrint();
                        }

                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 仕入明細書

                    case DataPgEvidence.PGName.Purchase.PurchaseDPrint:
                        if (this.entitySetting != null)
                        {
                            if (this.entitySetting.total_kbn == 0)
                            {
                                rpt = new rptPurchaseDPrint();
                            }
                            else
                            {
                                rpt = new rptPurchaseDPrintTotal();
                            }
                        }
                        else
                        {
                            rpt = new rptPurchaseDPrint();
                        }

                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 仕入日(月)報

                    case DataPgEvidence.PGName.Purchase.PurchaseDayPrint:
                    case DataPgEvidence.PGName.Purchase.PurchaseMonthPrint:
                        rpt = new rptPurchaseDayPrint();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 仕入推移表

                    case DataPgEvidence.PGName.Purchase.PurchaseChangePrint:
                        rpt = new rptPurchaseChangePrint();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 出金明細書

                    case DataPgEvidence.PGName.PaymentCash.PaymentCashDPrint:
                        if (this.entitySetting != null)
                        {
                            if (this.entitySetting.total_kbn == 0)
                            {
                                rpt = new rptPaymentCashDPrint();
                            }
                            else
                            {
                                rpt = new rptPaymentCashDPrintTotal();
                            }
                        }
                        else
                        {
                            rpt = new rptPaymentCashDPrint();
                        }

                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 出金日(月)報

                    case DataPgEvidence.PGName.PaymentCash.PaymentCashDayPrint:
                    case DataPgEvidence.PGName.PaymentCash.PaymentCashMonthPrint:
                        rpt = new rptPaymentCashDayPrint();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 支払予定表

                    case DataPgEvidence.PGName.Plan.PaymentPlanPrint:
                        rpt = new rptPaymentPlanPrint();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 買掛残高一覧表

                    case DataPgEvidence.PGName.PaymentManagement.PaymentCreditBalancePrint:
                        rpt = new rptPaymentCreditBalancePrint();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 支払残高一覧表

                    case DataPgEvidence.PGName.PaymentManagement.PaymentBalancePrint:
                        rpt = new rptPaymentBalancePrint();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #endregion

                    #region 在庫系レポート

                    #region 入出庫一覧表

                    case DataPgEvidence.PGName.InOutDeliver.InOutDeliverDPrint:
                        rpt = new rptInOutDeliverDPrint();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #region 在庫一覧表

                    case DataPgEvidence.PGName.Inventory.InventoryListPrint:
                        rpt = new rptInventoryListPrint();
                        rpt.SetDataSource(ds);
                        break;

                    #endregion

                    #endregion

                    default:
                        return false;
                }

                if (this.entitySetting != null)
                {
                    // 余白設定
                    int _leftMargin = rpt.PrintOptions.PageMargins.leftMargin;
                    int _rightMargin = rpt.PrintOptions.PageMargins.rightMargin;
                    int _topMargin = rpt.PrintOptions.PageMargins.topMargin;
                    int _bottomMargin = rpt.PrintOptions.PageMargins.bottomMargin;
                    CrystalDecisions.Shared.PageMargins margins;
                    margins.leftMargin = _leftMargin + ExCast.zCInt(this.entitySetting.left_margin * 25.40);
                    margins.rightMargin = _rightMargin + ExCast.zCInt(this.entitySetting.right_margin * 25.40);
                    margins.topMargin = _topMargin + ExCast.zCInt(this.entitySetting.top_margin * 25.40);
                    margins.bottomMargin = _bottomMargin + ExCast.zCInt(this.entitySetting.bottom_margin * 25.40);
                    rpt.PrintOptions.ApplyPageMargins(margins);

                    switch (this.entitySetting.orientation)
                    { 
                        case 1: // 縦
                            rpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;
                            break;
                        case 2: // 横
                            rpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
                            break;
                    }

                    switch (this.entitySetting.size)
                    {
                        case 1: // A3
                            rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA3;
                            break;
                        case 2: // A4
                            rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4;
                            break;
                        case 3: // A5
                            rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA5;
                            break;
                    }

                }
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".ReportToPdf(Report Setting)", ex);
                CommonUtl.gstrErrMsg = CLASS_NM + ".ReportToPdf(Report Setting)" + Environment.NewLine + ex.Message;
                return false;
            }

            #endregion

            #region Export

            ExportOptions exportOpts = null;
            DiskFileDestinationOptions diskOpts = null;
            try
            {
                // Export Option 設定
                exportOpts = new ExportOptions();
                diskOpts = new DiskFileDestinationOptions();
                diskOpts.DiskFileName = this.reportFilePath;

                exportOpts = rpt.ExportOptions;
                exportOpts.DestinationOptions = diskOpts;
                exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
                exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
                rpt.Export();
            }
            catch (Exception ex)
            {
                CommonUtl.ExLogger.Error(CLASS_NM + ".ReportToPdf(Export)", ex);
                CommonUtl.gstrErrMsg = CLASS_NM + ".ReportToPdf(Export)" + Environment.NewLine + ex.Message;
                return false;
            }
            finally
            {
                if (exportOpts != null) exportOpts = null;
                if (diskOpts != null) diskOpts = null;
            }

            #endregion

            return true;
        }