Exemplo n.º 1
1
		private void GeneratePDF()
		{
            ReportDocument rpt = new ReportDocument();
            switch (cboView.SelectedItem.Value)
            {
                case "0":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/ChartOfAccountsDetails.rpt"));
                    break;
                case "1":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/ChartOfAccountsSummary.rpt"));
                    break;
            }

			ExportOptions exportop = new ExportOptions();
			DiskFileDestinationOptions dest = new DiskFileDestinationOptions();
			
			string strPath = Server.MapPath(@"\RetailPlus\temp\");

			string strFileName = "chartofacc_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + ".pdf";
			if (System.IO.File.Exists(strPath + strFileName))
				System.IO.File.Delete(strPath + strFileName);

			dest.DiskFileName = strPath + strFileName;

			exportop = rpt.ExportOptions;
	
			SetDataSource(rpt);

			exportop.DestinationOptions = dest;
			exportop.ExportDestinationType = ExportDestinationType.DiskFile;
			exportop.ExportFormatType = ExportFormatType.PortableDocFormat;
			rpt.Export();   rpt.Close();    rpt.Dispose();
			
			fraViewer.Attributes.Add("src","/RetailPlus/temp/" + strFileName);
		}
Exemplo n.º 2
0
        public void ExportarRelatorioPdf(string caminho_arquivo)
        {
            InicializaRpt();

            foreach (var p in _relatorio.parametros)
            {
                relatorio.SetParameterValue(p.parametro, p.valor);
            }

            ExportOptions CrExportOptions;
            DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
            PdfRtfWordFormatOptions    CrFormatTypeOptions          = new PdfRtfWordFormatOptions();

            CrDiskFileDestinationOptions.DiskFileName = caminho_arquivo;
            CrExportOptions = relatorio.ExportOptions;//Report document  object has to be given here
            CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
            CrExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
            CrExportOptions.DestinationOptions    = CrDiskFileDestinationOptions;
            CrExportOptions.FormatOptions         = CrFormatTypeOptions;

            relatorio.Export();

            //((BasePage)this.Page).ResponsePdf(adExtratoPDF.caminho_arquivo, adExtratoPDF.nome_arquivo);

            //ResponsePdf(adExtratoPDF.caminho_arquivo, adExtratoPDF.nome_arquivo);
        }
Exemplo n.º 3
0
        private void GeneraReport(string StringaOdl)
        {
            report_pmp DtRpt = new report_pmp();

            TheSite.SchemiXSD.ReportPmp ds = new TheSite.SchemiXSD.ReportPmp();
            ds = DtRpt.GetDataRpt(StringaOdl);
            string pathRptSource = Server.MapPath(Request.ApplicationPath + ConfigurationSettings.AppSettings["SourceReports"]);

            crReportDocument.Load(pathRptSource + "REPORT_PMP.rpt");
            crReportDocument.SetDataSource(ds);
            CRView1.ReportSource = crReportDocument;
            CRView1.DataBind();
            //  per pdf
            string        Fname = Server.MapPath("../Report/" + Session.SessionID.ToString() + ".pdf");//pathRptSource  + Session.SessionID.ToString() + ".pdf" ;
            ExportOptions optExp;
            DiskFileDestinationOptions optDsk    = new DiskFileDestinationOptions();
            PdfRtfWordFormatOptions    optPdfRtf = new PdfRtfWordFormatOptions();

            optExp = crReportDocument.ExportOptions;
            optExp.ExportFormatType      = ExportFormatType.PortableDocFormat;
            optExp.FormatOptions         = optPdfRtf;
            optExp.ExportDestinationType = ExportDestinationType.DiskFile;
            optDsk.DiskFileName          = Fname;
            optExp.DestinationOptions    = optDsk;

            crReportDocument.Export();
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "application/pdf";
            Response.WriteFile(Fname);
            Response.Flush();
            Response.Close();
            System.IO.File.Delete(Fname);
        }
        protected void btnBuscar0_Click1(object sender, EventArgs e)
        {
            try
            {
                ReportDocument crystalrpt = new ReportDocument();
                crystalrpt.Load(Server.MapPath(@"~/Reportes/ReporteGenerico.rpt"));
                //crystalrpt.SetDatabaseLogon("adminSAEDI", "SAEDI.2018*");
                crystalrpt.Refresh();
                crystalrpt.SetParameterValue("@IdProceso", DropDownList1.SelectedValue);
                crystalrpt.SetParameterValue("@IdPersona", DropDownList2.SelectedValue);
                ExportOptions exportOption;
                DiskFileDestinationOptions diskFileDestinationOptions = new DiskFileDestinationOptions();
                exportOption = crystalrpt.ExportOptions;
                {
                    exportOption.ExportDestinationType    = ExportDestinationType.DiskFile;
                    exportOption.ExportFormatType         = ExportFormatType.Excel;
                    exportOption.ExportDestinationOptions = diskFileDestinationOptions;
                    exportOption.ExportFormatOptions      = new ExcelFormatOptions();
                }
                crystalrpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "ReporteCuestionario" + DropDownList2.SelectedItem.Text);

                crystalrpt.Export();
            }
            catch { }
        }
        /// <summary>
        /// Print or Export Crystal Report
        /// </summary>
        private void PerformOutput()
        {
            if (_printToPrinter)
            {
                var copy = ReportArguments.PrintCopy;
                _reportDoc.PrintToPrinter(copy, true, 0, 0);
                _logger.Write(string.Format("Report printed to : {0}", _reportDoc.PrintOptions.PrinterName));
            }
            else
            {
                _reportDoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                DiskFileDestinationOptions diskOptions = new DiskFileDestinationOptions
                {
                    DiskFileName = _outputFilename
                };

                _reportDoc.ExportOptions.DestinationOptions = diskOptions;
                _reportDoc.Export();
                _logger.Write(string.Format("Report exported to : {0}", _outputFilename));
            }

            if (ReportArguments.ToBurst)
            {
                PageBreaker pb        = new PageBreaker();
                var         outPath   = $"{System.IO.Path.GetDirectoryName(_outputFilename)}\\{BURST_DIR}";
                var         pageCount = pb.SplitPDFByBookmark(_outputFilename, outPath);
                Console.WriteLine($"Number of file genearated = {pageCount}");
            }

            Console.WriteLine("Completed");
        }
Exemplo n.º 6
0
        //Test
        private void GeneraPDF(ReportDocument objInforme, string pathFile)
        {
            string strMsgResul = string.Empty;

            try
            {
                //string strRutaArchivo = pathPDF + "Reporte_" + proveedor + "_" + tie + "_" + pedido + ".pdf";

                //DiskFileDestinationOptions diskDestination = new DiskFileDestinationOptions();
                //objInforme.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;//ExportDestinationType.DiskFile;
                //objInforme.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;//.CrystalReport; //.NoFormat; //.PortableDocFormat;//.RichText;// //ExportFormatType.PortableDocFormat;//ExportFormatType.CrystalReport;//
                //diskDestination.DiskFileName = pathFile;
                //objInforme.ExportOptions.DestinationOptions = diskDestination;
                //objInforme.Export();

                DiskFileDestinationOptions diskDestination = new DiskFileDestinationOptions();
                objInforme.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                objInforme.ExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
                diskDestination.DiskFileName = pathFile;
                objInforme.ExportOptions.DestinationOptions = diskDestination;
                objInforme.Export();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 7
0
        private void ExportarEXCEL(ReportDocument rep)
        {
            String ruta_exportacion;

            ruta_exportacion = Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings["ruta_exportacion_pdf"]);
            //ruta_exportacion = System.Configuration.ConfigurationSettings.AppSettings["ruta_exportacion_pdf"];

            ExportOptions exportOpts            = new ExportOptions();
            DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();

            exportOpts = rep.ExportOptions;
            exportOpts.ExportFormatType = ExportFormatType.Excel;

            exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
            diskOpts.DiskFileName            = ruta_exportacion + Session.SessionID.ToString() + ".xls";
            exportOpts.DestinationOptions    = diskOpts;

            rep.Export();

            Response.ClearContent();
            Response.ClearHeaders();

            Response.AddHeader("Content-Disposition", "attachment;filename=Procedencia_Alumnos.xls");
            Response.ContentType = "application/vnd.ms-excel";
            Response.WriteFile(diskOpts.DiskFileName.ToString());
            Response.Flush();
            Response.Close();
            System.IO.File.Delete(diskOpts.DiskFileName.ToString());
        }
Exemplo n.º 8
0
        private void ExportarPDF(ReportDocument rep)
        {
            String ruta_exportacion;

            ruta_exportacion = Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings["ruta_exportacion_pdf"]);
            //ruta_exportacion = System.Configuration.ConfigurationSettings.AppSettings["ruta_exportacion_pdf"];

            ExportOptions exportOpts            = new ExportOptions();
            DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();

            exportOpts = rep.ExportOptions;
            exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;

            exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
            diskOpts.DiskFileName            = ruta_exportacion + Session.SessionID.ToString() + ".pdf";
            exportOpts.DestinationOptions    = diskOpts;

            rep.Export();

            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "application/pdf";
            Response.WriteFile(diskOpts.DiskFileName.ToString());
            Response.Flush();
            Response.Close();
            System.IO.File.Delete(diskOpts.DiskFileName.ToString());
        }
        public void Exportar(string key)
        {
            try
            {
                ReportDocument objRpt = new ReportDocument();
                DataSet ds = (DataSet)this.GetDataReport(key);

                string reportPath = "C:\\Reportes\\CRTejTicket_rpt.rpt";
                objRpt.Load(reportPath);

                ExportOptions crExportOptions = new ExportOptions();

                objRpt.SetDataSource(ds.Tables[0]);
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.InitialDirectory = Environment.SpecialFolder.MyDocuments.ToString();
                saveFileDialog.Filter = "Document (*.pdf)|*.PDF";
                saveFileDialog.FilterIndex = 1;
                saveFileDialog.FileName = "Etiqueta.pdf";
                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    objRpt.ExportToDisk(ExportFormatType.PortableDocFormat, saveFileDialog.FileName); ;
                }

                crExportOptions = objRpt.ExportOptions;
                objRpt.Export();

            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Exemplo n.º 10
0
        private void ExportarEXCEL(ReportDocument rep)
        {
            String ruta_exportacion;

            ruta_exportacion = Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings["ruta_exportacion_pdf"]);
            //ruta_exportacion = System.Configuration.ConfigurationSettings.AppSettings["ruta_exportacion_pdf"];

            ExportOptions exportOpts = new ExportOptions();
            DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();

            exportOpts = rep.ExportOptions;
            exportOpts.ExportFormatType = ExportFormatType.Excel;

            exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
            diskOpts.DiskFileName = ruta_exportacion + Session.SessionID.ToString() + ".xls";
            exportOpts.DestinationOptions = diskOpts;

            rep.Export();

            Response.ClearContent();
            Response.ClearHeaders();

            Response.AddHeader ("Content-Disposition", "attachment;filename=Morosidad.xls");
            Response.ContentType = "application/vnd.ms-excel";
            Response.WriteFile(diskOpts.DiskFileName.ToString());
            Response.Flush();
            Response.Close();
            System.IO.File.Delete(diskOpts.DiskFileName.ToString());
        }
Exemplo n.º 11
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                int            idOrientador = (int)Session["id"];
                ReportDocument crystalrpt   = new ReportDocument();
                crystalrpt.Load(Server.MapPath(@"~/Reportes/ReporteAsistenciaDiaria.rpt"));
                //crystalrpt.SetDatabaseLogon("adminSAEDI", "SAEDI.2018*");
                crystalrpt.Refresh();
                crystalrpt.SetParameterValue("@Orientador", idOrientador);
                crystalrpt.SetParameterValue("@Anio", ddlAnio.SelectedValue);
                crystalrpt.SetParameterValue("@Mes", ddlMes.SelectedValue);
                crystalrpt.SetParameterValue("@IdProceso", ddlProceso.SelectedValue);
                ExportOptions exportOption;
                DiskFileDestinationOptions diskFileDestinationOptions = new DiskFileDestinationOptions();
                exportOption = crystalrpt.ExportOptions;
                {
                    exportOption.ExportDestinationType    = ExportDestinationType.DiskFile;
                    exportOption.ExportFormatType         = ExportFormatType.Excel;
                    exportOption.ExportDestinationOptions = diskFileDestinationOptions;
                    exportOption.ExportFormatOptions      = new ExcelFormatOptions();
                }

                crystalrpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "ReporteAsistenciaDiaria" + ddlMes.SelectedItem.Text);
                crystalrpt.Export();
            }
            catch { }
        }
        protected void btnBuscar0_Click(object sender, EventArgs e)
        {
            ReportDocument crystalrpt = new ReportDocument();

            crystalrpt.Load(Server.MapPath(@"~/Reportes/AsistenciaMensual.rpt"));
            //crystalrpt.SetDatabaseLogon("adminSAEDI", "SAEDI.2018*");
            crystalrpt.Refresh();
            crystalrpt.SetParameterValue("@Anio", DropDownList1.SelectedValue);
            crystalrpt.SetParameterValue("@Mes", DropDownList2.SelectedValue);
            crystalrpt.SetParameterValue("@IdProceso", ddlProceso.SelectedValue);
            //crystalrpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "ReporteAsistenciaDiaria"+ ddlMes.SelectedItem.Text);

            //CrystalReportViewer1.ReportSource = crystalrpt;
            //CrystalReportViewer1.DataBind();
            ExportOptions exportOption;
            DiskFileDestinationOptions diskFileDestinationOptions = new DiskFileDestinationOptions();

            exportOption = crystalrpt.ExportOptions;
            {
                exportOption.ExportDestinationType    = ExportDestinationType.DiskFile;
                exportOption.ExportFormatType         = ExportFormatType.Excel;
                exportOption.ExportDestinationOptions = diskFileDestinationOptions;
                exportOption.ExportFormatOptions      = new ExcelFormatOptions();
            }
            crystalrpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "ReporteAsistenciaMensual" + DropDownList2.SelectedItem.Text);

            crystalrpt.Export();
        }
Exemplo n.º 13
0
        private void PrintSlip(int id, int?no)
        {
            var obj        = _service.GetVisitorByAutoIDForReport(id);
            var reportPara = _service.GetReportParameter();

            if (obj.ResultObj.Count > 0)
            {
                List <CustomVisitor> listData = (List <CustomVisitor>)obj.ResultObj;
                DataTable            dt       = ConvertToDataTable(listData);

                ReportDocument rpt  = new ReportDocument();
                string         path = System.Reflection.Assembly.GetExecutingAssembly().Location;
                //var appPath = Application.StartupPath + "\\" + "ReportSlip.rpt";
                //var appPath = Application.StartupPath + "\\" + "ReportSlip_New.rpt";
                //var appPath = Application.StartupPath + "\\" + "ReportSlip_Bando.rpt";
                //var appPath = Application.StartupPath + "\\" + "ReportSlip_JBF.rpt";
                var appPath = Application.StartupPath + "\\" + "ReportSlip_Charoen.rpt";
                rpt.Load(appPath);
                rpt.SetDataSource(dt);
                rpt.PrintToPrinter(1, true, 0, 0);


                rpt.ExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
                rpt.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                DiskFileDestinationOptions objDiskOpt = new DiskFileDestinationOptions();
                string dir = DIRECTORY_IN + "\\" + no + "\\";
                objDiskOpt.DiskFileName = dir + "SLIP.pdf";
                rpt.ExportOptions.DestinationOptions = objDiskOpt;
                rpt.Export();
            }
        }
 private string ExportarPDF()
 {
     try
     {
         DsPlanillaRedespacho       ds  = (DsPlanillaRedespacho)Session["DsPlanillaRedespacho"];
         ReportDocument             oRD = new ReportDocument();
         ExportOptions              oExO;
         DiskFileDestinationOptions oExDo = new DiskFileDestinationOptions();
         string nombArchi  = "PlanillaRedespacho_" + this.txtPlanillaRedespachoID.Text + "_" + this.AgenciaConectadaID + ".pdf";
         string sNombrePDF = Server.MapPath(".") + "/ReportesPDF/" + nombArchi;
         if (System.IO.File.Exists(sNombrePDF))
         {
             System.IO.File.Delete(sNombrePDF);
         }
         oRD.Load(Server.MapPath("." + "/Reportes/PlanillaRedespacho.rpt"));
         oRD.SetDataSource(ds);
         oExDo.DiskFileName = sNombrePDF;
         oExO = oRD.ExportOptions;
         oExO.ExportDestinationType = ExportDestinationType.DiskFile;
         oExO.ExportFormatType      = ExportFormatType.PortableDocFormat;
         oExO.DestinationOptions    = oExDo;
         oRD.Export();
         oRD.Close();
         oRD.Dispose();
         return(nombArchi);
     }
     catch (Exception ex)
     {
         string mensaje = "Error al exportar a PDF: " + ex.Message;
         ((ErrorWeb)this.phErrores.Controls[0]).setMensaje(mensaje);
         return("");
     }
 }
Exemplo n.º 15
0
        private void ExportarPDF(ReportDocument rep)
        {
            String ruta_exportacion;

            ruta_exportacion = Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings["ruta_exportacion_pdf"]);
            //ruta_exportacion = System.Configuration.ConfigurationSettings.AppSettings["ruta_exportacion_pdf"];

            ExportOptions exportOpts = new ExportOptions();
            DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();

            exportOpts = rep.ExportOptions;
            exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;

            exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
            diskOpts.DiskFileName = ruta_exportacion + Session.SessionID.ToString() + ".pdf";
            exportOpts.DestinationOptions = diskOpts;

            rep.Export();

            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "application/pdf";
            Response.WriteFile(diskOpts.DiskFileName.ToString());
            Response.Flush();
            Response.Close();
            System.IO.File.Delete(diskOpts.DiskFileName.ToString());
        }
        protected void btnBuscar0_Click(object sender, EventArgs e)
        {
            try
            {
                int            idOrientador = (int)Session["id"];
                ReportDocument crystalrpt   = new ReportDocument();
                crystalrpt.Load(Server.MapPath(@"~/Reportes/ReportePreguntasCerradasOrientador.rpt"));
                //crystalrpt.SetDatabaseLogon("adminSAEDI", "SAEDI.2018*");
                crystalrpt.Refresh();
                crystalrpt.SetParameterValue("@IdProceso", DropDownList1.SelectedValue);
                crystalrpt.SetParameterValue("@IdOrientador", idOrientador);
                ExportOptions exportOption;
                DiskFileDestinationOptions diskFileDestinationOptions = new DiskFileDestinationOptions();
                exportOption = crystalrpt.ExportOptions;
                {
                    exportOption.ExportDestinationType    = ExportDestinationType.DiskFile;
                    exportOption.ExportFormatType         = ExportFormatType.Excel;
                    exportOption.ExportDestinationOptions = diskFileDestinationOptions;
                    exportOption.ExportFormatOptions      = new ExcelFormatOptions();
                }
                crystalrpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "ReportePreguntasCerradas");

                crystalrpt.Export();
            }
            catch { }
        }
        private void frmConsolidatedReports_Load(object sender, EventArgs e)
        {
            using (new LoadingClass.PleaseWait(this.Location, "Generando..."))
            {
                rp = new Reports.crConsolidatedReports();

                foreach (var com in _componentId)
                {
                    ChooseReport(rp, com);
                }

                crystalReportViewer1.EnableDrillDown = false;
                crystalReportViewer1.ReportSource    = rp;

                ReportDocument repDoc = rp;

                repDoc.ExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
                repDoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                DiskFileDestinationOptions objDiskOpt = new DiskFileDestinationOptions();
                objDiskOpt.DiskFileName = Application.StartupPath + @"\TempMerge\Crystal1.pdf";
                repDoc.ExportOptions.DestinationOptions = objDiskOpt;
                repDoc.Export();
                //
                //crystalReportViewer1.Show();
            }
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            if ((int.Parse(ddlAnio1.SelectedValue) > int.Parse(ddlAnio2.SelectedValue)) || ((int.Parse(ddlAnio1.SelectedValue) == int.Parse(ddlAnio2.SelectedValue)) && int.Parse(ddlMes1.SelectedValue) > int.Parse(ddlMes2.SelectedValue)))
            {
                Response.Write(@"<script>alert('RANGO INCORRECTO');setTimeout(function(){window.location = '" + Request.RawUrl + @"';}, 10);</script>");
            }
            else
            {
                ReportDocument crystalrpt = new ReportDocument();
                crystalrpt.Load(Server.MapPath(@"~/Reportes/AsistenciaRango.rpt"));
                //crystalrpt.SetDatabaseLogon("adminSAEDI", "SAEDI.2018*");
                crystalrpt.Refresh();
                crystalrpt.SetParameterValue("@Anio", ddlAnio1.SelectedValue);
                crystalrpt.SetParameterValue("@Mes", ddlMes1.SelectedValue);
                crystalrpt.SetParameterValue("@Anio2", ddlAnio2.SelectedValue);
                crystalrpt.SetParameterValue("@Mes2", ddlMes2.SelectedValue);
                crystalrpt.SetParameterValue("@IdProceso", ddlProceso.SelectedValue);
                //crystalrpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "ReporteAsistenciaDiaria"+ ddlMes.SelectedItem.Text);

                //CrystalReportViewer1.ReportSource = crystalrpt;
                //CrystalReportViewer1.DataBind();
                ExportOptions exportOption;
                DiskFileDestinationOptions diskFileDestinationOptions = new DiskFileDestinationOptions();
                exportOption = crystalrpt.ExportOptions;
                {
                    exportOption.ExportDestinationType    = ExportDestinationType.DiskFile;
                    exportOption.ExportFormatType         = ExportFormatType.Excel;
                    exportOption.ExportDestinationOptions = diskFileDestinationOptions;
                    exportOption.ExportFormatOptions      = new ExcelFormatOptions();
                }
                crystalrpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, "AsistenciaRango");

                crystalrpt.Export();
            }
        }
Exemplo n.º 19
0
		private void GeneratePDF()
		{
            ReportDocument rpt = new ReportDocument();
            rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/GeneralLedger.rpt"));

			ExportOptions exportop = new ExportOptions();
			DiskFileDestinationOptions dest = new DiskFileDestinationOptions();
			
			string strPath = Server.MapPath(@"\RetailPlus\temp\");

			string strFileName = "generalledger_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + ".pdf";
			if (System.IO.File.Exists(strPath + strFileName))
				System.IO.File.Delete(strPath + strFileName);

			dest.DiskFileName = strPath + strFileName;

			exportop = rpt.ExportOptions;
	
			SetDataSource(rpt);

			exportop.DestinationOptions = dest;
			exportop.ExportDestinationType = ExportDestinationType.DiskFile;
			exportop.ExportFormatType = ExportFormatType.PortableDocFormat;
			rpt.Export();   rpt.Close();    rpt.Dispose();
			
			fraViewer.Attributes.Add("src","/RetailPlus/temp/" + strFileName);
		}
Exemplo n.º 20
0
    private void ActionWise(string action, string username)
    {
        NewDAL.DBManager objDB = new DBManager();
        objDB.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["FeesManagementConn"].ConnectionString;
        objDB.DBManager(DataAccessLayer.DataProvider.SqlServer, objDB.ConnectionString);
        objDB.Open();
        DataTable drs = new DataTable();

        SqlDataReader dr = (SqlDataReader)objDB.ExecuteReader(CommandType.Text, "select * from audit_report where user_id in(" + username + ") and instituteid='" + ddlInstitute.SelectedValue + "' and action in(" + action + ") and entry_Date between'" + txtFrom.Text + "' and '" + txtTo.Text + "'");

        if (dr.HasRows)
        {
            drs.Load(dr);
        }
        if (drs.Rows.Count == 0)
        {
            objFun.MsgBox1("No record found to print.", UpdatePanel1);
            return;
        }
        ReportDocument rpt1   = new ReportDocument();
        string         spath  = ""; //= Server.MapPath("Report\\CWFD.rpt").Replace("Fee\\Fee\\", "Fee\\");
        string         spath1 = Server.MapPath("..\\Report\\");

        spath = Server.MapPath("..\\Report\\AUWReport.rpt");
        //  stredds.Tables["DataTable1"].Merge(drs, true, MissingSchemaAction.Ignore);
        rpt1.Load(spath);
        rpt1.SetDataSource(drs);
        CrystalReportViewer1.ReportSource = rpt1;
        CrystalReportViewer1.DataBind();
        CrystalReportViewer1.RefreshReport();
        ExportOptions exportOpts1 = rpt1.ExportOptions;

        rpt1.ExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
        rpt1.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
        rpt1.ExportOptions.DestinationOptions    = new DiskFileDestinationOptions();
        ((DiskFileDestinationOptions)rpt1.ExportOptions.DestinationOptions).DiskFileName = spath1 + "ActionWise.pdf";

        //Session["instName"]
        //((CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.Sections["GroupHeaderSection4"].ReportObjects["GroupNameSemester1"]).Text = dtInst.Rows[0].ItemArray[0].ToString();
        //((CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.Sections["Section5"].ReportObjects["Text27"]).Text = Session["instName"].ToString();
        //((CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.Sections["Section5"].ReportObjects["Text29"]).Text = Session["U_Name"].ToString();
        //((CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.Sections["Section1"].ReportObjects["Text1"]).Text = Session["instName"].ToString();

        //((CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.Sections["Section1"].ReportObjects["Text8"]).Text = dtInst.Rows[0].ItemArray[0].ToString();
        //((CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.Sections["Section1"].ReportObjects["Text8"]).Text = dtInst.Rows[0].ItemArray[0].ToString();
        // ((CrystalDecisions.CrystalReports.Engine.TextObject)rpt1.ReportDefinition.Sections["Section1"].ReportObjects["Text8"]).Text = dtInst.Rows[0].ItemArray[0].ToString();
        rpt1.Export();
        rpt1.Close();
        rpt1.Dispose();
        Response.ClearContent();
        Response.ClearHeaders();
        Response.ContentType = "application/pdf";
        Response.AppendHeader("Content-Disposition", "attachment; filename=" + "ActionWise.pdf");
        Response.WriteFile(spath1 + "ActionWise.pdf");
        Response.Flush();
        Response.End();
        File.Delete(Server.MapPath(spath1 + "ActionWise.pdf"));
        Response.Close();
    }
Exemplo n.º 21
0
        public void ExportReport(ReportDocument oReport, string cFileName, ExportTypes oExportTypes, int nFirstPage, int nLastPage)
        {
            ExportOptions              oExportOptions      = new ExportOptions();
            PdfRtfWordFormatOptions    oFormatOptions      = ExportOptions.CreatePdfRtfWordFormatOptions();
            DiskFileDestinationOptions oDestinationOptions = ExportOptions.CreateDiskFileDestinationOptions();

            switch (oExportTypes)
            {
            case ExportTypes.PDF:
            case ExportTypes.MSWord:
                oExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                PdfRtfWordFormatOptions oPDFFormatOptions = ExportOptions.CreatePdfRtfWordFormatOptions();

                if (nFirstPage > 0 && nLastPage > 0)
                {
                    oPDFFormatOptions.FirstPageNumber = nFirstPage;
                    oPDFFormatOptions.LastPageNumber  = nLastPage;
                    oPDFFormatOptions.UsePageRange    = true;
                }
                oExportOptions.ExportFormatOptions = oPDFFormatOptions;
                break;

            case ExportTypes.MSExcel:
                oExportOptions.ExportFormatType = ExportFormatType.Excel;
                ExcelFormatOptions oExcelFormatOptions = ExportOptions.CreateExcelFormatOptions();

                if (nFirstPage > 0 && nLastPage > 0)
                {
                    oExcelFormatOptions.FirstPageNumber = nFirstPage;
                    oExcelFormatOptions.LastPageNumber  = nLastPage;
                    oExcelFormatOptions.UsePageRange    = true;
                }
                oExcelFormatOptions.ExcelUseConstantColumnWidth = false;
                oExportOptions.ExportFormatOptions = oExcelFormatOptions;
                break;

            case ExportTypes.HTML:
                oExportOptions.ExportFormatType = ExportFormatType.HTML40;
                HTMLFormatOptions oHTMLFormatOptions = ExportOptions.CreateHTMLFormatOptions();
                if (nFirstPage > 0 && nLastPage > 0)
                {
                    oHTMLFormatOptions.FirstPageNumber = nFirstPage;
                    oHTMLFormatOptions.LastPageNumber  = nLastPage;
                    oHTMLFormatOptions.UsePageRange    = true;
                }
                // can set additional HTML export options here

                oExportOptions.ExportFormatOptions = oHTMLFormatOptions;
                break;
            }


            oDestinationOptions.DiskFileName        = cFileName;
            oExportOptions.ExportDestinationOptions = oDestinationOptions;
            oExportOptions.ExportDestinationType    = ExportDestinationType.DiskFile;

            oReport.Export(oExportOptions);
        }
Exemplo n.º 22
0
        private string ExportarPDF()
        {                       //cuando venga 0 en solicitud se han pedidos todas
            if (Session["dsClientes"] != null)
            {
                //el dataset que le voy a pasar al generador de reportes crystal
                DsClientes        clie    = (DsClientes)Session["dsClientes"];
                DsReporteClientes reporte = new DsReporteClientes();

                for (int i = 0; i <= clie.Datos.Count - 1; i++)
                {
                    DsClientes.DatosRow        drClie    = (DsClientes.DatosRow)clie.Datos.Rows[i];
                    DsReporteClientes.DatosRow drReporte = (DsReporteClientes.DatosRow)reporte.Datos.NewDatosRow();
                }
                string empresa = System.Configuration.ConfigurationSettings.AppSettings["empresa"];

//				for (int i=0; i<reporte.Datos.Count-1;i++)
//				{
//					byte[] d= null;
//					DsReporteClientes.DatosRow drDatos= (DsReporteClientes.DatosRow) reporte.Datos.Rows[i];
//					d = ConversionImagen(Server.MapPath("." + "/Reportes/images/"+ empresa + ".JPG"));
//					drDatos["Imagen"]=d;
//				}

                //			byte[] im= null;
                //			DsSolicitudRetiroImpresion.SolicitudRow dr= (DsSolicitudRetiroImpresion.SolicitudRow) dsSolicitud.Solicitud.Rows[0];
                //			im = ConversionImagen(Server.MapPath("." + "/Reportes/images/blanco.JPG"));
                //			for (int i=0; i<dsSolicitud.Solicitud.Count;i++)
                //			{
                //				dr["Imagen"]=im;
                //			}

                ReportDocument             oRD = new ReportDocument();
                ExportOptions              oExO;
                DiskFileDestinationOptions oExDo = new DiskFileDestinationOptions();
                string nombArchi  = "Clientes_" + this.AgenciaConectadaID + ".pdf";
                string sNombrePDF = Server.MapPath(".") + "/ReportesPDF/" + nombArchi;
                if (System.IO.File.Exists(sNombrePDF))
                {
                    System.IO.File.Delete(sNombrePDF);
                }
                oRD.Load(Server.MapPath("." + "/Reportes/Clientes.rpt"));
                oRD.SetDataSource(clie);
                oExDo.DiskFileName = sNombrePDF;
                oExO = oRD.ExportOptions;
                oExO.ExportDestinationType = ExportDestinationType.DiskFile;
                oExO.ExportFormatType      = ExportFormatType.PortableDocFormat;
                oExO.DestinationOptions    = oExDo;
                oRD.Export();
                oRD.Close();
                oRD.Dispose();
                return(nombArchi);
            }
            else
            {
                ((ErrorWeb)this.phErrores.Controls[0]).setMensaje("No se ha podido consultar los datos de la solicitud");
                return("");
            }
        }
Exemplo n.º 23
0
        private void bindReport(DataSet _dsRpt)
        {
            try
            {
                DsAnalisiStatistiche dsP = new  DsAnalisiStatistiche();
                int i = 0;
                for (i = 0; i <= _dsRpt.Tables[0].Rows.Count - 1; i++)
                {
                    dsP.Tables["tblgiudizio"].ImportRow(_dsRpt.Tables[0].Rows[i]);
                }
                if (i == 0)
                {
                    throw new Exception("* Non ci sono Rdl nell'intervallo temporale che hai selezionato, cambia intervallo e riprova.");
                }
//				ReportClass _Report;
//				_Report = _stdRpt.getReport;
//				_Report.SetDataSource(dsP);
                //rptEngineOra.DisplayGroupTree=false;
                //rptEngineOra.DisplayToolbar=true;

                //rptEngineOra.ReportSource=_Report;
                string pathRptSource = Server.MapPath(Request.ApplicationPath + ConfigurationSettings.AppSettings["SourceReports"]);
                _stdRpt.ImpostaSourceReport(crReportDocument, pathRptSource);
                crReportDocument.SetDataSource(dsP);
                switch (tipoDocumento)
                {
                case  "PDF":
                    string Fname = pathRptSource + Session.SessionID.ToString() + ".pdf";
                    crDiskFileDestinationOptions = new DiskFileDestinationOptions();
                    crDiskFileDestinationOptions.DiskFileName = Fname;
                    crExportOptions = crReportDocument.ExportOptions;
                    crExportOptions.DestinationOptions    = crDiskFileDestinationOptions;
                    crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                    crExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
                    crReportDocument.Export();
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.ContentType = "application/pdf";
                    Response.WriteFile(Fname);
                    Response.Flush();
                    Response.Close();
                    System.IO.File.Delete(Fname);
                    break;

                case "HTML":
                    rptEngineOra.ReportSource = crReportDocument;
                    break;

                default:
                    // non fai nulla
                    break;
                }
            }
            catch (Exception ex)
            {
                Server.Transfer("Error.aspx?msgErr=" + ex.Message);
            }
        }
Exemplo n.º 24
0
        public static void GenerateReport(string FileName, ReportDocument rpt, System.Web.UI.Control ClientScriptBlockControl, ExportFormatType pvtExportFormatType)
        {
            try
            {
                ExportOptions exportop          = new ExportOptions();
                DiskFileDestinationOptions dest = new DiskFileDestinationOptions();

                string strFileExtensionName = ".pdf";
                switch (pvtExportFormatType)
                {
                case ExportFormatType.PortableDocFormat: strFileExtensionName = ".pdf"; exportop.ExportFormatType = ExportFormatType.PortableDocFormat; break;

                case ExportFormatType.WordForWindows: strFileExtensionName = ".doc"; exportop.ExportFormatType = ExportFormatType.WordForWindows; break;

                case ExportFormatType.Excel: strFileExtensionName = ".xls"; exportop.ExportFormatType = ExportFormatType.Excel; break;
                }

                string strPath     = System.Web.HttpContext.Current.Server.MapPath(@"\retailplus\temp\");
                string strFileName = FileName + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + strFileExtensionName;

                if (System.IO.File.Exists(strPath + strFileName))
                {
                    System.IO.File.Delete(strPath + strFileName);
                }

                dest.DiskFileName              = strPath + strFileName;
                exportop.DestinationOptions    = dest;
                exportop.ExportDestinationType = ExportDestinationType.DiskFile;
                rpt.Export(exportop); //rpt.Close(); rpt.Dispose();

                // remove the error
                if (pvtExportFormatType == ExportFormatType.WordForWindows || pvtExportFormatType == ExportFormatType.Excel || pvtExportFormatType == ExportFormatType.PortableDocFormat)
                {
                    // the maximum report processing jobs limit configured by your system administrator has been reached.
                    rpt.Close(); rpt.Dispose();
                }

                if (pvtExportFormatType == ExportFormatType.PortableDocFormat)
                {
                    string newWindowUrl = Constants.ROOT_DIRECTORY + "/temp/" + strFileName;
                    string javaScript   = "window.open('" + newWindowUrl + "');";
                    System.Web.UI.ScriptManager.RegisterClientScriptBlock(ClientScriptBlockControl, ClientScriptBlockControl.GetType(), "openwindow", javaScript, true);
                }
                else
                {
                    string newWindowUrl = Constants.ROOT_DIRECTORY + "/temp/" + strFileName;
                    string javaScript   = "window.open('" + newWindowUrl + "','_self');";
                    System.Web.UI.ScriptManager.RegisterClientScriptBlock(ClientScriptBlockControl, ClientScriptBlockControl.GetType(), "openwindow", javaScript, true);

                    //System.Diagnostics.Process p = new System.Diagnostics.Process();
                    //p.StartInfo.FileName = System.Web.HttpContext.Current.Server.MapPath(Constants.ROOT_DIRECTORY + "/temp/" + strFileName);
                    //p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
                    //p.Start();
                }
            }
            catch (Exception ex) { throw ex; }
        }
Exemplo n.º 25
0
        public string Imprimir(int solicitudes, int agencia)
        {
            string nombArchi = "";

            string empresa = System.Configuration.ConfigurationSettings.AppSettings["empresa"];
            DsSolicitudRetiroImpresion dsSolicitud = new DsSolicitudRetiroImpresion();
            //el dataset que le voy a pasar al generador de reportes crystal
            ISolicitudRetiro sol = SolicitudRetiroFactory.GetSolicitudRetiroFactory();

            sol.SolicitudRetiroID = solicitudes;

            dsSolicitud = (DsSolicitudRetiroImpresion)sol.ConsultarSolicitudAImprimir();



            for (int i = 0; i < dsSolicitud.Orden.Count; i++)
            {
                byte[] d = null;
                DsSolicitudRetiroImpresion.OrdenRow drOrden = (DsSolicitudRetiroImpresion.OrdenRow)dsSolicitud.Orden.Rows[i];
                d = ConversionImagen(Server.MapPath("." + "/Reportes/images/" + empresa + ".JPG"));
                drOrden["Codigo"] = d;
            }

            byte[] im = null;
            DsSolicitudRetiroImpresion.SolicitudRow dr = (DsSolicitudRetiroImpresion.SolicitudRow)dsSolicitud.Solicitud.Rows[0];
            im = ConversionImagen(Server.MapPath("." + "/Reportes/images/blanco.JPG"));
            for (int i = 0; i < dsSolicitud.Solicitud.Count; i++)
            {
                dr["Imagen"] = im;
            }

            if ((dsSolicitud.Solicitud.Count > 0) && (dsSolicitud.Orden.Count > 0))
            {
                ExportOptions oExO;
                DiskFileDestinationOptions oExDo = new DiskFileDestinationOptions();
                nombArchi = "SolicitudRetiro_" + solicitudes + "_" + agencia + ".pdf";
                string sNombrePDF = Server.MapPath(".") + "/ReportesPDF/" + nombArchi;
                if (System.IO.File.Exists(sNombrePDF))
                {
                    System.IO.File.Delete(sNombrePDF);
                }
                oRD.Load(Server.MapPath("." + "/Reportes/ReporteSolicitudRetiro2.rpt"));
                oRD.SetDataSource(dsSolicitud);
                oExDo.DiskFileName = sNombrePDF;
                oExO = oRD.ExportOptions;
                oExO.ExportDestinationType = ExportDestinationType.DiskFile;
                oExO.ExportFormatType      = ExportFormatType.PortableDocFormat;
                oExO.DestinationOptions    = oExDo;
                oRD.Export();
                oRD.Close();
                oRD.Dispose();
                return(nombArchi);
            }

            return(nombArchi);
        }
Exemplo n.º 26
0
    protected void GeneratePOAsPDF(DataTable dt, string strPath, string FileName)
    {
        string repFilePath = Server.MapPath("POReport.rpt");

        //using (ReportDocument repDoc = new ReportDocument())
        //{

        using (ReportDocument repDoc = new ReportDocument())
        {
            repDoc.Load(repFilePath);

            repDoc.SetDataSource(dt);


            decimal Total_Price  = 0;
            decimal Exchane_rate = 1;
            decimal Vat          = 0;
            decimal sercharge    = 0;
            decimal discount     = 0;
            foreach (DataRow dr in dt.Rows)
            {
                Exchane_rate = Convert.ToDecimal(dr["EXCHANGE_RATE"].ToString());
                discount     = Convert.ToDecimal(dr["DISCOUNT"].ToString());
                Vat          = Convert.ToDecimal(dr["VAT"].ToString());
                sercharge    = Convert.ToDecimal(dr["SURCHARGES"].ToString());
                Total_Price  = Total_Price + (Convert.ToDecimal(dr["REQUESTED_QTY"].ToString()) * Convert.ToDecimal(dr["QUOTED_RATE"].ToString()) - (Convert.ToDecimal(dr["REQUESTED_QTY"].ToString()) * Convert.ToDecimal(dr["QUOTED_RATE"].ToString()) * Convert.ToDecimal(dr["QUOTED_DISCOUNT"].ToString()) / 100));
            }
            repDoc.DataDefinition.FormulaFields[1].Text = (Total_Price / Exchane_rate).ToString();
            repDoc.DataDefinition.FormulaFields[2].Text = (Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[1].Text) * discount / 100).ToString();
            repDoc.DataDefinition.FormulaFields[3].Text = ((Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[1].Text) - (Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[1].Text) * discount / 100)) * sercharge / 100).ToString();
            repDoc.DataDefinition.FormulaFields[4].Text = ((Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[1].Text) - Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[2].Text) + Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[3].Text)) * Vat / 100).ToString();
            repDoc.DataDefinition.FormulaFields[0].Text = ((Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[1].Text) - Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[2].Text) + Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[3].Text) + Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[4].Text)).ToString());

            ExportOptions exp             = new ExportOptions();
            DiskFileDestinationOptions dk = new DiskFileDestinationOptions();
            PdfRtfWordFormatOptions    pd = new PdfRtfWordFormatOptions();

            string sFile = strPath + FileName;
            dk.DiskFileName = strPath + FileName;

            exp.ExportDestinationType = ExportDestinationType.DiskFile;
            exp.ExportFormatType      = ExportFormatType.PortableDocFormat;
            exp.DestinationOptions    = dk;
            exp.FormatOptions         = pd;
            repDoc.Export(exp);

            //for email attachment

            string destFile = Server.MapPath("../Uploads/Purchase") + "\\" + FileName;;
            File.Copy(sFile, destFile, true);

            repDoc.Close();
            repDoc.Dispose();
        }
        //}
    }
Exemplo n.º 27
0
 public static void ExportarReporte(string ruta, ReportDocument reporte)
 {
     reporte.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
     reporte.ExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
     reporte.ExportOptions.DestinationOptions    = new DiskFileDestinationOptions {
         DiskFileName = ruta
     };
     reporte.ExportOptions.FormatOptions = new PdfRtfWordFormatOptions();
     reporte.Export();
 }
Exemplo n.º 28
0
        void Exportar(ReportDocument DocImpresion, string c_archivo)
        {
            DocImpresion.ExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
            DocImpresion.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
            DiskFileDestinationOptions objDiskOpt = new DiskFileDestinationOptions();

            objDiskOpt.DiskFileName = c_archivo;
            DocImpresion.ExportOptions.DestinationOptions = objDiskOpt;
            DocImpresion.Export();
        }
        private bool ExportarPDF()
        {
            DataSet                    GenDS = new DataSet();
            ReportDocument             oRD   = new ReportDocument();
            ExportOptions              oExO;
            DiskFileDestinationOptions oExDo = new DiskFileDestinationOptions();

            admGuiaO.AgenciaOrigenID = AgenciaConectadaID;
            DsGuiaFacturaImpresion dataSrc = admGuiaO.GetDataSetImpresionAgenciaAgencia();

            Session["DatosGuia"] = dataSrc;

            try
            {
                //ds = (DsRendicionesAgencias) Session["dsRendicionAgencia"];

                string sNombrePDF = Server.MapPath(".") + "\\ReportesPDF\\Guia_" + this.admGuiaO.GuiaID + "_" + this.AgenciaConectadaID + ".pdf";

                //Load report
                oRD.Load(Server.MapPath("." + "/Reportes/GuiaImpresa.rpt"));

                //Set Report Datasource
                //BindGrilla();


                oRD.SetDataSource(dataSrc);


                //Export to PDF
                oExDo.DiskFileName = sNombrePDF;
                oExO = oRD.ExportOptions;
                //PrintOptions oExPrint = oRD.PrintOptions;
                //oExPrint.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4Small;
                //oExPrint.PrinterName = "\\" + "\\CQUIROGA\\HP DeskJet 810C";
                //oExPrint.PrinterName = "HP DeskJet 810C";

                oExO.ExportDestinationType = ExportDestinationType.DiskFile;


                oExO.ExportFormatType   = ExportFormatType.PortableDocFormat;
                oExO.DestinationOptions = oExDo;

                //oRD.PrintToPrinter(1,false,1,1);
                oRD.Export();

                oRD.Close();
                oRD.Dispose();

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        void ExportCrystalReport(ReportDocument cryRpt, string formatExport, string pathReportGenerate)
        {
            if (string.IsNullOrEmpty(pathReportGenerate))
            {
                throw new Exception("Path report generate not found");
            }

            if (cryRpt == null)
            {
                throw new Exception("Resource not found");
            }

            ExportFormatType exportFormatType = ExportFormatType.NoFormat;
            string           extensionFile    = Path.GetExtension(pathReportGenerate);
            object           formatOption     = new PdfRtfWordFormatOptions();

            switch (formatExport)
            {
            case "WORD":
                exportFormatType = ExportFormatType.WordForWindows;
                extensionFile    = ".doc";
                break;

            case "PDF":
                exportFormatType = ExportFormatType.PortableDocFormat;
                break;

            case "EXCEL":
                exportFormatType = ExportFormatType.Excel;
                extensionFile    = ".xls";
                formatOption     = new ExcelFormatOptions();
                break;
            }

            var downloadReportPath = System.Web.Hosting.HostingEnvironment.MapPath("~/DownloadReports/");

            //Check exist folder DownloadReports
            if (!Directory.Exists(downloadReportPath))
            {
                Directory.CreateDirectory(downloadReportPath);
            }

            DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();

            CrDiskFileDestinationOptions.DiskFileName = pathReportGenerate;
            ExportOptions CrExportOptions = cryRpt.ExportOptions;

            {
                CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                CrExportOptions.ExportFormatType      = exportFormatType;
                CrExportOptions.DestinationOptions    = CrDiskFileDestinationOptions;
                CrExportOptions.FormatOptions         = formatOption;
            }
            cryRpt.Export();
        }
Exemplo n.º 31
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ExportOptions objExOpt;

            CrystalReportViewer1.ReportSource = (object)getReportDocument();
            CrystalReportViewer1.DataBind();
            // Get the report document
            ReportDocument repDoc = getReportDocument();

            repDoc.ExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
            repDoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
            DiskFileDestinationOptions objDiskOpt = new DiskFileDestinationOptions();

            string        strLine  = "09605954432 5969 59681 2993 00";
            List <string> txtLines = new List <string>();
            string        strnew   = strLine.Replace(" ", "");
            string        path     = @"C:\CrystalExport\newline.txt";

            for (int i = 0; i < strnew.Count(); i++)
            {
                txtLines.Add(strnew[i].ToString());
            }

            foreach (string str in txtLines)
            {
                File.AppendAllText(path, str + Environment.NewLine);
            }



            string filePath = @"\\192.168.15.10\IASFileUpload\ReceiptFile\3501600072585\3501600072585_12122e11300319.pdf";

            using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
            {
                StreamReader sr = new StreamReader(fs, Encoding.GetEncoding("WINDOWS-874"));
                // Write data to the file
                //newFile.Write(Buffer, 0, Buffer.Length);
                HashAlgorithm ha = HashAlgorithm.Create();
                //FileStream fs = new FileStream(filePath, FileMode.Open);

                byte[] hash = ha.ComputeHash(fs);
                fs.Close();

                objDiskOpt.DiskFileName = @"C:\CrystalExport\TFA.pdf";
                repDoc.ExportOptions.DestinationOptions = objDiskOpt;
                repDoc.Export();

                //hashValue = BitConverter.ToString(hash);
            }

            //objDiskOpt.DiskFileName = @"C:\CrystalExport\TFA.pdf";
            //repDoc.ExportOptions.DestinationOptions = objDiskOpt;
            //repDoc.Export();
        }
Exemplo n.º 32
0
    protected void btnexport_Click(object sender, EventArgs e)
    {
        ReportDocument rptExcel = new ReportDocument();
        string         Degree   = "0";

        if (ddlDegree.SelectedValue == "9")
        {
            Degree = "9";
        }
        string Term = "0";

        if (ddlTerm.SelectedIndex != 0)
        {
            Term = ddlTerm.SelectedValue;
        }
        string        connection;
        SqlConnection con = null;

        connection = ConfigurationManager.ConnectionStrings["SkyLineConnection"].ToString();
        con        = new SqlConnection(connection);
        SqlCommand cmd = new SqlCommand("SP_STUDENTMASTERFILE", con);

        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add("@TERMID", Term);
        cmd.Parameters.Add("@degreetypeid", Degree);
        cmd.Parameters.Add("@groupcode", ddlCountry.SelectedValue);
        SqlDataAdapter da = new SqlDataAdapter();

        da.SelectCommand     = cmd;
        cmd.CommandTimeout   = 300;
        Server.ScriptTimeout = 3000000;
        DataTable datatable = new DataTable();

        da.Fill(datatable);
        string strExportFile = Server.MapPath(".") + "/StudentMasterfile.xls";

        rptExcel.Load(Server.MapPath("~/Report/STUDENTLIST.rpt"));
        rptExcel.SetDataSource(datatable);
        rptExcel.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
        rptExcel.ExportOptions.ExportFormatType      = ExportFormatType.Excel;
        ExcelFormatOptions objExcelOptions = new ExcelFormatOptions();

        objExcelOptions.ExcelUseConstantColumnWidth = false;
        rptExcel.ExportOptions.FormatOptions        = objExcelOptions;
        DiskFileDestinationOptions objOptions = new DiskFileDestinationOptions();

        objOptions.DiskFileName = strExportFile;
        rptExcel.ExportOptions.DestinationOptions = objOptions;
        rptExcel.SetDatabaseLogon("software", "DelFirMENA$idea");
        rptExcel.Export();
        objOptions = null;
        rptExcel   = null;
        Response.Redirect("StudentMasterfile.xls");
    }
Exemplo n.º 33
0
        public static void GenerateReport(string FileName, ReportDocument rpt, System.Web.UI.Control ClientScriptBlockControl, ExportFormatType pvtExportFormatType)
        {
            try
            {
                ExportOptions exportop = new ExportOptions();
                DiskFileDestinationOptions dest = new DiskFileDestinationOptions();

                string strFileExtensionName = ".pdf";
                switch (pvtExportFormatType)
                {
                    case ExportFormatType.PortableDocFormat: strFileExtensionName = ".pdf"; exportop.ExportFormatType = ExportFormatType.PortableDocFormat; break;
                    case ExportFormatType.WordForWindows: strFileExtensionName = ".doc"; exportop.ExportFormatType = ExportFormatType.WordForWindows; break;
                    case ExportFormatType.Excel: strFileExtensionName = ".xls"; exportop.ExportFormatType = ExportFormatType.Excel; break;
                }

                string strPath = System.Web.HttpContext.Current.Server.MapPath(@"\retailplus\temp\");
                string strFileName = FileName + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + strFileExtensionName;

                if (System.IO.File.Exists(strPath + strFileName))
                    System.IO.File.Delete(strPath + strFileName);

                dest.DiskFileName = strPath + strFileName;
                exportop.DestinationOptions = dest;
                exportop.ExportDestinationType = ExportDestinationType.DiskFile;
                rpt.Export(exportop); //rpt.Close(); rpt.Dispose();
                
                // remove the error
                if (pvtExportFormatType == ExportFormatType.WordForWindows || pvtExportFormatType == ExportFormatType.Excel || pvtExportFormatType == ExportFormatType.PortableDocFormat)
                {
                    // the maximum report processing jobs limit configured by your system administrator has been reached.
                    rpt.Close(); rpt.Dispose();
                }

                if (pvtExportFormatType == ExportFormatType.PortableDocFormat)
                {
                    string newWindowUrl = Constants.ROOT_DIRECTORY + "/temp/" + strFileName;
                    string javaScript = "window.open('" + newWindowUrl + "');";
                    System.Web.UI.ScriptManager.RegisterClientScriptBlock(ClientScriptBlockControl, ClientScriptBlockControl.GetType(), "openwindow", javaScript, true);
                }
                else
                {
                    string newWindowUrl = Constants.ROOT_DIRECTORY + "/temp/" + strFileName;
                    string javaScript = "window.open('" + newWindowUrl + "','_self');";
                    System.Web.UI.ScriptManager.RegisterClientScriptBlock(ClientScriptBlockControl, ClientScriptBlockControl.GetType(), "openwindow", javaScript, true);

                    //System.Diagnostics.Process p = new System.Diagnostics.Process();
                    //p.StartInfo.FileName = System.Web.HttpContext.Current.Server.MapPath(Constants.ROOT_DIRECTORY + "/temp/" + strFileName);
                    //p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
                    //p.Start();
                }
            }
            catch (Exception ex) { throw ex; }
        }
Exemplo n.º 34
0
        private void GenerateHTML()
        {
            ReportDocument rpt = new ReportDocument();

            switch (cboView.SelectedItem.Value)
            {
            case "0":
                rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/ChartOfAccountsDetails.rpt"));
                break;

            case "1":
                rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/ChartOfAccountsSummary.rpt"));
                break;
            }

            HTMLFormatOptions htmlOpts = new HTMLFormatOptions();

            ExportOptions exportop          = new ExportOptions();
            DiskFileDestinationOptions dest = new DiskFileDestinationOptions();

            string strPath = Server.MapPath(@"\RetailPlus\temp\html\");
//			DeleteTempDirectory(strPath);

            string strFileName = "chartofacc_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + ".htm";

            if (System.IO.File.Exists(strPath + strFileName))
            {
                System.IO.File.Delete(strPath + strFileName);
            }

            htmlOpts.HTMLFileName             = strFileName;
            htmlOpts.HTMLEnableSeparatedPages = true;;
            htmlOpts.HTMLHasPageNavigator     = true;
            htmlOpts.HTMLBaseFolderName       = strPath;
            rpt.ExportOptions.FormatOptions   = htmlOpts;

            exportop = rpt.ExportOptions;

            exportop.ExportDestinationType = ExportDestinationType.DiskFile;
            exportop.ExportFormatType      = ExportFormatType.HTML40;

            dest.DiskFileName           = strFileName.ToString();
            exportop.DestinationOptions = dest;

            SetDataSource(rpt);

            rpt.Export();   rpt.Close();    rpt.Dispose();

            strFileName = "//" + Request.ServerVariables["SERVER_NAME"].ToString() + FindHTMLFile(strPath, strFileName);

            fraViewer.Attributes.Add("src", strFileName);
        }
        private void BtnImprimir_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var boton = e.Source as Button;
                if (boton != null)
                {
                    var elemento      = boton.CommandParameter as ImpresionCalidadMezcladoModel;
                    var calidad       = new CalidadMezcladoFormulasAlimentoPL();
                    var listaAuxiliar = new List <ImpresionCalidadMezcladoModel> {
                        elemento
                    };
                    calidad.CalculosDetalle(listaAuxiliar);
                    var documento = new ReportDocument();
                    var reporte   = String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory,
                                                  "\\Administracion\\Impresiones\\rptEf.MezRotomix 2.rpt");
                    documento.Load(reporte);

                    documento.DataSourceConnections.Clear();
                    documento.SetDataSource(listaAuxiliar);
                    documento.Refresh();

                    ExportOptions rptExportOption;
                    var           rptFileDestOption = new DiskFileDestinationOptions();
                    var           rptFormatOption   = new PdfRtfWordFormatOptions();
                    string        reportFileName    = string.Format("{0}_{1}_{2}.pdf", @"C:\CheckListCalidadMezclado",
                                                                    elemento.Tecnica,
                                                                    Contexto.Fecha.ToString("ddMMyyyy"));
                    rptFileDestOption.DiskFileName = reportFileName;
                    rptExportOption = documento.ExportOptions;
                    {
                        rptExportOption.ExportDestinationType    = ExportDestinationType.DiskFile;
                        rptExportOption.ExportFormatType         = ExportFormatType.PortableDocFormat;
                        rptExportOption.ExportDestinationOptions = rptFileDestOption;
                        rptExportOption.ExportFormatOptions      = rptFormatOption;
                    }
                    documento.Export();
                    SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                      Properties.Resources.Impresion_ReporteGeneradoConExito, MessageBoxButton.OK,
                                      MessageImage.Correct);
                    Process.Start(reportFileName);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal],
                                  Properties.Resources.ImpresionSupervisionTecnicasDeteccion_ErrorImpresion,
                                  MessageBoxButton.OK,
                                  MessageImage.Error);
            }
        }
Exemplo n.º 36
0
        private bool SendWebMail(string strTo, string subj, string cont, string cc, string bcc, string strfrom)
        {
            // generate reports
            DataTable dre = bus.generatereport();

            rd.Load(Server.MapPath(Request.ApplicationPath) + "/user/MonthlyReport.rpt");
            rd.SetDataSource(dre);

            // location of empty pdf file
            string filename = Server.MapPath("~/pdf/Monthly_Report.pdf");

            // export the report to pdf and write to empty pdf file inside pdf folder
            ExportOptions CrExportOptions;
            DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
            PdfRtfWordFormatOptions    CrFormatTypeOptions          = new PdfRtfWordFormatOptions();

            CrDiskFileDestinationOptions.DiskFileName = filename;
            CrExportOptions = rd.ExportOptions;//Report document  object has to be given here
            CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
            CrExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
            CrExportOptions.DestinationOptions    = CrDiskFileDestinationOptions;
            CrExportOptions.FormatOptions         = CrFormatTypeOptions;
            rd.Export();

            // send email with attachment

            bool        flg = false;
            MailMessage msg = new MailMessage();

            msg.Body    = "<table  border='1' cellpadding='0' cellspacing='0' style='width: 750px; border-color: black;'><tr><td colspan='9'><br>&nbsp &nbspDear Sir / Madam,<br /><br />&nbsp&nbsp&nbsp&nbsp&nbspPFA Monthly report for the Month of <b>" + dre.Rows[0][5].ToString() + " " + dre.Rows[0][6].ToString() + "</b>. The details are as follows.<br /><br /></td></tr><tr style='font-weight: 700;'></tr><tr><td colspan='9'><br/><p></p><p> &nbsp&nbsp&nbspOpening Date:   " + dre.Rows[0][2].ToString() + "</p><p>&nbsp&nbsp&nbspOpening Balance:   " + dre.Rows[0][7].ToString() + "</p><p>&nbsp&nbsp&nbspClosing Balance:   " + dre.Rows[0][15].ToString() + "</p><p>&nbsp&nbsp&nbspOpened By:   " + dre.Rows[0][4].ToString() + " </p><p>&nbsp&nbsp&nbspFreezed Date:   " + dre.Rows[0][3].ToString() + " </p><p>&nbsp&nbsp&nbspclick<a href=" + url + "> here </a>to login into the application</p><br/></td></tr><tr></tr><td colspan='9' style='font-weight: bold' align='right'><br /><br />Regards,<br />Team Petty Cash App</td></tr><tr><td align='center'><p style='color:blue;'> This is a system generated response. Please do not respond to this email id.</p></td></tr></table>";
            msg.From    = strfrom;
            msg.To      = strTo;
            msg.Subject = subj + " " + dre.Rows[0][5].ToString() + " " + dre.Rows[0][6].ToString();
            msg.Cc      = cc;
            msg.Bcc     = bcc;
            //System.Net.Mail.Attachment attach;
            //attach = new System.Net.Mail.Attachment()
            msg.Attachments.Add(new MailAttachment(filename));
            msg.BodyFormat = MailFormat.Html;
            try
            {
                //SmtpMail.SmtpServer = "175.143.44.165";
                SmtpMail.SmtpServer = "192.168.1.4"; // change the ip address to this when hosting in server
                SmtpMail.Send(msg);
                flg = true;
            }
            catch (Exception)
            {
                flg = false;
            }
            return(flg);
        }
        public void PrintReport(string key)
        {
            try
            {
                ReportDocument objRpt = new ReportDocument();
                DataSet ds = (DataSet)this.GetDataReport(key);

                string reportPath = "C:\\Reportes\\CRIngreso_etiqueta02.rpt";
                objRpt.Load(reportPath);

                DiskFileDestinationOptions crDiskFileDestinationOption = new DiskFileDestinationOptions();
                PdfRtfWordFormatOptions crFormatTypeOption = new PdfRtfWordFormatOptions();
                ExportOptions crExportOptions = new ExportOptions();

                objRpt.SetDataSource(ds.Tables[0]);
                string strfolder = "C:\\Reporte\\";
                crDiskFileDestinationOption.DiskFileName = strfolder + "Etiqueta.pdf";

                crExportOptions = objRpt.ExportOptions;
                crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                crExportOptions.ExportDestinationOptions = crDiskFileDestinationOption;
                crExportOptions.ExportFormatOptions = crFormatTypeOption;
                objRpt.Export();

                this.printDialog1.Document = this.printDocument1;
                DialogResult dr = this.printDialog1.ShowDialog();
                if (dr == DialogResult.OK)
                {

                    PageMargins margins;

                    margins = objRpt.PrintOptions.PageMargins;
                    margins.bottomMargin = 250;
                    margins.leftMargin = 250;
                    margins.rightMargin = 250;
                    margins.topMargin = 250;
                    objRpt.PrintOptions.ApplyPageMargins(margins);

                    string PrinterName = this.printDocument1.PrinterSettings.PrinterName;
                    objRpt.PrintOptions.PrinterName = PrinterName;
                    objRpt.PrintToPrinter(1, false, 0, 0);

                }

            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        public void GeneratePDF(string poId)
        {
            ReportDocument rptDoc = new ReportDocument();
            dsPSMS ds = new dsPSMS();
            DataTable dt = new DataTable();

            dt.TableName = "PO";
            dt = getAllPOs();

            ds.Tables["dtPO"].Merge(dt);

            //subreport data table
            dt = new DataTable();
            dt.TableName = "Terms";
            dt = getAllTerms();
            ds.Tables["dtTerms"].Merge(dt);

            rptDoc.Load(Server.MapPath("~/Reports/crPO.rpt"));
            rptDoc.SetDataSource(ds);

            string fileName = "PO" + poId + "_.pdf";

            String targetFolder = Server.MapPath(POAttachmentfolderPath);
            ExportOptions CrExportOptions;
            DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
            PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
            CrDiskFileDestinationOptions.DiskFileName = targetFolder + "\\" + fileName;
            CrExportOptions = rptDoc.ExportOptions;
            {
                CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                CrExportOptions.FormatOptions = CrFormatTypeOptions;
            }
            rptDoc.Export();

            string strFields = "";
            string[] strValues = new string[3];
            strFields = "[POID],[FilePath],[Note]";

            string filePath = POAttachmentfolderPath + "/" + fileName;
            string sqlStr = "select [FilePath] from [dbo].[POAttach] where [FilePath]=@FilePath";
            DataTable hasData = am.DataAccess.RecordSet(sqlStr, new string[] { filePath });
            if (hasData.Rows.Count == 0)
            {
                strValues = new string[] { poId.ToString() , filePath , txtAttachmentNote.Text.Trim() };
                am.DataAccess.BatchQuery.Insert("[dbo].[POAttach]", strFields, strValues);
                am.DataAccess.BatchQuery.Execute();
            }
        }
        private void loadReport()
        {
            DataTable lData = ((DataTable)Session["WRK_TABLE"]);

            ParameterFields paramFields = new ParameterFields();
            ParameterField paramField = new ParameterField();
            ParameterDiscreteValue dctField = new ParameterDiscreteValue();

            if (Session["WRK_TABLE"] != null)
            {
                if (lData.Rows.Count > 0)
                {
                    CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
                    myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                    myReportDocument.Load(Server.MapPath(hidReportName.Value + ".rpt"));
                    myReportDocument.SetDataSource(lData);

                    ExportOptions relExportOptions;
                    DiskFileDestinationOptions relDiskFileDestinationOptions;
                    string strPDFTemp = Server.MapPath(@"~\Aut\Reports\Files\" + hidReportName.Value + ".pdf");

                    relDiskFileDestinationOptions = new DiskFileDestinationOptions();
                    relDiskFileDestinationOptions.DiskFileName = strPDFTemp;
                    relExportOptions = myReportDocument.ExportOptions;
                    relExportOptions.ExportDestinationOptions = relDiskFileDestinationOptions;
                    relExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                    relExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

                    myReportDocument.Export();

                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.ContentType = "application/pdf";
                    Response.AddHeader("content-disposition", "inline; filename=ReportName.pdf");
                    Response.WriteFile(strPDFTemp);
                    Response.Flush();
                    Response.Close();

                    System.IO.File.Delete(strPDFTemp);
                }
            }
        }
Exemplo n.º 40
0
        private void Export(ExportFormatType pvtExportFormatType)
        {
            ReportDocument rpt = new ReportDocument();
            rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/_StockTransactionReport.rpt"));

            SetDataSource(rpt);

            ExportOptions exportop = new ExportOptions();
            DiskFileDestinationOptions dest = new DiskFileDestinationOptions();
            string strPath = Server.MapPath(@"\retailplus\temp\");
            string strFileExtensionName = ".pdf";
            switch (pvtExportFormatType)
            {
                case ExportFormatType.PortableDocFormat: strFileExtensionName = ".pdf"; exportop.ExportFormatType = ExportFormatType.PortableDocFormat; break;
                case ExportFormatType.WordForWindows: strFileExtensionName = ".doc"; exportop.ExportFormatType = ExportFormatType.WordForWindows; break;
                case ExportFormatType.Excel: strFileExtensionName = ".xls"; exportop.ExportFormatType = ExportFormatType.Excel; break;
            }
            string strFileName = "tranreport_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + strFileExtensionName;
            if (System.IO.File.Exists(strPath + strFileName))
                System.IO.File.Delete(strPath + strFileName);

            dest.DiskFileName = strPath + strFileName;
            exportop.DestinationOptions = dest;
            exportop.ExportDestinationType = ExportDestinationType.DiskFile;
            rpt.Export(exportop); //rpt.Close(); rpt.Dispose(); 

            if (pvtExportFormatType == ExportFormatType.PortableDocFormat)
            {
                rpt.Close(); rpt.Dispose();
                Response.Redirect(Constants.ROOT_DIRECTORY + "/temp/" + strFileName, false);
            }
            else 
            {
                CRViewer.ReportSource = rpt;
                Session["ReportDocument"] = rpt;
                CRSHelper.OpenExportedReport(strFileName); // OpenExportedReport(strFileName);
            }
            
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dt;

                String sql = "Select * FROM tableAttendance";

                SqlCommand com = new SqlCommand(sql, conn);

                conn.Open();

                SqlDataAdapter da = new SqlDataAdapter(com);
                dt = new DataTable("dt");
                da.Fill(dt);

                ReportDocument rpt = new ReportDocument();
                rpt.Load(Server.MapPath("crystalreportforattendance.rpt"));
                rpt.SetDatabaseLogon("sa", "yugioh", @"JOP-PC\SQLEXPRESS", "ISAttandaceManagementSystem");

                rpt.SetDataSource(dt);

                crvattendance.ReportSource = rpt;
                MemoryStream oStream;
                oStream = (MemoryStream)
                rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                //rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "Appointment");
                Response.Clear();
                Response.Buffer = true;
                Response.ContentType = "application/pdf";
                Response.BinaryWrite(oStream.ToArray());
                Response.End();
                rpt.Export();

                conn.Close();
                conn.Dispose();
            }
        }
        public void PrintReport(string key)
        {
            try
             {
                 ReportDocument objRpt = new ReportDocument();
                 DataSet ds = (DataSet)this.GetDataReport(key);

                 //string reportPath = Application.StartupPath + "\\Reportes\\OrdenCompraxprov.rpt";

                 string reportPath = "C:\\Reportes\\OrdenCompraxprov.rpt";
                 objRpt.Load(reportPath);

                 DiskFileDestinationOptions crDiskFileDestinationOption = new DiskFileDestinationOptions();
                 PdfRtfWordFormatOptions crFormatTypeOption = new PdfRtfWordFormatOptions();
                 ExportOptions crExportOptions = new ExportOptions();

                 objRpt.SetDataSource(ds.Tables[0]);
                 string strfolder = "C:\\Reporte\\";
                 crDiskFileDestinationOption.DiskFileName = strfolder +  "Data.pdf";
                 crExportOptions = objRpt.ExportOptions;

                 crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                 crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

                 crExportOptions.ExportDestinationOptions = crDiskFileDestinationOption;
                 crExportOptions.ExportFormatOptions = crFormatTypeOption;
                 objRpt.Export();

                 MessageBox.Show("Registros exportados", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Information);

             }
             catch (Exception ex)
             {

             }
        }
Exemplo n.º 43
0
    private void ExportPDF()
    {
        try
        {
            lblInfo.Text = "Gerando arquivo pdf para anexo";
            DirectoryInfo dinfo = new DirectoryInfo(Server.MapPath("Pedidos"));
            if (!dinfo.Exists)
            {
                dinfo.Create();
            }
            if (File.Exists(Server.MapPath("Pedidos\\" + sCodigoPedido + ".pdf")))
            {
                File.Delete(Server.MapPath("Pedidos\\" + sCodigoPedido + ".pdf"));
            }
            CarregaDataTableParaImpressao();
            ReportDocument rpt = new ReportDocument();
            dsPedido TabelaImpressao = (dsPedido)Session["PedidoRes"];
            rpt.Load(Server.MapPath("rptPedido.rpt"));
            rpt.SetDataSource(TabelaImpressao);

            CrystalDecisions.Web.CrystalReportViewer cryView = new CrystalDecisions.Web.CrystalReportViewer();
            ExportOptions CrExportOptions;
            DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
            PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
            CrDiskFileDestinationOptions.DiskFileName = Server.MapPath("Pedidos\\" + sCodigoPedido + ".pdf");
            CrExportOptions = rpt.ExportOptions;
            {
                CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                CrExportOptions.FormatOptions = CrFormatTypeOptions;
            }
            rpt.Export();
            lblInfo.Text = "Exportando arquivo para o servidor";
        }
        catch (Exception ex)
        {
            throw ex;
            //lblInfo.Text = ex.Message + (ex.InnerException != null ? ex.InnerException.Message : "");
        }
    }
        private void muestrareporte(String IdOperacion)
        {
            SqlDataAdapter adapter;
            DataSet ds = new DataSet();

            String archivo = "";

            DataTable dtVoucher = new DataTable();
            DataSet dsVoucher = new DataSet();

            String emailenviavoucher = "";

            dtVoucher.Columns.Add("IdOperacion");
            dtVoucher.Columns.Add("FechaEmision");
            dtVoucher.Columns.Add("NroVoucher");

            dtVoucher.Columns.Add("Pasajero_Nombre");
            dtVoucher.Columns.Add("Pasajero_Apellido");
            dtVoucher.Columns.Add("Pasajero_Documento");

            dtVoucher.Columns.Add("Pasajero_FechaNac");
            dtVoucher.Columns.Add("Pasajero_TipoTelefono");
            dtVoucher.Columns.Add("Pasajero_Telefono");

            dtVoucher.Columns.Add("Pasajero_Celular");
            dtVoucher.Columns.Add("Pasajero_Email");
            dtVoucher.Columns.Add("ContactoEmergencia_Apellido");

            dtVoucher.Columns.Add("ContactoEmergencia_Nombre");
            dtVoucher.Columns.Add("ContactoEmergencia_Email");

            dtVoucher.Columns.Add("ProductoDescripcion");
            dtVoucher.Columns.Add("OrigenDescripcion");

            dtVoucher.Columns.Add("DestinoDescripcion");
            dtVoucher.Columns.Add("FechaPartida");

            dtVoucher.Columns.Add("FechaRegreso");
            dtVoucher.Columns.Add("ImporteTarifaPesos");
            dtVoucher.Columns.Add("ImporteTarifaDolar");

            dtVoucher.Columns.Add("IdCobertura");
            dtVoucher.Columns.Add("DescripcionCobertura");
            dtVoucher.Columns.Add("ValorCobertura");
            dtVoucher.Columns.Add("MonedaDescripcion");
            dtVoucher.Columns.Add("SimboloMoneda");

            dtVoucher.Columns.Add("IdCobertura2");
            dtVoucher.Columns.Add("DescripcionCobertura2");
            dtVoucher.Columns.Add("ValorCobertura2");
            dtVoucher.Columns.Add("MonedaDescripcion2");
            dtVoucher.Columns.Add("SimboloMoneda2");
            dtVoucher.Columns.Add("EmailEnviaVoucher");

            try
            {

                System.Data.SqlClient.SqlConnection conn;
                conn = new System.Data.SqlClient.SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;

                conn.Open();
                SqlCommand command = new SqlCommand("spselImprimeVoucher", conn);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("Id_Operacion", Convert.ToInt32(IdOperacion));
                command.ExecuteNonQuery();
                adapter = new SqlDataAdapter(command);
                adapter.Fill(ds);
                conn.Close();
                ds.Dispose();

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {

                    DataRow row = dtVoucher.NewRow();
                    row["IdOperacion"] = ds.Tables[0].Rows[i]["IdOperacion"].ToString();
                    row["FechaEmision"] = ds.Tables[0].Rows[i]["FechaEmision"].ToString(); ;
                    row["NroVoucher"] = ds.Tables[0].Rows[i]["NroVoucher"].ToString();

                    row["Pasajero_Nombre"] = ds.Tables[0].Rows[i]["Pasajero_Nombre"].ToString();
                    row["Pasajero_Apellido"] = ds.Tables[0].Rows[i]["Pasajero_Apellido"].ToString();
                    row["Pasajero_Documento"] = ds.Tables[0].Rows[i]["Pasajero_Documento"].ToString();
                    row["Pasajero_FechaNac"] = ds.Tables[0].Rows[i]["Pasajero_FechaNac"].ToString();
                    row["Pasajero_TipoTelefono"] = ds.Tables[0].Rows[i]["Pasajero_TipoTelefono"].ToString();
                    row["Pasajero_Telefono"] = ds.Tables[0].Rows[i]["Pasajero_Telefono"].ToString();
                    row["Pasajero_Celular"] = ds.Tables[0].Rows[i]["Pasajero_Celular"].ToString();
                    row["Pasajero_Email"] = ds.Tables[0].Rows[i]["Pasajero_Email"].ToString();

                    row["ContactoEmergencia_Apellido"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Apellido"].ToString();
                    row["ContactoEmergencia_Nombre"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Nombre"].ToString();
                    row["ContactoEmergencia_Email"] = ds.Tables[0].Rows[i]["ContactoEmergencia_Email"].ToString();

                    row["ProductoDescripcion"] = ds.Tables[0].Rows[i]["ProductoDescripcion"].ToString();
                    row["OrigenDescripcion"] = ds.Tables[0].Rows[i]["OrigenDescripcion"].ToString();
                    row["DestinoDescripcion"] = ds.Tables[0].Rows[i]["DestinoDescripcion"].ToString();
                    row["FechaPartida"] = ds.Tables[0].Rows[i]["FechaPartida"].ToString();
                    row["FechaRegreso"] = ds.Tables[0].Rows[i]["FechaRegreso"].ToString();
                    row["ImporteTarifaPesos"] = ds.Tables[0].Rows[i]["ImporteTarifaPesos"].ToString();
                    row["ImporteTarifaDolar"] = ds.Tables[0].Rows[i]["ImporteTarifaDolar"].ToString();

                    row["IdCobertura"] = ds.Tables[0].Rows[i]["IdCobertura"].ToString();
                    row["DescripcionCobertura"] = ds.Tables[0].Rows[i]["DescripcionCobertura"].ToString();
                    row["ValorCobertura"] = ds.Tables[0].Rows[i]["ValorCobertura"].ToString();
                    row["MonedaDescripcion"] = ds.Tables[0].Rows[i]["MonedaDescripcion"].ToString();
                    row["SimboloMoneda"] = ds.Tables[0].Rows[i]["SimboloMoneda"].ToString();

                    row["IdCobertura2"] = ds.Tables[0].Rows[i]["IdCobertura2"].ToString();
                    row["DescripcionCobertura2"] = ds.Tables[0].Rows[i]["DescripcionCobertura2"].ToString();
                    row["ValorCobertura2"] = ds.Tables[0].Rows[i]["ValorCobertura2"].ToString();
                    row["MonedaDescripcion2"] = ds.Tables[0].Rows[i]["MonedaDescripcion2"].ToString();
                    row["SimboloMoneda2"] = ds.Tables[0].Rows[i]["SimboloMoneda2"].ToString();
                    row["EmailEnviaVoucher"] = ds.Tables[0].Rows[i]["EmailEnviaVoucher"].ToString();
                    emailenviavoucher = ds.Tables[0].Rows[i]["EmailEnviaVoucher"].ToString();

                    dtVoucher.Rows.Add(row);

                }

                ds.Dispose();
                dsVoucher.Tables.Add(dtVoucher);

                ReportDocument reporte = new ReportDocument(); // creating object of crystal report
                reporte.Load(Server.MapPath("~/Reportes/pagoconfirmado.rpt")); // path of report
                reporte.SetDataSource(dsVoucher.Tables[0]);

                dsVoucher.Dispose();

                DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
                reporte.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                reporte.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

                archivo = "C:/Data/Tusegurodeviaje/Reports/TempReports/pagoconfirmado_" + IdOperacion + ".pdf";

                diskOpts.DiskFileName = archivo;
                reporte.ExportOptions.DestinationOptions = diskOpts;

                reporte.Export();

                //CrystalReportViewer1.ReportSource = reporte;
                //reporte.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "pagoconfirmado" + IdOperacion);
                enviaemail(archivo, emailenviavoucher);

            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            finally
            {
            }
        }
Exemplo n.º 45
0
 private static void ExportPDF(ReportDocument rpt, string sCaminhoSave)
 {
     CrystalDecisions.Windows.Forms.CrystalReportViewer cryView = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
     ExportOptions CrExportOptions;
     DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
     PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
     CrDiskFileDestinationOptions.DiskFileName = sCaminhoSave;
     CrExportOptions = rpt.ExportOptions;
     {
         CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
         CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
         CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
         CrExportOptions.FormatOptions = CrFormatTypeOptions;
     }
     rpt.Export();
 }
Exemplo n.º 46
0
        private static void saveToFileSytem(ReportDocument informeBasico, string nombreInforme, string ApplicationPath)
        {
            ExportOptions informeOpcion = new ExportOptions();
            informeOpcion.ExportFormatType = ExportFormatType.PortableDocFormat;
            informeOpcion.ExportDestinationType = ExportDestinationType.DiskFile;
            DiskFileDestinationOptions destino = new DiskFileDestinationOptions();

            destino.DiskFileName = ApplicationPath + "\\informes\\" + nombreInforme;

            informeOpcion.ExportDestinationOptions = destino;

            informeBasico.Export(informeOpcion);
        }
Exemplo n.º 47
0
 public override void Start()
 {
     FrmProgress frmProgreso = new FrmProgress();
     frmProgreso.Start(2, "Exportando ...");
     frmProgreso.Next();
     try
     {
         CReporte reporte = null;
         ExportFormatOptions opciones = null;
         ExportFormatType formato;
         string nombreArchivo = string.Empty;
         string extension = string.Empty;
         string sql = string.Empty;
         if (base.m_ObjectFlow is DocumentoGenerico)
         {
             DocumentoGenerico documento = (DocumentoGenerico)base.m_ObjectFlow;
             reporte = documento.TipoDocumento.Reporte;
             nombreArchivo = string.Format("{0} - Nº {1} {2}", reporte.Nombre, documento.Numeracion, DateTime.Now.ToString("yyyy-MM-dd"));
             sql = reporte.SQL;
             foreach (ParametroReporte Parametro in reporte.ParametrosSQL)
                 sql = sql.Replace(Parametro.Nombre, documento.ValueByProperty(Parametro.Propiedad).ToString());
         }
         else if (base.m_ObjectFlow is CReporte)
         {
             reporte = (CReporte)base.m_ObjectFlow;
             nombreArchivo = string.Format("{0} {1}", reporte.Nombre, DateTime.Now.ToString("yyyy-MM-dd"));
             sql = reporte.SQL;
             foreach (ParametroReporte Parametro in reporte.ParametrosSQL)
                 sql = sql.Replace(Parametro.Nombre, Parametro.Valor);
         }
         switch (base.m_Parameter)
         {
             case TypeEnum.CEnumExportFormat.PDF:
                 formato = ExportFormatType.PortableDocFormat;
                 opciones = new PdfRtfWordFormatOptions();
                 extension = ".pdf";
                 break;
             case TypeEnum.CEnumExportFormat.WORD:
                 formato = ExportFormatType.WordForWindows;
                 opciones = new PdfRtfWordFormatOptions();
                 extension = ".doc";
                 break;
             case TypeEnum.CEnumExportFormat.EXCEL:
                 formato = ExportFormatType.Excel;
                 opciones = new ExcelFormatOptions();
                 extension = ".xls";
                 break;
             default:
                 throw new Exception("El formato no es válido.");
         }
         if (reporte != null)
         {
             
             ReportDocument CryRpt = new ReportDocument();
             CryRpt.Load(String.Format("{0}{1}", FrmMain.CarpetaReportes, reporte.Ubicacion));
             frmProgreso.Next();
             // Si existe una consulta SQL se ejecuta.
             if (sql.Trim().Length > 0) { CryRpt.SetDataSource(HelperNHibernate.GetDataSet(sql)); }
             // Se reemplazan los parámetros Crystal.
             foreach (ParametroReporte Parametro in reporte.ParametrosCrystal)
                 CryRpt.SetParameterValue(Parametro.Nombre, Parametro.Valor);
             // Se exporta el reporte.
             ExportOptions CrExportOptions;
             DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
             CrDiskFileDestinationOptions.DiskFileName = string.Format("{0}{1}{2}", FrmMain.CarpetaExportacion, nombreArchivo, extension);
             CrExportOptions = CryRpt.ExportOptions;
             {
                 CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                 CrExportOptions.ExportFormatType = formato;
                 CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                 CrExportOptions.FormatOptions = opciones;
             }
             // Se exporta el archivo.
             CryRpt.Export();
             // Se inicia un proceso para abrir el archivo.
             Process.Start(CrDiskFileDestinationOptions.DiskFileName);
         }
         else
             throw new Exception("Entidad no válida.");
         base.m_ResultProcess = EnumResult.SUCESS;
     }
     catch (Exception ex)
     {
         SoftException.Control(ex);
     }
     finally
     {
         frmProgreso.Close();
         base.Start();
     }
 }
Exemplo n.º 48
0
		private void GeneratePDF()
		{
			ReportDocument rpt = new ReportDocument();

			switch (cboReportType.SelectedItem.Text)
			{
                case "Posted PO":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedPO.rpt"));
                    break;
                case "Posted PO Returns":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedPOReturns.rpt"));
                    break;
                case "Posted Debit Memo":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedDebitMemo.rpt"));
                    break;
                case "By Vendor":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PurchaseAnalysis.rpt"));
                    break;
                default:
                    return;
					
			}

			ExportOptions exportop = new ExportOptions();
			DiskFileDestinationOptions dest = new DiskFileDestinationOptions();
			
			string strPath = Server.MapPath(@"\retailplus\temp\");

			string strFileName = cboReportType.SelectedItem.Text.Replace(" ", "").ToLower() + "_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + ".pdf";
			if (System.IO.File.Exists(strPath + strFileName))
				System.IO.File.Delete(strPath + strFileName);

			dest.DiskFileName = strPath + strFileName;

			exportop = rpt.ExportOptions;
	
			SetDataSource(rpt);

			exportop.DestinationOptions = dest;
			exportop.ExportDestinationType = ExportDestinationType.DiskFile;
			exportop.ExportFormatType = ExportFormatType.PortableDocFormat;
			rpt.Export();   rpt.Close();    rpt.Dispose();

			fraViewer.Attributes.Add("src",Constants.ROOT_DIRECTORY + "/temp/" + strFileName);
		}
Exemplo n.º 49
0
		private void GenerateHTML()
		{
            ReportDocument rpt = new ReportDocument();
            rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/GeneralLedger.rpt"));

			HTMLFormatOptions htmlOpts = new HTMLFormatOptions();
 
			ExportOptions exportop = new ExportOptions();
			DiskFileDestinationOptions dest = new DiskFileDestinationOptions();
			
			string strPath = Server.MapPath(@"\RetailPlus\temp\html\");
//			DeleteTempDirectory(strPath);

			string strFileName = "generalledger_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + ".htm";
			if (System.IO.File.Exists(strPath + strFileName))
				System.IO.File.Delete(strPath + strFileName);

			htmlOpts.HTMLFileName = strFileName;
			htmlOpts.HTMLEnableSeparatedPages = true;;
			htmlOpts.HTMLHasPageNavigator = true;
			htmlOpts.HTMLBaseFolderName = strPath;
			rpt.ExportOptions.FormatOptions = htmlOpts;

			exportop = rpt.ExportOptions;

			exportop.ExportDestinationType = ExportDestinationType.DiskFile;
			exportop.ExportFormatType = ExportFormatType.HTML40;
			
			dest.DiskFileName = strFileName.ToString();
			exportop.DestinationOptions = dest;

			SetDataSource(rpt);

			rpt.Export();   rpt.Close();    rpt.Dispose();

			strFileName = "//" + Request.ServerVariables["SERVER_NAME"].ToString() + FindHTMLFile(strPath,strFileName);	
			
			fraViewer.Attributes.Add("src",strFileName);
		}
Exemplo n.º 50
0
        /// <summary>
        /// Generate a Word, Excel or PDF report from a Crystal Reports template.
        /// </summary>
        /// <param name="templateFileBytes"></param>
        /// <param name="ds"></param>
        /// <param name="outputFormat"></param>
        /// <returns></returns>
        public static byte[] GenerateFromCrystalReportTemplate(byte[] templateFileBytes, DataSet ds, int? outputFormat)
        {
            // Crystal Reports behave in a strange way. It can only load
            // the template from disk and output the final report to disk 
            // (but not to/from memory stream). So we need to set up
            // temporary file paths in the ReportTempFolder.
            // 
            string reportTempFolder = ConfigurationManager.AppSettings["ReportTempFolder"];
            string templatePath = reportTempFolder + Guid.NewGuid().ToString();
            string outputPath = reportTempFolder + Guid.NewGuid().ToString();

            // Write the crystal report template file out to disk.
            //
            FileStream fs = new FileStream(templatePath, FileMode.Create);
            try { fs.Write(templateFileBytes, 0, templateFileBytes.Length); }
            finally { fs.Close(); }

            // Create the new Crystal Report objects, load the template 
            // and set the data source.
            //
            ReportDocument doc = new ReportDocument();
            doc.Load(templatePath);
            doc.SetDataSource(ds);

            // 2011 04 29
            // Kien Trung
            // Open all the sub reports and set data source to them.
            foreach (ReportDocument sub in doc.Subreports)
                sub.SetDataSource(ds);

            // Then we export the output to a file.
            //
            ExportOptions exportOpts = doc.ExportOptions;
            if (outputFormat == DocumentOutputFormat.AcrobatPDF)
                exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
            else if (outputFormat == DocumentOutputFormat.MicrosoftExcel)
                exportOpts.ExportFormatType = ExportFormatType.Excel;
            else if (outputFormat == DocumentOutputFormat.MicrosoftWord)
                exportOpts.ExportFormatType = ExportFormatType.WordForWindows;
            exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
            exportOpts.DestinationOptions = new DiskFileDestinationOptions();
            ((DiskFileDestinationOptions)doc.ExportOptions.DestinationOptions).DiskFileName = outputPath;
            doc.Export();

            // And we then read the file and return it to the caller.
            //
            FileStream fs2 = new FileStream(outputPath, FileMode.Open);
            byte[] output = new byte[fs2.Length];
            try { fs2.Read(output, 0, (int)fs2.Length); }
            finally { fs2.Close(); }
            return output;
        }
        private void imprimepresupuesto()
        {
            String opciones;
            String[] Datos;

            SqlConnection connection;
            SqlDataAdapter adapter;

            try
            {
                DataSet dspresupuesto= new DataSet();

                opciones = Request.QueryString["op"];
                Datos = opciones.Split('_');

                System.Data.SqlClient.SqlConnection conn;
                conn = new System.Data.SqlClient.SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;

                conn.Open();
                SqlCommand command = new SqlCommand("spselImprimeCotizacion", conn);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("FechaDesde", Datos[0].ToString());
                command.Parameters.AddWithValue("FechaHasta",  Datos[1].ToString());
                command.Parameters.AddWithValue("idOrigen",  Datos[2].ToString());
                command.Parameters.AddWithValue("IdDestino", Datos[3].ToString() );
                command.Parameters.AddWithValue("Email", Datos[4].ToString());
                command.Parameters.AddWithValue("edades", Datos[5].ToString());

                command.ExecuteNonQuery();
                adapter = new SqlDataAdapter(command);
                adapter.Fill(dspresupuesto);
                conn.Close();

                String archivo = "";

                ReportDocument rptDoc = new ReportDocument();
                rptDoc.Load(Server.MapPath("~/Reportes/presupuesto1.rpt"));
                rptDoc.SetDataSource(dspresupuesto.Tables[0]);

                dspresupuesto.Dispose();

                DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();

                string targetFileName = "C:/Data/Tusegurodeviaje/Reports/TempReports/presupuesto_" + (new Random()).Next() + ".pdf";

                //string targetFileName = Request.PhysicalApplicationPath + "C:\Data\Tusegurodeviaje\Reports\TempReports\\presupuesto" + (new Random()).Next() + ".pdf";

                rptDoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                rptDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

                diskOpts.DiskFileName = targetFileName;

                //archivo = Server.MapPath(targetFileName);
                rptDoc.ExportOptions.DestinationOptions = diskOpts;

                // Export report ... Server-Side.
                rptDoc.Export();
                CrystalReportViewer1.ReportSource = rptDoc;
                rptDoc.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "presupuesto");

            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            finally
            {

            }
        }
Exemplo n.º 52
0
        public static byte[] GetInformePreliminar(int ajusteId, string ruta)
        {
            // Instancia del reporte

              String reportPath = ruta + "docs\\crInformePreliminar.rpt";

              //MODIFICAR CON LA AGREGACION DE LA EXTENCION DEL PDF
              String nombre = "PASA-IP-" + ajusteId + "-" + DateTime.Now.Day + DateTime.Now.Month + DateTime.Now.Year + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + DateTime.Now.Millisecond + ".pdf";
              ReportDocument informeBasico = new ReportDocument();
              informeBasico.Load(reportPath);

              dsReporteTableAdapters.InformeBasicoImagenesTableAdapter dtImagenes = new dsReporteTableAdapters.InformeBasicoImagenesTableAdapter();
              DataTable imagenes = (DataTable)dtImagenes.GetData(ajusteId);
              informeBasico.OpenSubreport("crIBImagen.rpt").SetDataSource(imagenes);

              dsReporteTableAdapters.InformeBasicoDocumentacionSolicitadaTableAdapter dtdocumentacion = new dsReporteTableAdapters.InformeBasicoDocumentacionSolicitadaTableAdapter();
              DataTable documentacion = (DataTable)dtdocumentacion.GetData(ajusteId);
              informeBasico.OpenSubreport("crIBDocumentacion.rpt").SetDataSource(documentacion);

              dsReporteTableAdapters.InformeBasicoReclamoTableAdapter dtreclamo = new dsReporteTableAdapters.InformeBasicoReclamoTableAdapter();
              DataTable reclamo = (DataTable)dtreclamo.GetData(ajusteId);
              informeBasico.OpenSubreport("crIBReclamo.rpt").SetDataSource(reclamo);

              dsReporteTableAdapters.InformeBasicoInspeccionTableAdapter dtinspeccion = new dsReporteTableAdapters.InformeBasicoInspeccionTableAdapter();
              DataTable inspeccion = (DataTable)dtinspeccion.GetData(ajusteId);
              informeBasico.OpenSubreport("crIBInspeccion.rpt").SetDataSource(inspeccion);

              dsReporteTableAdapters.InformeBasicoOcurrenciaDetalleTableAdapter dtdetalleocurrencia = new dsReporteTableAdapters.InformeBasicoOcurrenciaDetalleTableAdapter();
              DataTable detalleocurrencia = (DataTable)dtdetalleocurrencia.GetData(ajusteId);
              informeBasico.OpenSubreport("crIBDetalleOcurrencia.rpt").SetDataSource(detalleocurrencia);

              dsReporteTableAdapters.InformeBasicoOcurrenciaCabeceraTableAdapter dtocurrencia = new dsReporteTableAdapters.InformeBasicoOcurrenciaCabeceraTableAdapter();
              DataTable ocurrencia = (DataTable)dtocurrencia.GetData(ajusteId);
              informeBasico.OpenSubreport("crIBOcurrencia.rpt").SetDataSource(ocurrencia);

              dsReporteTableAdapters.InformeBasicoClausulasTableAdapter dtclausulas = new dsReporteTableAdapters.InformeBasicoClausulasTableAdapter();
              DataTable clausulas = (DataTable)dtclausulas.GetData(ajusteId);
              informeBasico.OpenSubreport("crIBClausulas.rpt").SetDataSource(clausulas);

              dsReporteTableAdapters.InformeBasicoDeduciblesTableAdapter dtdeducibles = new dsReporteTableAdapters.InformeBasicoDeduciblesTableAdapter();
              DataTable deducibles = (DataTable)dtdeducibles.GetData(ajusteId);
              informeBasico.OpenSubreport("crIBDeducibles.rpt").SetDataSource(deducibles);

              dsReporteTableAdapters.InformeBasicoPolizaDetalleTableAdapter dtdetallepoliza = new dsReporteTableAdapters.InformeBasicoPolizaDetalleTableAdapter();
              DataTable detallePoliza = (DataTable)dtdetallepoliza.GetData(ajusteId);
              informeBasico.OpenSubreport("crIBDetallePoliza.rpt").SetDataSource(detallePoliza);

              dsReporteTableAdapters.InformeBasicoPolizaTableAdapter dtPoliza = new dsReporteTableAdapters.InformeBasicoPolizaTableAdapter();
              DataTable poliza = (DataTable)dtPoliza.GetData(ajusteId);
              informeBasico.OpenSubreport("crIBPoliza.rpt").SetDataSource(poliza);

              dsReporteTableAdapters.InformeBasicoFechaAvisoCoordinacionTableAdapter dtfechacoordinacion = new dsReporteTableAdapters.InformeBasicoFechaAvisoCoordinacionTableAdapter();
              DataTable fechaCoordinacion = (DataTable)dtfechacoordinacion.GetData(ajusteId);
              informeBasico.OpenSubreport("crIBFechaAviso.rpt").SetDataSource(fechaCoordinacion);

              dsReporteTableAdapters.InformeBasicoGeneralesTableAdapter dtgenerales = new dsReporteTableAdapters.InformeBasicoGeneralesTableAdapter();
              DataTable datosgenerales = (DataTable)dtgenerales.GetData(ajusteId);
              informeBasico.OpenSubreport("crIBGenerales.rpt").SetDataSource(datosgenerales);

              dsReporteTableAdapters.InformeBasicoCabeceraTableAdapter cabeceraAdapter = new dsReporteTableAdapters.InformeBasicoCabeceraTableAdapter();
              informeBasico.SetDataSource((DataTable)cabeceraAdapter.GetData(ajusteId));

              //informeBasico.FileName = "InformeBasico" + ajusteId + ".pdf";
              ExportOptions informeOpcion = new ExportOptions();
              informeOpcion.ExportFormatType = ExportFormatType.PortableDocFormat;
              informeOpcion.ExportDestinationType = ExportDestinationType.DiskFile;
              DiskFileDestinationOptions destino = new DiskFileDestinationOptions();

              nombre = "InformeBasicoAYP.pdf";
              destino.DiskFileName = ruta + "informes\\" + nombre;

              informeOpcion.ExportDestinationOptions = destino;

              informeBasico.Export(informeOpcion);

              //dsReporteTableAdapters.InformeBasicoSelectTableAdapter tainforme = new dsReporteTableAdapters.InformeBasicoSelectTableAdapter();
              //tainforme.Insert(ajusteId, nombre, ruta + "informes\\");

              MemoryStream oStream;
              oStream = (MemoryStream)informeBasico.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
              return oStream.ToArray();
        }
Exemplo n.º 53
0
        private void enviaemail(String IdOperacion)
        {
            SqlDataAdapter adapter;
            DataSet ds = new DataSet();
            String archivo = "";

            try
            {

                ReportDocument reporte = new ReportDocument(); // creating object of crystal report
                reporte.Load(Server.MapPath("~/Reportes/voucher.rpt")); // path of report

                //ParameterField myParam = new ParameterField();
                //ParameterDiscreteValue myDiscreteValue = new ParameterDiscreteValue();
                //myParam.ParameterFieldName = "Id_Operacion";
                //myDiscreteValue.Value = Convert.ToInt32(IdOperacion);
                //myParam.CurrentValues.Add(myDiscreteValue);
                //reporte.ParameterFields.Add(myParam);

                reporte.SetParameterValue("@Id_Operacion", Convert.ToInt32(IdOperacion));

                //ParameterDiscreteValue crtParamDiscreteValue;
                //ParameterField crtParamField;
                //ParameterFields crtParamFields;

                //crtParamDiscreteValue = new ParameterDiscreteValue();
                //crtParamField = new ParameterField();
                //crtParamFields = new ParameterFields();

                //crtParamDiscreteValue.Value = Convert.ToInt32(IdOperacion);
                //crtParamField.ParameterFieldName = "Id_Operacion";
                //crtParamField.CurrentValues.Add(crtParamDiscreteValue);
                //crtParamFields.Add(crtParamField);

                //CrystalReportViewer1.ParameterFieldInfo = crtParamFields;

                ////this.CrystalReportViewer1.RefreshReport();
                //CrystalReportViewer1.ReportSource = reporte;

                //reporte.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "voucher");

                DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
                reporte.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                reporte.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

                archivo = Server.MapPath("~/Reportes/TempReports/v" + IdOperacion + ".pdf");
                diskOpts.DiskFileName = archivo;
                reporte.ExportOptions.DestinationOptions = diskOpts;

                reporte.Export();

                MailMessage mail = new MailMessage();
                //set the addresses
                string emailAddressList = System.Configuration.ConfigurationManager.AppSettings["emailsToSend"];
                string displayName = System.Configuration.ConfigurationManager.AppSettings["displayNameEmailAddressToSendAuthorizationDocs"];
                mail.From = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["fromEmailAddressToSendAuthorizationDocs"], displayName);
                mail.To.Add(emailAddressList);
                mail.IsBodyHtml = true;
                //set the content
                mail.Subject = "Voucher";
                //set the body
                mail.Body += "Muchas gracias.<br />";

                //MailAttachment objArchivo = new MailAttachment("E:\\Email\\pedido.pdf");

                mail.Attachments.Add(new Attachment(archivo));
                //mail.Attachments.Add(archivo);

                string SMTPServer = System.Configuration.ConfigurationManager.AppSettings["SMTPServer"];
                SmtpClient smtp = new SmtpClient(SMTPServer); //specify the mail server address

                smtp.Send(mail);

            }
            catch (Exception ex)
            {

                Response.Write(ex.Message);

            }
            finally
            {
            }
        }
Exemplo n.º 54
0
        private void imprimecomparativa()
        {
            String opciones = "";
            String[] Datos;
            DataSet ds = new DataSet();
            DataSet dsCompara = new DataSet();
            SqlDataAdapter adapter;
            String valorcobertura = "-";
            String tabla = "";
            Boolean band = false;
            int planes = 0;
            String archivo = "";
            DataTable dtComparativa = new DataTable();
            DataSet dsComparativa = new DataSet();

            dtComparativa.Columns.Add("Producto");
            dtComparativa.Columns.Add("Cobertura");
            dtComparativa.Columns.Add("Importe");

            opciones = Request.QueryString["op"];
            Datos = opciones.Split('*');
            planes = (Datos.Count() - 1);

            try
            {

                System.Data.SqlClient.SqlConnection conn;
                conn = new System.Data.SqlClient.SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;

                conn.Open();
                SqlCommand command = new SqlCommand("spselCoberturas", conn);
                command.CommandType = CommandType.StoredProcedure;
                command.ExecuteNonQuery();
                adapter = new SqlDataAdapter(command);
                adapter.Fill(ds);
                conn.Close();

                if ((ds != null) && (ds.Tables[0].Rows.Count > 0))
                {

                    for (int x = 0; x < ds.Tables[0].Rows.Count; x++)
                    {
                        for (int j = 0; j < Datos.Count() - 1; j++)
                        {

                            System.Data.SqlClient.SqlConnection conn1;
                            conn1 = new System.Data.SqlClient.SqlConnection();
                            conn1.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;

                            conn1.Open();
                            SqlCommand command1 = new SqlCommand("spselComparativa", conn1);
                            command1.CommandType = CommandType.StoredProcedure;
                            command1.Parameters.AddWithValue("IDProducto", Convert.ToInt32(Datos[j].ToString()));
                            command1.ExecuteNonQuery();
                            adapter = new SqlDataAdapter(command1);
                            adapter.Fill(dsCompara);
                            conn1.Close();

                            valorcobertura = "-";
                            band = false;
                            for (int z = 0; z < dsCompara.Tables[0].Rows.Count; z++)
                            {
                                if (ds.Tables[0].Rows[x]["IdCobertura"].ToString() == dsCompara.Tables[0].Rows[z]["IdCobertura"].ToString())
                                {

                                    DataRow row = dtComparativa.NewRow();
                                    row["Producto"] = dsCompara.Tables[0].Rows[x]["Nombre"].ToString();
                                    row["Cobertura"] = dsCompara.Tables[0].Rows[x]["Descripcion"].ToString();
                                    row["Importe"] = dsCompara.Tables[0].Rows[x]["ValorCobertura"].ToString();
                                    dtComparativa.Rows.Add(row);
                                    band = true;
                                    break;
                                }
                            }
                            dsCompara.Dispose();
                        }
                    }
                }

                ds.Dispose();

                dsComparativa.Tables.Add(dtComparativa);

                ReportDocument reporte = new ReportDocument();
                reporte.Load(Server.MapPath("~/Reportes/comparativa.rpt"));
                reporte.SetDataSource(dsComparativa.Tables[0]);
                dsComparativa.Dispose();

                DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
                reporte.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                reporte.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

                archivo = "C:/Data/Tusegurodeviaje/Reports/TempReports/plan_" + (new Random()).Next() + ".pdf";
                diskOpts.DiskFileName = archivo;
                reporte.ExportOptions.DestinationOptions = diskOpts;

                reporte.Export();

                enviamensaje(archivo);

            }
            catch (Exception ex)
            {
                lblError.Text = "Error enviando correo electrónico: " + ex.Message;
            }
            finally
            {
            }
        }
Exemplo n.º 55
0
		private void GenerateHTML()
		{
			ReportDocument rpt = new ReportDocument();

			switch (cboReportType.SelectedItem.Text)
			{
				case "Posted PO":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedPO.rpt"));
					break;
				case "Posted PO Returns":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedPOReturns.rpt"));
					break;
				case "Posted Debit Memo":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedDebitMemo.rpt"));
					break;
				case "By Vendor":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PurchaseAnalysis.rpt"));
					break;
				default:
					return;
					
			}

			HTMLFormatOptions htmlOpts = new HTMLFormatOptions();
 
			ExportOptions exportop = new ExportOptions();
			DiskFileDestinationOptions dest = new DiskFileDestinationOptions();
			
			string strPath = Server.MapPath(@"\retailplus\temp\html\");

			string strFileName = cboReportType.SelectedItem.Text.Replace(" ", "").ToLower() + "_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + ".htm";
			if (System.IO.File.Exists(strPath + strFileName))
				System.IO.File.Delete(strPath + strFileName);

			htmlOpts.HTMLFileName = strFileName;
			htmlOpts.HTMLEnableSeparatedPages = true;;
			htmlOpts.HTMLHasPageNavigator = true;
			htmlOpts.HTMLBaseFolderName = strPath;
			rpt.ExportOptions.FormatOptions = htmlOpts;

			exportop = rpt.ExportOptions;

			exportop.ExportDestinationType = ExportDestinationType.DiskFile;
			exportop.ExportFormatType = ExportFormatType.HTML40;
			
			dest.DiskFileName = strFileName.ToString();
			exportop.DestinationOptions = dest;

			SetDataSource(rpt);

            Session["ReportDocument"] = rpt;

			rpt.Export();   rpt.Close();    rpt.Dispose();

			strFileName = "//" + Request.ServerVariables["SERVER_NAME"].ToString() + FindHTMLFile(strPath,strFileName);	
			
			fraViewer.Attributes.Add("src",strFileName);
		}
Exemplo n.º 56
0
    protected void btnPresupuesto_Click(object sender, EventArgs e)
    {
        /*

        DataSet dss = BRBitacora.buscarPorFiltro("","","","","");
        DataTable dt = dss.Tables[0];
        //dt.Columns.Add("id");

        //TransArteReport report = new TransArteReport();
        //DataTable _tabla = report.DataTable1;

        ReportDocument rpt = new ReportDocument();

        rpt.Load(Server.MapPath("../Reportes/ReportBitacora.rpt"));
        rpt.SetDataSource(dt);
        */

        ReportDocument rpt = new ReportDocument();
        String szFileName = "";
        String strServerPath = "";
        rpt.PrintOptions.PaperOrientation = PaperOrientation.DefaultPaperOrientation;
        rpt.PrintOptions.PaperSize = PaperSize.DefaultPaperSize;
        rpt.PrintOptions.PaperSource = PaperSource.Upper;
        rpt.PrintOptions.PrinterDuplex = PrinterDuplex.Default;
        DataSet dss = BRBitacora.buscarPorFiltro("", "", "", "", "");
        DataTable dt = dss.Tables[0];

        dt.Columns.Add("Logo", System.Type.GetType("System.Byte[]"));//Agrego la columna con el tipo de dato "System.Byte[]",donde guardare mi imagen.
        dt.Rows[0]["Logo"] = CargarImagen("C:\\TransArte\\Website\\images\\logoMini.PNG");//Cargo La imagen

        dt.Columns.Add("UsuarioFiltro", System.Type.GetType("System.String"));//Agrego la columna con el tipo de dato "System.Byte[]",donde guardare mi imagen.
        dt.Rows[0]["UsuarioFiltro"] = "MAXIMILIANO";//Cargo La imagen

        rpt.Load(Server.MapPath("../Reportes/ReportBitacora.rpt"));
        rpt.SetDataSource(dt);
        szFileName = "bitacora.pdf";
        strServerPath = Server.MapPath("~") + "\\Reportes\\";

        DiskFileDestinationOptions dfdoFile = new DiskFileDestinationOptions();
        dfdoFile.DiskFileName = strServerPath + szFileName;

        rpt.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
        rpt.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
        rpt.ExportOptions.DestinationOptions = dfdoFile;
        rpt.Export();
        Response.Redirect("../Reportes/" + szFileName, false);

        /*
         *
          http://localhost:49173/website/Servicio/Reportes.aspx
         *
         * */
    }
        public void VistaPrevia(string key)
        {
            try
            {
                ReportDocument objRpt = new ReportDocument();
                DataSet ds = (DataSet)this.GetDataReport(key);

                //string reportPath = Application.StartupPath + "\\Reporte\\co_ordenCompra_rpt.rpt";
                string reportPath = "C:\\Reportes\\co_ordenCompra_rpt.rpt";
                objRpt.Load(reportPath);

                DiskFileDestinationOptions crDiskFileDestinationOption = new DiskFileDestinationOptions();
                PdfRtfWordFormatOptions crFormatTypeOption = new PdfRtfWordFormatOptions();
                ExportOptions crExportOptions = new ExportOptions();

                objRpt.SetDataSource(ds.Tables[0]);
                string strfolder = "C:\\Reporte\\";
                crDiskFileDestinationOption.DiskFileName = strfolder + txtnu_oc.Text + ".pdf";

                crExportOptions = objRpt.ExportOptions;
                crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

                crExportOptions.ExportDestinationOptions = crDiskFileDestinationOption;
                crExportOptions.ExportFormatOptions = crFormatTypeOption;

                objRpt.Export();

            }
            catch (Exception ex)
            {

            }
        }
        public void PrintReport(string key)
        {
            try
            {
                //----------------------------------------
                ReportDocument objRpt = new ReportDocument();
                DataSet ds = (DataSet)this.GetDataReport(key);

                string reportPath = "C:\\Reportes\\CRIngreso_etiqueta02.rpt";
                objRpt.Load(reportPath);

                DiskFileDestinationOptions crDiskFileDestinationOption = new DiskFileDestinationOptions();
                PdfRtfWordFormatOptions crFormatTypeOption = new PdfRtfWordFormatOptions();
                ExportOptions crExportOptions = new ExportOptions();

                objRpt.SetDataSource(ds.Tables[0]);
                string strfolder = "C:\\Reporte\\";
                crDiskFileDestinationOption.DiskFileName = strfolder + "Etiqueta.pdf";
                crExportOptions = objRpt.ExportOptions;
                crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                crExportOptions.ExportDestinationOptions = crDiskFileDestinationOption;
                crExportOptions.ExportFormatOptions = crFormatTypeOption;
                objRpt.Export();
                //---------------------------------------
                 ////string PrinterName = this.printDocument1.PrinterSettings.PrinterName;
                 //string NombreImpresora = "";

                 ////for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
                 ////{
                 ////    PrinterSettings a = new PrinterSettings();
                 ////    a.PrinterName = PrinterSettings.InstalledPrinters[i].ToString();
                 ////    if (a.IsDefaultPrinter)
                 ////    {

                 ////        PrinterName = PrinterSettings.InstalledPrinters[i].ToString();
                 ////    }
                 ////}

                //this.printDialog1.Document = this.printDocument1;
                //DialogResult dr = this.printDialog1.ShowDialog();
                //if (dr == DialogResult.OK)
                //     {
                         PageMargins margins;
                         margins = objRpt.PrintOptions.PageMargins;
                         margins.bottomMargin = 250;
                         margins.leftMargin = 250;
                         margins.rightMargin = 250;
                         margins.topMargin = 250;
                         objRpt.PrintOptions.ApplyPageMargins(margins);
                     //string PrinterName = this.printDocument1.PrinterSettings.PrinterName;
                     //                    ////objRpt.PrintOptions.PrinterName = PrinterName;
                    objRpt.PrintOptions.PrinterName = GetImpresoraDefecto();
                         //objRpt.PrintOptions.PrinterName = PrinterName;
                         objRpt.PrintToPrinter(1, false, 0, 0);
                     //}

            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
Exemplo n.º 59
0
        private void ExportarComprobanteButton_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = System.Windows.Forms.Cursors.WaitCursor;
                if (DetalleLoteDataGridView.SelectedRows.Count != 0)
                {
                    for (int i = 0; i < DetalleLoteDataGridView.SelectedRows.Count; i++)
                    {
                        int renglon = DetalleLoteDataGridView.SelectedRows[i].Index;
                        ReportDocument ReporteDocumento = new ReportDocument();
                        ProcesarComprobante(out ReporteDocumento, lote, renglon);

                        //Nombre del comprobante ( pdf )
                        System.Text.StringBuilder sb = new System.Text.StringBuilder();
                        sb.Append(lote.CuitVendedor);
                        sb.Append("-");
                        sb.Append(Convert.ToInt32(lote.PuntoVenta).ToString("0000"));
                        sb.Append("-");
                        sb.Append(Convert.ToInt32(lote.Comprobantes[renglon].IdTipoComprobante).ToString("00"));
                        sb.Append("-");
                        sb.Append(Convert.ToInt32(lote.Comprobantes[renglon].NumeroComprobante).ToString("00000000"));
                        sb.Append(".pdf");

                        //ExportOptions
                        DiskFileDestinationOptions crDiskFileDestinationOptions = new DiskFileDestinationOptions();
                        crDiskFileDestinationOptions.DiskFileName = Aplicacion.Aplic.ArchPathPDF + sb.ToString();
                        ReporteDocumento.ExportOptions.ExportDestinationOptions = crDiskFileDestinationOptions;
                        ReporteDocumento.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                        ReporteDocumento.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                        PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
                        ReporteDocumento.ExportOptions.ExportFormatOptions = CrFormatTypeOptions;
                        ReporteDocumento.Export();
                        ReporteDocumento.Close();
                    }
                    if (DetalleLoteDataGridView.SelectedRows.Count == 1)
                    {
                        MessageBox.Show("El comprobante seleccionado se ha exportado satisfactoriamente.", "Exportar Comprobantes", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    }
                    else
                    {
                        MessageBox.Show("Los comprobantes seleccionados se han exportado satisfactoriamente.", "Exportar Comprobantes", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Problemas al procesar el comprobante", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            finally
            {
                Cursor = System.Windows.Forms.Cursors.Default;
            }
        }
Exemplo n.º 60
0
        protected void lnkbtnDownload_Click(object sender, EventArgs e)
        {
            try
            {
                ReportDocument doc = new ReportDocument();
                string fileName = Server.MapPath("~/Reports/Invoice.rpt");
                doc.Load(fileName);

                doc.SetParameterValue("@invoiceNo", lblInvoiceNo.Text);
                doc.SetParameterValue("@notes", lblNotes.Text);
                doc.SetParameterValue("@subTotal", lbldiscount.Text);
                doc.SetParameterValue("@discount", lbldiscount.Text);

                doc.SetParameterValue("@Tax", lblTaxAmount.Text);
                doc.SetParameterValue("@total", lblTotalAmount.Text);
                doc.SetParameterValue("@invoiceDate", lblInvoiceDate.Text);

                doc.SetParameterValue("@clientName", clientName);
                doc.SetParameterValue("@clientAdd", clientAdd);
                doc.SetParameterValue("@clientState", clientState);
                doc.SetParameterValue("@clientCountry", clientCountry);
                doc.SetParameterValue("@clientEmail", clientEmail);

                doc.SetParameterValue("@description", lbldesc.Text);
                doc.SetParameterValue("@NoOfEmailsSent", lblnoofemailsent.Text);
                doc.SetParameterValue("@priceRate", lblprice.Text);
                doc.SetParameterValue("@amount", lblamount.Text);

                doc.SetParameterValue("@status", lblStatus.Text);

                doc.SetParameterValue("@clientMobileNo", clientMobileNo);
                //set the export options to PDF
                ExportOptions exportOpts = doc.ExportOptions;
                exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
                exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
                exportOpts.DestinationOptions = new DiskFileDestinationOptions();

                // Set the disk file options.
                DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
                ((DiskFileDestinationOptions)doc.ExportOptions.DestinationOptions).DiskFileName = Server.MapPath("~/pages/ReportSummary/Invoice.pdf");
                doc.Export();

                Response.Clear();
                Response.AddHeader("content-disposition", "attachment;filename=Invoice.pdf");
                Response.ContentType = "Application/pdf";

                //Get the physical path to the file.
                string FilePath = Server.MapPath("~/pages/ReportSummary/Invoice.pdf");

                //Write the file directly to the HTTP content output stream.
                Response.WriteFile(FilePath);
                Response.End();
            }
            catch (Exception ex)
            {
                //ExceptionPolicy.HandleException(ex, "Web.UIPolicy");
            }
        }