Option Explicit On Option Strict On Imports System.Data Imports System.IO Imports Extensiones Imports GemBox.Spreadsheet Imports Microsoft.Reporting.WebForms Partial Class Contabilidad_RepEstadoResultadosPorSegmento Inherits ClsPaginas #Region " PROPIEDADES NORMAL " 'Private Property DtDatos As DataTable ' Get ' DtDatos = DirectCast(ViewState("DtDatos"), DataTable) ' End Get ' Set(ByVal value As DataTable) ' ViewState("DtDatos") = value ' End Set 'End Property Private Property DSDatos As DataSet Get DSDatos = DirectCast(ViewState("DSDatos"), DataSet) End Get Set(ByVal value As DataSet) ViewState("DSDatos") = value End Set End Property Private Property DtIngresos As DataTable Get DtIngresos = DirectCast(ViewState("DtIngresos"), DataTable) End Get Set(ByVal value As DataTable) ViewState("DtIngresos") = value End Set End Property Private Property DtGastos As DataTable Get DtGastos = DirectCast(ViewState("DtGastos"), DataTable) End Get Set(ByVal value As DataTable) ViewState("DtGastos") = value End Set End Property Private Property TotalActual As Double Get TotalActual = ViewState("TotalActual").ToString.ToDouble End Get Set(value As Double) ViewState("TotalActual") = value End Set End Property Private Property TotalAnterior As Double Get TotalAnterior = ViewState("TotalAnterior").ToString.ToDouble End Get Set(value As Double) ViewState("TotalAnterior") = value End Set End Property Private Property PorcentajeActual As String Get PorcentajeActual = ViewState("PorcentajeActual").ToString End Get Set(value As String) ViewState("PorcentajeActual") = value End Set End Property Private Property PorcentajeAcumulado As String Get PorcentajeAcumulado = ViewState("PorcentajeAcumulado").ToString End Get Set(value As String) ViewState("PorcentajeAcumulado") = value End Set End Property Private Property FechaI As String Get Return ViewState("FechaI").ToString End Get Set(value As String) ViewState("FechaI") = value End Set End Property Private Property FechaF As String Get Return ViewState("FechaF").ToString End Get Set(value As String) ViewState("FechaF") = value End Set End Property Private Property ReporteComplementario As Boolean Get ReporteComplementario = CBool(ViewState("ReporteComplementario").ToString) End Get Set(value As Boolean) ViewState("ReporteComplementario") = value End Set End Property #End Region #Region " PROPIEDADES MENSUAL " Private Property DtDatosMensual As DataTable Get DtDatosMensual = DirectCast(ViewState("DtDatosMensual"), DataTable) End Get Set(ByVal value As DataTable) ViewState("DtDatosMensual") = value End Set End Property #End Region #Region " PROPIEDADES ANUAL " Private Property DtDatosAnual As DataTable Get DtDatosAnual = DirectCast(ViewState("DtDatosAnual"), DataTable) End Get Set(ByVal value As DataTable) ViewState("DtDatosAnual") = value End Set End Property Private Property Anos As Integer Get Anos = ViewState("Anos").ToString.ToEntero End Get Set(value As Integer) ViewState("Anos") = value End Set End Property #End Region #Region " PROPIEDADES" Private Property TipoReporte As Integer Get TipoReporte = ViewState("TipoReporte").ToString.ToEntero End Get Set(value As Integer) ViewState("TipoReporte") = value End Set End Property Private Property IndexFinal As Integer Get If ViewState("IndexFinal") Is Nothing Then Return 0 Else Return ViewState("IndexFinal").ToString.ToEntero End If End Get Set(value As Integer) ViewState("IndexFinal") = value End Set End Property #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then If UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC Then BtnConsultar.Enabled = True TabNormal.Enabled = True 'TabMensual.Enabled = True 'TabAnual.Enabled = True CargaSegmentosNegocio() If UsuarioActual.Empresa.UsaAC Then TipoReporte = -1 Else TipoReporte = 1 tdTipoReporte.Visible = True End If CargaDatosGenerales() DdlEjercicio.SelectedValue = Now.Year.ToString Anos = 0 'Normal TotalActual = 0 TotalAnterior = 0 DdlPeriodo.SelectedValue = Now.Month.ToString TabContainer_ActiveTabChanged(TabContainer, EventArgs.Empty) Else Alert("La empresa no usa Contabilidad ni Armonización Contable", TipoMensaje.MsgError) End If End If End Sub Private Sub CargaDatosGenerales() Dim ClsConta As New ClsContPAQi(UsuarioActual.Empresa) If ClsConta.GetEjercicios() Then DdlEjercicio.DataSource = ClsConta.DtResultados Else DdlEjercicio.DataSource = Nothing End If ClsConta.Dispose() DdlEjercicio.DataBind() End Sub Private Sub CargaSegmentosNegocio() Dim ObjContpaq As New ClsContPAQi(UsuarioActual.Empresa) Dim strGlobal As String = "" If ObjContpaq.GetSegmentosNegocio(-1, "-1") Then DdlSegmentoNegocio.DataSource = ObjContpaq.DtResultados DdlSegmentoNegocio.DataBind() End If ObjContpaq.Dispose() DdlSegmentoNegocio.Items.Insert(0, New ListItem("Todos", "-1")) DdlSegmentoNegocio.SelectedValue = "-1" End Sub #Region " NORMAL " Private Sub CargaDatos() FechasReporte() 'ColumnasGv() FechaI = String.Format("01/01/{0}", DdlEjercicio.SelectedValue) Dim FechaInicial As Date Dim FechaFinal As Date = New DateTime(DdlEjercicio.SelectedValue.ToEntero, DdlPeriodo.SelectedValue.ToEntero, 1) FechaFinal = FechaFinal.LastDayOfMonth If DdlTipoConsulta.SelectedValue.ToEntero = 1 Then FechaInicial = FechaFinal.FirstDayOfMonth Else FechaInicial = FechaI.ToDate End If FechaI = FechaInicial.ToString("dd/MM/yyyy") FechaF = FechaFinal.ToString("dd/MM/yyyy") ' FechaF = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, CDate(FechaI))).ToString("dd/MM/yyyy") TipoReporte = If(TipoReporte = -1, -1, DdlTipoReporte.SelectedValue.ToEntero) Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) If ObjConta.GetEstadoActividadesSegmento(FechaInicial, FechaFinal, TipoReporte, -1) Then 'If ObjConta.GetEstadoActividades(FechaI.ToDate, FechaFinal, TipoReporte, DdlSegmentoNegocio.SelectedValue.ToEntero) Then DSDatos = ObjConta.DSResultados If DSDatos IsNot Nothing AndAlso DSDatos.Tables.Count = 3 Then Try HDSegmentos.Value = DSDatos.Tables(2).Rows(0)(0).ToString liLnkDescarPersonalizado.Visible = True Catch ex As Exception End Try CargaGrids() SumaTotales() End If Else Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) End If ObjConta.Dispose() UpAcciones.Update() End Sub Sub ColumnasGv() If DdlTipoConsulta.SelectedValue.ToEntero = 1 Then 'Mensual GvIngresos.Columns(1).Visible = False GvIngresos.Columns(2).Visible = False GvIngresos.Columns(3).Visible = True GvIngresos.Columns(4).Visible = True GvIngresos2.Columns(1).Visible = False GvIngresos2.Columns(2).Visible = False GvIngresos2.Columns(3).Visible = True GvIngresos2.Columns(4).Visible = True ElseIf DdlTipoConsulta.SelectedValue.ToEntero = 2 Then 'Acumulado GvIngresos.Columns(1).Visible = True GvIngresos.Columns(2).Visible = True GvIngresos.Columns(3).Visible = False GvIngresos.Columns(4).Visible = False GvIngresos2.Columns(1).Visible = True GvIngresos2.Columns(2).Visible = True GvIngresos2.Columns(3).Visible = False GvIngresos2.Columns(4).Visible = False End If UpDatos.Update() UpDatosExelReder.Update() End Sub Private Sub CargaGrids() DtIngresos = DSDatos.Tables(1).FiltraParametros("Orden Like '0004%' OR Tipo = 'H'") DtGastos = DSDatos.Tables(1).FiltraParametros("Orden Like '0005%' OR Tipo = 'G'") Dim DTCabeceras As DataTable = DSDatos.Tables(0) Dim Row As DataRow = DtIngresos.NewRow Dim MaxColumns = DTCabeceras.Rows.Count + 6 Dim IndexActual As Integer = 0 Dim TotalActualLocal = 0.0, TotalAnteriorLocal = 0.0 Row = DtIngresos.NewRow Row.Item("Nombre") = "INGRESOS" DtIngresos.Rows.InsertAt(Row, 0) Row = DtIngresos.NewRow If DtIngresos.Rows.Count > 0 Then For Each dr As DataRow In DtIngresos.FiltraParametros("CtaMayor = 1").Rows TotalActualLocal += dr("ImporteActual").ToString.ToDouble TotalAnteriorLocal += dr("ImporteAcumulado").ToString.ToDouble Next Row.Item("Nombre") = "TOTAL INGRESOS " Row.Item("ImporteActual") = TotalActualLocal.ToString Row.Item("PorcentajeActual") = If(TotalActualLocal > 0, (TotalActualLocal * 100 / TotalActualLocal).ToString, "0").FormatoNumero Row.Item("ImporteAcumulado") = TotalAnteriorLocal.ToString Row.Item("PorcentajeAcumulado") = If(TotalAnteriorLocal > 0, (TotalAnteriorLocal * 100 / TotalAnteriorLocal).ToString, "0").FormatoNumero Row.Item("CtaMayor") = -1 IndexActual = 0 For Each Dr As DataRow In DTCabeceras.Rows Dim IndexGV As Integer = 6 + IndexActual If DSDatos.Tables(1).SUM($"[{Dr("id").ToString}]") <> 0 Then Try Row.Item($"{Dr("id").ToString}") = DSDatos.Tables(1).SUM($"[{Dr("id").ToString}]", "tipo='H'") Catch ex As Exception End Try End If IndexActual = IndexActual + 1 If IndexGV >= 206 Then Exit For End If Next DtIngresos.Rows.Add(Row) Else Row.Item("Nombre") = "TOTAL INGRESOS " Row.Item("ImporteActual") = "0.00" Row.Item("ImporteAcumulado") = "0.00" Row.Item("CtaMayor") = -1 DtIngresos.Rows.Add(Row) End If Row = DtIngresos.NewRow Row.Item("Nombre") = "EGRESOS" DtIngresos.Rows.Add(Row) Dim T1 = TotalActualLocal, T2 = TotalAnteriorLocal TotalActual = TotalActualLocal TotalAnterior = TotalAnteriorLocal TotalActualLocal = 0 TotalAnteriorLocal = 0 Row = DtGastos.NewRow If DtGastos.Rows.Count > 0 Then For Each dr As DataRow In DtGastos.FiltraParametros("CtaMayor = 1").Rows TotalActualLocal += dr("ImporteActual").ToString.ToDouble TotalAnteriorLocal += dr("ImporteAcumulado").ToString.ToDouble Next Row.Item("Nombre") = "TOTAL EGRESOS" Row.Item("ImporteActual") = TotalActualLocal Row.Item("PorcentajeActual") = If(T1 > 0, (TotalActualLocal * 100 / T1).ToString, "0").FormatoNumero Row.Item("ImporteAcumulado") = TotalAnteriorLocal.ToString Row.Item("PorcentajeAcumulado") = If(T2 > 0, (TotalAnteriorLocal * 100 / T2).ToString, "0").FormatoNumero Row.Item("CtaMayor") = -1 DtGastos.Rows.Add(Row) IndexActual = 0 For Each Dr As DataRow In DTCabeceras.Rows Dim IndexGV As Integer = 6 + IndexActual If DSDatos.Tables(1).SUM($"[{Dr("id").ToString}]") <> 0 Then Try Row.Item($"{Dr("id").ToString}") = DSDatos.Tables(1).SUM($"[{Dr("id").ToString}]", "tipo='G'") Catch ex As Exception End Try End If IndexActual = IndexActual + 1 If IndexGV >= 206 Then Exit For End If Next Else Row.Item("Nombre") = "TOTAL GASTOS" Row.Item("ImporteActual") = "0.00" Row.Item("ImporteAcumulado") = "0.00" Row.Item("CtaMayor") = -1 DtGastos.Rows.Add(Row) End If TotalActual -= TotalActualLocal TotalAnterior -= TotalAnteriorLocal 'INSERTA UTILIDAD Row = DtGastos.NewRow Row.Item("Nombre") = "Utilidad (o Pérdida)" Row.Item("ImporteActual") = TotalActual Row.Item("PorcentajeActual") = If(T1 > 0, (TotalActual * 100 / T1).ToString, "0").FormatoNumero Row.Item("ImporteAcumulado") = TotalAnterior.ToString Row.Item("PorcentajeAcumulado") = If(T2 > 0, (TotalAnterior * 100 / T2).ToString, "0").FormatoNumero Row.Item("CtaMayor") = -2 'GvGastos.DataSource = DtGastos For x As Integer = 7 To GvIngresos.Columns.Count - 1 GvIngresos.Columns(x).Visible = False GvIngresos2.Columns(x).Visible = False 'GvGastos.Columns(x).Visible = False Next IndexActual = 0 For Each Dr As DataRow In DTCabeceras.Rows Dim IndexGV As Integer = 6 + IndexActual GvIngresos.Columns(IndexGV).Visible = True CType(GvIngresos.Columns(IndexGV), BoundField).DataField = Dr("id").ToString GvIngresos.Columns(IndexGV).HeaderText = Dr("Nombre").ToString GvIngresos2.Columns(IndexGV).Visible = True CType(GvIngresos2.Columns(IndexGV), BoundField).DataField = Dr("id").ToString GvIngresos2.Columns(IndexGV).HeaderText = Dr("Nombre").ToString If DSDatos.Tables(1).SUM($"[{Dr("id").ToString}]") = 0 Then GvIngresos.Columns(IndexGV).Visible = False GvIngresos2.Columns(IndexGV).Visible = False 'GvGastos.Columns(IndexGV).Visible = False Else Try Row.Item($"{Dr("id").ToString}") = DSDatos.Tables(1).SUM($"[{Dr("id").ToString}]", "tipo='H'") - DSDatos.Tables(1).SUM($"[{Dr("id").ToString}]", "tipo='G'") Catch ex As Exception End Try End If IndexActual = IndexActual + 1 If IndexGV >= 206 Then Exit For End If Next IndexActual = IndexActual + 7 Try If DdlTipoConsulta.SelectedValue.ToEntero = 1 Then GvIngresos.Columns(IndexActual).Visible = True CType(GvIngresos.Columns(IndexActual), BoundField).DataField = "ImporteActual" GvIngresos.Columns(IndexActual).HeaderText = "Total" GvIngresos2.Columns(IndexActual).Visible = True CType(GvIngresos2.Columns(IndexActual), BoundField).DataField = "ImporteActual" GvIngresos2.Columns(IndexActual).HeaderText = "Total" Else GvIngresos.Columns(IndexActual).Visible = True CType(GvIngresos.Columns(IndexActual), BoundField).DataField = "ImporteAcumulado" GvIngresos.Columns(IndexActual).HeaderText = "Total" GvIngresos2.Columns(IndexActual).Visible = True CType(GvIngresos2.Columns(IndexActual), BoundField).DataField = "ImporteAcumulado" GvIngresos2.Columns(IndexActual).HeaderText = "Total" End If IndexFinal = IndexActual Catch ex As Exception GuardaLog("Error al generar reporte estado de resultados" & ex.StackTrace) End Try DtGastos.Rows.Add(Row) DtIngresos.Merge(DtGastos, False, MissingSchemaAction.Add) DtIngresos.AcceptChanges() GvIngresos.DataSource = DtIngresos GvIngresos2.DataSource = DtIngresos GvIngresos.DataBind() GvIngresos2.DataBind() 'GvGastos.DataBind() UpDatos.Update() UpDatosExelReder.Update() PorcentajeActual = Row.Item("PorcentajeActual").ToString PorcentajeAcumulado = Row.Item("PorcentajeAcumulado").ToString DtGastos.Rows.Remove(Row) End Sub Private Sub SumaTotales() 'Llena Lb´s Totales LbTotalActual.Text = TotalActual.ToString.FormatoNumero LbTotalAnterior.Text = TotalAnterior.ToString.FormatoNumero 'LbTotalActual.ForeColor = If(TotalActual < 0, Drawing.Color.Red, Drawing.Color.Black) 'LbTotalAnterior.ForeColor = If(TotalAnterior < 0, Drawing.Color.Red, Drawing.Color.Black) End Sub #Region "GV´S ROW DATA BOUND" Protected Sub GvNormal_RowDataBound(sender As Object, e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.Header Then e.Row.ControlStyle.Font.Bold = True e.Row.Attributes.Add("style", "border-top:2px solid black;") End If If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DBCampo("Id").ToString.ToEntero > 0 Then If Not e.Row.FCHyperLink("HLNombre") Is Nothing Then e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoSegmento.aspx?Id={ e.Row.DBCampo("Id").ToString.ToEntero}&Ejercicio={DdlEjercicio.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}&Tipo={DdlTipoConsulta.SelectedValue}&Segmentos={HDSegmentos.Value}&FI={FechaI}&FF={FechaF}" End If End If If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then 'e.Row.CssClass = "SubTotales3" ' e.Row.ControlStyle.Font.Bold = True End If If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then e.Row.FCHyperLink("HLActual").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&CM=1", e.Row.DBCampo("Id"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString) e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&CM=1", e.Row.DBCampo("Id"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString) End If If e.Row.DBCampo("ImporteActual").ToString.ToDouble < 0 Then 'e.Row.FCHyperLink("HLActual").ForeColor = Drawing.Color.Red End If If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then ' e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red End If 'UTILIDAD If e.Row.DBCampo("CtaMayor").ToString.ToEntero = -2 Then e.Row.Attributes.Add("style", "vertical-align: bottom;") e.Row.ControlStyle.Font.Bold = True ' e.Row.Cells(0).Attributes.Add("style", "padding-top:50px;") e.Row.Cells(0).Font.Size = 12 e.Row.Cells(0).Font.Bold = True ' e.Row.Cells(1).Attributes.Add("style", "padding-top:50px;") e.Row.Cells(1).Font.Size = 12 e.Row.Cells(1).Font.Bold = True 'e.Row.Cells(2).Attributes.Add("style", "padding-top:50px;") e.Row.Cells(2).Font.Size = 12 e.Row.Cells(2).Font.Bold = True ' e.Row.Cells(3).Attributes.Add("style", "padding-top:50px;") e.Row.Cells(3).Font.Size = 12 e.Row.Cells(3).Font.Bold = True ' e.Row.Cells(4).Attributes.Add("style", "padding-top:50px;") e.Row.Cells(4).Font.Size = 12 e.Row.Cells(4).Font.Bold = True ' e.Row.Cells(5).Attributes.Add("style", "padding-top:50px;") e.Row.Cells(5).Font.Size = 12 e.Row.Cells(5).Font.Bold = True 'e.Row.Font.Size = 12 'e.Row.Cells(IndexFinal).ForeColor = Drawing.Color.Red End If 'TOTALES If e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then e.Row.ControlStyle.Font.Bold = True e.Row.Attributes.Add("style", "border-top:2px solid black;") End If If e.Row.DBCampo("Nombre").ToString.Contiene("INGRESOS", "EGRESOS") Then e.Row.ControlStyle.BackColor = Drawing.Color.LightGray e.Row.ControlStyle.Font.Bold = True End If End If End Sub Protected Sub GvGastos_RowDataBound(sender As Object, e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then If e.Row.DBCampo("CtaMayor").ToString.ToEntero = -2 Then e.Row.ControlStyle.BackColor = Drawing.Color.LightGray e.Row.Cells(IndexFinal).ForeColor = Drawing.Color.Red End If ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then End If If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then e.Row.FCHyperLink("HLActual").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&CM=1", e.Row.DBCampo("Id"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString) e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&CM=1", e.Row.DBCampo("Id"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString) End If If e.Row.DBCampo("ImporteActual").ToString.ToDouble < 0 Then e.Row.FCHyperLink("HLActual").ForeColor = Drawing.Color.Red e.Row.FCHyperLink("HLActual").Font.Bold = True End If If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red e.Row.FCHyperLink("HLAnterior").Font.Bold = True End If End If End Sub #End Region #End Region Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) 'Nota: ' 0 = Normal ' 1 = Mensual ' 2 = Anual If TabContainer.ActiveTabIndex = 0 Then CargaDatos() ElseIf TabContainer.ActiveTabIndex = 1 Then 'CargaDatosMensual() ElseIf TabContainer.ActiveTabIndex = 2 Then ' CargaDatosAnual() End If End Sub #Region " IMPRESION " #End Region Protected Sub TabContainer_ActiveTabChanged(sender As Object, e As EventArgs) 'Nota: ' 0 = Normal ' 1 = Mensual ' 2 = Anual 'Esconde Todo de lo variable de Filtros TdSubTotales.Visible = False TdPeriodo.Visible = False If TabContainer.ActiveTabIndex = 0 Then TdPeriodo.Visible = True ElseIf TabContainer.ActiveTabIndex = 1 Then TdSubTotales.Visible = True ElseIf TabContainer.ActiveTabIndex = 2 Then End If UpFiltros.Update() 'BtnConsultar_Click(BtnConsultar, EventArgs.Empty) End Sub Private Sub GvIngresos_RowDataBound(sender As Object, e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DBCampo("Id").ToString.ToEntero > 0 Then e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoSegmento.aspx?Id={ e.Row.DBCampo("Id").ToString.ToEntero}&Ejercicio={DdlEjercicio.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}&Tipo={DdlTipoConsulta.SelectedValue}&Segmentos={HDSegmentos.Value}&FI={FechaI}&FF={FechaF}" End If End If End Sub Private Sub FechasReporte() Dim FechaInicio As Date Dim FechaFin As Date If DdlTipoConsulta.SelectedValue.ToEntero = 1 Then FechaInicio = New Date(DdlEjercicio.SelectedValue.ToEntero, DdlPeriodo.SelectedValue.ToEntero, 1) FechaFin = FechaInicio.LastDayOfMonth() Else FechaInicio = New Date(DdlEjercicio.SelectedValue.ToEntero, 1, 1) FechaFin = New Date(DdlEjercicio.SelectedValue.ToEntero, DdlPeriodo.SelectedValue.ToEntero, 1).LastDayOfMonth End If Dim UrlImagen = $"http://{ HttpContext.Current.Request.Url.Host}:{HttpContext.Current.Request.Url.Port}/Empresas/{UsuarioActual.CveEmpresa}/Logo.png" If File.Exists($"{UsuarioActual.Empresa.Ruta}Logo.png") Then ImgLogoReporte.Attributes.Add("src", UrlImagen) Else ImgLogoReporte.Attributes.Add("src", "") End If LblTituloAniosRango.Text = $"{ UsuarioActual.Empresa.Empresa }" LblFechas.Text = $"{FechaInicio.ToString("dd/MMMM/yyyy")} al {FechaFin.ToString("dd/MMMM/yyyy")}" LblFechaReporte.Text = Now.ToString("dd/MMMM/yyyy") End Sub Protected Sub LnkDescarPersonalizados_Click(sender As Object, e As EventArgs) DescargaReporte() End Sub Private Sub DescargaReporte() Dim htmlFuente As String = txtDatos.Text Dim RutaLogo As String = $"{Server.MapPath("~")}\Empresas\{UsuarioActual.CveEmpresa}\logo.png" htmlFuente = htmlFuente.Replace("