Option Explicit On Option Strict On Imports System.Data Imports Extensiones Partial Class Contabilidad2_RepAnexoCatalogoAnual Inherits ClsPaginas #Region " PROPIEDADES " Public Property CveCuenta As Integer Get Return ViewState("CveCuenta").ToString.ToEntero End Get Set(value As Integer) ViewState("CveCuenta") = value End Set End Property Public Property EsVertical As Integer Get Return ViewState("EsVertical").ToString.ToEntero End Get Set(value As Integer) ViewState("EsVertical") = value End Set End Property #End Region Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then Dim EjercicioParametro, SubProyectoParametro, DivisorParametro As Integer CveCuenta = IfNull(Request("C"), "-1").ToString.ToEntero EjercicioParametro = IfNull(Request("E"), "-1").ToString.ToEntero SubProyectoParametro = IfNull(Request("S"), "-1").ToString.ToEntero DivisorParametro = IfNull(Request("D"), "-1").ToString.ToEntero EsVertical = IfNull(Request("V"), "-1").ToString.ToEntero InicializaValores() DdlEjercicio.SelectedValueExist(EjercicioParametro.ToString) DdlSubProyecto.SelectedValueExist(SubProyectoParametro.ToString) DdlDivisor.SelectedValueExist(DivisorParametro.ToString) CargaDatos() End If End Sub #Region " INICIALIZA VALORES " Private Sub InicializaValores() CargaCombos() End Sub Private Sub CargaCombos() Dim Conta As New ClsContabilidad If Conta.GetEjercicios(UsuarioActual.CveEmpresa) Then DdlEjercicio.DataSource = Conta.DtResultados Else DdlEjercicio.DataSource = Nothing End If Conta.Dispose() DdlEjercicio.DataBind() DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa) DdlSubProyecto.DataBind() DdlSubProyecto.Items.Insert(0, New ListItem("Todos", "-1")) DdlSubProyecto.SelectedValue = "-1" End Sub #End Region #Region " CARGA DATOS " Protected Sub BtnCargaAsignados_Click(sender As Object, e As EventArgs) Handles BtnCargaAsignados.Click CargaDatos() End Sub Private Sub CargaDatos() Dim Conta As New ClsContabilidad If Conta.GetAnexoCatalogoAnual(CveCuenta, DdlEjercicio.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then Dim DtHeaders As DataTable = Conta.DSResultados.Tables(0) GvAnual.DataSource = Conta.DSResultados.Tables(1) Dim Index = 1 For Index = 1 To GvAnual.Columns.Count - 1 GvAnual.Columns(Index).Visible = False Next Index Index = 1 For Each Dr As DataRow In DtHeaders.Rows GvAnual.Columns(Index).Visible = True CType(GvAnual.Columns(Index), BoundField).DataField = $"Ejercicio{Dr("Ejercicio").ToString}" GvAnual.Columns(Index).HeaderText = Dr("Ejercicio").ToString If Not DdlEjercicio.SelectedValue = Dr("Ejercicio").ToString Then If EsVertical <> 1 Then GvAnual.Columns(Index + 1).Visible = True CType(GvAnual.Columns(Index + 1), BoundField).DataField = $"Ejercicio{Dr("Ejercicio").ToString}VariacionImporte" GvAnual.Columns(Index + 1).HeaderText = "$" End If GvAnual.Columns(Index + 2).Visible = True CType(GvAnual.Columns(Index + 2), BoundField).DataField = $"Ejercicio{Dr("Ejercicio").ToString}{If(EsVertical = 1, "", "Variacion")}Porcentaje" GvAnual.Columns(Index + 2).HeaderText = "%" End If Index += 3 Next GvAnual.DataBind() UpAnual.Update() Else GvAnual.DataSource = Nothing End If GvAnual.DataBind() UpAnual.Update() RegistraScript($"LimpiaCeros({DdlDivisor.SelectedValue});") Conta.Dispose() End Sub #End Region #Region " GV ROW DATABOUND " Protected Sub GvAnual_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAnual.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowIndex = 0 Then e.Row.Style.Add("font-weight", "bold") End If e.Row.Style.Add("text-indent", $"{e.Row.DBCampo("Level").ToString.ToEntero * 2}em") End If End Sub #End Region End Class