Option Explicit On Option Strict On Imports System.Data Imports System.IO Imports Extensiones Imports Microsoft.Reporting.WebForms Partial Class Contabilidad_RepIVADiferencias Inherits ClsPaginas #Region "PROPIEDADES" Private Property DtDatos As DataTable Get Return CType(ViewState("DtDatos"), DataTable) End Get Set(value As DataTable) ViewState("DtDatos") = value End Set End Property Private Property Ejercicio As Integer Get Ejercicio = ViewState("Ejercicio").ToString.ToEntero End Get Set(value As Integer) ViewState("Ejercicio") = value End Set End Property Private Property PeriodoNumero As Integer Get PeriodoNumero = ViewState("PeriodoNumero").ToString.ToEntero End Get Set(value As Integer) ViewState("PeriodoNumero") = value End Set End Property Private Property Periodo As String Get Periodo = ViewState("Periodo").ToString End Get Set(value As String) ViewState("Periodo") = value End Set End Property #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then CargaCombos() If UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC Then BtnConsultar.Enabled = True Ejercicio = DdlEjercicio.SelectedValue.ToEntero PeriodoNumero = DdlPeriodo.SelectedValue.ToEntero CargaDatos() Else Alert("La empresa no usa contabilidad ni Armonización Contable", TipoMensaje.MsgAdvertencia) End If End If End Sub Private Sub CargaCombos() DdlEjercicio.Items.Insert(0, NowADS().Year.ToString) DdlEjercicio.Items.Insert(1, NowADS().AddYears(-1).Year.ToString) DdlPeriodo.SelectedValue = NowADS().Month.ToString End Sub Private Sub CargaDatos() Dim ObjCont As New ClsContPAQi(UsuarioActual.Empresa) If ObjCont.GetIVAsDiferencias(Ejercicio, PeriodoNumero) Then DtDatos = ObjCont.DtResultados Else DtDatos = Nothing End If ObjCont.Dispose() Gv.DataSource = DtDatos Gv.DataBind() UPPDatos.Update() Periodo = DdlPeriodo.SelectedItem.ToString End Sub Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click Ejercicio = DdlEjercicio.SelectedValue.ToEntero PeriodoNumero = DdlPeriodo.SelectedValue.ToEntero CargaDatos() End Sub Private Sub LnkExcel_Click(sender As Object, e As EventArgs) Handles LnkExcel.Click 'Gv.ExportToExcel("DiferenciasIVA") ImprimirReporte("Excel") End Sub Private Sub BtnImprimir_Click(sender As Object, e As EventArgs) Handles BtnImprimir.Click ImprimirReporte() End Sub Private Sub ImprimirReporte(Optional Formato As String = "PDF") 'ubicacion del rdlc Dim reportpath As String = Server.MapPath("~/Empresas/Grales/Formatos/RepIvaDiferencias.rdlc") '"Empresas/Grales/Formatos/RepIvaDiferencias.rdlc" 'nombre del reporte Dim fileName As String = "Diferencias IVA" If Not IsNothing(DtDatos) AndAlso DtDatos.Rows.Count > 0 Then Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png") 'parametros a enviar al reporte Dim params As New List(Of ReportParameter) params.Add(New ReportParameter("pImg", If(Imagen.Exists, $"file://{Imagen.FullName}", ""))) params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("Ejercicio", Ejercicio.ToString)) params.Add(New ReportParameter("Periodo", Periodo)) params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario)) params.Add(New ReportParameter("FechaImpresion", NowADS().ToShortDateString)) ImprimirPDF(reportpath, DtDatos, params, fileName, Formato) Else Alert("No se encontraron registros", TipoMensaje.MsgAdvertencia) End If End Sub End Class