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>
<Triggers>
<asp:PostBackTrigger ControlID="LnkImprimirPDF" />
<asp:PostBackTrigger ControlID="LnkComprobante" />
</Triggers>
</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(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
LnkComprobante.Visible = True
CveIE = e.Row.DBCampo("CveIE").ToString.ToEntero
@@ -931,7 +931,6 @@ Partial Class ContabilidadC_RegPrePoliza
If e.Row.DataKey("CveConcepto").ToEntero.Contiene(30) Then
e.Row.FCLinkButton("ImgBancos").Visible = True
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"
End If
@@ -1766,19 +1765,16 @@ Partial Class ContabilidadC_RegPrePoliza
End Sub
Protected Sub LnkImprimirPDF_Click(sender As Object, e As EventArgs)
Dim pdf() As Byte
Dim filtro() As String = {"CveCompra", "CveIE", "CveConceptoContable"}
Dim filtroComplemento() As String = {"CveIE"}
Dim Pathpdf As New List(Of String)
Dim nombre As String = "recibo"
Dim pdfs = New List(Of Byte())
Dim Path As String
Dim Factura() As Byte
Dim dt As DataTable = DtMovimientos.FiltraParametros("", "", filtro)
Dim ObjCompra As New ClsCompras
Dim ObjIE As New ClsBancos()
Dim i As Integer = 0
Dim pathPoliza As String
Dim TieneComprobante As Boolean = True
Try
@@ -1789,27 +1785,39 @@ Partial Class ContabilidadC_RegPrePoliza
End If
For Each Row As DataRow In dt.Rows
If TieneComprobante Then
If Row("CveConceptoContable").ToString.ToEntero = 30 Then
If Row("CveIE").ToString.ToEntero > 0 Then
If ObjIE.GetBancosIE(Row("CveIE").ToString.ToEntero, UsuarioActual.CveEmpresa) Then
If ObjIE.DtResultados.Rows.Count > 0 Then
Path = String.Format("{0}IE\{1}", UsuarioActual.Empresa.Ruta, ObjIE.Comprobante.ToString)
If File.Exists(Path) Then
TieneComprobante = True
Dim formato As String = System.IO.Path.GetExtension(Path)
If formato.ToLower.Contiene(".jpg", ".png", ".jpeg") Then
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))
crea_archivo.Open()
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)
End Using
Pathpdf.Add(ComprobantePDF)
Else
Pathpdf.Add(Path)
End If
Else
TieneComprobante = False
Exit For
End If
End If
End If
@@ -1829,17 +1837,22 @@ Partial Class ContabilidadC_RegPrePoliza
End If
End If
End If
End If
Next
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
Dim dr As DataRow = ObjCompra.DtResultados.Rows(0)
Dim RFC As String = dr("RFCde").ToString
Dim CveFactura As String = dr("CveFactura").ToString
Console.WriteLine(RFC & CveFactura)
If CveFactura <> "" Then
Path = String.Format("{0}Compras\{1}\{2}.pdf", UsuarioActual.Empresa.Ruta, RFC, CveFactura)
Console.WriteLine(Path)
If File.Exists(Path) Then
Pathpdf.Add(Path)
End If
@@ -1852,6 +1865,10 @@ Partial Class ContabilidadC_RegPrePoliza
If File.Exists(pathPoliza) Then
Directory.Delete(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick), True)
End If
Else
Alert("No se tiene cargado comprobante de pago", TipoMensaje.MsgAdvertencia)
End If
Catch ex As Exception
Alert("Error al descargar el paquete", TipoMensaje.MsgError)
@@ -1873,7 +1890,6 @@ Partial Class ContabilidadC_RegPrePoliza
dtVC = ObjConta.DtResultados
dr = dtVC.Rows(0)
Dim ruta As String = ""
params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("TipoPoliza", dr("TipoPoliza").ToString))
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("Moneda", ""))
params.Add(New ReportParameter("CodigoPostal", ""))
If UsuarioActual.CveEmpresa = 119 Then
params.Add(New ReportParameter("UsuarioRegistro", GlobalDTUsuarios(dr("CveUsuario").ToString.ToEntero).FiltroPrimeroValor("Nombre")))
End If
If Archivo.Exists Then
ruta = UsuarioActual.Empresa.Ruta & "Formatos/Polizas.rdlc"
Else
ruta = "Empresas/Grales/Formatos/Polizas.rdlc"
End If
Bytes = StreamPDF(ruta, dtVC, params, "ppoliza")
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
Return String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString)
ObjConta.Dispose()
End Function