Mejoras en descarga de paquetes de egresos

This commit is contained in:
HECTOR RODRIGUEZ
2021-04-29 20:55:05 -07:00
parent c3747e4b64
commit f2b3d29d1f
2 changed files with 96 additions and 88 deletions

View File

@@ -84,7 +84,6 @@
</ContentTemplate> </ContentTemplate>
<Triggers> <Triggers>
<asp:PostBackTrigger ControlID="LnkImprimirPDF" />
<asp:PostBackTrigger ControlID="LnkComprobante" /> <asp:PostBackTrigger ControlID="LnkComprobante" />
</Triggers> </Triggers>
</asp:UpdatePanel> </asp:UpdatePanel>

View File

@@ -544,7 +544,7 @@ Partial Class ContabilidadC_RegPrePoliza
If CveConceptoContable.Contiene(68) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}", e.Row.DBCampo("CveMovimientoAlmacen")) If CveConceptoContable.Contiene(68) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}", e.Row.DBCampo("CveMovimientoAlmacen"))
If CveConceptoContable.Contiene(30, 204) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE")) If CveConceptoContable.Contiene(30, 204) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE"))
If CveConceptoContable.Contiene(30) AndAlso UsuarioActual.CveRol = 1 Then If CveConceptoContable.Contiene(30) Then
LnkImprimirPDF.Visible = True LnkImprimirPDF.Visible = True
LnkComprobante.Visible = True LnkComprobante.Visible = True
CveIE = e.Row.DBCampo("CveIE").ToString.ToEntero CveIE = e.Row.DBCampo("CveIE").ToString.ToEntero
@@ -931,7 +931,6 @@ Partial Class ContabilidadC_RegPrePoliza
If e.Row.DataKey("CveConcepto").ToEntero.Contiene(30) Then If e.Row.DataKey("CveConcepto").ToEntero.Contiene(30) Then
e.Row.FCLinkButton("ImgBancos").Visible = True e.Row.FCLinkButton("ImgBancos").Visible = True
If CveTipoTransaccion > 0 And CveCuenta > 0 And Folio.Length > 0 And ImporteDocumento > 0 And Beneficiario.Length > 0 Then If CveTipoTransaccion > 0 And CveCuenta > 0 And Folio.Length > 0 And ImporteDocumento > 0 And Beneficiario.Length > 0 Then
e.Row.FCLinkButton("ImgBancos").CssClass = "btn btn-circle btn-sm green" e.Row.FCLinkButton("ImgBancos").CssClass = "btn btn-circle btn-sm green"
End If End If
@@ -1766,19 +1765,16 @@ Partial Class ContabilidadC_RegPrePoliza
End Sub End Sub
Protected Sub LnkImprimirPDF_Click(sender As Object, e As EventArgs) Protected Sub LnkImprimirPDF_Click(sender As Object, e As EventArgs)
Dim pdf() As Byte
Dim filtro() As String = {"CveCompra", "CveIE", "CveConceptoContable"} Dim filtro() As String = {"CveCompra", "CveIE", "CveConceptoContable"}
Dim filtroComplemento() As String = {"CveIE"} Dim filtroComplemento() As String = {"CveIE"}
Dim Pathpdf As New List(Of String) Dim Pathpdf As New List(Of String)
Dim nombre As String = "recibo"
Dim pdfs = New List(Of Byte()) Dim pdfs = New List(Of Byte())
Dim Path As String Dim Path As String
Dim Factura() As Byte
Dim dt As DataTable = DtMovimientos.FiltraParametros("", "", filtro) Dim dt As DataTable = DtMovimientos.FiltraParametros("", "", filtro)
Dim ObjCompra As New ClsCompras Dim ObjCompra As New ClsCompras
Dim ObjIE As New ClsBancos() Dim ObjIE As New ClsBancos()
Dim i As Integer = 0
Dim pathPoliza As String Dim pathPoliza As String
Dim TieneComprobante As Boolean = True
Try Try
@@ -1789,70 +1785,91 @@ Partial Class ContabilidadC_RegPrePoliza
End If End If
For Each Row As DataRow In dt.Rows For Each Row As DataRow In dt.Rows
If Row("CveConceptoContable").ToString.ToEntero = 30 Then If TieneComprobante Then
If Row("CveIE").ToString.ToEntero > 0 Then If Row("CveConceptoContable").ToString.ToEntero = 30 Then
If ObjIE.GetBancosIE(Row("CveIE").ToString.ToEntero, UsuarioActual.CveEmpresa) Then If Row("CveIE").ToString.ToEntero > 0 Then
If ObjIE.DtResultados.Rows.Count > 0 Then If ObjIE.GetBancosIE(Row("CveIE").ToString.ToEntero, UsuarioActual.CveEmpresa) Then
Path = String.Format("{0}IE\{1}", UsuarioActual.Empresa.Ruta, ObjIE.Comprobante.ToString) If ObjIE.DtResultados.Rows.Count > 0 Then
If File.Exists(Path) Then Path = String.Format("{0}IE\{1}", UsuarioActual.Empresa.Ruta, ObjIE.Comprobante.ToString)
Dim formato As String = System.IO.Path.GetExtension(Path) If File.Exists(Path) Then
If formato.ToLower.Contiene(".jpg", ".png", ".jpeg") Then TieneComprobante = True
Dim ComprobantePDF As String = String.Format("{0}\{1}\comprobante.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick) Dim formato As String = System.IO.Path.GetExtension(Path)
Using crea_archivo = New iTextSharp.text.Document If formato.ToLower.Contiene(".jpg", ".png", ".jpeg") Then
PdfWriter.GetInstance(crea_archivo, New FileStream(ComprobantePDF, FileMode.Create)) Dim ComprobantePDF As String = String.Format("{0}\{1}\comprobante.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick)
crea_archivo.Open() Using crea_archivo = New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 18, 18, 18, 18)
Dim image As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Path) PdfWriter.GetInstance(crea_archivo, New FileStream(ComprobantePDF, FileMode.Create))
crea_archivo.Add(image) crea_archivo.Open()
End Using Dim image As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Path)
Pathpdf.Add(ComprobantePDF) If image.Height > image.Width Then
Dim percentage As Double = 0.0F
percentage = 700 / image.Height
image.ScalePercent(percentage * 100)
Else
Dim percentage As Double = 0.0F
percentage = 540 / image.Width
image.ScalePercent(percentage * 100)
End If
crea_archivo.Add(image)
End Using
Pathpdf.Add(ComprobantePDF)
Else
Pathpdf.Add(Path)
End If
Else Else
Pathpdf.Add(Path) TieneComprobante = False
Exit For
End If End If
End If
End If
End If
End If
If Row("CveConceptoContable").ToString.ToEntero.Contiene(17, 309, 312, 308) Then
If ObjCompra.GetCompras(Row("CveCompra").ToString.ToEntero, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then
If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then
Dim dr As DataRow = ObjCompra.DtResultados.Rows(0)
Dim RFC As String = dr("RFC").ToString
Dim CveFactura As String = dr("CveFactura").ToString
Path = String.Format("{0}Compras\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, RFC, CveFactura)
If File.Exists(Path) Then
Pathpdf.Add(Path)
End If End If
End If End If
End If End If
End If End If
End If End If
If Row("CveConceptoContable").ToString.ToEntero.Contiene(17, 309, 312, 308) Then Next
If ObjCompra.GetCompras(Row("CveCompra").ToString.ToEntero, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then
If TieneComprobante Then
dt = DtMovimientos.FiltraParametros("", "", filtroComplemento)
For Each Row As DataRow In dt.Rows
If ObjCompra.GetCompraComplementoPago(-1, UsuarioActual.CveEmpresa, Row("CveIE").ToString.ToEntero) Then
Console.WriteLine(Row("CveIE").ToString)
If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then
Dim dr As DataRow = ObjCompra.DtResultados.Rows(0) Dim dr As DataRow = ObjCompra.DtResultados.Rows(0)
Dim RFC As String = dr("RFC").ToString Dim RFC As String = dr("RFCde").ToString
Dim CveFactura As String = dr("CveFactura").ToString Dim CveFactura As String = dr("CveFactura").ToString
Path = String.Format("{0}Compras\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, RFC, CveFactura) Console.WriteLine(RFC & CveFactura)
If File.Exists(Path) Then If CveFactura <> "" Then
Path = String.Format("{0}Compras\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, RFC, CveFactura)
Pathpdf.Add(Path) Console.WriteLine(Path)
If File.Exists(Path) Then
Pathpdf.Add(Path)
End If
End If End If
End If End If
End If End If
End If Next
Next
dt = DtMovimientos.FiltraParametros("", "", filtroComplemento) MergePdfFiles(Pathpdf.ToArray)
For Each Row As DataRow In dt.Rows If File.Exists(pathPoliza) Then
If ObjCompra.GetCompraComplementoPago(-1, UsuarioActual.CveEmpresa, Row("CveIE").ToString.ToEntero) Then Directory.Delete(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick), True)
If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then
Dim dr As DataRow = ObjCompra.DtResultados.Rows(0)
Dim RFC As String = dr("RFCde").ToString
Dim CveFactura As String = dr("CveFactura").ToString
If CveFactura <> "" Then
Path = String.Format("{0}Compras\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, RFC, CveFactura)
If File.Exists(Path) Then
Pathpdf.Add(Path)
End If
End If
End If
End If End If
Next Else
Alert("No se tiene cargado comprobante de pago", TipoMensaje.MsgAdvertencia)
MergePdfFiles(Pathpdf.ToArray)
If File.Exists(pathPoliza) Then
Directory.Delete(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick), True)
End If End If
Catch ex As Exception Catch ex As Exception
Alert("Error al descargar el paquete", TipoMensaje.MsgError) Alert("Error al descargar el paquete", TipoMensaje.MsgError)
End Try End Try
@@ -1870,42 +1887,34 @@ Partial Class ContabilidadC_RegPrePoliza
If ObjConta.GetPrePolizasDetalle(CvePrePoliza) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then If ObjConta.GetPrePolizasDetalle(CvePrePoliza) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
Dim dtVC As DataTable Dim dtVC As DataTable
Dim dr As DataRow Dim dr As DataRow
dtVC = ObjConta.DtResultados dtVC = ObjConta.DtResultados
dr = dtVC.Rows(0) dr = dtVC.Rows(0)
Dim ruta As String = "" Dim ruta As String = ""
params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("TipoPoliza", dr("TipoPoliza").ToString))
params.Add(New ReportParameter("TipoPoliza", dr("TipoPoliza").ToString)) params.Add(New ReportParameter("Finicio", dr("Fecha").ToString.ToDate.ToShortDateString))
params.Add(New ReportParameter("Finicio", dr("Fecha").ToString.ToDate.ToShortDateString)) params.Add(New ReportParameter("FFin", dr("Fecha").ToString.ToDate.ToShortDateString))
params.Add(New ReportParameter("FFin", dr("Fecha").ToString.ToDate.ToShortDateString)) params.Add(New ReportParameter("Fecha", dr("Fecha").ToString.ToDate.ToShortDateString))
params.Add(New ReportParameter("Fecha", dr("Fecha").ToString.ToDate.ToShortDateString)) 'params.Add(New ReportParameter("Nombre", dr("Cuenta").ToString))
'params.Add(New ReportParameter("Nombre", dr("Cuenta").ToString)) 'params.Add(New ReportParameter("Cuenta", dr("Codigo").ToString))
'params.Add(New ReportParameter("Cuenta", dr("Codigo").ToString)) params.Add(New ReportParameter("Numero", dr("FolioPoliza").ToString))
params.Add(New ReportParameter("Numero", dr("FolioPoliza").ToString)) params.Add(New ReportParameter("Moneda", ""))
params.Add(New ReportParameter("Moneda", "")) params.Add(New ReportParameter("CodigoPostal", ""))
params.Add(New ReportParameter("CodigoPostal", "")) If UsuarioActual.CveEmpresa = 119 Then
params.Add(New ReportParameter("UsuarioRegistro", GlobalDTUsuarios(dr("CveUsuario").ToString.ToEntero).FiltroPrimeroValor("Nombre")))
If UsuarioActual.CveEmpresa = 119 Then End If
params.Add(New ReportParameter("UsuarioRegistro", GlobalDTUsuarios(dr("CveUsuario").ToString.ToEntero).FiltroPrimeroValor("Nombre"))) If Archivo.Exists Then
End If ruta = UsuarioActual.Empresa.Ruta & "Formatos/Polizas.rdlc"
Else
If Archivo.Exists Then ruta = "Empresas/Grales/Formatos/Polizas.rdlc"
ruta = UsuarioActual.Empresa.Ruta & "Formatos/Polizas.rdlc" End If
Else Bytes = StreamPDF(ruta, dtVC, params, "ppoliza")
ruta = "Empresas/Grales/Formatos/Polizas.rdlc" If Not File.Exists(String.Format("{0}{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString)) Then
End If DirectoryExistsCreate(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick))
File.WriteAllBytes(String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString), Bytes)
Bytes = StreamPDF(ruta, dtVC, params, "ppoliza") End If
If Not File.Exists(String.Format("{0}{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString)) Then
DirectoryExistsCreate(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick))
File.WriteAllBytes(String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString), Bytes)
End If
Return String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString)
End If End If
Return String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString)
ObjConta.Dispose() ObjConta.Dispose()
End Function End Function