コード例 #1
0
ファイル: Viewer.cs プロジェクト: jalil1408/BiomPSP
        public bool BuildReport(
            string rptFullCs, string rptId,
            bool hasDs, DatabaseType dsType, string dsFullCs,
            bool withoutViewer, string withoutViewerPrinterName, short withoutViewerCopies,
            bool registered, string unregisterText,
            bool askAutoDetectPrm, params object[] dsPrm)
        {
            Cfg.DbRpt.Setup(Cfg.RptDbType, rptFullCs);

            SetRptCfg();

            Registered = registered;
            UnregisterText = unregisterText;

            IS_WITHOUT_VIEWER = withoutViewer;
            WITHOUT_VIEWER_PRINTER_NAME = (withoutViewerPrinterName == null || withoutViewerPrinterName == "" ? UtlGen.GetDefaultPrinterName() : withoutViewerPrinterName);
            WITHOUT_VIEWER_COPIES = withoutViewerCopies;

            Rpt = MprRpt.FromDb(rptId);

            this.Visible = Rpt != null;

            if (Rpt == null)
            {
                return false;
            }

            DataSourceDbType = dsType;
            DataSourceFullCs = dsFullCs;

            if(!IS_WITHOUT_VIEWER) SetUserInterface();

            epError.SetError(bPrint, "");

            IsDsMissing = MissingDs(hasDs);

            if (IsDsMissing)
            {
                epError.SetError(bPrint, "Cannot connect to data source!");
                return false;
            }

            AddDefaultPrm(dsPrm);

            IsPrmMissing = false;

            if (askAutoDetectPrm)
            {
                string mp = AddAutoDetectedPrm(false);
                IsPrmMissing = mp.Length > 0;

                if (IsPrmMissing)
                {
                    epError.SetError(bPrint, "Parameters missing: " + UtlGen.WindowsNewLine + mp);
                    return false;
                }
            }
            else
            {
                AddAutoDetectedPrm(true);
            }

            string mf = ShowMissingFonts();
            epWarning.SetError(bPrint, "");

            if (mf.Length > 0)
            {
                epWarning.SetError(bPrint, "Fonts missing: " + UtlGen.WindowsNewLine + mf);
            }

            if (!IS_WITHOUT_VIEWER)
            {
                RefreshPreview();
            }

            return true;
        }
コード例 #2
0
ファイル: Viewer.cs プロジェクト: jalil1408/BiomPSP
        private void printDocument_BeginPrint(object sender, PrintEventArgs e)
        {
            if (!DesignMode)
            {
                Rpt = MprRpt.FromDbToIH(Rpt.ID);

                if (Rpt.Layout == ReportLayout.TopToRight || Rpt.Layout == ReportLayout.TopToLeft ||
                    (Rpt.Layout == ReportLayout.Custom && Rpt.LandscapePaper == true))
                {
                    printDocument.DefaultPageSettings.PaperSize = new PaperSize(null, Rpt.PaperSize.Height, Rpt.PaperSize.Width);
                }
                else
                {
                    printDocument.DefaultPageSettings.PaperSize = new PaperSize(null, Rpt.PaperSize.Width, Rpt.PaperSize.Height);
                }

                printDocument.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);

                if (printDocument.PrintController.IsPreview)
                {
                    PrinterMargins = new Margins(0, 0, 0, 0);
                }
                else
                {
                    PrinterMargins = UtlGen.PrinterMargins(printDocument.PrinterSettings, printDocument.DefaultPageSettings.Landscape);
                }

                PRM[Cfg.PRM_PRINT_DATE_VALUE_INDEX] = DateTime.Now.ToShortDateString();
                PRM[Cfg.PRM_PRINT_TIME_VALUE_INDEX] = DateTime.Now.ToLongTimeString();
                PRM[Cfg.PRM_PAGES_COUNT_VALUE_INDEX] = PAGES_COUNT;

                printDocument.DocumentName = Rpt.Name;

                DataRowCollection C = Cfg.DbRpt.DataTable("SELECT * FROM " + MprTblObj.TableName +
                    " WHERE " + MprTblObj.id_rpt_obj + "=" + Rpt.ID +
                    " AND " + MprTblObj.section_obj + "='" + ObjectSection.Details + "'").Rows;

                if (C.Count == 1)
                {
                    DetGrd = MprObjGrd.FromDbToIH(C[0][MprTblObj.id_obj].ToString());
                    DetRows = Rows(DetGrd);
                    PRM[Cfg.PRM_DET_ROWS_COUNT_VALUE_INDEX] = DetRows.Count;
                }
                else
                {
                    DetGrd = null;
                    DetRows = null;
                    PRM[Cfg.PRM_DET_ROWS_COUNT_VALUE_INDEX] = "0";
                }

                START_Y = 0;
                PAGE_NUMBER = 0;

                INDEX_S = 0;
                INDEX_F = -1;
            }
            else
            {
                e.Cancel = true;
            }
        }
コード例 #3
0
ファイル: MprRpt.cs プロジェクト: jalil1408/BiomPSP
        public static int ToDb(MprRpt rpt, string id_rpt)
        {
            if (id_rpt == null)
            {
                return
                    Cfg.DbRpt.Insert(true, MprTblRpt.TableName, MprTblRpt.id_rpt,
                    MprTblRpt.name_rpt, rpt.Name,
                    MprTblRpt.desc_rpt, rpt.Description,
                    MprTblRpt.author_rpt, rpt.Author,
                    MprTblRpt.date_cr_rpt, rpt.CreationDate,
                    MprTblRpt.with_adv_opt_rpt, rpt.WithAdvOptions,
                    MprTblRpt.margins_type_rpt, rpt.MarginsType.ToString(),
                    MprTblRpt.paper_virt_bg_color_rpt, UtlConvert.ToString(rpt.PaperVirtualBackgroundColor),

                    MprTblRpt.show_print_dialog_rpt, rpt.ShowPrintDialog,
                    MprTblRpt.printer_name_rpt, rpt.PrinterName,
                    MprTblRpt.copies_to_print_rpt, rpt.CopiesToPrint,

                    MprTblRpt.layout_rpt, rpt.Layout.ToString(),
                    MprTblRpt.landscape_paper_rpt, rpt.LandscapePaper,
                    MprTblRpt.rotate_angle_rpt, rpt.RotateAngle,
                    MprTblRpt.translate_point_rpt, UtlConvert.ToString(rpt.TranslatePoint),
                    MprTblRpt.paper_size_rpt, UtlConvert.ToString(rpt.PaperSize),
                    MprTblRpt.page_margins_rpt, UtlConvert.ToString(rpt.PaperMargins),
                    MprTblRpt.page_box_style_rpt, rpt.PageBoxStyle.ToString(),
                    MprTblRpt.pg_hd_height_rpt, rpt.PageHeaderHeight,
                    MprTblRpt.pg_hd_box_style_rpt, rpt.PageHeaderBoxStyle.ToString(),
                    MprTblRpt.pg_hd_first_pg_rpt, rpt.PageHeaderFirstPage,
                    MprTblRpt.rpt_hd_height_rpt, rpt.ReportHeaderHeight,

                    MprTblRpt.page_bgi_rpt, UtlConvert.ToByteA(rpt.PageBackgroundImage),
                    MprTblRpt.print_page_bgi_rpt, rpt.PrintPageBackgroundImage,
                    MprTblRpt.print_virt_bgi_rpt, rpt.PrintVirtualBackgroundImages,
                    MprTblRpt.print_virt_box_rpt, rpt.PrintVirtualBoxes,

                    MprTblRpt.rpt_ft_height_rpt, rpt.ReportFooterHeight,
                    MprTblRpt.pg_ft_height_rpt, rpt.PageFooterHeight,
                    MprTblRpt.pg_ft_box_style_rpt, rpt.PageFooterBoxStyle.ToString(),
                    MprTblRpt.rpt_ft_box_style_rpt, rpt.ReportFooterBoxStyle.ToString(),
                    MprTblRpt.rpt_hd_box_style_rpt, rpt.ReportHeaderBoxStyle.ToString()
                    );
            }
            else
            {
                return
                    Cfg.DbRpt.Update(true, MprTblRpt.TableName, MprTblRpt.id_rpt, rpt.ID,
                    MprTblRpt.name_rpt, rpt.Name,
                    MprTblRpt.desc_rpt, rpt.Description,
                    MprTblRpt.author_rpt, rpt.Author,
                    MprTblRpt.date_cr_rpt, rpt.CreationDate,
                    MprTblRpt.with_adv_opt_rpt, rpt.WithAdvOptions,
                    MprTblRpt.margins_type_rpt, rpt.MarginsType.ToString(),
                    MprTblRpt.paper_virt_bg_color_rpt, UtlConvert.ToString(rpt.PaperVirtualBackgroundColor),

                    MprTblRpt.show_print_dialog_rpt, rpt.ShowPrintDialog,
                    MprTblRpt.printer_name_rpt, rpt.PrinterName,
                    MprTblRpt.copies_to_print_rpt, rpt.CopiesToPrint,

                    MprTblRpt.page_bgi_rpt, UtlConvert.ToByteA(rpt.PageBackgroundImage),
                    MprTblRpt.print_page_bgi_rpt, rpt.PrintPageBackgroundImage,
                    MprTblRpt.print_virt_bgi_rpt, rpt.PrintVirtualBackgroundImages,
                    MprTblRpt.print_virt_box_rpt, rpt.PrintVirtualBoxes,

                    MprTblRpt.layout_rpt, rpt.Layout.ToString(),
                    MprTblRpt.landscape_paper_rpt, rpt.LandscapePaper,
                    MprTblRpt.rotate_angle_rpt, rpt.RotateAngle,
                    MprTblRpt.translate_point_rpt, UtlConvert.ToString(rpt.TranslatePoint),
                    MprTblRpt.paper_size_rpt, UtlConvert.ToString(rpt.PaperSize),
                    MprTblRpt.page_margins_rpt, UtlConvert.ToString(rpt.PaperMargins),
                    MprTblRpt.page_box_style_rpt, rpt.PageBoxStyle.ToString(),
                    MprTblRpt.pg_hd_height_rpt, rpt.PageHeaderHeight,
                    MprTblRpt.pg_hd_box_style_rpt, rpt.PageHeaderBoxStyle.ToString(),
                    MprTblRpt.pg_hd_first_pg_rpt, rpt.PageHeaderFirstPage,
                    MprTblRpt.rpt_hd_height_rpt, rpt.ReportHeaderHeight,
                    MprTblRpt.rpt_ft_height_rpt, rpt.ReportFooterHeight,
                    MprTblRpt.pg_ft_height_rpt, rpt.PageFooterHeight,
                    MprTblRpt.pg_ft_box_style_rpt, rpt.PageFooterBoxStyle.ToString(),
                    MprTblRpt.rpt_ft_box_style_rpt, rpt.ReportFooterBoxStyle.ToString(),
                    MprTblRpt.rpt_hd_box_style_rpt, rpt.ReportHeaderBoxStyle.ToString()
                    );
            }
        }