コード例 #1
0
        public void PrintDocuments(IEnumerable <tblDocumentCommon> documents)
        {
            // сортируем по фио и приоритету печати

            // для пациента
            // 2 договора на продажу
            // товарный чек
            // 2 договора на услугу

            var xSortedDocs = (from doc in documents
                               let docOrdPriority = (doc is tblDocumentProduct) ? 0 : ((doc is tblDocumentSalesReceipt) ? 1 : 2)
                                                    orderby doc.ShortName, docOrdPriority
                               select doc).ToList();
            List <DocumentAdapter> xSource = new List <DocumentAdapter>(1);

            xSource.Add(null);
            foreach (tblDocumentCommon doc in xSortedDocs)
            {
                DocumentAdapter xPrintAdapter = new DocumentAdapter(doc);
                xSource[0] = xPrintAdapter;
                PrinterSettings xPrintsettings = (doc is tblDocumentSalesReceipt) ? SalesReceiptPrinterSettings : DefaultDocPrinterSettings;
                xPrintsettings.Copies = doc.CopiesCount;
                ReportClass xReport = GetReport(doc, xSource);
                try
                {
                    xReport.PrintToPrinter(xPrintsettings, xPrintsettings.DefaultPageSettings, false);
                    doc.Printed    = true;
                    doc.IsSelected = false;
                }
                finally
                {
                    xReport.Dispose();
                }
            }
        }
コード例 #2
0
        public ReportClass GetReport(tblDocumentCommon doc, List <DocumentAdapter> reportSource = null)
        {
            List <DocumentAdapter> xSource = reportSource;

            if (xSource == null)
            {
                DocumentAdapter xPrintAdapter = new DocumentAdapter(doc);
                xSource = new List <DocumentAdapter>(1);
                xSource.Add(xPrintAdapter);
            }
            ReportClass xReport;

            if (doc is tblDocumentService)
            {
                xReport = new DocService();
            }
            else if (doc is tblDocumentProduct)
            {
                xReport = new DocSale();
            }
            else if (doc is tblDocumentSalesReceipt)
            {
                xReport = new SaleReceipt();
            }
            else
            {
                throw new Exception("Не определен шаблон документа");
            }
            xReport.SetDataSource(xSource);
            return(xReport);
        }