Beispiel #1
0
        public static void PrintReportA8(string IDBienNhan, string reportPath, string PrinterName, string CamThem, string ThayGiayCho)
        {
            Model.camdochieuduongEntities camdochieuduongEntity = new Model.camdochieuduongEntities();
            Model.GiaoDich GD = camdochieuduongEntity.GiaoDiches.Find(IDBienNhan);

            CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc =
                new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            rptDoc.Load(reportPath);
            rptDoc.SetParameterValue("P_IDBienNhan", GD.IDBienNhan);
            rptDoc.SetParameterValue("P_ThayGiayCho", ThayGiayCho);
            rptDoc.SetParameterValue("P_KhachHang", "Tên: " + GD.KhachHang);
            rptDoc.SetParameterValue("P_DienThoai", "SĐT: " + GD.DienThoai);
            rptDoc.SetParameterValue("P_TienCam", "Tiền Cầm: " + String.Format("{0:n0}", GD.TienCam) + " Đ");
            rptDoc.SetParameterValue("P_CamThem", CamThem);
            var MoTa = "Mô Tả: " + GD.MoTa;

            if (GD.TruHotCon != "")
            {
                MoTa = MoTa + "(Còn: " + GD.TruHotCon + ")";
            }
            rptDoc.SetParameterValue("P_MoTa", MoTa);
            rptDoc.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;

            //PaperSize xCustomSize = new PaperSize("Custom", 6, 8);
            //xCustomSize.PaperName = PaperKind.Custom;
            //PrintDocument.DefaultPageSettings.PaperSize = xCustomSize;
            //rptDoc.PrintOptions.PaperSize = ;
            rptDoc.PrintOptions.PaperSize   = CrystalDecisions.Shared.PaperSize.DefaultPaperSize;
            rptDoc.PrintOptions.PrinterName = PrinterName;
            rptDoc.PrintToPrinter(1, false, 1, 1);
        }
Beispiel #2
0
        private void printaFactura(string nomdocumento)
        {
            try
            {
                Herramientas herramientas = new Herramientas();

                var informe = herramientas.GetResourcesPath3();

                CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                rd.Load(informe + "\\" + nomdocumento + ".pdf");


                CrystalDecisions.CrystalReports.Engine.PrintOptions rptoption = rd.PrintOptions;
                rptoption.PrinterName = "\\\\192.168.1.35\\EPSON LX-350 ESC/P";
                rptoption.PaperSize   = (CrystalDecisions.Shared.PaperSize)GetIDPaperSize("\\\\192.168.1.35\\EPSON LX-350 ESC/P", "A4");//(CrystalDecisions.Shared.PaperSize)ext.GetIDPaperSize(Convert.ToString(System.Drawing.Printing.PrinterSettings.InstalledPrinters[3]), "documentoFioviza");

                rd.PrintToPrinter(1, false, 1, 1);

                rd.Close();
                rd.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Se encontro el siguiente problema" + ex.Message, "Venta", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #3
0
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            try
            {
                ser = AdmSerie.MuestraSerie(factur.CodSerie, frmLogin.iCodAlmacen);
                CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                rd.Load("CRNotaDebito.rpt");
                CRNotaDebito rpt = new CRNotaDebito();
                rd.SetDataSource(ds.ReportNotaDebitoCompra(Convert.ToInt32(CodNotaS), frmLogin.iCodAlmacen));
                CrystalDecisions.CrystalReports.Engine.PrintOptions rptoption = rd.PrintOptions;
                rptoption.PrinterName = ser.NombreImpresora;
                rptoption.PaperSize   = (CrystalDecisions.Shared.PaperSize)ext.GetIDPaperSize(ser.NombreImpresora, ser.PaperSize);
                rptoption.ApplyPageMargins(new CrystalDecisions.Shared.PageMargins(1100, 1850, 200, 1300));
                //CrystalDecisions.Shared.PageMargins margenes = rd.PrintOptions.PageMargins;
                rd.PrintToPrinter(1, false, 1, 1);
                rd.Close();
                rd.Dispose();

                //CRNotaDebito rpt = new CRNotaDebito();
                //frmRptNotaCredito frm = new frmRptNotaCredito();
                //CrystalDecisions.CrystalReports.Engine.PrintOptions rptoption = rpt.PrintOptions;
                //rptoption.PrinterName = ser.NombreImpresora;//Convert.ToString(System.Drawing.Printing.PrinterSettings.InstalledPrinters[3]);
                //rptoption.PaperSize = (CrystalDecisions.Shared.PaperSize)ext.GetIDPaperSize(ser.NombreImpresora, ser.PaperSize);
                //rpt.SetDataSource(ds.ReportNotaDebitoCompra(Convert.ToInt32(CodNotaS), frmLogin.iCodAlmacen).Tables[0]);
                //frm.crvNotaCredito.ReportSource = rpt;
                //frm.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Se encontro el siguiente problema " + ex.Message, "Nota de Credito", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #4
0
        public void ViewReport(CrystalDecisions.Windows.Forms.CrystalReportViewer CrViewer, string Reportname, string rsSelectionformula, string paraname1, string paraname2, string paraname3, string paraname4, string paraname5, string paraname6, string paraname7, string paravalue1, string paravalue2, string paravalue3, string paravalue4, string paravalue5, string paravalue6, string paravalue7, int SendToPrinter, Form frm)
        {
            rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            string REPORTSPATH = Application.StartupPath + ConfigurationManager.AppSettings["ShareFolder"];

            rpt.Load((REPORTSPATH + ("\\" + Reportname)));
            rpt.SetParameterValue(paraname1, paravalue1);
            rpt.SetParameterValue(paraname2, paravalue2);
            rpt.SetParameterValue(paraname3, paravalue3);
            rpt.SetParameterValue(paraname4, paravalue4);
            rpt.SetParameterValue(paraname5, paravalue5);
            rpt.SetParameterValue(paraname6, paravalue6);
            rpt.SetParameterValue(paraname7, paravalue7);
            //  CrystalDecisions.CrystalReports.Engine.Table tdCurr;

            foreach (CrystalDecisions.CrystalReports.Engine.Table tdCurr in rpt.Database.Tables)
            {
                rptTLInfo = new CrystalDecisions.Shared.TableLogOnInfo();
                rptTLInfo = tdCurr.LogOnInfo;
                // With...
                //SERVERNAME.Password = "******";
                //dataBaseName.ServerName = "SA";
                rptTLInfo.ConnectionInfo.DatabaseName = "IMS";
                tdCurr.ApplyLogOnInfo(rptTLInfo);
            }
            rpt.SetDatabaseLogon("", "", ".", "IMS");
            rpt.SummaryInfo.ReportAuthor = RptAuthor;
            if ((rsSelectionformula != ""))
            {
                rpt.RecordSelectionFormula = rsSelectionformula;
            }

            if ((SendToPrinter == 1))
            {
                try
                {
                    rpt.PrintToPrinter(1, true, 1, 1);
                }
                catch (Exception ex)
                {
                    //  MsgBox(ex.Message);
                }
            }
            else
            {
                //if (((Para1 == null)
                //            == false)) {
                //    CrViewer.ParameterFieldInfo = parameters;
                //}

                CrViewer.ReportSource = rpt;
                CrViewer.Refresh();
                if ((frm.Tag != "ALL BILL REPORT"))
                {
                    //    frm.Show();
                    //   SHOW_PLEASE_WAIT(false);
                }
            }
        }
Beispiel #5
0
        private static void ImprimirTicket(string Identificador)
        {
            string returnValue = null;

            // Look for the name in the connectionStrings section.
            ConnectionStringSettings settings =
                ConfigurationManager.ConnectionStrings["ProfitContenedor.Properties.Settings.Profit_RGConnectionString"];

            // If found, return the connection string.
            if (settings != null)
            {
                returnValue = settings.ConnectionString;
            }

            //SqlConnection sqlConn = new SqlConnection("Server=172.16.1.4;uid=profit;password=profit;initial catalog=Profit_RG;");
            SqlConnection sqlConn = new SqlConnection(returnValue);

            SqlCommand comd;

            comd             = new SqlCommand();
            comd.Connection  = sqlConn;
            comd.CommandType = CommandType.StoredProcedure;
            comd.CommandText = "pRepTicket_Pedido";

            comd.Parameters.Add("@Rowguid", SqlDbType.Char);
            comd.Parameters[0].Value = Identificador;

            SqlDataAdapter sqlAdapter = new SqlDataAdapter();

            sqlAdapter.SelectCommand = comd;
            DataSet ds = new DataSet();

            sqlAdapter.Fill(ds, "pRepTicket_Pedido");

            CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            string Filename = @"\\172.16.1.4\Profit\Publicaciones\Profit Expansion\Reportes\RepTicketPedido.rpt";

            oRpt.Load(Filename);

            string NombreImpresora = "";//Donde guardare el nombre de la impresora por defecto

            //Busco la impresora por defecto
            for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
            {
                PrinterSettings a = new PrinterSettings();
                a.PrinterName = PrinterSettings.InstalledPrinters[i].ToString();
                if (a.IsDefaultPrinter)
                {
                    NombreImpresora = PrinterSettings.InstalledPrinters[i].ToString();
                }
            }

            oRpt.SetDataSource(ds);                          //Asigno la fuente de datos a mi reporte.
            oRpt.PrintOptions.PrinterName = NombreImpresora; //Asigno la impresora
            oRpt.PrintToPrinter(1, false, 0, 0);             //Imprimo 1 copias
        }
 private void shapedButton1_Click(object sender, EventArgs e)
 {
     if (DGV_BILL_LIST.SelectedRows.Count > 0)
     {
         REPORT.RESERVATION_NO = DGV_BILL_LIST.SelectedRows[0].Cells[0].Value.ToString();
         CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
         rptDoc.Load(Application.StartupPath + "\\reports\\RECEIPT.rpt");
         rptDoc.PrintToPrinter(1, true, 1, 1);
     }
 }
Beispiel #7
0
 private void btPrint_Click(object sender, System.EventArgs e)
 {
     try
     {
         m_objDocument.PrintToPrinter(1, false, 0, 1);
     }
     catch
     {
         MessageBox.Show("没有安装打印机!");
     }
 }
Beispiel #8
0
        public static void PrintReport(string IDBienNhan, string reportPath, string PrinterName)
        {
            Model.camdochieuduongEntities camdochieuduongEntity = new Model.camdochieuduongEntities();
            Model.GiaoDich GD         = camdochieuduongEntity.GiaoDiches.Find(IDBienNhan);
            var            TienCamChu = "";

            if (GD.TienCam != 0)
            {
                TienCamChu = camdochieuduong.Function.ConvertMoneyToChar.NumberToText(GD.TienCam.ToString());
            }
            else
            {
                TienCamChu = "";
            }

            CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc =
                new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            rptDoc.Load(reportPath);

            rptDoc.SetParameterValue("ms", GD.IDBienNhan);
            rptDoc.SetParameterValue("P_KhachHang", GD.KhachHang);
            rptDoc.SetParameterValue("P_DienThoai", GD.DienThoai);
            rptDoc.SetParameterValue("P_MoTa", GD.MoTa);
            rptDoc.SetParameterValue("P_TruHotCon", GD.TruHotCon);
            rptDoc.SetParameterValue("P_TienCam", String.Format("{0:n0}", GD.TienCam));
            rptDoc.SetParameterValue("P_GiaTri", String.Format("{0:n0}", GD.GiaTri));
            rptDoc.SetParameterValue("P_NgayCam", GD.NgayCam.ToString());
            rptDoc.SetParameterValue("P_GioCam", GD.NgayCam.Value.TimeOfDay.ToString());
            rptDoc.SetParameterValue("P_TienCamChu", TienCamChu);

            rptDoc.PrintOptions.ApplyPageMargins(new CrystalDecisions.Shared.PageMargins(0, 0, 0, 0));
            rptDoc.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;
            rptDoc.PrintOptions.PaperSize        = CrystalDecisions.Shared.PaperSize.PaperA4;


            rptDoc.PrintOptions.PrinterName = PrinterName.Trim();
            rptDoc.PrintToPrinter(1, false, 0, 0);
        }
Beispiel #9
0
 private void btnImprimir_Click(object sender, EventArgs e)
 {
     try
     {
         ser = AdmSerie.MuestraSerie(venta.CodSerie, frmLogin.iCodAlmacen);
         CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
         rd.Load("CRNotaDebitoVenta.rpt");
         CRNotaDebitoVenta rpt = new CRNotaDebitoVenta();
         rd.SetDataSource(ds.ReportNotaDebitoVenta(Convert.ToInt32(venta.CodFacturaVenta), frmLogin.iCodAlmacen));
         CrystalDecisions.CrystalReports.Engine.PrintOptions rptoption = rd.PrintOptions;
         rptoption.PrinterName = ser.NombreImpresora;
         rptoption.PaperSize   = (CrystalDecisions.Shared.PaperSize)ext.GetIDPaperSize(ser.NombreImpresora, ser.PaperSize);
         rptoption.ApplyPageMargins(new CrystalDecisions.Shared.PageMargins(1100, 1850, 200, 1300));
         //CrystalDecisions.Shared.PageMargins margenes = rd.PrintOptions.PageMargins;
         rd.PrintToPrinter(1, false, 1, 1);
         rd.Close();
         rd.Dispose();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Se encontro el siguiente problema" + ex.Message, "Nota Débito", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #10
0
        public string printCrystalReportsToPDF(CrystalDecisions.CrystalReports.Engine.ReportDocument result)
        {
            System.Threading.Monitor.Enter(lockObject);

            if (string.IsNullOrEmpty(PDFCreaterPrinterName))
            {
                PDFCreaterPrinterName = DEFAULT_PRINTERNAME;
            }
            string pdfExportFilename = System.IO.Path.GetTempFileName();

            System.IO.File.Delete(pdfExportFilename);
            pdfExportFilename = pdfExportFilename.Replace(".tmp", ".pdf");

            bool creatorStarted = false;

            try
            {
                creator         = new PDFCreator.clsPDFCreatorClass();
                creator.eError += new PDFCreator.__clsPDFCreator_eErrorEventHandler(creator_eError);
                creator.eReady += new PDFCreator.__clsPDFCreator_eReadyEventHandler(creator_eReady);
                String paramters = "/NoProcessingAtStartup";

                TimeSpan timeoutDuration = new TimeSpan(0, 0, 0, 120);
                DateTime lastCheck       = DateTime.Now;
                DateTime startTime       = lastCheck;

                while (!creator.cStart(paramters, false) && ((lastCheck - startTime) < timeoutDuration))
                {
                    if (creator.cError.Number == 2)
                    {
                        System.Threading.Thread.Sleep(1000);
                    }
                    else
                    {
                        throw new Exception("Cannot launch PDFCreator. Error: " + pdfErrorMessage);
                    }
                }
                creatorStarted = true;



                PDFCreator.clsPDFCreatorOptions opt = creator.cOptions;
                opt.UseAutosave          = 1;
                opt.UseAutosaveDirectory = 1;
                opt.AutosaveDirectory    = System.IO.Path.GetDirectoryName(pdfExportFilename);
                opt.AutosaveFormat       = 0;
                //  Do NOT add the file extension to AutosaveFilename variable.
                //  The creator will add the extension automatically.
                opt.AutosaveFilename = System.IO.Path.GetFileNameWithoutExtension(pdfExportFilename);
                creator.cOptions     = opt;

                creator.cClearCache();
                creator.cDefaultPrinter = PDFCreaterPrinterName;

                result.PrintOptions.PrinterName = PDFCreaterPrinterName;

                result.PrintToPrinter(1, true, 0, 0);
                creator.cPrinterStop = false;
                //if (!creator.cIsPrintable(exportFileName))
                //{
                //    throw new Exception("File: " + exportFileName + " is not printable.");
                //}

                //creator.cPrintFile(exportFileName);

                Ready = false;

                lastCheck = DateTime.Now;
                startTime = lastCheck;

                while (!Ready && ((lastCheck - startTime) < timeoutDuration))
                {
                    System.Threading.Thread.Sleep(500);
                    lastCheck = DateTime.Now;
                }

                creator.cPrinterStop = true;
                System.Threading.Thread.Sleep(1000);
                creator.cClose();
                creatorStarted = false;
                if (!Ready)
                {
                    throw new Exception("PDF creation failed. This maybe due to timeout.");
                }
                if (!System.IO.File.Exists(pdfExportFilename))
                {
                    throw new Exception("Output file not found: " + pdfExportFilename);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (creatorStarted)
                {
                    creator.cClose();
                }
                System.Threading.Monitor.Exit(lockObject);
            }
            return(pdfExportFilename);
        }
Beispiel #11
0
        /// <summary>
        /// Programacion del Reporte: RepEtiqueta
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonItem4_Click(object sender, EventArgs e)
        {
            try
            {
                string returnValue = null;

                // Look for the name in the connectionStrings section.
                ConnectionStringSettings settings =
                    ConfigurationManager.ConnectionStrings["ProfitContenedor.Properties.Settings.Profit_RGConnectionString"];

                // If found, return the connection string.
                if (settings != null)
                {
                    returnValue = settings.ConnectionString;
                }

                //SqlConnection sqlConn = new SqlConnection("Server=172.16.1.4;uid=profit;password=profit;initial catalog=Profit_RG;");
                SqlConnection sqlConn = new SqlConnection(returnValue);


                SqlCommand comd;
                comd             = new SqlCommand();
                comd.Connection  = sqlConn;
                comd.CommandType = CommandType.StoredProcedure;
                comd.CommandText = "pRepEtiqueta";

                comd.Parameters.Add("@id_activo", SqlDbType.NChar);
                comd.Parameters[0].Value = txtCo_activo.Text.Trim();



                SqlDataAdapter sqlAdapter = new SqlDataAdapter();
                sqlAdapter.SelectCommand = comd;
                DataSet ds = new DataSet();
                sqlAdapter.Fill(ds, "pRepEtiqueta");

                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                string Filename = @"\\172.16.1.4\Profit\Publicaciones\Profit Expansion\Reportes\RepEtiqueta.rpt";

                oRpt.Load(Filename);

                string NombreImpresora = "";//Donde guardare el nombre de la impresora por defecto

                //Busco la impresora por defecto
                for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
                {
                    PrinterSettings a = new PrinterSettings();
                    a.PrinterName = PrinterSettings.InstalledPrinters[i].ToString();
                    if (a.IsDefaultPrinter)
                    {
                        NombreImpresora = PrinterSettings.InstalledPrinters[i].ToString();
                    }
                }

                oRpt.SetDataSource(ds);                          //Asigno la fuente de datos a mi reporte.
                oRpt.PrintOptions.PrinterName = NombreImpresora; //Asigno la impresora
                oRpt.PrintToPrinter(1, false, 0, 0);             //Imprimo 1 copias

                //FrmRep Fr = new FrmRep(ds, "RepEtiqueta.rpt", false);
                //Fr.Show();
            }
            catch (Exception ex1)
            {
                MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }