コード例 #1
0
        public void Print()
        {
            myReport.PrintOptions.PrinterName = cbbPrinter.Text;
            myReport.PrintOptions.PaperSource = paperSource;

            switch (pageRangeManager.GetValue())
            {
            case PageRange.E_Page_All:
                myReport.PrintToPrinter(nudCopies.Value, btnCollate.Checked, 0, 0);
                break;

            case PageRange.E_Page_Current:
                var page = crystalReportViewer1.GetCurrentPageNumber();
                myReport.PrintToPrinter(nudCopies.Value, btnCollate.Checked, page, page);
                break;

            case PageRange.E_Page_Range:
                myReport.PrintToPrinter(nudCopies.Value, btnCollate.Checked, nudFromPage.Value, nudToPage.Value);
                break;
            }

            if (OnPrinted != null)
            {
                OnPrinted(this, EventArgs.Empty);
            }
        }
コード例 #2
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();
                }
            }
        }
コード例 #3
0
ファイル: Utils.cs プロジェクト: hpbaotho/thanhtuan
 public static void Print(ReportClass reportClass,string printerName)
 {
     Service.ServiceGet serviceGet = new ServiceGet();
     Printer printer = serviceGet.GetPrinterByName(StaticClass.storeId, StaticClass.stationId, printerName);
     if (!(printer == null || printer.Details == "NONE" || printer.Disable == true))
     {
         reportClass.DataSourceConnections[0].SetConnection(StaticClass.serverName, StaticClass.databaseName, true);
         reportClass.PrintOptions.PrinterName = printer.Details;
         reportClass.PrintOptions.ApplyPageMargins(new PageMargins(1, 2, 1, 0));
         reportClass.PrintToPrinter(1,false,0,0);
     }
 }
コード例 #4
0
        public static void Print(ReportClass reportClass, string printerName)
        {
            Service.ServiceGet serviceGet = new ServiceGet();
            Printer            printer    = serviceGet.GetPrinterByName(StaticClass.storeId, StaticClass.stationId, printerName);

            if (!(printer == null || printer.Details == "NONE" || printer.Disable == true))
            {
                reportClass.DataSourceConnections[0].SetConnection(StaticClass.serverName, StaticClass.databaseName, true);
                reportClass.PrintOptions.PrinterName = printer.Details;
                reportClass.PrintOptions.ApplyPageMargins(new PageMargins(1, 2, 1, 0));
                reportClass.PrintToPrinter(1, false, 0, 0);
            }
        }
コード例 #5
0
        public void imprimir(ReportClass reporte)
        {
            PrintDialog dialog1 = new PrintDialog();

            if (dialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                int  copies   = dialog1.PrinterSettings.Copies;
                int  fromPage = dialog1.PrinterSettings.FromPage;
                int  toPage   = dialog1.PrinterSettings.ToPage;
                bool collate  = dialog1.PrinterSettings.Collate;

                reporte.PrintOptions.PrinterName = dialog1.PrinterSettings.PrinterName;
                reporte.PrintToPrinter(copies, collate, fromPage, toPage);
            }
            reporte.Dispose();
            dialog1.Dispose();
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: jhkmnm/Deliver
 private bool Print(DataSet ds)
 {
     try
     {
         rpt.SetDataSource(ds.Tables["mainTable"]);
         ReportDocument poRptSub = rpt.Subreports[0];
         DataTable      dtSub    = ds.Tables["sunTable"];
         poRptSub.SetDataSource(dtSub);
         rpt.PrintToPrinter(1, true, 0, 0);
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show("打印出错:" + Environment.NewLine + ex.Message + ex.StackTrace);
         return(false);
     }
 }
コード例 #7
0
        public void imprimir(ReportClass reporte)//recibe un objeto repor,abre el dilogo impresora y si da si va a sacar las opciones,llama al metodo impri repor de donde a donde
        {
            PrintDialog dialog1 = new PrintDialog();

            if (dialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                int  copies   = dialog1.PrinterSettings.Copies;
                int  fromPage = dialog1.PrinterSettings.FromPage;
                int  toPage   = dialog1.PrinterSettings.ToPage;
                bool collate  = dialog1.PrinterSettings.Collate;

                reporte.PrintOptions.PrinterName = dialog1.PrinterSettings.PrinterName;
                reporte.PrintToPrinter(copies, collate, fromPage, toPage);
            }
            reporte.Dispose();
            dialog1.Dispose();
        }
コード例 #8
0
        public void PrintPreview(ReportClass iReport, string rpt_procedure, Hashtable ht, bool isPrint)
        {
            try
            {
                DataTable DTab_reportData = (DataTable)ReportData(rpt_procedure);
                if (DTab_reportData.Rows.Count > 0)
                {
                    if (isPrint == false)
                    {
                        // frmRptv ifrmPrint = new frmRptv();

                        iReport.SetDataSource(DTab_reportData);
                        foreach (object obj in ht.Keys)
                        {
                            iReport.SetParameterValue(obj.ToString(), ht[obj]);
                        }
                        frmPrint ifrmPrint = new frmPrint(iReport);
                        ifrmPrint.Visible = true;
                    }
                    else
                    {
                        iReport.ReportOptions.EnableSaveDataWithReport = true;
                        iReport.SetDataSource(DTab_reportData);
                        foreach (object obj in ht.Keys)
                        {
                            iReport.SetParameterValue(obj.ToString(), ht[obj]);
                        }
                        iReport.PrintToPrinter(1, false, 0, 0); //iReport.PrintToPrinter(1, false, 0, 0);
                    }
                }
                else
                {
                    MessageBox.Show("No Records Found");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
            }
        }
コード例 #9
0
ファイル: Utils.cs プロジェクト: hpbaotho/thanhtuan
 public static void Print(ReportClass reportClass,string printerName)
 {
     Service.ServiceGet serviceGet = new ServiceGet();
     Printer printer = serviceGet.GetPrinterByName(StaticClass.storeId, StaticClass.stationId, printerName);
     if (!(printer == null || printer.Details == "NONE" || printer.Disable == true))
     {
         if (StaticClass.mode == "AUT")
         {
             reportClass.DataSourceConnections[0].SetConnection(StaticClass.serverName, StaticClass.databaseName, true);
         }
         else if (StaticClass.mode == "SQL")
         {
             //reportClass.DataSourceConnections[0].SetConnection(StaticClass.serverName, StaticClass.databaseName,
                                                               // StaticClass.userName, StaticClass.password);
             reportClass.SetDatabaseLogon(StaticClass.userName, StaticClass.password, StaticClass.serverName,
                                          StaticClass.databaseName,true);
             reportClass.DataSourceConnections[0].IntegratedSecurity = false;
         }
         else
         {
             return;
         }
         
         
         if(printerName == "Hóa đơn")
         {
             reportClass.PrintOptions.ApplyPageMargins(new PageMargins(1, 2, 1, 0));
         }
         
         try
         {
             reportClass.PrintOptions.PrinterName = printer.Details;
             reportClass.PrintToPrinter(1, false, 0, 0);
         }
         catch (Exception)
         {
             Alert.Show("Lỗi máy in", Color.Red);
         }
         
     }
 }
コード例 #10
0
        public static void Print(ReportClass reportClass, string printerName)
        {
            Service.ServiceGet serviceGet = new ServiceGet();
            Printer            printer    = serviceGet.GetPrinterByName(StaticClass.storeId, StaticClass.stationId, printerName);

            if (!(printer == null || printer.Details == "NONE" || printer.Disable == true))
            {
                if (StaticClass.mode == "AUT")
                {
                    reportClass.DataSourceConnections[0].SetConnection(StaticClass.serverName, StaticClass.databaseName, true);
                }
                else if (StaticClass.mode == "SQL")
                {
                    //reportClass.DataSourceConnections[0].SetConnection(StaticClass.serverName, StaticClass.databaseName,
                    // StaticClass.userName, StaticClass.password);
                    reportClass.SetDatabaseLogon(StaticClass.userName, StaticClass.password, StaticClass.serverName,
                                                 StaticClass.databaseName, true);
                    reportClass.DataSourceConnections[0].IntegratedSecurity = false;
                }
                else
                {
                    return;
                }


                if (printerName == "Hóa đơn")
                {
                    reportClass.PrintOptions.ApplyPageMargins(new PageMargins(1, 2, 1, 0));
                }

                try
                {
                    reportClass.PrintOptions.PrinterName = printer.Details;
                    reportClass.PrintToPrinter(1, false, 0, 0);
                }
                catch (Exception)
                {
                    Alert.Show("Lỗi máy in", Color.Red);
                }
            }
        }
コード例 #11
0
ファイル: ChildForm.cs プロジェクト: anastasiaramos/moleQule
        protected void PrintReport(ReportClass rpt, string printerName, int nCopies)
        {
            if (rpt != null)
            {
                try
                {
                    System.Drawing.Printing.PrinterSettings printer_settings = new System.Drawing.Printing.PrinterSettings();
                    printer_settings.PrinterName = printerName;
                    printer_settings.Copies      = (short)nCopies;
                    System.Drawing.Printing.PageSettings page_settings = new System.Drawing.Printing.PageSettings(printer_settings);

                    CrystalDecisions.CrystalReports.Engine.ReportClass report = rpt;
                    report.PrintToPrinter(printer_settings, page_settings, false);
                }
                catch
                {
                    rpt.PrintToPrinter(nCopies, true, 0, 0);
                }
            }
            else
            {
                PgMng.ShowInfoException(Resources.Messages.NO_DATA_REPORTS);
            }
        }
コード例 #12
0
        private void CRVEtiquetas_Load(object sender, EventArgs e)
        {
            int NumEtiquetaActual = 0;
            int HojaActual        = 0;

            DSEtiq1[] Dss = new DSEtiq1[CalcularCantidadDeHojas()];

            Dss[HojaActual] = new DSEtiq1();

            if (tipo != "Grande")
            {
                // Dejamos en blanco las primeras etiquetas en caso de seleccionar una posicion que no se la de por defecto.
                int WPosicion = (tipo == "Chica") ? posicion * 2 : posicion;

                for (int j = 0; j < WPosicion; j++)
                {
                    DataRow dr = dt.Rows[0];
                    Dss[0].Tables[NumEtiquetaActual].Rows.Add("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");

                    NumEtiquetaActual++;
                }
            }

            for (int row = 0; row < dt.Rows.Count; row++)
            {
                for (int i = 0; i < CantidadesDeEtiquetas[row]; i++)
                {
                    DataRow dr = dt.Rows[row];

                    // Quitamos espacios en blanco.

                    for (int x = 0; x < dr.ItemArray.Count(); x++)
                    {
                        dr[x] = dr[x].ToString().Trim();
                    }

                    string[] SGA = _ObtenerDatosSGA(dr[2].ToString());

                    if (tipo == "Chica")
                    {
                        Dss[HojaActual].Tables[NumEtiquetaActual].Rows.Add(
                            dr[4], dr[3], dr[9],
                            dr[6], dr[7], dr[0],
                            dr[10], dr[8], dr[5],
                            SGA[0], SGA[1], SGA[2],
                            SGA[3], SGA[4], SGA[5],
                            SGA[6], SGA[7], SGA[8],
                            SGA[9], SGA[10], SGA[11], SGA[14],
                            SGA[15], SGA[16], SGA[17],
                            SGA[18], SGA[19], SGA[20],
                            SGA[21], SGA[22], SGA[23],
                            SGA[24], SGA[25], SGA[26],
                            SGA[27], SGA[28], "", "", SGA[12], dr[11]
                            );

                        NumEtiquetaActual++;

                        Dss[HojaActual].Tables[NumEtiquetaActual].Rows.Add(
                            dr[4], dr[3], dr[9],
                            dr[6], dr[7], dr[0],
                            dr[10], dr[8], dr[5],
                            SGA[0], SGA[1], SGA[2],
                            SGA[3], SGA[4], SGA[5],
                            SGA[6], SGA[7], SGA[8],
                            SGA[9], SGA[10], SGA[11], SGA[14],
                            SGA[15], SGA[16], SGA[17],
                            SGA[18], SGA[19], SGA[20],
                            SGA[21], SGA[22], SGA[23],
                            SGA[24], SGA[25], SGA[26],
                            SGA[27], SGA[28], "", "", SGA[12], dr[11]
                            );

                        NumEtiquetaActual++;
                    }
                    else
                    {
                        Dss[HojaActual].Tables[NumEtiquetaActual].Rows.Add(
                            dr[4], dr[3], dr[9],
                            dr[6], dr[7], dr[0],
                            dr[10], dr[8], dr[5],
                            SGA[0], SGA[1], SGA[2],
                            SGA[3], SGA[4], SGA[5],
                            SGA[6], SGA[7], SGA[8],
                            SGA[9], SGA[10], SGA[11], SGA[14],
                            SGA[15], SGA[16], SGA[17],
                            SGA[18], SGA[19], SGA[20],
                            SGA[21], SGA[22], SGA[23],
                            SGA[24], SGA[25], SGA[26],
                            SGA[27], SGA[28], "", "", SGA[12], dr[11]
                            );

                        NumEtiquetaActual++;
                    }

                    if (EsFinalDeHoja(NumEtiquetaActual))
                    {
                        NumEtiquetaActual = 0;

                        HojaActual++;

                        if (HojaActual < CalcularCantidadDeHojas())
                        {
                            Dss[HojaActual] = new DSEtiq1();
                        }
                    }
                }
            }


            foreach (DSEtiq1 ds in Dss)
            {
                DSEtiq1     _ds   = ds;
                ReportClass ECImp = ObtenerRptSegunTipo();

                ECImp.SetDataSource(_ds);

                if (_EnProduccion)
                {
                    //CRVEtiquetas.Visible = true;
                    //CRVEtiquetas.ReportSource = ECImp;
                    ECImp.PrintToPrinter(1, true, 0, 0);

                    Close();
                }
                else
                {
                    CRVEtiquetas.Visible      = true;
                    CRVEtiquetas.ReportSource = ECImp;
                }
            }
        }
コード例 #13
0
ファイル: Form1.cs プロジェクト: jhkmnm/Barcode
        private bool Print(DataTable dt)
        {
            Cursor = Cursors.WaitCursor;

            if (dt == null || dt.Rows.Count == 0)
            {
                MessageBox.Show("请选择要打印的项");
                return(false);
            }
            if (rpt == null)
            {
                if (ddlPageSize.Text == "40 x 30")
                {
                    rpt = new ProductWeight();
                }
                else if (ddlPageSize.Text == "40 x 60")
                {
                    rpt = new ProductWeight60();
                }
                else
                {
                    rpt = new ProductWeight50();
                }
                rpt.PrintOptions.PrinterName = ddlPrinter.Text;
                var doc = new System.Drawing.Printing.PrintDocument
                {
                    PrinterSettings =
                    {
                        PrinterName = ddlPrinter.Text
                    }
                };
                var  papername = ddlPageSize.Text;
                bool hassize   = false;
                if (!string.IsNullOrEmpty(papername))
                {
                    for (var i = 0; i <= doc.PrinterSettings.PaperSizes.Count - 1; i++)
                    {
                        if (doc.PrinterSettings.PaperSizes[i].PaperName.ToLower() == papername)
                        {
                            hassize = true;
                            rpt.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)doc.PrinterSettings.PaperSizes[i].RawKind;
                            break;
                        }
                    }
                }
                if (!hassize)
                {
                    MessageBox.Show("系统内未找到" + ddlPageSize.Text + "的纸张,请先配置纸张");
                    Cursor = Cursors.Default;
                    return(false);
                }
            }
            logger.Info("创建打印对象并设置纸张");
            try
            {
                rpt.SetDataSource(dt);
                rpt.PrintToPrinter(1, true, 0, 0);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("打印出错:" + Environment.NewLine + ex.Message + ex.StackTrace);
                return(false);
            }
            finally
            {
                logger.Info("打印完成");
                Cursor = Cursors.Default;
            }
        }