protected void btnpdf_Click(object sender, EventArgs e)
        {
            CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
            myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            string strRuta = Server.MapPath("ListadoArticulos1.rpt");
            myReportDocument.Load(strRuta);

            DataTable dt = objListado.ListarTodos();
            myReportDocument.SetDataSource(dt);

            myReportDocument.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, false, "Listado");
        }
Beispiel #2
0
 protected void btnImprimmer_Click(object sender, EventArgs e)
 {
     CrystalDecisions.CrystalReports.Engine.ReportDocument rpth = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
     rpth.Load(Server.MapPath("~/Report/rptAgence.rpt"));
     rpth.SetDataSource(GetTableAgence());
     rpth.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, String.Format("Liste_Agence_{0}", DateTime.Now));
 }
 protected void btnImpression_Click(object sender, EventArgs e)
 {
     CrystalDecisions.CrystalReports.Engine.ReportDocument rpth = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
     rpth.Load(Server.MapPath("~/Report/rptPersonne.rpt"));
     rpth.SetDataSource(GetTablePersonne());
     rpth.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "Liste Personne");
 }
Beispiel #4
0
        public void GetReport()
        {
            try
            {
                string sReportHeading = "";
                string sAmtInWords    = "";
                string sReportcomment = "";
                string sReportInFile  = "";
                string strSQL         = "";

                sReportHeading = "";
                if (SessionUserData.AppInfo.TempStrVariable_1 == "IGST")
                {
                    sReportInFile = "GST_I_Invoice.rpt";
                }
                else
                {
                    sReportInFile = "GST_SU_Invoice.rpt";
                }

                strSQL = " AAA_M_USP_Print_Invoice " + SessionUserData.Company.CompanyID +
                         "," + SessionUserData.Company.BranchID +
                         "," + SessionUserData.Company.YearID +
                         "," + SessionUserData.AppInfo.TempIntVariable_1;
                DataTable myDS = new DataTable();
                myDS = MaheshAF18.Application.MEF.DA_GetDataTable(strSQL);

                if (File.Exists(Server.MapPath(myDS.Rows[0]["BL_Logo_Url"].ToString())))
                {
                    FileStream stream  = new FileStream(Server.MapPath(myDS.Rows[0]["BL_Logo_Url"].ToString()), FileMode.Open, FileAccess.Read);
                    byte[]     ImgData = new byte[stream.Length];
                    stream.Read(ImgData, 0, Convert.ToInt32(stream.Length));
                    stream.Close();
                    myDS.Rows[0]["BL_Logo_Img"] = ImgData;
                }



                decimal vatTotalAmt = Convert.ToDecimal(0 + myDS.Rows[0]["SINV_HDR_Total_Gross_Amt"].ToString());
                sAmtInWords = MaheshAF18.Utility.NoToWord.AmtInWord_INR(vatTotalAmt);
                CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);

                myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                myReportDocument.Load(Server.MapPath("..\\Rpt\\") + sReportInFile + "");

                myReportDocument.Database.Tables[0].SetDataSource(myDS);
                //myReportDocument.SetParameterValue("pRepHeading", sReportHeading);
                myReportDocument.SetParameterValue("AmtInWords ", sAmtInWords);
                myReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, "Invoice");
                //Session["reportDataSource"] = myReportDocument;
                //CrystalReportViewer1.DisplayGroupTree = false;
                //CrystalReportViewer1.ReportSource = myReportDocument;
                //CrystalReportViewer1.DataBind();
            }
            catch (Exception ex)
            {
                DisplayCustomMessageSummary(ex.Message);
            }
        }
Beispiel #5
0
        protected void btnReporte_OnClick(object Sender, EventArgs E)
        {
            dtsTramitesPagos dtsTramitesPagos = new dtsTramitesPagos();

            cargarTramitesPagos(Convert.ToInt32(ddlAnios.SelectedValue));

            List <Objetos.TramitePago> lstTramitesPagos = TramitePagoBL.ObtenerListaTramitesPagosPorAnio(Convert.ToInt32(ddlAnios.SelectedValue));

            foreach (var tramitePago in lstTramitesPagos)
            {
                dtsTramitesPagos.TramitesPagos.AddTramitesPagosRow(
                    tramitePago.FechaActaEntregaRecepcionBienesContratados == null ? "" : tramitePago.FechaActaEntregaRecepcionBienesContratados.Value.ToShortDateString(),
                    tramitePago.NumActaEntregaRecepcionBienesContratados,
                    tramitePago.FechaRecepcionFacturaBienesContratados == null ? "": tramitePago.FechaRecepcionFacturaBienesContratados.Value.ToShortDateString(),
                    tramitePago.FechaFacturaBienesContratados == null ? "" : tramitePago.FechaFacturaBienesContratados.Value.ToShortDateString(),
                    tramitePago.NumFacturaBienesContratados,
                    tramitePago.FolioInstanciaEjercicioFiscal,
                    tramitePago.OficioSolicitudPagoSefin,
                    tramitePago.FechaOficioSolicitudSefin == null ? "" : tramitePago.FechaOficioSolicitudSefin.Value.ToShortDateString(),
                    tramitePago.NumContrareciboPago.ToString(),
                    tramitePago.NumTransferenciaBancaria,
                    tramitePago.IdTramitePago.ToString()
                    );
            }
            CrystalDecisions.CrystalReports.Engine.ReportDocument repote = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            try
            {
                CrystalDecisions.Shared.ExportFormatType formato = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                repote.Load(Server.MapPath("./../") + "Reportes/CrystalReports/ReporteTramitesPagos.rpt");
                repote.SetDataSource(dtsTramitesPagos);
                repote.ExportToHttpResponse(formato, Response, true, string.Format("TramitePago{0}", ddlAnios.SelectedValue));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #6
0
 public void ProcessRequest(HttpContext context)
 {
     try
     {
         CrystalDecisions.CrystalReports.Engine.ReportDocument doc
             = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
         doc.Load(HttpContext.Current.Server.MapPath("~/Reporting/sample.rpt"));
         ExportOptions options = new ExportOptions();
         options.ExportFormatType = ExportFormatType.PortableDocFormat;
         string contentType = "application/pdf";
         String fileName    = "InterplanReport"; //use for infoXpert upload file name
                                                 //export report
         doc.ExportToHttpResponse(
             options,
             context.Response,
             false,
             null
             );
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #7
0
        protected void Page_Init(object sender, EventArgs e)
        {
            try
            {
                var culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB");
                culture.NumberFormat.CurrencySymbol = string.Empty;
                System.Threading.Thread.CurrentThread.CurrentCulture   = culture;
                System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
                base.InitializeCulture();

                string lcomp = Server.MapPath("~/Facturacion/Electronica/Reportes/Iva_Compras.xsd");
                System.IO.File.Copy(lcomp, @System.IO.Path.GetTempPath() + "Iva_Compras.xsd", true);

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

                bool   HayME      = false;
                string reportPath = "";
                if (Session["monedasExtranjeras"] != null)
                {
                    HayME = (bool)Session["monedasExtranjeras"];
                }
                if (!HayME)
                {
                    reportPath = Server.MapPath("~/Facturacion/Electronica/Reportes/IvaComprasCR.rpt");
                }
                else
                {
                    reportPath = Server.MapPath("~/Facturacion/Electronica/Reportes/IvaComprasMECR.rpt");
                }
                oRpt.Load(reportPath);
                Entidades.IvaCompras ivaCompras = new Entidades.IvaCompras();
                if (Session["ivaCompras"] != null)
                {
                    ivaCompras = (Entidades.IvaCompras)Session["ivaCompras"];
                    DataSet       ds    = new DataSet();
                    XmlSerializer objXS = new XmlSerializer(ivaCompras.GetType());
                    StringWriter  objSW = new StringWriter();
                    objXS.Serialize(objSW, ivaCompras);
                    StringReader objSR = new StringReader(objSW.ToString());
                    ds.ReadXml(objSR);
                    oRpt.SetDataSource(ds);
                }
                else
                {
                    Response.Redirect("~/Facturacion/Electronica/Reportes/IvaComprasFiltros.aspx", true);
                }
                string formatoRptExportar = "";
                if (Session["formatoRptExportar"] != null)
                {
                    formatoRptExportar = (string)Session["formatoRptExportar"];
                }
                if (Session["mostrarFechaYHora"] != null)
                {
                    if ((bool)Session["mostrarFechaYHora"] == false)
                    {
                        oRpt.DataDefinition.FormulaFields["MostrarFechaYHora"].Text = "'N'";
                    }
                }
                oRpt.PrintOptions.PaperSize        = CrystalDecisions.Shared.PaperSize.PaperLetter;
                oRpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
                oRpt.DataDefinition.FormulaFields["RazSoc"].Text = "'" + ((Entidades.Sesion)Session["Sesion"]).Cuit.RazonSocial + "'";
                if (formatoRptExportar == "")
                {
                    CrystalReportViewer1.GroupTreeStyle.ShowLines = false;
                    CrystalReportViewer1.HasToggleGroupTreeButton = false;
                    CrystalReportViewer1.ToolPanelView            = CrystalDecisions.Web.ToolPanelViewType.None;
                    CrystalReportViewer1.ReportSource             = oRpt;
                    CrystalReportViewer1.HasPrintButton           = true;
                }
                else
                {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    sb.Append(ivaCompras.Cuit);
                    sb.Append("-");
                    sb.Append(Convert.ToDateTime(ivaCompras.PeriodoDsd).ToString("yyyyMMdd"));
                    sb.Append("-");
                    sb.Append(Convert.ToDateTime(ivaCompras.PeriodoHst).ToString("yyyyMMdd"));

                    if (formatoRptExportar == "PDF")
                    {
                        CrystalDecisions.Shared.ExportOptions           exportOpts = new CrystalDecisions.Shared.ExportOptions();
                        CrystalDecisions.Shared.PdfRtfWordFormatOptions pdfOpts    = CrystalDecisions.Shared.ExportOptions.CreatePdfRtfWordFormatOptions();
                        exportOpts.ExportFormatType    = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                        exportOpts.ExportFormatOptions = pdfOpts;
                        oRpt.ExportToHttpResponse(exportOpts, Response, true, sb.ToString());
                    }
                    if (formatoRptExportar == "Excel")
                    {
                        CrystalDecisions.Shared.ExportOptions      exportOpts = new CrystalDecisions.Shared.ExportOptions();
                        CrystalDecisions.Shared.ExcelFormatOptions pdfOpts    = CrystalDecisions.Shared.ExportOptions.CreateExcelFormatOptions();
                        exportOpts.ExportFormatType    = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                        exportOpts.ExportFormatOptions = pdfOpts;
                        oRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Excel, Server.MapPath("~/TempExcel/") + sb.ToString() + ".xls");

                        System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                        response.ClearContent();
                        response.Clear();
                        response.ContentType = "application/vnd.ms-excel";
                        response.AddHeader("Content-Disposition", "attachment; filename=" + sb.ToString() + ".xls" + ";");
                        response.TransmitFile(Server.MapPath("~/TempExcel/" + sb.ToString() + ".xls"));
                        response.Flush();
                        response.End();
                    }
                }
            }
            catch (System.Threading.ThreadAbortException)
            {
                Trace.Warn("Thread abortado");
            }
            catch (Exception ex)
            {
                WebForms.Excepciones.Redireccionar(ex, "~/NotificacionDeExcepcion.aspx");
            }
        }
Beispiel #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB");

            culture.NumberFormat.CurrencySymbol = string.Empty;
            System.Threading.Thread.CurrentThread.CurrentCulture   = culture;
            System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
            base.InitializeCulture();

            if (Session["lote"] == null)
            {
                Response.Redirect("~/Inicio.aspx");
            }
            else
            {
                try
                {
                    string lcomp = Server.MapPath("~/Facturacion/Electronica/Reportes/lote_comprobantesT.xsd");
                    System.IO.File.Copy(lcomp, @System.IO.Path.GetTempPath() + "lote_comprobantesT.xsd", true);

                    string imagen = Server.MapPath("~/Facturacion/Electronica/Reportes/Imagen.xsd");
                    System.IO.File.Copy(imagen, @System.IO.Path.GetTempPath() + "Imagen.xsd", true);

                    facturaRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                    string reportPath = Server.MapPath("~/Facturacion/Electronica/Reportes/FacturaT.rpt");
                    facturaRpt.Load(reportPath);

                    FeaEntidades.Turismo.lote_comprobantes lc = (FeaEntidades.Turismo.lote_comprobantes)Session["lote"];
                    AsignarCamposOpcionales(lc);
                    ReemplarResumenImportesMonedaExtranjera(lc);
                    DataSet ds = new DataSet();

                    XmlSerializer objXS = new XmlSerializer(lc.GetType());
                    StringWriter  objSW = new StringWriter();
                    objXS.Serialize(objSW, lc);
                    StringReader objSR = new StringReader(objSW.ToString());
                    ds.ReadXml(objSR);

                    bool original = true;
                    try
                    {
                        original = (bool)Session["EsComprobanteOriginal"];
                        if (original == false)
                        {
                            facturaRpt.DataDefinition.FormulaFields["Borrador"].Text = "'BORRADOR'";
                        }
                    }
                    catch
                    {
                    }

                    facturaRpt.SetDataSource(ds);
                    facturaRpt.PrintOptions.PaperSize        = CrystalDecisions.Shared.PaperSize.PaperLetter;
                    facturaRpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;

                    IncrustarLogo(lc.comprobante[0].cabecera.informacion_vendedor.cuit.ToString(), lc.comprobante[0].cabecera.informacion_comprobante.punto_de_venta.ToString());
                    string cae = lc.comprobante[0].cabecera.informacion_comprobante.cae;
                    if (cae.Replace(" ", string.Empty).Equals(string.Empty))
                    {
                        cae = "99999999999999";
                    }
                    GenerarCodigoBarras(lc.comprobante[0].cabecera.informacion_vendedor.cuit + lc.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString("00") + lc.comprobante[0].cabecera.informacion_comprobante.punto_de_venta.ToString("0000") + cae + System.DateTime.Now.ToString("yyyyMMdd"));
                    AsignarParametros(lc.comprobante[0].resumen.importe_total_factura);

                    facturaRpt.Subreports["impuestos"].DataDefinition.FormulaFields["TipoDeComprobante"].Text = "'" + lc.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString() + "'";
                    facturaRpt.Subreports["resumen"].DataDefinition.FormulaFields["TipoDeComprobante"].Text   = "'" + lc.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString() + "'";

                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    sb.Append(lc.comprobante[0].cabecera.informacion_vendedor.cuit);
                    sb.Append("-");
                    sb.Append(lc.comprobante[0].cabecera.informacion_comprobante.punto_de_venta.ToString("0000"));
                    sb.Append("-");
                    sb.Append(lc.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString("00"));
                    sb.Append("-");
                    sb.Append(lc.comprobante[0].cabecera.informacion_comprobante.numero_comprobante.ToString("00000000"));
                    if (original == false)
                    {
                        sb.Append("-BORRADOR");
                    }

                    CrystalDecisions.Shared.ExportOptions           exportOpts = new CrystalDecisions.Shared.ExportOptions();
                    CrystalDecisions.Shared.PdfRtfWordFormatOptions pdfOpts    = CrystalDecisions.Shared.ExportOptions.CreatePdfRtfWordFormatOptions();
                    exportOpts.ExportFormatType    = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                    exportOpts.ExportFormatOptions = pdfOpts;
                    facturaRpt.ExportToHttpResponse(exportOpts, Response, true, sb.ToString());
                }
                catch (System.Threading.ThreadAbortException)
                {
                    Trace.Warn("Thread abortado");
                }
                catch (Exception ex)
                {
                    RN.Sesion.GrabarLogTexto(Server.MapPath("~/Consultar.txt"), "Reporte: " + ex.Message + " " + ex.StackTrace);
                    throw new Exception(ex.Message);
                    //WebForms.Excepciones.Redireccionar(ex, "~/Excepciones/Excepciones.aspx");
                }
            }
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            try
            {
                var culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB");
                culture.NumberFormat.CurrencySymbol = string.Empty;
                System.Threading.Thread.CurrentThread.CurrentCulture = culture;
                System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
                base.InitializeCulture();
                
                string lcomp = Server.MapPath("~/Facturacion/Electronica/Reportes/Iva_Ventas.xsd");
                System.IO.File.Copy(lcomp, @System.IO.Path.GetTempPath() + "Iva_Ventas.xsd", true);

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

                bool HayME = false;
                string reportPath = "";
                if (Session["monedasExtranjeras"] != null)
                {
                    HayME = (bool)Session["monedasExtranjeras"];
                }
                if (!HayME)
                {
                    reportPath = Server.MapPath("~/Facturacion/Electronica/Reportes/IvaVentasCR.rpt");
                }
                else
                {
                    reportPath = Server.MapPath("~/Facturacion/Electronica/Reportes/IvaVentasMECR.rpt");
                }
                oRpt.Load(reportPath);
                Entidades.IvaVentas ivaVentas = new Entidades.IvaVentas();
                if (Session["ivaVentas"] != null)
                {
                    ivaVentas = (Entidades.IvaVentas)Session["ivaVentas"];
                    DataSet ds = new DataSet();
                    XmlSerializer objXS = new XmlSerializer(ivaVentas.GetType());
                    StringWriter objSW = new StringWriter();
                    objXS.Serialize(objSW, ivaVentas);
                    StringReader objSR = new StringReader(objSW.ToString());
                    ds.ReadXml(objSR);
                    oRpt.SetDataSource(ds);
                }
                else
                {
                    Response.Redirect("~/Facturacion/Electronica/Reportes/IvaVentasFiltros.aspx", true);
                }
                string formatoRptExportar = "";
                if (Session["formatoRptExportar"] != null)
                {
                    formatoRptExportar = (string)Session["formatoRptExportar"];
                }
                if (Session["mostrarFechaYHora"] != null)
                {
                    if ((bool)Session["mostrarFechaYHora"] == false)
                    {
                        oRpt.DataDefinition.FormulaFields["MostrarFechaYHora"].Text = "'N'";
                    }
                }
                oRpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLetter;
                oRpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
                oRpt.DataDefinition.FormulaFields["RazSoc"].Text = "'" + ((Entidades.Sesion)Session["Sesion"]).Cuit.RazonSocial + "'";
                if (formatoRptExportar == "")
                {
                    CrystalReportViewer1.GroupTreeStyle.ShowLines = false;
                    CrystalReportViewer1.HasToggleGroupTreeButton = false;
                    CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
                    CrystalReportViewer1.ReportSource = oRpt;
                    CrystalReportViewer1.HasPrintButton = true;
                }
                else
                {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    sb.Append(ivaVentas.Cuit);
                    sb.Append("-");
                    sb.Append(Convert.ToDateTime(ivaVentas.PeriodoDsd).ToString("yyyyMMdd"));
                    sb.Append("-");
                    sb.Append(Convert.ToDateTime(ivaVentas.PeriodoHst).ToString("yyyyMMdd"));

                    if (formatoRptExportar == "PDF")
                    {
                        CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();
                        CrystalDecisions.Shared.PdfRtfWordFormatOptions pdfOpts = CrystalDecisions.Shared.ExportOptions.CreatePdfRtfWordFormatOptions();
                        exportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                        exportOpts.ExportFormatOptions = pdfOpts;
                        oRpt.ExportToHttpResponse(exportOpts, Response, true, sb.ToString());
                    }
                    if (formatoRptExportar == "Excel")
                    {
                        CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();
                        CrystalDecisions.Shared.ExcelFormatOptions pdfOpts = CrystalDecisions.Shared.ExportOptions.CreateExcelFormatOptions();
                        exportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                        exportOpts.ExportFormatOptions = pdfOpts;
                        oRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Excel, Server.MapPath("~/TempExcel/") + sb.ToString() + ".xls");
                        
                        System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                        response.ClearContent();
                        response.Clear();
                        response.ContentType = "application/vnd.ms-excel";
                        response.AddHeader("Content-Disposition", "attachment; filename=" + sb.ToString() + ".xls" + ";");
                        response.TransmitFile(Server.MapPath("~/TempExcel/" + sb.ToString() + ".xls"));
                        response.Flush();
                        response.End();  
                    }
                }
            }
            catch (System.Threading.ThreadAbortException)
            {
                Trace.Warn("Thread abortado");
            }
            catch (Exception ex)
            {
                WebForms.Excepciones.Redireccionar(ex, "~/NotificacionDeExcepcion.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB");
            culture.NumberFormat.CurrencySymbol = string.Empty;
            System.Threading.Thread.CurrentThread.CurrentCulture = culture;
            System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
            base.InitializeCulture();

            if (Session["lote"] == null)
            {
                Response.Redirect("~/Inicio.aspx");
            }
            else
            {
                try
                {
                    string lcomp = Server.MapPath("~/Facturacion/Electronica/Reportes/lote_comprobantes.xsd");
                    System.IO.File.Copy(lcomp, @System.IO.Path.GetTempPath() + "lote_comprobantes.xsd", true);

                    string imagen = Server.MapPath("~/Facturacion/Electronica/Reportes/Imagen.xsd");
                    System.IO.File.Copy(imagen, @System.IO.Path.GetTempPath() + "Imagen.xsd", true);

                    facturaRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                    string reportPath = Server.MapPath("~/Facturacion/Electronica/Reportes/Factura.rpt");
                    facturaRpt.Load(reportPath);

                    FeaEntidades.InterFacturas.lote_comprobantes lc = (FeaEntidades.InterFacturas.lote_comprobantes)Session["lote"];
                    AsignarCamposOpcionales(lc);
					ReemplarResumenImportesMonedaExtranjera(lc);
					DataSet ds = new DataSet();

                    XmlSerializer objXS = new XmlSerializer(lc.GetType());
                    StringWriter objSW = new StringWriter();
                    objXS.Serialize(objSW, lc);
                    StringReader objSR = new StringReader(objSW.ToString());
                    ds.ReadXml(objSR);

                    bool original = true;
                    try
                    {
                        original = (bool)Session["EsComprobanteOriginal"];
                        if (original == false)
                        {
                            facturaRpt.DataDefinition.FormulaFields["Borrador"].Text = "'BORRADOR'";
                        }
                    }
                    catch
                    { 
                    }

					facturaRpt.SetDataSource(ds);
                    facturaRpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLetter;
                    facturaRpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;

                    IncrustarLogo(lc.cabecera_lote.cuit_vendedor.ToString(), lc.comprobante[0].cabecera.informacion_comprobante.punto_de_venta.ToString());
					string cae = lc.comprobante[0].cabecera.informacion_comprobante.cae;
					if (cae.Replace(" ",string.Empty).Equals(string.Empty))
					{
						cae = "99999999999999";
					}
					GenerarCodigoBarras(lc.cabecera_lote.cuit_vendedor + lc.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString("00") + lc.comprobante[0].cabecera.informacion_comprobante.punto_de_venta.ToString("0000") + cae +System.DateTime.Now.ToString("yyyyMMdd"));
					AsignarParametros(lc.comprobante[0].resumen.importe_total_factura);

                    facturaRpt.Subreports["impuestos"].DataDefinition.FormulaFields["TipoDeComprobante"].Text = "'" + lc.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString() + "'"; 
                    facturaRpt.Subreports["resumen"].DataDefinition.FormulaFields["TipoDeComprobante"].Text = "'" + lc.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString() + "'"; 

                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    sb.Append(lc.cabecera_lote.cuit_vendedor);
                    sb.Append("-");
                    sb.Append(lc.cabecera_lote.punto_de_venta.ToString("0000"));
                    sb.Append("-");
                    sb.Append(lc.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString("00"));
                    sb.Append("-");
                    sb.Append(lc.comprobante[0].cabecera.informacion_comprobante.numero_comprobante.ToString("00000000"));
                    if (original == false)
                    {
                        sb.Append("-BORRADOR");
                    }

                    CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();
                    CrystalDecisions.Shared.PdfRtfWordFormatOptions pdfOpts = CrystalDecisions.Shared.ExportOptions.CreatePdfRtfWordFormatOptions();
                    exportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                    exportOpts.ExportFormatOptions = pdfOpts;
                    facturaRpt.ExportToHttpResponse(exportOpts, Response, true, sb.ToString());
                }
                catch (System.Threading.ThreadAbortException)
                {
                    Trace.Warn("Thread abortado");
                }
                catch (Exception ex)
                {
                    RN.Sesion.GrabarLogTexto(Server.MapPath("~/Consultar.txt"), "Reporte: " + ex.Message + " " + ex.StackTrace);
                    throw new Exception(ex.Message); 
                    //WebForms.Excepciones.Redireccionar(ex, "~/Excepciones/Excepciones.aspx");
                }
            }
        }
Beispiel #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["lote"] == null)
            {
                Response.Redirect("~/Inicio.aspx");
            }
            else
            {
                try
                {
                    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
                    
                    string lcomp = Server.MapPath("~/Facturacion/Electronica/Reportes/lote_comprobantes.xsd");
                    System.IO.File.Copy(lcomp, @System.IO.Path.GetTempPath() + "lote_comprobantes.xsd", true);

                    string imagen = Server.MapPath("~/Facturacion/Electronica/Reportes/Imagen.xsd");
                    System.IO.File.Copy(imagen, @System.IO.Path.GetTempPath() + "Imagen.xsd", true);

                    facturaRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                    string reportPath = Server.MapPath("~/Facturacion/Electronica/Reportes/Factura.rpt");
                    facturaRpt.Load(reportPath);

                    FeaEntidades.InterFacturas.lote_comprobantes lc = (FeaEntidades.InterFacturas.lote_comprobantes)Session["lote"];
                    AsignarCamposOpcionales(lc);
					ReemplarResumenImportesMonedaExtranjera(lc);
					DataSet ds = new DataSet();

                    XmlSerializer objXS = new XmlSerializer(lc.GetType());
                    StringWriter objSW = new StringWriter();
                    objXS.Serialize(objSW, lc);
                    StringReader objSR = new StringReader(objSW.ToString());
                    ds.ReadXml(objSR);

					
					facturaRpt.SetDataSource(ds);
                    facturaRpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperLetter;
                    facturaRpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;

                    IncrustarLogo();
					string cae = lc.comprobante[0].cabecera.informacion_comprobante.cae;
					if (cae.Replace(" ",string.Empty).Equals(string.Empty))
					{
						cae = "99999999999999";
					}
					GenerarCodigoBarras(lc.cabecera_lote.cuit_vendedor + lc.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString("00") + lc.comprobante[0].cabecera.informacion_comprobante.punto_de_venta.ToString("0000") + cae +System.DateTime.Now.ToString("yyyyMMdd"));
					AsignarParametros(lc.comprobante[0].resumen.importe_total_factura);

                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    sb.Append(lc.cabecera_lote.cuit_vendedor);
                    sb.Append("-");
                    sb.Append(lc.cabecera_lote.punto_de_venta.ToString("0000"));
                    sb.Append("-");
                    sb.Append(lc.comprobante[0].cabecera.informacion_comprobante.tipo_de_comprobante.ToString("00"));
                    sb.Append("-");
                    sb.Append(lc.comprobante[0].cabecera.informacion_comprobante.numero_comprobante.ToString("00000000"));

                    CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();
                    CrystalDecisions.Shared.PdfRtfWordFormatOptions pdfOpts = CrystalDecisions.Shared.ExportOptions.CreatePdfRtfWordFormatOptions();
                    exportOpts.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                    exportOpts.ExportFormatOptions = pdfOpts;
                    facturaRpt.ExportToHttpResponse(exportOpts, Response, true, sb.ToString());


                }
                catch (System.Threading.ThreadAbortException)
                {
                    Trace.Warn("Thread abortado");
                }
                catch (Exception ex)
                {
                    CedeiraUIWebForms.Excepciones.Redireccionar(ex, "~/Excepciones/Excepcion.aspx");
                }
            }
        }