Mejoras en reportes y cambios para generacion poliza
This commit is contained in:
@@ -6150,7 +6150,8 @@ Public Class ClsPaginas
|
|||||||
params.Add(New CrystalParametro("ClienteTelefono", Vta.ClienteSucursal.TelefonoSucursal))
|
params.Add(New CrystalParametro("ClienteTelefono", Vta.ClienteSucursal.TelefonoSucursal))
|
||||||
Else
|
Else
|
||||||
params.Add(New CrystalParametro("ClienteContactoMail", Vta.Cliente.MailCotizacion))
|
params.Add(New CrystalParametro("ClienteContactoMail", Vta.Cliente.MailCotizacion))
|
||||||
params.Add(New CrystalParametro("ClienteTelefono", If(Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.RFC = "XAXX010101000", Vta.TelefonoGenerico, Vta.Cliente.Telefono)))
|
params.Add(New CrystalParametro("ClienteTelefono", If(Vta.TipoDocto.Contiene("Ing", "Rem") AndAlso Vta.Cliente.Telefono.Length > 6, Vta.TelefonoGenerico, Vta.Cliente.Telefono)))
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If UsuarioActual.CveEmpresa.Contiene(17) Then
|
If UsuarioActual.CveEmpresa.Contiene(17) Then
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
<asp:HyperLink ID="HLModalActualizarTC" NavigateUrl="#" runat="server" Visible="false" data-toggle="modal" data-target="#ModalActualizarTC" Style="color: #686868;"><i class="fa fa-usd" style="color:#686868;"></i> Actualizar Tipo Cambio</asp:HyperLink>
|
<asp:HyperLink ID="HLModalActualizarTC" NavigateUrl="#" runat="server" Visible="false" data-toggle="modal" data-target="#ModalActualizarTC" Style="color: #686868;"><i class="fa fa-usd" style="color:#686868;"></i> Actualizar Tipo Cambio</asp:HyperLink>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<asp:HyperLink ID="HpLPrePoliza" NavigateUrl="#" runat="server" Visible="false" Style="color: #686868;"><i class="fa fa-usd" style="color:#686868;"></i> PrePoliza</asp:HyperLink>
|
<asp:HyperLink ID="HpLPrePoliza" NavigateUrl="#" runat="server" Visible="false" Style="color: #686868;"><i class="" style="color:#686868;"></i> PrePoliza</asp:HyperLink>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<%-- <li>
|
<%-- <li>
|
||||||
|
|||||||
@@ -1773,26 +1773,26 @@ Partial Class ContabilidadC_RegPrePoliza
|
|||||||
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 pathPoliza As String
|
Dim pathPoliza As String = ""
|
||||||
Dim TieneComprobante As Boolean = True
|
Dim TieneComprobante As Boolean
|
||||||
|
|
||||||
Try
|
Try
|
||||||
|
TieneComprobante = VerificarComprobante()
|
||||||
|
If TieneComprobante Then
|
||||||
|
|
||||||
|
Path = ImprimirPolizaPDF(IdPoliza)
|
||||||
|
pathPoliza = Path
|
||||||
|
If File.Exists(Path) Then
|
||||||
|
Pathpdf.Add(Path)
|
||||||
|
End If
|
||||||
|
|
||||||
Path = ImprimirPolizaPDF(IdPoliza)
|
For Each Row As DataRow In dt.Rows
|
||||||
pathPoliza = Path
|
|
||||||
If File.Exists(Path) Then
|
|
||||||
Pathpdf.Add(Path)
|
|
||||||
End If
|
|
||||||
|
|
||||||
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)
|
||||||
@@ -1815,9 +1815,6 @@ Partial Class ContabilidadC_RegPrePoliza
|
|||||||
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
|
||||||
@@ -1837,10 +1834,9 @@ 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
|
||||||
@@ -1865,6 +1861,7 @@ 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
|
Else
|
||||||
Alert("No se tiene cargado comprobante de pago", TipoMensaje.MsgAdvertencia)
|
Alert("No se tiene cargado comprobante de pago", TipoMensaje.MsgAdvertencia)
|
||||||
End If
|
End If
|
||||||
@@ -2322,5 +2319,40 @@ Partial Class ContabilidadC_RegPrePoliza
|
|||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Function VerificarComprobante() As Boolean
|
||||||
|
Dim filtro() As String = {"CveCompra", "CveIE", "CveConceptoContable"}
|
||||||
|
Dim Path As String
|
||||||
|
Dim dt As DataTable = DtMovimientos.FiltraParametros("", "", filtro)
|
||||||
|
Dim ObjIE As New ClsBancos()
|
||||||
|
Dim TieneComprobante As Boolean = True
|
||||||
|
|
||||||
|
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
|
||||||
|
Else
|
||||||
|
TieneComprobante = False
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
TieneComprobante = False
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
ObjIE.Dispose()
|
||||||
|
Return TieneComprobante
|
||||||
|
|
||||||
|
End Function
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,14 @@
|
|||||||
<li>
|
<li>
|
||||||
<asp:LinkButton ID="LnkComplementoPago" runat="server" Visible="false" OnClick="LnkComplementoPago_Click" Style="color: #686868;"><i class="fa fa-money" style="color:#686868;"></i> Crear Complemento de Pago</asp:LinkButton>
|
<asp:LinkButton ID="LnkComplementoPago" runat="server" Visible="false" OnClick="LnkComplementoPago_Click" Style="color: #686868;"><i class="fa fa-money" style="color:#686868;"></i> Crear Complemento de Pago</asp:LinkButton>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<asp:LinkButton ID="LnkImprimirPDF" runat="server" Visible="false" OnClick="LnkImprimirPDF_Click" Style="color: #686868;"><i class="fa fa-file-pdf-o" style="color:#686868;"></i> Imprimir Poliza</asp:LinkButton>
|
||||||
|
</li>
|
||||||
|
|
||||||
</ContentTemplate>
|
</ContentTemplate>
|
||||||
|
<Triggers>
|
||||||
|
<asp:PostBackTrigger ControlID="LnkComprobante" />
|
||||||
|
</Triggers>
|
||||||
</asp:UpdatePanel>
|
</asp:UpdatePanel>
|
||||||
|
|
||||||
<asp:UpdatePanel runat="server">
|
<asp:UpdatePanel runat="server">
|
||||||
@@ -835,7 +842,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script src="/Metronic/assets/global/plugins/dropzone/dropzone.js"></script>
|
<script src="/Metronic/assets/global/plugins/dropzone/dropzone.js"></script>
|
||||||
</asp:Content>
|
</asp:Content>
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ Imports Extensiones
|
|||||||
Imports System.Linq
|
Imports System.Linq
|
||||||
Imports System.Web.Services
|
Imports System.Web.Services
|
||||||
Imports GemBox.Spreadsheet
|
Imports GemBox.Spreadsheet
|
||||||
|
Imports Microsoft.Reporting.WebForms
|
||||||
|
Imports System.IO
|
||||||
|
Imports iTextSharp.text.pdf
|
||||||
|
|
||||||
Partial Class ContabilidadC_RegPrePolizaS
|
Partial Class ContabilidadC_RegPrePolizaS
|
||||||
Inherits ClsPaginas
|
Inherits ClsPaginas
|
||||||
|
|
||||||
@@ -159,6 +162,40 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
ViewState("IndiceGrid") = value
|
ViewState("IndiceGrid") = value
|
||||||
End Set
|
End Set
|
||||||
End Property
|
End Property
|
||||||
|
Public Property IdPoliza As Integer
|
||||||
|
Get
|
||||||
|
Return CType(ViewState("IdPoliza"), Integer)
|
||||||
|
End Get
|
||||||
|
Set(value As Integer)
|
||||||
|
ViewState("IdPoliza") = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
Public Property Tick As String
|
||||||
|
Get
|
||||||
|
Return CType(ViewState("Tick"), String)
|
||||||
|
End Get
|
||||||
|
Set(value As String)
|
||||||
|
ViewState("Tick") = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
|
||||||
|
Public Property CveIE As Integer
|
||||||
|
Get
|
||||||
|
Return CType(ViewState("CveIE"), Integer)
|
||||||
|
End Get
|
||||||
|
Set(value As Integer)
|
||||||
|
ViewState("CveIE") = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
|
||||||
|
Public Property TipoPoliza As String
|
||||||
|
Get
|
||||||
|
Return CType(ViewState("TipoPoliza"), String)
|
||||||
|
End Get
|
||||||
|
Set(value As String)
|
||||||
|
ViewState("TipoPoliza") = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||||
@@ -175,6 +212,8 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
Observaciones = "-1"
|
Observaciones = "-1"
|
||||||
Beneficiario = "-1"
|
Beneficiario = "-1"
|
||||||
Actualizar = False
|
Actualizar = False
|
||||||
|
IdPoliza = -1
|
||||||
|
|
||||||
|
|
||||||
If IfNull(Request("Tipo"), "").ToString = "NOMPROV" Then
|
If IfNull(Request("Tipo"), "").ToString = "NOMPROV" Then
|
||||||
DivTipoGasto.Visible = True
|
DivTipoGasto.Visible = True
|
||||||
@@ -365,7 +404,9 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
DdlTipoPoliza.SelectedValue = dr("CveTipoPoliza")
|
DdlTipoPoliza.SelectedValue = dr("CveTipoPoliza")
|
||||||
TxtFechaDocumento.Text = dr("Fecha")
|
TxtFechaDocumento.Text = dr("Fecha")
|
||||||
TxtConcepto.Text = dr("Concepto")
|
TxtConcepto.Text = dr("Concepto")
|
||||||
DivDatosPoliza.Visible = True
|
DivDatosPoliza.Visible = True
|
||||||
|
TipoPoliza = DdlTipoPoliza.SelectedItem.Text
|
||||||
|
Folio = dr("FolioPoliza").ToString
|
||||||
|
|
||||||
If UsuarioActual.CveRol = 1 OrElse UsuarioActual.TienePermisoProceso(221) Then
|
If UsuarioActual.CveRol = 1 OrElse UsuarioActual.TienePermisoProceso(221) Then
|
||||||
'DivAgregarConceptos.Visible = True
|
'DivAgregarConceptos.Visible = True
|
||||||
@@ -470,7 +511,13 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
If CveConceptoContable.Contiene(1, 2, 13, 38, 207, 203, 39, 61, 62, 63) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", e.Row.DataKey("CveVenta"))
|
If CveConceptoContable.Contiene(1, 2, 13, 38, 207, 203, 39, 61, 62, 63) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", e.Row.DataKey("CveVenta"))
|
||||||
If CveConceptoContable.Contiene(5, 6, 17, 18, 14, 19, 25, 26, 60, 234, 235, 240) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Compras/Compras.aspx?CveCompra={0}", e.Row.DataKey("CveCompra"))
|
If CveConceptoContable.Contiene(5, 6, 17, 18, 14, 19, 25, 26, 60, 234, 235, 240) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Compras/Compras.aspx?CveCompra={0}", e.Row.DataKey("CveCompra"))
|
||||||
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) Then
|
||||||
|
LnkImprimirPDF.Visible = True
|
||||||
|
LnkComprobante.Visible = True
|
||||||
|
CveIE = e.Row.DBCampo("CveIE").ToString.ToEntero
|
||||||
|
End If
|
||||||
|
|
||||||
'e.Row.FCHyperLink("HlReferencia").NavigateUrl = CveConceptoContable
|
'e.Row.FCHyperLink("HlReferencia").NavigateUrl = CveConceptoContable
|
||||||
|
|
||||||
@@ -689,6 +736,8 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
dr("CvePersonal") = drt("CvePersonal")
|
dr("CvePersonal") = drt("CvePersonal")
|
||||||
dr("CveClasificacion") = -1
|
dr("CveClasificacion") = -1
|
||||||
dr("MultipleSubProyecto") = drt("MultipleSubProyecto")
|
dr("MultipleSubProyecto") = drt("MultipleSubProyecto")
|
||||||
|
dr("FolioPoliza") = drt("FolioPoliza")
|
||||||
|
|
||||||
DtMovimientos.Rows.Add(dr)
|
DtMovimientos.Rows.Add(dr)
|
||||||
Next
|
Next
|
||||||
|
|
||||||
@@ -1951,5 +2000,150 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
End Sub
|
End Sub
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
|
#Region "Paquete Egresos"
|
||||||
|
Protected Sub LnkImprimirPDF_Click(sender As Object, e As EventArgs)
|
||||||
|
Dim Pathpdf As New List(Of String)
|
||||||
|
Dim Path As String
|
||||||
|
Try
|
||||||
|
|
||||||
|
Path = ImprimirPolizaPDF(IdPoliza)
|
||||||
|
If File.Exists(Path) Then
|
||||||
|
Pathpdf.Add(Path)
|
||||||
|
End If
|
||||||
|
|
||||||
|
MergePdfFiles(Pathpdf.ToArray)
|
||||||
|
If File.Exists(Path) Then
|
||||||
|
Directory.Delete(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick), True)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Catch ex As Exception
|
||||||
|
Alert("Error al descargar la poliza", TipoMensaje.MsgError)
|
||||||
|
End Try
|
||||||
|
End Sub
|
||||||
|
Private Function ImprimirPolizaPDF(IdPoliza As Integer) As String
|
||||||
|
Dim ObjConta As New ClsContabilidad
|
||||||
|
'Dim ObjPoliza As New ClsContPAQi(UsuarioActual.Empresa)
|
||||||
|
|
||||||
|
Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/Polizas.rdlc", UsuarioActual.Empresa.Ruta))
|
||||||
|
Dim params As New List(Of ReportParameter)
|
||||||
|
Dim Bytes As Byte() = Nothing
|
||||||
|
|
||||||
|
|
||||||
|
'If ObjPoliza.GetPoliza(IdPoliza, -1, -1, -1, -1) AndAlso ObjPoliza.DtResultados.Rows.Count > 0 Then
|
||||||
|
If ObjConta.GetPrePolizasDetalle(CvePrePoliza) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
|
||||||
|
Dim dtVC As DataTable
|
||||||
|
Dim dr As DataRow
|
||||||
|
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))
|
||||||
|
params.Add(New ReportParameter("FFin", 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("Cuenta", dr("Codigo").ToString))
|
||||||
|
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
|
||||||
|
End If
|
||||||
|
Return String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString)
|
||||||
|
ObjConta.Dispose()
|
||||||
|
|
||||||
|
End Function
|
||||||
|
Private Sub MergePdfFiles(ByVal pdfFiles() As String)
|
||||||
|
Dim result As Boolean = False
|
||||||
|
Dim pdfCount As Integer = 0
|
||||||
|
Dim f As Integer = 0
|
||||||
|
Dim fileName As String
|
||||||
|
Dim reader As iTextSharp.text.pdf.PdfReader = Nothing
|
||||||
|
Dim pageCount As Integer = 0
|
||||||
|
Dim pdfDoc As iTextSharp.text.Document = Nothing
|
||||||
|
Dim writer As PdfWriter = Nothing
|
||||||
|
Dim cb As PdfContentByte = Nothing
|
||||||
|
|
||||||
|
Dim page As PdfImportedPage = Nothing
|
||||||
|
Dim rotation As Integer = 0
|
||||||
|
|
||||||
|
|
||||||
|
Try
|
||||||
|
pdfCount = pdfFiles.Length
|
||||||
|
If pdfCount > 0 Then
|
||||||
|
fileName = pdfFiles(f)
|
||||||
|
reader = New iTextSharp.text.pdf.PdfReader(fileName)
|
||||||
|
pageCount = reader.NumberOfPages
|
||||||
|
pdfDoc = New iTextSharp.text.Document(reader.GetPageSizeWithRotation(1), 18, 18, 18, 18)
|
||||||
|
writer = PdfWriter.GetInstance(pdfDoc, New FileStream(String.Format("{0}\{1}\{2}-{3}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, TipoPoliza, Folio), FileMode.Create))
|
||||||
|
|
||||||
|
With pdfDoc
|
||||||
|
.Open()
|
||||||
|
End With
|
||||||
|
cb = writer.DirectContent
|
||||||
|
While f < pdfCount
|
||||||
|
Dim i As Integer = 0
|
||||||
|
While i < pageCount
|
||||||
|
i += 1
|
||||||
|
pdfDoc.SetPageSize(reader.GetPageSizeWithRotation(i))
|
||||||
|
pdfDoc.NewPage()
|
||||||
|
page = writer.GetImportedPage(reader, i)
|
||||||
|
rotation = reader.GetPageRotation(i)
|
||||||
|
If rotation = 90 Then
|
||||||
|
cb.AddTemplate(page, 0, -1.0F, 1.0F, 0, 0, reader.GetPageSizeWithRotation(i).Height)
|
||||||
|
ElseIf rotation = 270 Then
|
||||||
|
cb.AddTemplate(page, 0, 1.0F, -1.0F, 0, reader.GetPageSizeWithRotation(i).Width + 60, -30)
|
||||||
|
Else
|
||||||
|
cb.AddTemplate(page, 1.0F, 0, 0, 1.0F, 0, 0)
|
||||||
|
End If
|
||||||
|
End While
|
||||||
|
f += 1
|
||||||
|
If f < pdfCount Then
|
||||||
|
fileName = pdfFiles(f)
|
||||||
|
reader = New iTextSharp.text.pdf.PdfReader(fileName)
|
||||||
|
pageCount = reader.NumberOfPages
|
||||||
|
End If
|
||||||
|
End While
|
||||||
|
|
||||||
|
|
||||||
|
pdfDoc.Close()
|
||||||
|
|
||||||
|
Dim Archivo As New System.IO.FileInfo(String.Format("{0}\{1}\{2}-{3}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, TipoPoliza, Folio))
|
||||||
|
|
||||||
|
If Archivo.Exists Then
|
||||||
|
HttpContext.Current.Response.Clear()
|
||||||
|
HttpContext.Current.Response.ClearContent()
|
||||||
|
HttpContext.Current.Response.ContentType = "application/octet-stream"
|
||||||
|
HttpContext.Current.Response.AppendHeader("Content-disposition", String.Format("attachment; filename={0}", Archivo.Name))
|
||||||
|
HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString())
|
||||||
|
HttpContext.Current.Response.TransmitFile(String.Format("{0}\{1}\{2}-{3}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, TipoPoliza, Folio))
|
||||||
|
Response.Flush() ' send it to the client to download
|
||||||
|
HttpContext.Current.Response.SuppressContent = True
|
||||||
|
HttpContext.Current.ApplicationInstance.CompleteRequest()
|
||||||
|
|
||||||
|
End If
|
||||||
|
result = True
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
End Try
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
#End Region
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user