Option Explicit On Option Strict On Imports System.Data Imports Extensiones Partial Class Contabilidad2_RepEstadoResultadosHorizontal 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 Public Property DtHeaders As DataTable Get Return CType(ViewState("DtHeaders"), DataTable) End Get Set(value As DataTable) ViewState("DtHeaders") = 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 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" 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) CargaDatos() End Sub Private Sub CargaDatos() Dim Conta As New ClsContabilidad Dim IdGV = "" If Tab.ActiveTabIndex = 0 Then IdGV = GvMensual2.ClientID If Conta.GetEstadoResultadoMensualHorizontal(DdlEjercicio.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) Then GvMensual2.DataSource = Conta.DtResultados Else GvMensual2.DataSource = Nothing End If GvMensual2.DataBind() UpMensual.Update() ElseIf Tab.ActiveTabIndex = 1 Then IdGV = GvAnual.ClientID If Conta.GetEstadoResultadosAnualHorizontal(DdlEjercicio.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) Then DtHeaders = 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 = $"a{Dr("Ejercicio").ToString}" GvAnual.Columns(Index).HeaderText = Dr("Ejercicio").ToString titulos.Append($"{IIf(Index = 1, "", ",")}{Dr("Ejercicio").ToString}") If Not DdlEjercicio.SelectedValue = Dr("Ejercicio").ToString Then GvAnual.Columns(Index + 1).Visible = True CType(GvAnual.Columns(Index + 1), BoundField).DataField = $"Variaciona{Dr("Ejercicio").ToString}Importe" GvAnual.Columns(Index + 1).HeaderText = "$" GvAnual.Columns(Index + 2).Visible = True CType(GvAnual.Columns(Index + 2), BoundField).DataField = $"Variaciona{Dr("Ejercicio").ToString}Porcentaje" GvAnual.Columns(Index + 2).HeaderText = "%" End If Index += 3 Next HdfTitulosA.Value = titulos.ToString GvAnual.DataBind() 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($"a{Dr("Ejercicio").ToString}")}") If Not DdlEjercicio.SelectedValue = Dr("Ejercicio").ToString Then Porcentajes.Append($"{prefix}{row($"Variaciona{Dr("Ejercicio").ToString}Porcentaje")}") Else Porcentajes.Append($"{prefix}0") End If Index += 3 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() UPModal.Update() Else GvAnual.DataSource = Nothing End If ElseIf Tab.ActiveTabIndex = 2 Then IdGV = GvCC.ClientID If Conta.GetEstadoResultadosHorizontalCC(DdlEjercicio.SelectedValue.ToEntero, -1, DdlSubProyecto.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) Then DtHeaders = Conta.DSResultados.Tables(0) GvCC.DataSource = Conta.DSResultados.Tables(1) Dim Index = 4 For Index = 4 To GvCC.Columns.Count - 1 GvCC.Columns(Index).Visible = False Next Index Index = 4 Dim Titulos As New StringBuilder Titulos.Append("Sin SubProyecto") For Each Dr As DataRow In DtHeaders.Rows GvCC.Columns(Index).Visible = True CType(GvCC.Columns(Index), BoundField).DataField = $"SubProyecto{Dr("SubProyecto").ToString}" GvCC.Columns(Index).HeaderText = Dr("SubProyecto").ToString Titulos.Append($",{Dr("SubProyecto")}") GvCC.Columns(Index + 1).Visible = True CType(GvCC.Columns(Index + 1), BoundField).DataField = $"SubProyecto{Dr("SubProyecto").ToString}Porcentaje" GvCC.Columns(Index + 1).HeaderText = "%" Index += 2 Next HdfTituloscc.Value = Titulos.ToString GvCC.DataBind() 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 valores.Append($"{row($"SubProyectoNA")}") Porcentajes.Append($"{row($"SubProyectoNAPorcentaje")}") For Each Dr As DataRow In DtHeaders.Rows valores.Append($",{row($"SubProyecto{Dr("SubProyecto").ToString}")}") If Not DdlSubProyecto.SelectedValue = Dr("SubProyecto").ToString Then Porcentajes.Append($",{row($"SubProyecto{Dr("SubProyecto").ToString}Porcentaje")}") Else Porcentajes.Append($",0") End If Next Dim lbl As Label = GvCC.Rows(IndexRow).FCLabel("lblchart") lbl.Attributes.Add("data-value", valores.ToString) lbl.Attributes.Add("data-porcentaje", Porcentajes.ToString) IndexRow += 1 Next UpCC.Update() UPModal.Update() Else GvCC.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) UpFiltros.Update() Conta.Dispose() End Sub #End Region #Region " GV ROW DATABOUND " Protected Sub GvMensual1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvMensual2.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/RepAnexoCatalogoMensual.aspx?C={e.Row.DBCampo("CveCuenta")}&E={DdlEjercicio.SelectedValue}&S={DdlSubProyecto.SelectedValue}&D={DdlDivisor.SelectedValue}" End If 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") 'e.Row.Style.Add("text-indent", "2em") cssclass = "txtid2em" 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") End If 'NORMAL If e.Row.DBCampo("CtaMayor").ToString = "1" Then ' e.Row.Style.Add("text-indent", "4em") cssclass = "txtid4em" Dim lbl As Label = e.Row.FCLabel("lblchart") lbl.Visible = True lbl.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"))) lbl.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 'CABECERA If e.Row.DBCampo("CtaMayor").ToString = "3" Then e.Row.Style.Add("font-weight", "bold") 'e.Row.Style.Add("text-indent", "2em") 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}" End If 'TOTAL Dim cssclass As String = "" If e.Row.DBCampo("CtaMayor").ToString = "99" Then e.Row.Style.Add("font-weight", "bold") e.Row.Style.Add("font-style", "italic") cssclass = "txtid2em" 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") End If 'NORMAL If e.Row.DBCampo("CtaMayor").ToString = "1" Then cssclass = "txtid4em" e.Row.FindControl("lblchart").Visible = True End If 'CABECERA If e.Row.DBCampo("CtaMayor").ToString = "3" Then e.Row.Style.Add("font-weight", "bold") cssclass = "txtid2em" Dim Index = 0 For Index = 1 To GvAnual.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 GvAnual.Columns.Count - 1 e.Row.Cells(Index).Text = "" Next Index End If End If End Sub Protected Sub GvCC_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCC.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/RepAnexoCatalogoCC.aspx?C={e.Row.DBCampo("CveCuenta")}&E={DdlEjercicio.SelectedValue}&S={DdlSubProyecto.SelectedValue}&D={DdlDivisor.SelectedValue}" End If 'TOTAL Dim cssclass As String = "" If e.Row.DBCampo("CtaMayor").ToString = "99" Then e.Row.Style.Add("font-weight", "bold") e.Row.Style.Add("font-style", "italic") cssclass = "txtid2em" 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") End If 'NORMAL If e.Row.DBCampo("CtaMayor").ToString = "1" Then cssclass = "txtid4em" e.Row.FindControl("lblchart").Visible = True End If 'CABECERA If e.Row.DBCampo("CtaMayor").ToString = "3" Then e.Row.Style.Add("font-weight", "bold") cssclass = "txtid2em" Dim Index = 0 For Index = 1 To GvAnual.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 GvAnual.Columns.Count - 1 e.Row.Cells(Index).Text = "" Next Index End If End If End Sub #End Region End Class