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,27 +1785,39 @@ 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 TieneComprobante Then
If Row("CveConceptoContable").ToString.ToEntero = 30 Then If Row("CveConceptoContable").ToString.ToEntero = 30 Then
If Row("CveIE").ToString.ToEntero > 0 Then If Row("CveIE").ToString.ToEntero > 0 Then
If ObjIE.GetBancosIE(Row("CveIE").ToString.ToEntero, UsuarioActual.CveEmpresa) Then If ObjIE.GetBancosIE(Row("CveIE").ToString.ToEntero, UsuarioActual.CveEmpresa) Then
If ObjIE.DtResultados.Rows.Count > 0 Then If ObjIE.DtResultados.Rows.Count > 0 Then
Path = String.Format("{0}IE\{1}", UsuarioActual.Empresa.Ruta, ObjIE.Comprobante.ToString) Path = String.Format("{0}IE\{1}", UsuarioActual.Empresa.Ruta, ObjIE.Comprobante.ToString)
If File.Exists(Path) Then If File.Exists(Path) Then
TieneComprobante = True
Dim formato As String = System.IO.Path.GetExtension(Path) Dim formato As String = System.IO.Path.GetExtension(Path)
If formato.ToLower.Contiene(".jpg", ".png", ".jpeg") Then If formato.ToLower.Contiene(".jpg", ".png", ".jpeg") Then
Dim ComprobantePDF As String = String.Format("{0}\{1}\comprobante.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick) Dim ComprobantePDF As String = String.Format("{0}\{1}\comprobante.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick)
Using crea_archivo = New iTextSharp.text.Document Using crea_archivo = New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 18, 18, 18, 18)
PdfWriter.GetInstance(crea_archivo, New FileStream(ComprobantePDF, FileMode.Create)) PdfWriter.GetInstance(crea_archivo, New FileStream(ComprobantePDF, FileMode.Create))
crea_archivo.Open() crea_archivo.Open()
Dim image As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Path) Dim image As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Path)
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) crea_archivo.Add(image)
End Using End Using
Pathpdf.Add(ComprobantePDF) Pathpdf.Add(ComprobantePDF)
Else Else
Pathpdf.Add(Path) Pathpdf.Add(Path)
End If End If
Else
TieneComprobante = False
Exit For
End If End If
End If End If
End If End If
@@ -1829,17 +1837,22 @@ Partial Class ContabilidadC_RegPrePoliza
End If End If
End If End If
End If End If
End If
Next Next
If TieneComprobante Then
dt = DtMovimientos.FiltraParametros("", "", filtroComplemento) dt = DtMovimientos.FiltraParametros("", "", filtroComplemento)
For Each Row As DataRow In dt.Rows For Each Row As DataRow In dt.Rows
If ObjCompra.GetCompraComplementoPago(-1, UsuarioActual.CveEmpresa, Row("CveIE").ToString.ToEntero) Then 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("RFCde").ToString Dim RFC As String = dr("RFCde").ToString
Dim CveFactura As String = dr("CveFactura").ToString Dim CveFactura As String = dr("CveFactura").ToString
Console.WriteLine(RFC & CveFactura)
If CveFactura <> "" Then If CveFactura <> "" Then
Path = String.Format("{0}Compras\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, RFC, CveFactura) Path = String.Format("{0}Compras\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, RFC, CveFactura)
Console.WriteLine(Path)
If File.Exists(Path) Then If File.Exists(Path) Then
Pathpdf.Add(Path) Pathpdf.Add(Path)
End If End If
@@ -1852,6 +1865,10 @@ Partial Class ContabilidadC_RegPrePoliza
If File.Exists(pathPoliza) Then If File.Exists(pathPoliza) Then
Directory.Delete(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick), True) Directory.Delete(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick), True)
End If End If
Else
Alert("No se tiene cargado comprobante de pago", TipoMensaje.MsgAdvertencia)
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)
@@ -1873,7 +1890,6 @@ Partial Class ContabilidadC_RegPrePoliza
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))
@@ -1884,28 +1900,21 @@ Partial Class ContabilidadC_RegPrePoliza
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 If UsuarioActual.CveEmpresa = 119 Then
params.Add(New ReportParameter("UsuarioRegistro", GlobalDTUsuarios(dr("CveUsuario").ToString.ToEntero).FiltroPrimeroValor("Nombre"))) params.Add(New ReportParameter("UsuarioRegistro", GlobalDTUsuarios(dr("CveUsuario").ToString.ToEntero).FiltroPrimeroValor("Nombre")))
End If End If
If Archivo.Exists Then If Archivo.Exists Then
ruta = UsuarioActual.Empresa.Ruta & "Formatos/Polizas.rdlc" ruta = UsuarioActual.Empresa.Ruta & "Formatos/Polizas.rdlc"
Else Else
ruta = "Empresas/Grales/Formatos/Polizas.rdlc" ruta = "Empresas/Grales/Formatos/Polizas.rdlc"
End If End If
Bytes = StreamPDF(ruta, dtVC, params, "ppoliza") Bytes = StreamPDF(ruta, dtVC, params, "ppoliza")
If Not File.Exists(String.Format("{0}{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString)) Then 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)) DirectoryExistsCreate(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick))
File.WriteAllBytes(String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString), Bytes) File.WriteAllBytes(String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString), Bytes)
End If 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