Пример #1
0
        private void LoadDocument(RouteListPrintableDocuments docType)
        {
            int rlNumber = GetRouteListNumber();

            if (rlNumber == 0)
            {
                return;
            }
            ReportInfo document = null;

            using (IUnitOfWork uow = UnitOfWorkFactory.CreateWithoutRoot()) {
                RouteList rl = uow.GetById <RouteList>(rlNumber);
                if (rl == null)
                {
                    MessageDialogHelper.RunErrorDialog($"Маршрутный лист с номером {rlNumber} не найден");
                    return;
                }
                document = PrintRouteListHelper.GetRDL(rl, docType, uow);
            }

            if (document == null)
            {
                MessageDialogHelper.RunErrorDialog("Не возможно получить печатную форму документа");
                return;
            }

            if (document.Source != null)
            {
                reportViewer.LoadReport(document.Source, document.GetParametersString(), document.ConnectionString, true, document.RestrictedOutputPresentationTypes);
            }
            else
            {
                reportViewer.LoadReport(document.GetReportUri(), document.GetParametersString(), document.ConnectionString, true, document.RestrictedOutputPresentationTypes);
            }
        }
Пример #2
0
        private void PrintDoc(RouteList route, RouteListPrintableDocuments type, PageOrientation orientation, int copies)
        {
            var reportInfo = PrintRouteListHelper.GetRDL(route, type, uow);

            var action = showDialog ? PrintOperationAction.PrintDialog : PrintOperationAction.Print;

            showDialog = false;

            Printer             = new PrintOperation();
            Printer.Unit        = Unit.Points;
            Printer.UseFullPage = true;
            //Printer.DefaultPageSetup = new PageSetup();

            if (PrintSettings == null)
            {
                Printer.PrintSettings = new PrintSettings();
            }
            else
            {
                Printer.PrintSettings = PrintSettings;
            }

            Printer.PrintSettings.Orientation = orientation;

            var rprint = new ReportPrinter(reportInfo);

            rprint.PrepareReport();

            Printer.NPages = rprint.PageCount;
            Printer.PrintSettings.NCopies = copies;
            if (copies > 1)
            {
                Printer.PrintSettings.Collate = true;
            }

            Printer.DrawPage += rprint.DrawPage;
            Printer.Run(action, null);

            PrintSettings = Printer.PrintSettings;
        }