Impresion de excel en estados de cuenta stimultsoft
This commit is contained in:
@@ -6118,7 +6118,12 @@ Public Class ClsPaginas
|
|||||||
rds.Value = DtDatos
|
rds.Value = DtDatos
|
||||||
lrds.Add(rds)
|
lrds.Add(rds)
|
||||||
|
|
||||||
ImprimirbytesPDF(StreamBytesStimulsoft("Facturas", RutaReporte, lrds, Parametros, NombreArchivo:=NombreArchivo, Formato:="PDF"), NombreArchivo, Formato, Content_Disposition:=Content_Disposition)
|
Dim Extension = "pdf"
|
||||||
|
If Formato.ToLower() = "excel" Then
|
||||||
|
Extension = "xlsx"
|
||||||
|
End If
|
||||||
|
|
||||||
|
ImprimirbytesPDF(StreamBytesStimulsoft("Facturas", RutaReporte, lrds, Parametros, NombreArchivo:=NombreArchivo, Formato:=Formato), NombreArchivo, Formato, Content_Disposition:=Content_Disposition, Extension:=Extension)
|
||||||
End Sub
|
End Sub
|
||||||
Public Sub ImprimirPDFMultiDS(RutaReporte As String, lrds As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional RDSName As String = "DataSet1", Optional MR As ReportViewer = Nothing)
|
Public Sub ImprimirPDFMultiDS(RutaReporte As String, lrds As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional RDSName As String = "DataSet1", Optional MR As ReportViewer = Nothing)
|
||||||
ImprimirPDF(RutaReporte, lrds, Parametros, NombreArchivo, Formato, MR)
|
ImprimirPDF(RutaReporte, lrds, Parametros, NombreArchivo, Formato, MR)
|
||||||
@@ -6582,10 +6587,9 @@ Public Class ClsPaginas
|
|||||||
''' <param name="NombreArchivo"></param>
|
''' <param name="NombreArchivo"></param>
|
||||||
''' <param name="Formato"></param>
|
''' <param name="Formato"></param>
|
||||||
''' <remarks></remarks>
|
''' <remarks></remarks>
|
||||||
Public Sub ImprimirbytesPDF(bytes As Byte(), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional Descarga As Boolean = False, Optional Content_Disposition As String = "attachment")
|
Public Sub ImprimirbytesPDF(bytes As Byte(), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional Descarga As Boolean = False, Optional Content_Disposition As String = "attachment", Optional Extension As String = "")
|
||||||
'limpio ReportViwer
|
'limpio ReportViwer
|
||||||
Dim mimeType As String = Nothing
|
Dim mimeType As String = Nothing
|
||||||
Dim extension As String = Nothing
|
|
||||||
|
|
||||||
'If Descarga Then
|
'If Descarga Then
|
||||||
' Try
|
' Try
|
||||||
@@ -6610,7 +6614,15 @@ Public Class ClsPaginas
|
|||||||
Response.ContentType = mimeType
|
Response.ContentType = mimeType
|
||||||
End If
|
End If
|
||||||
Response.ClearHeaders()
|
Response.ClearHeaders()
|
||||||
Response.AddHeader("content-disposition", String.Format("{0}; filename=""{1}.{2}""", Content_Disposition, NombreArchivo, If(Formato = "PDF", "pdf", "xls")))
|
|
||||||
|
Dim fileExtension As String = ""
|
||||||
|
If Not String.IsNullOrEmpty(extension) Then
|
||||||
|
fileExtension = extension
|
||||||
|
Else
|
||||||
|
fileExtension = If(Formato = "PDF", "pdf", "xls")
|
||||||
|
End If
|
||||||
|
|
||||||
|
Response.AddHeader("content-disposition", String.Format("{0}; filename=""{1}.{2}""", Content_Disposition, NombreArchivo, fileExtension))
|
||||||
Response.BinaryWrite(bytes) ' create the file
|
Response.BinaryWrite(bytes) ' create the file
|
||||||
Response.Flush() ' send it to the client to download
|
Response.Flush() ' send it to the client to download
|
||||||
bytes = Nothing
|
bytes = Nothing
|
||||||
|
|||||||
@@ -4249,7 +4249,23 @@ Partial Class Clientes
|
|||||||
Try
|
Try
|
||||||
Dim File As Byte()
|
Dim File As Byte()
|
||||||
If Archivo.Exists Then
|
If Archivo.Exists Then
|
||||||
File = ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato)
|
Dim ArchivoSti As New System.IO.FileInfo(String.Format("{0}Formatos/RepClientesCxC.mrt", UsuarioActual.Empresa.Ruta))
|
||||||
|
If ArchivoSti.Exists Then
|
||||||
|
Dim listass As New List(Of ReportParameter)
|
||||||
|
For Each item As CrystalParametro In lista
|
||||||
|
listass.Add(New ReportParameter(item.Nombre, item.Valor.ToString()))
|
||||||
|
Next
|
||||||
|
|
||||||
|
Dim lrds As New List(Of ReportDataSource)
|
||||||
|
Dim rds As New ReportDataSource
|
||||||
|
rds.Name = "Datos"
|
||||||
|
rds.Value = DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha")
|
||||||
|
lrds.Add(rds)
|
||||||
|
|
||||||
|
File = StreamBytesStimulsoft("Facturas", $"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.mrt", lrds, listass, NombreArchivo:="Estado de cuenta", Formato:=Formato)
|
||||||
|
Else
|
||||||
|
File = ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato)
|
||||||
|
End If
|
||||||
Else
|
Else
|
||||||
File = ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato)
|
File = ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato)
|
||||||
End If
|
End If
|
||||||
@@ -4282,7 +4298,6 @@ Partial Class Clientes
|
|||||||
Alert("El correo se envió con éxito", TipoMensaje.MsgInformacion)
|
Alert("El correo se envió con éxito", TipoMensaje.MsgInformacion)
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
Alert("Ocurrió un error al enviar el correo", TipoMensaje.MsgAdvertencia)
|
Alert("Ocurrió un error al enviar el correo", TipoMensaje.MsgAdvertencia)
|
||||||
|
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
@@ -4358,6 +4373,56 @@ Partial Class Clientes
|
|||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Public Sub ImprimirExcelStimulsoft(RutaReporte As String, DtDatos As DataTable, Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional RDSName As String = "Datos", Optional Content_Disposition As String = "attachment")
|
||||||
|
Dim lrds As New List(Of ReportDataSource)
|
||||||
|
Dim rds As New ReportDataSource
|
||||||
|
rds.Name = RDSName
|
||||||
|
rds.Value = DtDatos
|
||||||
|
lrds.Add(rds)
|
||||||
|
|
||||||
|
ImprimirbytesExcel(StreamBytesStimulsoft("Facturas", RutaReporte, lrds, Parametros, NombreArchivo:=NombreArchivo, Formato:="EXCEL"), NombreArchivo, "EXCEL", Content_Disposition:=Content_Disposition)
|
||||||
|
End Sub
|
||||||
|
Public Sub ImprimirbytesExcel(bytes As Byte(), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional Descarga As Boolean = False, Optional Content_Disposition As String = "attachment")
|
||||||
|
'limpio ReportViwer
|
||||||
|
Dim mimeType As String = Nothing
|
||||||
|
Dim extension As String = Nothing
|
||||||
|
|
||||||
|
'If Descarga Then
|
||||||
|
' Try
|
||||||
|
' bytes = bytes
|
||||||
|
' File.WriteAllBytes(String.Format("{0}PDF/whatever.gif", UsuarioActual.Empresa.Ruta), img)
|
||||||
|
' Catch ex As Exception
|
||||||
|
' If UsuarioActual.CveRol = 1 Then
|
||||||
|
' Alert(ex.Message, TipoMensaje.MsgAdvertencia)
|
||||||
|
' Else
|
||||||
|
' Alert("Ocurrió un error al generar la descarga. Favor de contactar a soporte tecnico cod'IMPDFclspag'", TipoMensaje.MsgAdvertencia)
|
||||||
|
' End If
|
||||||
|
' End Try
|
||||||
|
'End If
|
||||||
|
|
||||||
|
Try
|
||||||
|
bytes = bytes
|
||||||
|
Response.Buffer = True
|
||||||
|
Response.Clear()
|
||||||
|
Response.ContentType = "application/vnd.ms-excel"
|
||||||
|
Response.ClearHeaders()
|
||||||
|
Response.AddHeader("content-disposition", String.Format("{0}; filename=""{1}.{2}""", Content_Disposition, NombreArchivo, If(Formato = "PDF", "pdf", "xlsx")))
|
||||||
|
Response.BinaryWrite(bytes) ' create the file
|
||||||
|
Response.Flush() ' send it to the client to download
|
||||||
|
bytes = Nothing
|
||||||
|
HttpContext.Current.Response.SuppressContent = True
|
||||||
|
HttpContext.Current.ApplicationInstance.CompleteRequest()
|
||||||
|
'HttpContext.Current.Response.End()
|
||||||
|
Catch ex As Exception
|
||||||
|
|
||||||
|
If UsuarioActual.CveRol = 1 Then
|
||||||
|
Alert($"Error: {ex.Message} | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))}", TipoMensaje.MsgAdvertencia)
|
||||||
|
Else
|
||||||
|
Alert("Ocurrió un error al generar la descarga. Favor de contactar a soporte tecnico cod:'IMPDFclspag'", TipoMensaje.MsgAdvertencia)
|
||||||
|
End If
|
||||||
|
End Try
|
||||||
|
End Sub
|
||||||
Private Sub MandaCorreoEstadoCuenta(CveUsuario As Integer, CveEmpresa As Integer, CveCliente As Integer, File As Byte(), Para As String, Asunto As String, Body As String, Optional GuardarBitacora As Boolean = False)
|
Private Sub MandaCorreoEstadoCuenta(CveUsuario As Integer, CveEmpresa As Integer, CveCliente As Integer, File As Byte(), Para As String, Asunto As String, Body As String, Optional GuardarBitacora As Boolean = False)
|
||||||
|
|
||||||
Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para)
|
Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para)
|
||||||
|
|||||||
Reference in New Issue
Block a user