Option Explicit On Option Strict On Imports System.Data Imports Extensiones Partial Class Contabilidad_RepBalanceGeneralVertical Inherits ClsPaginas #Region " PROPIEDADES " Public Property EjercicioMin As Integer Get Return ViewState("EjercicioMin").ToString.ToEntero End Get Set(value As Integer) ViewState("EjercicioMin") = 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 DdlEjercicio.SelectedValueExist(Now.Year.ToString) InicializaValores() End If End Sub #Region " INICIALIZA VALORES " Private Sub InicializaValores() CargaCombos() CargaDatos() End Sub Private Sub CargaCombos() Dim Conta As New ClsContabilidad If Conta.GetEjercicios(UsuarioActual.CveEmpresa) Then DdlEjercicio.DataSource = Conta.DtResultados EjercicioMin = Conta.DtResultados.MIN("Ejercicio").ToEntero Else DdlEjercicio.DataSource = Nothing End If Conta.Dispose() DdlEjercicio.DataBind() DdlEjercicio.SelectedValueExist(Now.Year.ToString) DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa) DdlSubProyecto.DataBind() DdlSubProyecto.Items.Insert(0, New ListItem("Todos", "-1")) DdlSubProyecto.SelectedValue = "-1" DdlPeriodo.SelectedValue = Now.Month.ToString End Sub #End Region #Region " CARGA DATOS " Protected Sub BtnCargaAsignados_Click(sender As Object, e As EventArgs) Handles BtnCargaDatos.Click CargaDatos() End Sub Protected Sub Tab_ActiveTabChanged(sender As Object, e As EventArgs) If Tab.ActiveTabIndex = 2 Then ' DdlEjercicio.SelectedValueExist(EjercicioMin.ToString) End If CargaDatos() End Sub Private Sub CargaDatos() Dim Conta As New ClsContabilidad Dim IdGV = "" If Tab.ActiveTabIndex = 0 Then IdGV = GvVertical.ClientID If Conta.GetBalanceGeneralVertical(DdlEjercicio.SelectedValue.ToEntero, DdlPeriodo.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) Then GvVertical.DataSource = Conta.DtResultados Else GvVertical.DataSource = Nothing End If GvVertical.DataBind() UpNormal.Update() ElseIf Tab.ActiveTabIndex = 1 Then IdGV = GvMensual2.ClientID If Conta.GetBalanceGeneralMensualVertical(DdlEjercicio.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) Then GvMensual2.DataSource = Conta.DtResultados Else GvMensual2.DataSource = Nothing End If HdfTitulos.Value = "Enero,Febrero,Marzo,Abril,Mayo,Junio,Julio,Agosto,Septiembre,Octubre,Noviembre,Diciembre" GvMensual2.DataBind() UpMensual.Update() ElseIf Tab.ActiveTabIndex = 2 Then IdGV = GvAnual.ClientID If Conta.GetBalanceGeneralAnualVertical(DdlEjercicio.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, -1, 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 Dim titulos As New StringBuilder 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 titulos.Append($"{IIf(Index = 1, "", ",")}{Dr("Ejercicio").ToString}") GvAnual.Columns(Index + 1).Visible = True CType(GvAnual.Columns(Index + 1), BoundField).DataField = $"Ejercicio{Dr("Ejercicio").ToString}Porcentaje" GvAnual.Columns(Index + 1).HeaderText = "%" Index += 2 Next HdfTitulos.Value = titulos.ToString HdfTitulosA.Value = titulos.ToString GvAnual.DataBind() Index = 1 Dim IndexRow As Integer = 0 For Each row As DataRow In Conta.DSResultados.Tables(1).Rows Dim valores As New StringBuilder Dim Porcentajes As New StringBuilder Dim prefix As String = "" For Each Dr As DataRow In DtHeaders.Rows valores.Append($"{prefix}{row($"Ejercicio{Dr("Ejercicio").ToString}")}") Porcentajes.Append($"{prefix}{row($"Ejercicio{Dr("Ejercicio").ToString}Porcentaje")}") Index += 2 prefix = "," Next Dim lbl As Label = GvAnual.Rows(IndexRow).FCLabel("lblchart") lbl.Attributes.Add("data-value", valores.ToString) lbl.Attributes.Add("data-porcentaje", Porcentajes.ToString) IndexRow += 1 Next UpAnual.Update() Else GvAnual.DataSource = Nothing End If End If Dim Script = "" If DdlTipo.SelectedValue.ToEntero > 0 Then Script = $"LimpiaCeros({DdlDivisor.SelectedValue});EscondeRenglones('{IdGV}');" Else Script = $"LimpiaCeros({DdlDivisor.SelectedValue});" End If RegistraScript(Script) UPModal.Update() UpFiltros.Update() Conta.Dispose() End Sub #End Region #Region " GV ROW DATABOUND " Protected Sub GvVertical_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvVertical.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then 'GENERAL If e.Row.DBCampo("Clasificacion").ToString = "A" Then e.Row.CssClass = "Totales" e.Row.Cells(1).Text = "" e.Row.Cells(2).Text = "" End If 'CABECERA If e.Row.DBCampo("CtaMayor").ToString = "3" Then e.Row.Style.Add("font-weight", "bold") e.Row.Style.Add("text-indent", "2em") e.Row.Cells(1).Text = "" e.Row.Cells(2).Text = "" End If 'NORMAL If e.Row.DBCampo("CtaMayor").ToString = "1" Then e.Row.Style.Add("text-indent", "4em") e.Row.CssClass = "txtid4em" End If 'TOTAL If e.Row.DBCampo("CtaMayor").ToString = "99" Then e.Row.Style.Add("font-weight", "bold") e.Row.Style.Add("font-style", "italic") e.Row.Style.Add("text-indent", "2em") e.Row.Cells(2).Text = "100%" End If 'SUMA If e.Row.DBCampo("Clasificacion").ToString = "Z" Then e.Row.Style.Add("background-color", "#DDD") e.Row.Style.Add("font-weight", "bold") e.Row.Style.Add("font-style", "italic") e.Row.Cells(2).Text = "100%" End If End If End Sub Protected Sub GvMensual1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvMensual2.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then Dim lbl As Control = e.Row.FindControl("lblchart") Dim cssclass As String = "" e.Row.Attributes.Add("style", "height:28px;") 'TOTAL If e.Row.DBCampo("CtaMayor").ToString = "99" Then e.Row.Style.Add("font-weight", "bold") e.Row.Style.Add("font-style", "italic") If Not IsNothing(lbl) Then cssclass = "txtid2em" End If For Index = 2 To GvMensual2.Columns.Count - 1 Step 2 e.Row.Cells(Index).Text = "100%" Next Index End If 'SUMNA If e.Row.DBCampo("Clasificacion").ToString = "Z" Then e.Row.Style.Add("background-color", "#DDD") e.Row.Style.Add("font-weight", "bold") e.Row.Style.Add("font-style", "italic") For Index = 2 To GvMensual2.Columns.Count - 1 Step 2 e.Row.Cells(Index).Text = "100%" Next Index End If 'NORMAL If Not IsNothing(lbl) Then If e.Row.DBCampo("CtaMayor").ToString = "1" Then cssclass = "txtid4em" lbl.Visible = True DirectCast(lbl, Label).Attributes.Add("data-value", String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}", e.Row.DBCampo("Enero"), e.Row.DBCampo("Febrero"), e.Row.DBCampo("Marzo"), e.Row.DBCampo("Abril"), e.Row.DBCampo("Mayo"), e.Row.DBCampo("Junio"), e.Row.DBCampo("Julio"), e.Row.DBCampo("Agosto"), e.Row.DBCampo("Septiembre"), e.Row.DBCampo("Octubre"), e.Row.DBCampo("Noviembre"), e.Row.DBCampo("Diciembre"))) DirectCast(lbl, Label).Attributes.Add("data-porcentaje", String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}", e.Row.DBCampo("EneroPorcentaje"), e.Row.DBCampo("FebreroPorcentaje"), e.Row.DBCampo("MarzoPorcentaje"), e.Row.DBCampo("AbrilPorcentaje"), e.Row.DBCampo("MayoPorcentaje"), e.Row.DBCampo("JunioPorcentaje"), e.Row.DBCampo("JulioPorcentaje"), e.Row.DBCampo("AgostoPorcentaje"), e.Row.DBCampo("SeptiembrePorcentaje"), e.Row.DBCampo("OctubrePorcentaje"), e.Row.DBCampo("NoviembrePorcentaje"), e.Row.DBCampo("DiciembrePorcentaje"))) End If End If 'CABECERA If e.Row.DBCampo("CtaMayor").ToString = "3" Then e.Row.Style.Add("font-weight", "bold") cssclass = "txtid2em" For Index = 1 To GvMensual2.Columns.Count - 1 e.Row.Cells(Index).Text = "" Next Index End If 'GENERAL e.Row.CssClass = cssclass If e.Row.DBCampo("Clasificacion").ToString = "A" Then e.Row.CssClass = "Totales " & cssclass For Index = 1 To GvMensual2.Columns.Count - 1 e.Row.Cells(Index).Text = "" Next Index End If End If End Sub Protected Sub GvAnual_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAnual.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then 'LIGA SOLO EN DETALLE POR CAMPO CVECUENTA - TEMPORAL If e.Row.DBCampo("CtaMayor").ToString = "1" Then e.Row.FCHyperLink("HLNombre").NavigateUrl = $"/Contabilidad2/RepAnexoCatalogoAnual.aspx?C={e.Row.DBCampo("CveCuenta")}&E={DdlEjercicio.SelectedValue}&S={DdlSubProyecto.SelectedValue}&D={DdlDivisor.SelectedValue}&V=1" End If 'GENERAL If e.Row.DBCampo("Clasificacion").ToString = "A" Then e.Row.CssClass = "Totales" For Index = 1 To GvAnual.Columns.Count - 1 e.Row.Cells(Index).Text = "" Next Index End If 'CABECERA If e.Row.DBCampo("CtaMayor").ToString = "3" Then e.Row.Style.Add("font-weight", "bold") e.Row.CssClass = "txtid2em" Dim Index = 0 For Index = 1 To GvAnual.Columns.Count - 1 e.Row.Cells(Index).Text = "" Next Index End If 'NORMAL If e.Row.DBCampo("CtaMayor").ToString = "1" Then e.Row.Style.Add("text-indent", "4em") e.Row.CssClass = "txtid4em" End If 'TOTAL If e.Row.DBCampo("CtaMayor").ToString = "99" Then e.Row.Style.Add("font-weight", "bold") e.Row.Style.Add("font-style", "italic") e.Row.CssClass = "txtid2em" Dim Index = 0 For Index = 2 To GvAnual.Columns.Count - 1 Step 2 e.Row.Cells(Index).Text = "100%" Next Index End If 'SUMA If e.Row.DBCampo("Clasificacion").ToString = "Z" Then e.Row.Style.Add("background-color", "#DDD") e.Row.Style.Add("font-weight", "bold") e.Row.Style.Add("font-style", "italic") Dim Index = 0 For Index = 2 To GvAnual.Columns.Count - 1 Step 2 e.Row.Cells(Index).Text = "100%" Next Index End If End If End Sub #End Region End Class