diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb
index c8e653938..72dfecc12 100644
--- a/App_Code/ClsPaginas.vb
+++ b/App_Code/ClsPaginas.vb
@@ -6150,7 +6150,8 @@ Public Class ClsPaginas
params.Add(New CrystalParametro("ClienteTelefono", Vta.ClienteSucursal.TelefonoSucursal))
Else
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
If UsuarioActual.CveEmpresa.Contiene(17) Then
diff --git a/Bancos/IE.aspx b/Bancos/IE.aspx
index af9359a92..2db50bfd5 100644
--- a/Bancos/IE.aspx
+++ b/Bancos/IE.aspx
@@ -31,7 +31,7 @@
Actualizar Tipo Cambio
- PrePoliza
+ PrePoliza
<%--
diff --git a/Contabilidad/RegPrePoliza.aspx.vb b/Contabilidad/RegPrePoliza.aspx.vb
index 0f95cab57..8c836c659 100644
--- a/Contabilidad/RegPrePoliza.aspx.vb
+++ b/Contabilidad/RegPrePoliza.aspx.vb
@@ -1773,26 +1773,26 @@ Partial Class ContabilidadC_RegPrePoliza
Dim dt As DataTable = DtMovimientos.FiltraParametros("", "", filtro)
Dim ObjCompra As New ClsCompras
Dim ObjIE As New ClsBancos()
- Dim pathPoliza As String
- Dim TieneComprobante As Boolean = True
+ Dim pathPoliza As String = ""
+ Dim TieneComprobante As Boolean
+
Try
+ TieneComprobante = VerificarComprobante()
+ If TieneComprobante Then
+ Path = ImprimirPolizaPDF(IdPoliza)
+ pathPoliza = Path
+ If File.Exists(Path) Then
+ Pathpdf.Add(Path)
+ End If
- Path = ImprimirPolizaPDF(IdPoliza)
- pathPoliza = Path
- If File.Exists(Path) Then
- Pathpdf.Add(Path)
- End If
-
- For Each Row As DataRow In dt.Rows
- If TieneComprobante Then
+ For Each Row As DataRow In dt.Rows
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)
@@ -1815,9 +1815,6 @@ Partial Class ContabilidadC_RegPrePoliza
Else
Pathpdf.Add(Path)
End If
- Else
- TieneComprobante = False
- Exit For
End If
End If
End If
@@ -1837,10 +1834,9 @@ Partial Class ContabilidadC_RegPrePoliza
End If
End If
End If
- End If
- Next
+ 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
@@ -1865,6 +1861,7 @@ 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
@@ -2322,5 +2319,40 @@ Partial Class ContabilidadC_RegPrePoliza
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
diff --git a/Contabilidad/RegPrePolizaS.aspx b/Contabilidad/RegPrePolizaS.aspx
index 421303bcd..1bc7203c1 100644
--- a/Contabilidad/RegPrePolizaS.aspx
+++ b/Contabilidad/RegPrePolizaS.aspx
@@ -75,7 +75,14 @@
Crear Complemento de Pago
+
+ Imprimir Poliza
+
+
+
+
+
@@ -835,7 +842,7 @@
-
+
diff --git a/Contabilidad/RegPrePolizaS.aspx.vb b/Contabilidad/RegPrePolizaS.aspx.vb
index f62902ab6..50e7e9ff7 100644
--- a/Contabilidad/RegPrePolizaS.aspx.vb
+++ b/Contabilidad/RegPrePolizaS.aspx.vb
@@ -5,7 +5,10 @@ Imports Extensiones
Imports System.Linq
Imports System.Web.Services
Imports GemBox.Spreadsheet
-
+Imports Microsoft.Reporting.WebForms
+Imports System.IO
+Imports iTextSharp.text.pdf
+
Partial Class ContabilidadC_RegPrePolizaS
Inherits ClsPaginas
@@ -159,6 +162,40 @@ Partial Class ContabilidadC_RegPrePolizaS
ViewState("IndiceGrid") = value
End Set
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
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
@@ -175,6 +212,8 @@ Partial Class ContabilidadC_RegPrePolizaS
Observaciones = "-1"
Beneficiario = "-1"
Actualizar = False
+ IdPoliza = -1
+
If IfNull(Request("Tipo"), "").ToString = "NOMPROV" Then
DivTipoGasto.Visible = True
@@ -365,7 +404,9 @@ Partial Class ContabilidadC_RegPrePolizaS
DdlTipoPoliza.SelectedValue = dr("CveTipoPoliza")
TxtFechaDocumento.Text = dr("Fecha")
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
'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(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(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
@@ -689,6 +736,8 @@ Partial Class ContabilidadC_RegPrePolizaS
dr("CvePersonal") = drt("CvePersonal")
dr("CveClasificacion") = -1
dr("MultipleSubProyecto") = drt("MultipleSubProyecto")
+ dr("FolioPoliza") = drt("FolioPoliza")
+
DtMovimientos.Rows.Add(dr)
Next
@@ -1951,5 +2000,150 @@ Partial Class ContabilidadC_RegPrePolizaS
End Sub
#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