From dd8805e0779a5a39259d54103918d5c16ca31083 Mon Sep 17 00:00:00 2001 From: Rakcsle Supertramp Date: Tue, 6 Oct 2020 17:15:17 -0700 Subject: [PATCH] CveSubProyecto en conceptos 65 y 64 Fuctuacion Cambiaria --- Bancos/FluctuacionCambiaria.aspx | 149 +- Bancos/FluctuacionCambiaria.aspx.vb | 69 +- .../RepEstadoResultadosHorizontal - Copy.aspx | 1593 ++++++++++++ ...pEstadoResultadosHorizontal - Copy.aspx.vb | 2295 +++++++++++++++++ Finanzas/RepBalanceGeneralHorizontal.aspx.vb | 4 +- Finanzas/RepBalanceGeneralHorizontal2.aspx | 1592 ++++++++++++ Finanzas/RepBalanceGeneralHorizontal2.aspx.vb | 2295 +++++++++++++++++ vwd.webinfo | 2 + 8 files changed, 7934 insertions(+), 65 deletions(-) create mode 100644 Contabilidad2/RepEstadoResultadosHorizontal - Copy.aspx create mode 100644 Contabilidad2/RepEstadoResultadosHorizontal - Copy.aspx.vb create mode 100644 Finanzas/RepBalanceGeneralHorizontal2.aspx create mode 100644 Finanzas/RepBalanceGeneralHorizontal2.aspx.vb diff --git a/Bancos/FluctuacionCambiaria.aspx b/Bancos/FluctuacionCambiaria.aspx index c74d540a3..57b64e754 100644 --- a/Bancos/FluctuacionCambiaria.aspx +++ b/Bancos/FluctuacionCambiaria.aspx @@ -149,13 +149,7 @@ -
- -
-
- - -
+ @@ -230,10 +224,25 @@ -
- +
+
+
+ + + + + +
+ +
+ +
-
+ + + + +
-
- + + +
+
+
+ + + + + +
+ +
+ +
-
-
+ +
+ + + @@ -333,10 +358,24 @@ -
- + +
+
+
+ + + + + +
+ +
+ +
-
+ + +
-
- -
-
-
+ + + + + +
+
+
+ + + + + +
+ +
+ +
+
+ +
+ +
+ + -
- -
-
-
+
+
+
+ + + + + +
+
+ +
+
+
+ + + +
+
+
+ + + + + +
+ +
+ +
+
+ +
+ +
- +
-
-
+ + + + + + + + + + + + + + + +
  • + Generar Excel +
  • +
  • + Graficar +
  • +
    + + + + +
    +
    +
    + +
    +
    +
    +
      + + +
      + + +
      + + +
      + + +
      + + +
      + + + + + + + + + + + + + + +
      + + + +
      + + +
      + + +
      + + + + + +
      + + +
      + + NO + Trimestre + Cuatrimestre + +
      + +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + <%-- --%> + + + + + + + + <%-- --%> + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + +
    +

    Resultados del Ejercicio:

    +
    + + + +
    +
    +
    + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%----%> + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%-- --%> + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + + + + +
    + + + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%-- --%> + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + <%-- --%> + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%----%> + + + + + + + <%----%> + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%-- --%> + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + +
    +
    +
    + + + + + + + +
    + + + + + + + + + + + diff --git a/Contabilidad2/RepEstadoResultadosHorizontal - Copy.aspx.vb b/Contabilidad2/RepEstadoResultadosHorizontal - Copy.aspx.vb new file mode 100644 index 000000000..bb9bbfec4 --- /dev/null +++ b/Contabilidad2/RepEstadoResultadosHorizontal - Copy.aspx.vb @@ -0,0 +1,2295 @@ +Option Explicit On +Option Strict On + +Imports System.Data +Imports System.Drawing +Imports System.IO +Imports Extensiones +Imports GemBox.Spreadsheet +Imports Microsoft.Reporting.WebForms + +Partial Class Contabilidad_RepEstadoResultadosHorizontal + Inherits ClsPaginas + +#Region "PROPIEDADES" + + + Private Property DtDatosMes As DataTable + Get + DtDatosMes = DirectCast(ViewState("DtDatosMes"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosMes") = value + End Set + End Property + + Private Property DtIngresosMes As DataTable + Get + DtIngresosMes = DirectCast(ViewState("DtIngresosMes"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosMes") = value + End Set + End Property + Private Property DtGastosMes As DataTable + Get + DtGastosMes = DirectCast(ViewState("DtGastosMes"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosMes") = value + End Set + End Property + Private Property TotalActualMes As Double + Get + TotalActualMes = ViewState("TotalActualMes").ToString.ToDouble + End Get + Set(value As Double) + ViewState("TotalActualMes") = value + End Set + End Property + Private Property TotalAnteriorMes As Double + Get + TotalAnteriorMes = ViewState("TotalAnteriorMes").ToString.ToDouble + End Get + Set(value As Double) + ViewState("TotalAnteriorMes") = value + End Set + End Property + Private Property FechaIMes As String + Get + Return ViewState("FechaIMes").ToString + End Get + Set(value As String) + ViewState("FechaIMes") = value + End Set + End Property + Private Property FechaFMes As String + Get + Return ViewState("FechaFMes").ToString + End Get + Set(value As String) + ViewState("FechaFMes") = value + End Set + End Property + + Private Property listacolores As List(Of String) + Get + Return DirectCast(ViewState("listacolores"), List(Of String)) + End Get + Set(value As List(Of String)) + ViewState("listacolores") = value + End Set + End Property + + Private Property listaCampos As List(Of String()) + Get + Return DirectCast(ViewState("listaCampos"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCampos") = value + End Set + End Property + Private Property listaCamposanios As List(Of String()) + Get + Return DirectCast(ViewState("listaCamposanios"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCamposanios") = value + End Set + End Property + Private Property listaCamposaniosGastos As List(Of String()) + Get + Return DirectCast(ViewState("listaCamposaniosGastos"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCamposaniosGastos") = value + End Set + End Property + Private Property listaCamposaniosTotal As List(Of String()) + Get + Return DirectCast(ViewState("listaCamposaniosTotal"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCamposaniosTotal") = 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 " M E S H O R I Z O N T A L " + + Private Property DtDatosMesH As DataTable + Get + DtDatosMesH = DirectCast(ViewState("DtDatosMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosMesH") = value + End Set + End Property + + Private Property DtIngresosMesH As DataTable + Get + DtIngresosMesH = DirectCast(ViewState("DtIngresosMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosMesH") = value + End Set + End Property + + Private Property DtGastosMesH As DataTable + Get + DtGastosMesH = DirectCast(ViewState("DtGastosMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosMesH") = value + End Set + End Property + + Private Property DTTotalesMesH As DataTable + Get + DTTotalesMesH = DirectCast(ViewState("DTTotalesMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTTotalesMesH") = value + End Set + End Property + +#End Region + + +#Region " A N U A L H O R I Z O N T A L " + + Private Property DtDatosAnualH As DataTable + Get + DtDatosAnualH = DirectCast(ViewState("DtDatosAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosAnualH") = value + End Set + End Property + + Private Property DtIngresosAnualH As DataTable + Get + DtIngresosAnualH = DirectCast(ViewState("DtIngresosAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosAnualH") = value + End Set + End Property + + Private Property DtGastosAnualH As DataTable + Get + DtGastosAnualH = DirectCast(ViewState("DtGastosAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosAnualH") = value + End Set + End Property + + Private Property DTTotalesAnualH As DataTable + Get + DTTotalesAnualH = DirectCast(ViewState("DTTotalesAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTTotalesAnualH") = value + End Set + End Property + + + Private Property CountDinamicoAnual As Integer + + Get + If ViewState("CountDinamicoAnual") Is Nothing Then + Return 0 + Else + Return ViewState("CountDinamicoAnual").ToString.ToEntero + End If + + End Get + Set(value As Integer) + ViewState("CountDinamicoAnual") = value + End Set + End Property + +#End Region + +#Region " S U B P R O Y E C T O H O R I Z O N T A L " + + Private Property DtDatosSubProyectoH As DataTable + Get + DtDatosSubProyectoH = DirectCast(ViewState("DtDatosSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosSubProyectoH") = value + End Set + End Property + + Private Property DtIngresosSubProyectoH As DataTable + Get + DtIngresosSubProyectoH = DirectCast(ViewState("DtIngresosSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosSubProyectoH") = value + End Set + End Property + + Private Property DtGastosSubProyectoH As DataTable + Get + DtGastosSubProyectoH = DirectCast(ViewState("DtGastosSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosSubProyectoH") = value + End Set + End Property + + Private Property DTTotalesSubProyectoH As DataTable + Get + DTTotalesSubProyectoH = DirectCast(ViewState("DTTotalesSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTTotalesSubProyectoH") = value + End Set + End Property + + Private Property DTSubProyectosCabecerasH As DataTable + + Get + DTSubProyectosCabecerasH = DirectCast(ViewState("DTSubProyectosCabecerasH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTSubProyectosCabecerasH") = value + End Set + + End Property + + + Private Property CountDinamicoSubProyecto As Integer + + Get + If ViewState("CountDinamicoSubProyecto") Is Nothing Then + Return 0 + Else + Return ViewState("CountDinamicoSubProyecto").ToString.ToEntero + End If + + End Get + Set(value As Integer) + ViewState("CountDinamicoSubProyecto") = 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 + listacolores = New List(Of String) + listaCampos = New List(Of String()) + listaCamposanios = New List(Of String()) + listaCamposaniosGastos = New List(Of String()) + listaCamposaniosTotal = New List(Of String()) + listacolores.Add("#FF0F00") + listacolores.Add("#FF6600") + listacolores.Add("#F8FF01") + listacolores.Add("#04D215") + listacolores.Add("#2A0CD0") + listacolores.Add("#8A0CCF") + listacolores.Add("#CD0D74") + listacolores.Add("#754DEB") + listacolores.Add("#DDDDDD") + listacolores.Add("#999999") + listacolores.Add("#000000") + listacolores.Add("#FF0F00") + + TotalActualMes = 0 + TotalAnteriorMes = 0 + + CargaEjercicios() + + CargarCentrosDeCosto(Nothing, DdlSubproyecto, Nothing, LblSubProyecto) + TabSubProyecto.HeaderText = LblSubProyecto.Text & " " + + + + DdlEjercicio.SelectedValueExist(UsuarioActual.Empresa.EjercicioActual) + ValidaEjercicios() + + End If + End Sub + + Protected Sub Tab_ActiveTabChanged(sender As Object, e As EventArgs) + + If TAB.ActiveTabIndex = 0 Then + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = False + LiEjercicioLbl2.Visible = False + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + LblTri.Visible = False + DVTri.Visible = False + End If + + If TAB.ActiveTabIndex = 1 Then + + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = False + LiEjercicioLbl2.Visible = False + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + DdlPeriodo.SelectedValueExist(12) + + LblTri.Visible = True + DVTri.Visible = True + + + End If + + If TAB.ActiveTabIndex = 2 Then + + ValidaEjercicios() + + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = True + LiEjercicioLbl2.Visible = True + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + LblTri.Visible = False + DVTri.Visible = False + + End If + + If TAB.ActiveTabIndex = 3 Then + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = False + LiEjercicioLbl2.Visible = False + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + LblTri.Visible = False + DVTri.Visible = False + + End If + + UpFiltros.Update() + End Sub + + + Protected Sub DdlEjercicio_SelectedIndexChanged(sender As Object, e As EventArgs) + ValidaEjercicios() + End Sub + + Protected Sub DdlEjercicio2_SelectedIndexChanged(sender As Object, e As EventArgs) + ValidaEjercicios() + End Sub + + Private Sub ValidaEjercicios() + + + Dim EInicio As Integer = DdlEjercicio.SelectedValue.ToEntero + + + If EInicio > DdlEjercicio2.SelectedValue.ToEntero Then + + If DdlEjercicio2.Items.Count > 0 Then + DdlEjercicio2.SelectedIndex = DdlEjercicio2.Items.Count - 1 + End If + + Dim Fejerciosio As Integer = DdlEjercicio2.SelectedValue.ToEntero + + If Not EInicio + 1 > Fejerciosio Then + DdlEjercicio2.SelectedValueExist(EInicio + 1) + End If + + End If + + + UpFiltros.Update() + End Sub + + Private Sub CargaEjercicios() + 'Dim ClsConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ClsConta As New ClsContabilidad + If ClsConta.GetEjercicios(UsuarioActual.CveEmpresa) Then + DdlEjercicio.DataSource = ClsConta.DtResultados + DdlEjercicio2.DataSource = ClsConta.DtResultados + Else + DdlEjercicio.DataSource = Nothing + DdlEjercicio2.DataSource = Nothing + End If + ClsConta.Dispose() + DdlEjercicio.DataBind() + DdlEjercicio2.DataBind() + + DdlEjercicio.SelectedValueExist(UsuarioActual.Empresa.EjercicioActual.ToString) + If DdlEjercicio.Items.Count = 0 Then + DdlEjercicio.Items.Add(New ListItem(Now.Year.ToString, Now.Year.ToString)) + End If + DdlPeriodo.SelectedValue = Now.Month.ToString + End Sub + + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) + TotalActualMes = 0 + TotalAnteriorMes = 0 + + 'Mes + If TAB.ActiveTabIndex = 0 Then + CargaDatosMes() + End If + + 'MES HORIZONTAL + If TAB.ActiveTabIndex = 1 Then + CargaDatosMesH() + End If + + 'AÑO HORIZONTAL + If TAB.ActiveTabIndex = 2 Then + + If DdlEjercicio.SelectedValue.ToEntero > DdlEjercicio2.SelectedValue.ToEntero Then + Alert("El ejercicio inicio no debe ser mayor al ejercicio fin.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + CargaDatosAnualH() + End If + + 'SUBPROYECTO + If TAB.ActiveTabIndex = 3 Then + CargaDatosSubProyectoH() + End If + + + + + End Sub + + +#Region "MES" + + + + + + Private Sub CargaDatosMes() + + + FechaIMes = String.Format("01/{0}/{1}", DdlPeriodo.SelectedValue.PadLeft(2, CChar("0")), DdlEjercicio.SelectedValue) + FechaFMes = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, CDate(FechaIMes))).ToString("dd/MM/yyyy") + 'Dim TipoReporte = DdlTipoReporte.SelectedValue.ToEntero 'If(ReporteComplementario, DdlTipoReporte.SelectedValue.ToEntero, 1) + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + 'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosMensual(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then + DtDatosMes = ObjConta.DtResultados.FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosMes = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosMes IsNot Nothing Then + CargaGridsMes() + SumaTotales() + End If + + End Sub + Private Sub CargaGridsMes() + DtIngresosMes = DtDatosMes.FiltraParametros("Tipo ='H' ") + DtGastosMes = DtDatosMes.FiltraParametros("Tipo ='G' ") + Dim Row As DataRow = DtIngresosMes.NewRow + + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + If DtIngresosMes.Rows.Count > 0 Then + + For Each dr As DataRow In DtIngresosMes.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + DtIngresosMes.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosMes.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosMes.NewRow + If DtGastosMes.Rows.Count > 0 Then + + For Each dr As DataRow In DtGastosMes.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + Row.Item("Nombre") = "TOTAL GASTOS" + 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") = -1 + DtGastosMes.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosMes.Rows.Add(Row) + End If + + + GvIngresosMes.DataSource = DtIngresosMes + GvIngresosMes.DataBind() + + GvGastosMes.DataSource = DtGastosMes + GvGastosMes.DataBind() + + UpDatos.Update() + + End Sub + + + + Private Sub SumaTotales() + 'Llena Lb´s Totales + + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + LbTotalActual.Text = TotalActualMes.ToString("###,###,##0") + LbTotalAnterior.Text = TotalAnteriorMes.ToString("###,###,##0") + Else + LbTotalActual.Text = TotalActualMes.ToString("###,###,##0.00") + LbTotalAnterior.Text = TotalAnteriorMes.ToString("###,###,##0.00") + End If + + + + LbTotalActual.ForeColor = If(TotalActualMes < 0, Drawing.Color.Red, Color.Black) + + LbTotalAnterior.ForeColor = If(TotalAnteriorMes < 0, Drawing.Color.Red, Color.Black) + + + End Sub + +#Region "GV´S ROW DATA BOUND" + + Protected Sub GvIngresos_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf 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("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToEntero.ToString("###,###,##0") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToEntero.ToString("###,###,##0").ToString + Else + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToDecimal.ToString("###,###,##0.00").ToString + End If + + 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 + 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 + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + e.Row.FCHyperLink("HLActual").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + End If + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToEntero.ToString("###,###,##0") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToEntero.ToString("###,###,##0").ToString + Else + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToDecimal.ToString("###,###,##0.00").ToString + 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 + End If + End Sub + +#End Region + + + + +#End Region + + + +#Region "M E S H O R I Z O N T A L" + + Private Sub CargaDatosMesH() + + + FechaIMes = $"01/01/{DdlEjercicio.SelectedValue}" + Dim FechaFin As Date = $"01/{DdlPeriodo.SelectedValue.ToEntero.ToString("00")}/{DdlEjercicio.SelectedValue}".ToDate + FechaFMes = $"{FechaFin.LastDayOfMonth.Day.ToString("00")}/{DdlPeriodo.SelectedValue.ToEntero.ToString("00")}/{DdlEjercicio.SelectedValue}" + + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + 'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosMensualHorizontal(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then + DtDatosMesH = ObjConta.DtResultados.FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosMesH = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosMesH IsNot Nothing Then + CargaGridsMesH() + Else + + End If + + End Sub + + Private Sub CargaGridsMesH() + + DtIngresosMesH = DtDatosMesH.FiltraParametros("Tipo ='H' ") + DtGastosMesH = DtDatosMesH.FiltraParametros("Tipo ='G' ") + DTTotalesMesH = DtDatosMesH.Clone() + + Dim Row As DataRow = DtIngresosMesH.NewRow + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + + If DtIngresosMesH.Rows.Count > 0 Then + + For Each dr As DataRow In DtIngresosMesH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + Row.Item("Enero") = DtIngresosMesH.SUM("Enero", "NOT CtaMayor in (3,4)") + Row.Item("Febrero") = DtIngresosMesH.SUM("Febrero", "NOT CtaMayor in (3,4)") + Row.Item("Marzo") = DtIngresosMesH.SUM("Marzo", "NOT CtaMayor in (3,4)") + Row.Item("Abril") = DtIngresosMesH.SUM("Abril", "NOT CtaMayor in (3,4)") + Row.Item("Mayo") = DtIngresosMesH.SUM("Mayo", "NOT CtaMayor in (3,4)") + Row.Item("Junio") = DtIngresosMesH.SUM("Junio", "NOT CtaMayor in (3,4)") + Row.Item("Julio") = DtIngresosMesH.SUM("Julio", "NOT CtaMayor in (3,4)") + Row.Item("Agosto") = DtIngresosMesH.SUM("Agosto", "NOT CtaMayor in (3,4)") + Row.Item("Septiembre") = DtIngresosMesH.SUM("Septiembre", "NOT CtaMayor in (3,4)") + Row.Item("Octubre") = DtIngresosMesH.SUM("Octubre", "NOT CtaMayor in (3,4)") + Row.Item("Noviembre") = DtIngresosMesH.SUM("Noviembre", "NOT CtaMayor in (3,4)") + Row.Item("Diciembre") = DtIngresosMesH.SUM("Diciembre", "NOT CtaMayor in (3,4)") + + Row.Item("Tri1") = DtIngresosMesH.SUM("Tri1", "NOT CtaMayor in (3,4)") + Row.Item("Tri2") = DtIngresosMesH.SUM("Tri2", "NOT CtaMayor in (3,4)") + Row.Item("Tri3") = DtIngresosMesH.SUM("Tri3", "NOT CtaMayor in (3,4)") + Row.Item("Tri4") = DtIngresosMesH.SUM("Tri4", "NOT CtaMayor in (3,4)") + + Row.Item("Cua1") = DtIngresosMesH.SUM("Cua1", "NOT CtaMayor in (3,4)") + Row.Item("Cua2") = DtIngresosMesH.SUM("Cua2", "NOT CtaMayor in (3,4)") + Row.Item("Cua3") = DtIngresosMesH.SUM("Cua3", "NOT CtaMayor in (3,4)") + + + Row.Item("Nombre") = "TOTAL INGRESOS" + Row.Item("ImporteActual") = TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + + DtIngresosMesH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosMesH.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosMesH.NewRow + If DtGastosMesH.Rows.Count > 0 Then + + For Each dr As DataRow In DtGastosMesH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + + Row.Item("Enero") = DtGastosMesH.SUM("Enero", "NOT CtaMayor in (3,4)") + Row.Item("Febrero") = DtGastosMesH.SUM("Febrero", "NOT CtaMayor in (3,4)") + Row.Item("Marzo") = DtGastosMesH.SUM("Marzo", "NOT CtaMayor in (3,4)") + Row.Item("Abril") = DtGastosMesH.SUM("Abril", "NOT CtaMayor in (3,4)") + Row.Item("Mayo") = DtGastosMesH.SUM("Mayo", "NOT CtaMayor in (3,4)") + Row.Item("Junio") = DtGastosMesH.SUM("Junio", "NOT CtaMayor in (3,4)") + Row.Item("Julio") = DtGastosMesH.SUM("Julio", "NOT CtaMayor in (3,4)") + Row.Item("Agosto") = DtGastosMesH.SUM("Agosto", "NOT CtaMayor in (3,4)") + Row.Item("Septiembre") = DtGastosMesH.SUM("Septiembre", "NOT CtaMayor in (3,4)") + Row.Item("Octubre") = DtGastosMesH.SUM("Octubre", "NOT CtaMayor in (3,4)") + Row.Item("Noviembre") = DtGastosMesH.SUM("Noviembre", "NOT CtaMayor in (3,4)") + Row.Item("Diciembre") = DtGastosMesH.SUM("Diciembre", "NOT CtaMayor in (3,4)") + + Row.Item("Tri1") = DtGastosMesH.SUM("Tri1", "NOT CtaMayor in (3,4)") + Row.Item("Tri2") = DtGastosMesH.SUM("Tri2", "NOT CtaMayor in (3,4)") + Row.Item("Tri3") = DtGastosMesH.SUM("Tri3", "NOT CtaMayor in (3,4)") + Row.Item("Tri4") = DtGastosMesH.SUM("Tri4", "NOT CtaMayor in (3,4)") + + Row.Item("Cua1") = DtGastosMesH.SUM("Cua1", "NOT CtaMayor in (3,4)") + Row.Item("Cua2") = DtGastosMesH.SUM("Cua2", "NOT CtaMayor in (3,4)") + Row.Item("Cua3") = DtGastosMesH.SUM("Cua3", "NOT CtaMayor in (3,4)") + + Row.Item("Nombre") = "TOTAL GASTOS" + 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") = -1 + DtGastosMesH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosMesH.Rows.Add(Row) + End If + + If DtIngresosMesH.Rows.Count > 0 Then + + Row = DTTotalesMesH.NewRow + + Row.Item("Enero") = DtIngresosMesH.SUM("Enero", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Enero", "NOT CtaMayor in (-1,3,4)") + Row.Item("Febrero") = DtIngresosMesH.SUM("Febrero", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Febrero", "NOT CtaMayor in (-1,3,4)") + Row.Item("Marzo") = DtIngresosMesH.SUM("Marzo", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Marzo", "NOT CtaMayor in (-1,3,4)") + Row.Item("Abril") = DtIngresosMesH.SUM("Abril", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Abril", "NOT CtaMayor in (-1,3,4)") + Row.Item("Mayo") = DtIngresosMesH.SUM("Mayo", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Mayo", "NOT CtaMayor in (-1,3,4)") + Row.Item("Junio") = DtIngresosMesH.SUM("Junio", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Junio", "NOT CtaMayor in (-1,3,4)") + Row.Item("Julio") = DtIngresosMesH.SUM("Julio", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Julio", "NOT CtaMayor in (-1,3,4)") + Row.Item("Agosto") = DtIngresosMesH.SUM("Agosto", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Agosto", "NOT CtaMayor in (-1,3,4)") + Row.Item("Septiembre") = DtIngresosMesH.SUM("Septiembre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Septiembre", "NOT CtaMayor in (-1,3,4)") + Row.Item("Octubre") = DtIngresosMesH.SUM("Octubre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Octubre", "NOT CtaMayor in (-1,3,4)") + Row.Item("Noviembre") = DtIngresosMesH.SUM("Noviembre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Noviembre", "NOT CtaMayor in (-1,3,4)") + Row.Item("Diciembre") = DtIngresosMesH.SUM("Diciembre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Diciembre", "NOT CtaMayor in (-1,3,4)") + + Row.Item("Tri1") = DtIngresosMesH.SUM("Tri1", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri1", "NOT CtaMayor in (-1,3,4)") + Row.Item("Tri2") = DtIngresosMesH.SUM("Tri2", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri2", "NOT CtaMayor in (-1,3,4)") + Row.Item("Tri3") = DtIngresosMesH.SUM("Tri3", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri3", "NOT CtaMayor in (-1,3,4)") + Row.Item("Tri4") = DtIngresosMesH.SUM("Tri4", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri4", "NOT CtaMayor in (-1,3,4)") + + Row.Item("Cua1") = DtIngresosMesH.SUM("Cua1", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Cua1", "NOT CtaMayor in (-1,3,4)") + Row.Item("Cua2") = DtIngresosMesH.SUM("Cua2", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Cua2", "NOT CtaMayor in (-1,3,4)") + Row.Item("Cua3") = DtIngresosMesH.SUM("Cua3", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Cua3", "NOT CtaMayor in (-1,3,4)") + + Row.Item("Nombre") = "Resultados del Ejercicio:" + 'Row.Item("ImporteActual") = TotalActual.ToString + 'Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = DtIngresosMesH.SUM("ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") ' TotalAnterior.ToString + 'Row.Item("PorcentajeAcumulado") = "100.00" + 'Row.Item("CtaMayor") = -1 + + DTTotalesMesH.Rows.Add(Row) + + End If + + GvIngresosMesH.DataSource = DtIngresosMesH + GvIngresosMesH.DataBind() + + GvGastosMesH.DataSource = DtGastosMesH + GvGastosMesH.DataBind() + + GvTotalesMesH.DataSource = DTTotalesMesH + GvTotalesMesH.DataBind() + + + If DdlTri.SelectedValue.ToEntero = 0 Then 'ocultar trimestre cuatrimestre + + GvIngresosMesH.Columns(4).Visible = False + GvIngresosMesH.Columns(9).Visible = False + GvIngresosMesH.Columns(14).Visible = False + GvIngresosMesH.Columns(18).Visible = False + + GvGastosMesH.Columns(4).Visible = False + GvGastosMesH.Columns(9).Visible = False + GvGastosMesH.Columns(14).Visible = False + GvGastosMesH.Columns(18).Visible = False + + GvTotalesMesH.Columns(4).Visible = False + GvTotalesMesH.Columns(9).Visible = False + GvTotalesMesH.Columns(14).Visible = False + GvTotalesMesH.Columns(18).Visible = False + + GvIngresosMesH.Columns(6).Visible = False + GvIngresosMesH.Columns(12).Visible = False + GvIngresosMesH.Columns(19).Visible = False + + GvGastosMesH.Columns(6).Visible = False + GvGastosMesH.Columns(12).Visible = False + GvGastosMesH.Columns(19).Visible = False + + GvTotalesMesH.Columns(6).Visible = False + GvTotalesMesH.Columns(12).Visible = False + GvTotalesMesH.Columns(19).Visible = False + + + ElseIf DdlTri.SelectedValue.ToEntero = 1 Then 'Mostrar Trimestre + + + GvIngresosMesH.Columns(4).Visible = True + GvIngresosMesH.Columns(9).Visible = True + GvIngresosMesH.Columns(14).Visible = True + GvIngresosMesH.Columns(18).Visible = True + + GvGastosMesH.Columns(4).Visible = True + GvGastosMesH.Columns(9).Visible = True + GvGastosMesH.Columns(14).Visible = True + GvGastosMesH.Columns(18).Visible = True + + GvTotalesMesH.Columns(4).Visible = True + GvTotalesMesH.Columns(9).Visible = True + GvTotalesMesH.Columns(14).Visible = True + GvTotalesMesH.Columns(18).Visible = True + + GvIngresosMesH.Columns(6).Visible = False + GvIngresosMesH.Columns(12).Visible = False + GvIngresosMesH.Columns(19).Visible = False + + GvGastosMesH.Columns(6).Visible = False + GvGastosMesH.Columns(12).Visible = False + GvGastosMesH.Columns(19).Visible = False + + GvTotalesMesH.Columns(6).Visible = False + GvTotalesMesH.Columns(12).Visible = False + GvTotalesMesH.Columns(19).Visible = False + + ElseIf DdlTri.SelectedValue.ToEntero = 2 Then 'Mostrar Cuatrimestre + + GvIngresosMesH.Columns(4).Visible = False + GvIngresosMesH.Columns(9).Visible = False + GvIngresosMesH.Columns(14).Visible = False + GvIngresosMesH.Columns(18).Visible = False + + GvGastosMesH.Columns(4).Visible = False + GvGastosMesH.Columns(9).Visible = False + GvGastosMesH.Columns(14).Visible = False + GvGastosMesH.Columns(18).Visible = False + + GvTotalesMesH.Columns(4).Visible = False + GvTotalesMesH.Columns(9).Visible = False + GvTotalesMesH.Columns(14).Visible = False + GvTotalesMesH.Columns(18).Visible = False + + + GvIngresosMesH.Columns(6).Visible = True + GvIngresosMesH.Columns(12).Visible = True + GvIngresosMesH.Columns(19).Visible = True + + GvGastosMesH.Columns(6).Visible = True + GvGastosMesH.Columns(12).Visible = True + GvGastosMesH.Columns(19).Visible = True + + GvTotalesMesH.Columns(6).Visible = True + GvTotalesMesH.Columns(12).Visible = True + GvTotalesMesH.Columns(19).Visible = True + + End If + + + UpDatosMesH.Update() + + End Sub + + + Protected Sub GvIngresosMesH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + e.Row.ControlStyle.Font.Bold = True + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + + 'e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensualHorizontal.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&FF=31/12/{DdlEjercicio.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1" + + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}&TRCU={DdlTri.SelectedValue}" + + e.Row.FCHyperLink("HLEnero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/01/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLFebrero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/02/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/02/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMarzo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/03/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAbril").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMayo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/05/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJunio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/06/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJulio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/07/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAgosto").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/08/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLSeptiembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLOctubre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/10/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLNoviembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/11/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/11/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLDiciembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/12/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLTri1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri4").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLCua1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + + ' e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Or e.Row.DBCampo("Nombre") = "TOTAL INGRESOS" Then + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0") + Else + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0.00") + End If + + End If + + setgrafica(e) + + + + + e.Row.FCHyperLink("HLEnero").ForeColor = If(e.Row.DataKey("Enero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLEnero").ForeColor) + e.Row.FCHyperLink("HLFebrero").ForeColor = If(e.Row.DataKey("Febrero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLFebrero").ForeColor) + e.Row.FCHyperLink("HLMarzo").ForeColor = If(e.Row.DataKey("Marzo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMarzo").ForeColor) + e.Row.FCHyperLink("HLAbril").ForeColor = If(e.Row.DataKey("Abril").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLMayo").ForeColor = If(e.Row.DataKey("Mayo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLJunio").ForeColor = If(e.Row.DataKey("Junio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMayo").ForeColor) + e.Row.FCHyperLink("HLJulio").ForeColor = If(e.Row.DataKey("Julio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLJulio").ForeColor) + e.Row.FCHyperLink("HLAgosto").ForeColor = If(e.Row.DataKey("Agosto").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAgosto").ForeColor) + e.Row.FCHyperLink("HLSeptiembre").ForeColor = If(e.Row.DataKey("Septiembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLSeptiembre").ForeColor) + e.Row.FCHyperLink("HLOctubre").ForeColor = If(e.Row.DataKey("Octubre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLOctubre").ForeColor) + e.Row.FCHyperLink("HLNoviembre").ForeColor = If(e.Row.DataKey("Noviembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLNoviembre").ForeColor) + e.Row.FCHyperLink("HLDiciembre").ForeColor = If(e.Row.DataKey("Diciembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLDiciembre").ForeColor) + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + + End If + + End Sub + + Protected Sub GvGastosMesH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + + 'e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensualHorizontal.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&FF=31/12/{DdlEjercicio.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1" + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}&TRCU={DdlTri.SelectedValue}" + + e.Row.FCHyperLink("HLEnero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/01/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLFebrero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/02/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/02/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMarzo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/03/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAbril").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMayo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/05/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJunio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/06/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJulio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/07/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAgosto").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/08/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLSeptiembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLOctubre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/10/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLNoviembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/11/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/11/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLDiciembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/12/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLTri1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri4").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLCua1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + 'e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + End If + + + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Or e.Row.DBCampo("Nombre") = "TOTAL GASTOS" Then + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + + 'Enero,Febrero,Marzo,Abril,Mayo,Junio,Julio,Agosto,Septiembre,Octubre,Noviembre,Diciembre,PorcentajeAcumulado + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0") + + Else + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0.00") + End If + End If + + + setgrafica(e) + + + e.Row.FCHyperLink("HLEnero").ForeColor = If(e.Row.DataKey("Enero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLEnero").ForeColor) + e.Row.FCHyperLink("HLFebrero").ForeColor = If(e.Row.DataKey("Febrero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLFebrero").ForeColor) + e.Row.FCHyperLink("HLMarzo").ForeColor = If(e.Row.DataKey("Marzo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMarzo").ForeColor) + e.Row.FCHyperLink("HLAbril").ForeColor = If(e.Row.DataKey("Abril").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLMayo").ForeColor = If(e.Row.DataKey("Mayo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLJunio").ForeColor = If(e.Row.DataKey("Junio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMayo").ForeColor) + e.Row.FCHyperLink("HLJulio").ForeColor = If(e.Row.DataKey("Julio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLJulio").ForeColor) + e.Row.FCHyperLink("HLAgosto").ForeColor = If(e.Row.DataKey("Agosto").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAgosto").ForeColor) + e.Row.FCHyperLink("HLSeptiembre").ForeColor = If(e.Row.DataKey("Septiembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLSeptiembre").ForeColor) + e.Row.FCHyperLink("HLOctubre").ForeColor = If(e.Row.DataKey("Octubre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLOctubre").ForeColor) + e.Row.FCHyperLink("HLNoviembre").ForeColor = If(e.Row.DataKey("Noviembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLNoviembre").ForeColor) + e.Row.FCHyperLink("HLDiciembre").ForeColor = If(e.Row.DataKey("Diciembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLDiciembre").ForeColor) + + + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvTotalesMesH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.Header Then + e.Row.Attributes.Add("style", "display:none") + End If + + If e.Row.RowType = DataControlRowType.DataRow Then + + e.Row.Attributes.Add("style", "Font-weight: bold") + + + If DdlDivisor.SelectedValue.ToEntero > 0 Then + + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0") + + Else + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0.00") + End If + + setgrafica(e) + + e.Row.FCHyperLink("HLEnero").ForeColor = If(e.Row.DataKey("Enero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLEnero").ForeColor) + e.Row.FCHyperLink("HLFebrero").ForeColor = If(e.Row.DataKey("Febrero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLFebrero").ForeColor) + e.Row.FCHyperLink("HLMarzo").ForeColor = If(e.Row.DataKey("Marzo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMarzo").ForeColor) + e.Row.FCHyperLink("HLAbril").ForeColor = If(e.Row.DataKey("Abril").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLMayo").ForeColor = If(e.Row.DataKey("Mayo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLJunio").ForeColor = If(e.Row.DataKey("Junio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMayo").ForeColor) + e.Row.FCHyperLink("HLJulio").ForeColor = If(e.Row.DataKey("Julio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLJulio").ForeColor) + e.Row.FCHyperLink("HLAgosto").ForeColor = If(e.Row.DataKey("Agosto").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAgosto").ForeColor) + e.Row.FCHyperLink("HLSeptiembre").ForeColor = If(e.Row.DataKey("Septiembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLSeptiembre").ForeColor) + e.Row.FCHyperLink("HLOctubre").ForeColor = If(e.Row.DataKey("Octubre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLOctubre").ForeColor) + e.Row.FCHyperLink("HLNoviembre").ForeColor = If(e.Row.DataKey("Noviembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLNoviembre").ForeColor) + e.Row.FCHyperLink("HLDiciembre").ForeColor = If(e.Row.DataKey("Diciembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLDiciembre").ForeColor) + + + End If + + End Sub + + Public Sub setgrafica(e As GridViewRowEventArgs) + + Dim lista As New List(Of Object) + lista.Add(New With {.Texto = "Enero", .Valor = e.Row.DataKey("Enero").ToDecimal(), .Color = "#FF0F00"}) + lista.Add(New With {.Texto = "Febrero", .Valor = e.Row.DataKey("Febrero").ToDecimal(), .Color = "#FF6600"}) + lista.Add(New With {.Texto = "Marzo", .Valor = e.Row.DataKey("Marzo").ToDecimal(), .Color = "#F8FF01"}) + lista.Add(New With {.Texto = "Abril", .Valor = e.Row.DataKey("Abril").ToDecimal(), .Color = "#04D215"}) + lista.Add(New With {.Texto = "Mayo", .Valor = e.Row.DataKey("Mayo").ToDecimal(), .Color = "#2A0CD0"}) + lista.Add(New With {.Texto = "Junio", .Valor = e.Row.DataKey("Junio").ToDecimal(), .Color = "#8A0CCF"}) + lista.Add(New With {.Texto = "Julio", .Valor = e.Row.DataKey("Julio").ToDecimal(), .Color = "#CD0D74"}) + lista.Add(New With {.Texto = "Agosto", .Valor = e.Row.DataKey("Agosto").ToDecimal(), .Color = "#754DEB"}) + lista.Add(New With {.Texto = "Septiembre", .Valor = e.Row.DataKey("Septiembre").ToDecimal(), .Color = "#DDDDDD"}) + lista.Add(New With {.Texto = "Octubre", .Valor = e.Row.DataKey("Octubre").ToDecimal(), .Color = "#999999"}) + lista.Add(New With {.Texto = "Noviembre", .Valor = e.Row.DataKey("Noviembre").ToDecimal(), .Color = "#000000"}) + lista.Add(New With {.Texto = "Diciembre", .Valor = e.Row.DataKey("Diciembre").ToDecimal(), .Color = "#FF0F00"}) + e.Row.FCHyperLink("Hypgrafica").Attributes.Add("data-values", Newtonsoft.Json.JsonConvert.SerializeObject(lista)) + End Sub +#End Region + + + +#Region "Anual H O R I Z O N T A L" + + Private Sub CargaDatosAnualH() + + + FechaIMes = $"01/01/{DdlEjercicio.SelectedValue}" + FechaFMes = $"31/12/{DdlEjercicio2.SelectedValue}" + + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + 'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosAnualHorizontal(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, DdlPeriodo.SelectedValue.ToEntero, Periodo:=DdlPeriodo.SelectedValue.ToEntero) Then + DtDatosAnualH = ObjConta.DtResultados.FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosAnualH = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosAnualH IsNot Nothing Then + CargaGridsAnualH() + + End If + + End Sub + + Private Sub CargaGridsAnualH() + + DtIngresosAnualH = DtDatosAnualH.FiltraParametros("Tipo ='H' ") + DtGastosAnualH = DtDatosAnualH.FiltraParametros("Tipo ='G' ") + DTTotalesAnualH = DtDatosAnualH.Clone() + + Dim Row As DataRow = DtIngresosAnualH.NewRow + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + + + Dim IndexData As Integer = 0 + Dim IndexGv As Integer = 1 + Dim IndexMax As Integer = 1 + + + Dim IDX_LIMPIAR As Integer = 1 + + For IDX_LIMPIAR = 1 To 25 + + GvIngresosAnualH.Columns(IDX_LIMPIAR).Visible = False + GvGastosAnualH.Columns(IDX_LIMPIAR).Visible = False + GvTotalesAnualH.Columns(IDX_LIMPIAR).Visible = False + Next + listaCamposanios.Clear() + listaCamposaniosGastos.Clear() + listaCamposaniosTotal.Clear() + + If DtIngresosAnualH.Rows.Count > 0 Then + + + + + For Each dCoumn As DataColumn In DtIngresosAnualH.Columns + + If IndexData >= 13 Then + + If dCoumn.ColumnName.ToEntero > 0 And dCoumn.ColumnName.ToEntero <= DdlEjercicio2.SelectedValue.ToEntero Then + + CType(GvIngresosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + CType(GvIngresosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + + + listaCamposanios.Add(New String() {dCoumn.ColumnName.ToString(), dCoumn.ColumnName.ToString()}) + + listaCamposaniosTotal.Add(New String() {dCoumn.ColumnName.ToString(), dCoumn.ColumnName.ToString()}) + 'CType(GvIngresosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + 'CType(GvIngresosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + GvIngresosAnualH.Columns(IndexGv).Visible = True + + + CType(GvTotalesAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + CType(GvTotalesAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + 'CType(GvTotalesAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + 'CType(GvTotalesAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + GvTotalesAnualH.Columns(IndexGv).Visible = True + + IndexMax = IndexData + Else + GvIngresosAnualH.Columns(IndexGv).Visible = False + GvTotalesAnualH.Columns(IndexGv).Visible = False + End If + + + + IndexGv = IndexGv + 1 + End If + + IndexData = IndexData + 1 + + Next + + + For Each dr As DataRow In DtIngresosAnualH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + + Next + + IndexData = 13 + For IndexData = 13 To IndexMax + Row.Item(IndexData) = DtIngresosAnualH.SUM($"[{DtIngresosAnualH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (3,4)") + Next + + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = DtIngresosAnualH.SUM("ImporteActual", "NOT CtaMayor in (3,4)") 'TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = DtIngresosAnualH.SUM("ImporteAcumulado", "NOT CtaMayor in (3,4)") 'TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + Row.Item("CountDinamico") = DtGastosAnualH.MAX("CountDinamico") + CountDinamicoAnual = DtGastosAnualH.MAX("CountDinamico").ToEntero + DtIngresosAnualH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosAnualH.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosAnualH.NewRow + + If DtGastosAnualH.Rows.Count > 0 Then + + + IndexData = 0 + IndexGv = 1 + IndexMax = 0 + + For Each dCoumn As DataColumn In DtGastosAnualH.Columns + + If IndexData >= 13 Then + + If dCoumn.ColumnName.ToEntero > 0 And dCoumn.ColumnName.ToEntero <= DdlEjercicio2.SelectedValue.ToEntero Then + 'HyperLinkField + + CType(GvGastosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + CType(GvGastosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + listaCamposaniosGastos.Add(New String() {dCoumn.ColumnName.ToString(), dCoumn.ColumnName.ToString()}) + + 'CType(GvGastosAnualH.Columns(IndexGv), HyperLinkField).DataNavigateUrlFields = {"CveCuenta", "FechaInicial", "FechaFActual", "CveSubProyecto"} + 'CType(GvGastosAnualH.Columns(IndexGv), HyperLinkField).DataNavigateUrlFormatString = "/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1&CveSubProyecto{3}" + + 'CType(GvGastosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + 'CType(GvGastosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + + GvGastosAnualH.Columns(IndexGv).Visible = True + IndexMax = IndexData + Else + GvGastosAnualH.Columns(IndexGv).Visible = False + End If + + + + IndexGv = IndexGv + 1 + End If + + IndexData = IndexData + 1 + + Next + + + For Each dr As DataRow In DtGastosAnualH.FiltraParametros("Not CtaMayor In (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + IndexData = 13 + For IndexData = 13 To IndexMax + + Row.Item(IndexData) = DtGastosAnualH.SUM($"[{DtIngresosAnualH.Columns(IndexData).ColumnName}]", "Not CtaMayor In (3,4)") + + Next + + Row.Item("Nombre") = "TOTAL GASTOS" + 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") = -1 + Row.Item("CountDinamico") = DtGastosAnualH.MAX("CountDinamico") + DtGastosAnualH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosAnualH.Rows.Add(Row) + End If + + If DtIngresosAnualH.Rows.Count > 0 Then + + Row = DTTotalesAnualH.NewRow + + + IndexData = 13 + For IndexData = 13 To IndexMax + Row.Item(IndexData) = DtIngresosAnualH.SUM($"[{DtIngresosAnualH.Columns(IndexData).ColumnName}]", "Not CtaMayor In (-1,3,4)") - DtGastosAnualH.SUM($"[{DtGastosAnualH.Columns(IndexData).ColumnName}]", "Not CtaMayor In (-1,3,4)") + Next + + Row.Item("Nombre") = "Resultados del Ejercicio" + Row.Item("ImporteAcumulado") = DtIngresosAnualH.SUM($"ImporteAcumulado", "Not CtaMayor in (-1,3,4)") - DtGastosAnualH.SUM($"ImporteAcumulado", "Not CtaMayor in (-1,3,4)") + + + DTTotalesAnualH.Rows.Add(Row) + + End If + + GvIngresosAnualH.DataSource = DtIngresosAnualH + GvIngresosAnualH.DataBind() + + GvGastosAnualH.DataSource = DtGastosAnualH + GvGastosAnualH.DataBind() + + GvTotalesAnualH.DataSource = DTTotalesAnualH + GvTotalesAnualH.DataBind() + + UpDatosAnualH.Update() + + End Sub + + + + Protected Sub GvIngresosAnualH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCCAnual(e, listaCamposanios) + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales3" + e.Row.ControlStyle.Font.Bold = True + End If + + + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + Dim CveSubProyecto As Integer = e.Row.DataKey("CveSubProyecto").ToEntero + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + Dim Anio As String = CType(GvGastosAnualH.Columns(IndiceInicio), BoundField).DataField + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + 'e.Row.Cells(IndiceInicio).ForeColor = If(Importe < 0, Drawing.Color.Red, e.Row.Cells(IndiceInicio).ForeColor) + Next IndiceInicio + + 'e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogo.aspx?CveCuenta={CveCuenta}&FF=31/12/{DdlEjercicio2.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1&CveSubProyecto={CveSubProyecto}" + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + + Next IndiceInicio + + + End If + + + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvGastosAnualH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCCAnual(e, listaCamposaniosGastos) + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + Dim CveSubProyecto As Integer = e.Row.DataKey("CveSubProyecto").ToEntero + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + 'e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto=-1&EjercicioFinal={DdlEjercicio2.SelectedValue}" + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + For IndiceInicio = 1 To IndiceMax + Dim Anio As String = CType(GvGastosAnualH.Columns(IndiceInicio), BoundField).DataField + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00"))}" + 'e.Row.Cells(IndiceInicio).ForeColor = If(Importe < 0, Drawing.Color.Red, e.Row.Cells(IndiceInicio).ForeColor) + Next IndiceInicio + + 'e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogo.aspx?CveCuenta={CveCuenta}&FF=31/12/{DdlEjercicio2.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1&CveSubProyecto={CveSubProyecto}" + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + + Next IndiceInicio + + End If + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvTotalesAnualH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.Header Then + e.Row.Attributes.Add("style", "display:none") + End If + + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCCAnual(e, listaCamposaniosTotal) + e.Row.Attributes.Add("style", "Font-weight: bold") + End If + + End Sub + + Public Sub setgraficaCCAnual(e As GridViewRowEventArgs, listaCampos As List(Of String())) + Dim lista As New List(Of Object) + Dim colorindex As Integer = 0 + For Each campo As String() In listaCampos + lista.Add(New With {.Texto = campo(1), .Valor = e.Row.DBCampo(campo(0)).ToDecimal(), .Color = listacolores(colorindex)}) + colorindex = colorindex + 1 + If colorindex >= listacolores.Count Then + colorindex = 0 + End If + Next + e.Row.FCHyperLink("Hypgrafica").Attributes.Add("data-values", Newtonsoft.Json.JsonConvert.SerializeObject(lista)) + End Sub +#End Region + + +#Region "S U B P R O Y E C T O H O R I Z O N T A L" + + Private Sub CargaDatosSubProyectoH() + + + FechaIMes = $"01/01/{DdlEjercicio.SelectedValue}" + FechaFMes = $"01/{DdlPeriodo.SelectedValue.ToEntero.ToString("00")}/{DdlEjercicio.SelectedValue}" + FechaFMes = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, CDate(FechaFMes))).ToString("dd/MM/yyyy") + + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosSubProyectoHorizontal(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then + DTSubProyectosCabecerasH = ObjConta.DSResultados.Tables(0) + DtDatosSubProyectoH = ObjConta.DSResultados.Tables(1).FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosSubProyectoH = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosSubProyectoH IsNot Nothing And DTSubProyectosCabecerasH IsNot Nothing Then + CargaGridsSubProyectoH() + End If + + End Sub + + Private Sub CargaGridsSubProyectoH() + + DtIngresosSubProyectoH = DtDatosSubProyectoH.FiltraParametros("Tipo ='H' ") + DtGastosSubProyectoH = DtDatosSubProyectoH.FiltraParametros("Tipo ='G' ") + DTTotalesSubProyectoH = DtDatosSubProyectoH.Clone() + + Dim Row As DataRow = DtIngresosSubProyectoH.NewRow + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + + + Dim IndexData As Integer = 0 + Dim IndexGv As Integer = 1 + Dim IndexMax As Integer = 1 + Dim IndexSubProyecto = 0 + Dim IndexSubProyectoMAx As Integer = DTSubProyectosCabecerasH.Rows.Count - 1 + Dim IndexTotatles As Integer = 13 + IndexSubProyectoMAx + + '34 + Dim IDX_LIMPIAR As Integer = 1 + + For IDX_LIMPIAR = 1 To 35 + CType(GvIngresosSubProyectoH.Columns(IDX_LIMPIAR), BoundField).DataField = Nothing + CType(GvIngresosSubProyectoH.Columns(IDX_LIMPIAR), BoundField).HeaderText = "" + GvIngresosSubProyectoH.Columns(IDX_LIMPIAR).Visible = False + Next + listaCampos.Clear() + + + If DtIngresosSubProyectoH.Rows.Count > 0 Then + + For Each dCoumn As DataColumn In DtIngresosSubProyectoH.Columns + + If IndexData >= 13 Then + + If IndexSubProyecto <= IndexSubProyectoMAx Then + + CType(GvIngresosSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvIngresosSubProyectoH.Columns(IndexGv).Visible = True + + CType(GvTotalesSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvTotalesSubProyectoH.Columns(IndexGv).Visible = True + + If IndexSubProyecto <= IndexSubProyectoMAx Then + CType(GvIngresosSubProyectoH.Columns(IndexGv), BoundField).HeaderText = DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString + CType(GvTotalesSubProyectoH.Columns(IndexGv), BoundField).HeaderText = DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString + CType(GvGastosSubProyectoH.Columns(IndexGv), BoundField).HeaderText = DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString + End If + listaCampos.Add(New String() {dCoumn.ColumnName.ToString(), DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString()}) + Else + GvIngresosSubProyectoH.Columns(IndexGv).Visible = False + GvTotalesSubProyectoH.Columns(IndexGv).Visible = False + End If + + IndexGv = IndexGv + 1 + IndexSubProyecto = IndexSubProyecto + 1 + IndexMax = IndexMax + 1 + + End If + IndexData = IndexData + 1 + Next + + + For Each dr As DataRow In DtIngresosSubProyectoH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + IndexData = 13 + For IndexData = 13 To IndexTotatles + Row.Item(IndexData) = DtIngresosSubProyectoH.SUM($"[{DtIngresosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (3,4)") + Next + + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = DtIngresosSubProyectoH.SUM("ImporteActual", "NOT CtaMayor in (3,4)") 'TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = DtIngresosSubProyectoH.SUM("ImporteAcumulado", "NOT CtaMayor in (3,4)") 'TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + Row.Item("CountDinamico") = DtIngresosSubProyectoH.MAX("CountDinamico") + CountDinamicoSubProyecto = DtIngresosSubProyectoH.MAX("CountDinamico").ToEntero + DtIngresosSubProyectoH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosSubProyectoH.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosSubProyectoH.NewRow + + If DtGastosSubProyectoH.Rows.Count > 0 Then + + + IndexData = 0 + IndexGv = 1 + IndexMax = 0 + IndexSubProyecto = 0 + + For Each dCoumn As DataColumn In DtIngresosSubProyectoH.Columns + If IndexData >= 13 Then + If IndexSubProyecto <= IndexSubProyectoMAx Then + CType(GvGastosSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvGastosSubProyectoH.Columns(IndexGv).Visible = True + CType(GvTotalesSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvTotalesSubProyectoH.Columns(IndexGv).Visible = True + Else + GvIngresosSubProyectoH.Columns(IndexGv).Visible = False + GvTotalesSubProyectoH.Columns(IndexGv).Visible = False + End If + + IndexGv = IndexGv + 1 + IndexSubProyecto = IndexSubProyecto + 1 + End If + IndexData = IndexData + 1 + Next + + + + For Each dr As DataRow In DtGastosSubProyectoH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + IndexData = 13 + For IndexData = 13 To IndexTotatles + Row.Item(IndexData) = DtGastosSubProyectoH.SUM($"[{DtIngresosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (3,4)") + Next + + Row.Item("Nombre") = "TOTAL GASTOS" + 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") = -1 + Row.Item("CountDinamico") = DtGastosSubProyectoH.MAX("CountDinamico") + + DtGastosSubProyectoH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosSubProyectoH.Rows.Add(Row) + End If + + If DtIngresosSubProyectoH.Rows.Count > 0 Then + + Row = DTTotalesSubProyectoH.NewRow + + IndexData = 13 + For IndexData = 13 To IndexTotatles + Row.Item(IndexData) = DtIngresosSubProyectoH.SUM($"[{DtIngresosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (-1,3,4)") - DtGastosSubProyectoH.SUM($"[{DtGastosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (-1,3,4)") + Next + + Row.Item("Nombre") = "Resultado del ejercicio" + Row.Item("ImporteAcumulado") = DtIngresosSubProyectoH.SUM($"ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") - DtGastosSubProyectoH.SUM($"ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") + Row.Item("CtaMayor") = -2 + Row.Item("CountDinamico") = DtIngresosSubProyectoH.MAX("CountDinamico") + + DTTotalesSubProyectoH.Rows.Add(Row) + + End If + + DtIngresosSubProyectoH.Merge(DtGastosSubProyectoH) + DtIngresosSubProyectoH.Merge(DTTotalesSubProyectoH) + + + GvIngresosSubProyectoH.DataSource = DtIngresosSubProyectoH + GvIngresosSubProyectoH.DataBind() + + + + UpDatosSubProyectoH.Update() + + End Sub + + 'Private Sub SumaTotalesSubProyectoH() + ' ''Llena Lb´s Totales + ' ''********************************************************************************* + ' 'LbTotalActual.Text = TotalActualMes.ToString.FormatoNumero + ' 'LbTotalAnterior.Text = TotalAnteriorMes.ToString.FormatoNumero + + ' 'LbTotalActual.ForeColor = If(TotalActualMes < 0, Drawing.Color.Red, Color.Black) + ' 'LbTotalAnterior.ForeColor = If(TotalAnteriorMes < 0, Drawing.Color.Red, Color.Black) + + + 'End Sub + + Protected Sub GvIngresosSubProyectoH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales3" + e.Row.ControlStyle.Font.Bold = True + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -2 Then + + e.Row.ControlStyle.Font.Bold = True + e.Row.ControlStyle.Font.Size = 13 + End If + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + setgraficaCC(e) + 'Dim CveSubProyecto As Integer = e.Row.DataKey("CveSubProyecto").ToEntero + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoCC.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + Dim FEchaMesFinal As Date = New Date(DdlEjercicio.SelectedValue.ToEntero, DdlPeriodo.SelectedValue.ToEntero, 1).LastDayOfMonth + + For IndiceInicio = 1 To IndiceMax + + Dim CveSubProyectoIntermo As String = CType(GvGastosSubProyectoH.Columns(IndiceInicio), BoundField).DataField + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + + + If CveSubProyectoIntermo.ToEntero > 0 Then + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + End If + + + + Next IndiceInicio + + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoCC.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"
    { If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }
    " + Next IndiceInicio + + + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -2 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"
    { If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }
    " + + Next IndiceInicio + + + End If + e.Row.FCHyperLink("HLAnterior").Text = If(DdlDivisor.SelectedValue.ToEntero > 1, e.Row.DBCampo("ImporteAcumulado").ToString.ToDecimal.ToString("###,###,##0"), e.Row.DBCampo("ImporteAcumulado").ToString.ToDecimal.ToString("###,###,##0.00")) + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + + End If + + End Sub + + Protected Sub GvGastosSubProyectoH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCC(e) + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvTotalesSubProyectoH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.Header Then + ' e.Row.Attributes.Add("style", "display:none") + End If + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCC(e) + e.Row.Attributes.Add("style", "Font-weight: bold") + End If + End Sub + + Public Sub setgraficaCC(e As GridViewRowEventArgs) + Dim lista As New List(Of Object) + Dim colorindex As Integer = 0 + For Each campo As String() In listaCampos + lista.Add(New With {.Texto = campo(1), .Valor = e.Row.DBCampo(campo(0)).ToDecimal(), .Color = listacolores(colorindex)}) + colorindex = colorindex + 1 + If colorindex >= listacolores.Count Then + colorindex = 0 + End If + Next + e.Row.FCHyperLink("Hypgrafica").Attributes.Add("data-values", Newtonsoft.Json.JsonConvert.SerializeObject(lista)) + End Sub +#End Region + + + + + +#Region "DESCARGA EXCEL" + + Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click + Imprimir("Excel") + End Sub + + Private Sub Imprimir(Optional reporte As String = "PDF") + + + If TAB.ActiveTabIndex = 0 AndAlso GvIngresosMes.Rows.Count > 0 Then + ExportToExcelG(GvIngresosMes, GvGastosMes, TMesT1, "Reporte_Mensual", UsuarioActual, "Mensual") + ElseIf TAB.ActiveTabIndex = 1 AndAlso GvIngresosMesH.Rows.Count > 0 Then + ExportToExcelG(GvIngresosMesH, GvGastosMesH, TMesT1, "Reporte_Mensual_Horizontal", UsuarioActual, "Mensual Horizontal", Gv3:=GvTotalesMesH) + ElseIf TAB.ActiveTabIndex = 2 AndAlso GvIngresosAnualH.Rows.Count > 0 Then + ExportToExcelG(GvIngresosAnualH, GvGastosAnualH, TMesT1, "Reporte_Anual_Horizontal", UsuarioActual, "Anual Horizontal", Gv3:=GvTotalesAnualH) + + ElseIf TAB.ActiveTabIndex = 3 AndAlso GvIngresosSubProyectoH.Rows.Count > 0 Then + + ExportToExcelG(GvIngresosSubProyectoH, GvGastosSubProyectoH, TMesT1, "Reporte_Proyecto_Horizontal", UsuarioActual, $"Estado de Resultados Horizontal por {LblSubProyecto.Text}", Gv3:=GvTotalesSubProyectoH, EsPorSubProtyecto:=True) + + End If + + + End Sub + + 'Public Sub ExportToExcelG(Gv1 As GridView, Gv2 As GridView, NombreArchivoXLSx As String, Optional Titulo As String = "Reporte", Optional Usuario As Usuario = Nothing, Optional Filtros As String = "", Optional AlturaImagen As Double = 100, Optional AnchoImagen As Double = 100) + Public Sub ExportToExcelG(Gv1 As GridView, Gv2 As GridView, TablaResultados As HtmlTable, NombreArchivoXLSx As String, Usuario As Usuario, Titulo As String, Optional AlturaImagen As Double = 100, Optional AnchoImagen As Double = 100, Optional Gv3 As GridView = Nothing, Optional EsPorSubProtyecto As Boolean = False) + + Dim sw1 As New StringWriter() + Dim htw1 As New HtmlTextWriter(sw1) + Gv1.RenderControl(htw1) + + Dim sw2 As New StringWriter() + Dim htw2 As New HtmlTextWriter(sw2) + Gv2.RenderControl(htw2) + + + TablaResultados.Width = Gv2.Width.ToString + + Dim sw3 As New StringWriter() + Dim htw3 As New HtmlTextWriter(sw3) + TablaResultados.RenderControl(htw3) + + Dim options = GemBox.Spreadsheet.LoadOptions.HtmlDefault + + Dim htmlStream1 = New MemoryStream(options.Encoding.GetBytes(sw1.ToString())) + Dim htmlStream2 = New MemoryStream(options.Encoding.GetBytes(sw2.ToString())) + Dim htmlStream3 = New MemoryStream(options.Encoding.GetBytes(sw3.ToString())) + + htmlStream1.Position = 0 + Dim sr1 As New StreamReader(htmlStream1) + + htmlStream2.Position = 0 + Dim sr2 As New StreamReader(htmlStream2) + + htmlStream3.Position = 0 + Dim sr3 As New StreamReader(htmlStream3) + + + Dim myStr1 = sr1.ReadToEnd() + Dim myStr2 = sr2.ReadToEnd() + Dim myStr3 = sr3.ReadToEnd() + + sr1.Dispose() + sr2.Dispose() + sr3.Dispose() + + htmlStream1.Dispose() + htmlStream2.Dispose() + htmlStream3.Dispose() + + sw1.Dispose() + sw2.Dispose() + sw3.Dispose() + + If Gv3 IsNot Nothing Then + + Gv3.ShowHeader = False + + Dim sw4 As New StringWriter() + Dim htw4 As New HtmlTextWriter(sw4) + Gv3.RenderControl(htw4) + Dim htmlStream4 = New MemoryStream(options.Encoding.GetBytes(sw4.ToString())) + htmlStream4.Position = 0 + Dim sr4 As New StreamReader(htmlStream4) + myStr3 = sr4.ReadToEnd() + + sr4.Dispose() + htmlStream2.Dispose() + sw4.Dispose() + + End If + + + Dim HtmlCompleto As String = myStr1 & "
    " & myStr2 & "
    " & myStr3 + + + HtmlCompleto = Regex.Replace(HtmlCompleto, "\<[\/]*a[^\>]*\>", "") + + + Dim htmlStream5 = New MemoryStream(options.Encoding.GetBytes(HtmlCompleto)) + + GemBox.Spreadsheet.SpreadsheetInfo.SetLicense(SerialGemBoxSpreadsheet) + + Dim excel As GemBox.Spreadsheet.ExcelFile + + excel = GemBox.Spreadsheet.ExcelFile.Load(htmlStream5, options) + + If Usuario IsNot Nothing Then + + Dim TotalRowHeader As Integer = 8 + Dim TotalRowFooter As Integer = 2 + + + Dim worksheet = excel.Worksheets(0) + worksheet.Rows.InsertEmpty(0, TotalRowHeader) + Dim celdasConTexto = worksheet.GetUsedCellRange(True) + celdasConTexto.Style.Font.Name = "Calibri Light" + + Dim RangoNombreEmpresa = worksheet.Cells.GetSubrangeAbsolute(1, celdasConTexto.FirstColumnIndex, 1, celdasConTexto.LastColumnIndex) + RangoNombreEmpresa.Merged = True + RangoNombreEmpresa.Value = Usuario.Empresa.Empresa + RangoNombreEmpresa.Style.Font.Size = 18 * 20 + RangoNombreEmpresa.Style.Font.Name = "Calibri Light" + RangoNombreEmpresa.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoNombreEmpresa.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + + Dim RangoTitulo = worksheet.Cells.GetSubrangeAbsolute(3, celdasConTexto.FirstColumnIndex, 3, celdasConTexto.LastColumnIndex) + RangoTitulo.Merged = True + RangoTitulo.Value = Titulo + RangoTitulo.Style.Font.Size = 20 * 20 + RangoTitulo.Style.Font.Name = "Calibri Light" + RangoTitulo.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoTitulo.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + Dim RangoFechas = worksheet.Cells.GetSubrangeAbsolute(4, celdasConTexto.FirstColumnIndex, 4, celdasConTexto.LastColumnIndex) + RangoFechas.Merged = True + RangoFechas.Value = $"Fechas: {FechaIMes} a {FechaFMes}" + RangoFechas.Style.Font.Size = 15 * 20 + RangoFechas.Style.Font.Name = "Calibri Light" + RangoFechas.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoFechas.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + + If EsPorSubProtyecto And DdlSubproyecto.SelectedValue.ToEntero > 0 Then + Dim RangoSubProyecto = worksheet.Cells.GetSubrangeAbsolute(5, celdasConTexto.FirstColumnIndex, 5, celdasConTexto.LastColumnIndex) + RangoSubProyecto.Merged = True + RangoSubProyecto.Value = DdlSubproyecto.SelectedItem.Text + RangoSubProyecto.Style.Font.Size = 20 * 20 + RangoSubProyecto.Style.Font.Name = "Calibri Light" + RangoSubProyecto.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoSubProyecto.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + End If + + For i = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex + + worksheet.Rows(8).Cells(i).Style.Font.Size = 12 * 20 + worksheet.Rows(8).Cells(i).Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + worksheet.Rows(8).Cells(i).Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + worksheet.Rows(8).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(8).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255) + + + + If Not EsPorSubProtyecto Then + worksheet.Rows(8 + Gv1.Rows.Count + 2).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(8 + Gv1.Rows.Count + 2).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255) + Else + worksheet.Rows(18).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(18).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255) + End If + + + + If i > 0 Then + Try + worksheet.Columns(i).AutoFit(1) + Catch ex As Exception + End Try + End If + Next + + Dim IndexEndTable As Integer = Gv1.Rows.Count + Gv2.Rows.Count + 4 + TotalRowHeader + TotalRowFooter + + worksheet.Rows(IndexEndTable).Cells(0).Value = "Usuario Imprimió" + worksheet.Rows(IndexEndTable + 1).Cells(0).Value = Usuario.Nombre + + worksheet.Rows(IndexEndTable).Cells(2).Value = "Fecha Impresión" + worksheet.Rows(IndexEndTable + 1).Cells(2).Value = DateTime.Now.ToString("dd/MM/yyyy") + + Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", Usuario.Empresa.Ruta)) + + If Imagen.Exists Then + Dim Ruta As String = String.Format("{0}/Logo.png", Usuario.Empresa.Ruta) + Using sr As New StreamReader(Ruta) + Dim ms As New MemoryStream() + sr.BaseStream.CopyTo(ms) + worksheet.Pictures.Add(ms, ExcelPictureFormat.Png, "A1", AnchoImagen, AlturaImagen, LengthUnit.Pixel) + End Using + End If + + + + + + + For I = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex + + If I > 0 Then + + If DdlDivisor.SelectedValue.ToEntero = 1 Then + worksheet.Columns(I + 1).Style.NumberFormat = "#,##0.00" + Else + worksheet.Columns(I + 1).Style.NumberFormat = "#,##" + End If + + Try + worksheet.Columns(I).AutoFit(1) + Catch ex As Exception + End Try + + End If + Next + + End If + + excel.Save(HttpContext.Current.Response, $"{NombreArchivoXLSx}.xlsx") + + + End Sub + + Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) + End Sub + +#End Region + + + + + +End Class + diff --git a/Finanzas/RepBalanceGeneralHorizontal.aspx.vb b/Finanzas/RepBalanceGeneralHorizontal.aspx.vb index a893e59c8..4a65d9fd7 100644 --- a/Finanzas/RepBalanceGeneralHorizontal.aspx.vb +++ b/Finanzas/RepBalanceGeneralHorizontal.aspx.vb @@ -278,8 +278,8 @@ Partial Class Contabilidad_RepBalanceGeneralHorizontal '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}" + 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 diff --git a/Finanzas/RepBalanceGeneralHorizontal2.aspx b/Finanzas/RepBalanceGeneralHorizontal2.aspx new file mode 100644 index 000000000..cb5a8067e --- /dev/null +++ b/Finanzas/RepBalanceGeneralHorizontal2.aspx @@ -0,0 +1,1592 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepBalanceGeneralHorizontal2.aspx.vb" Inherits="Contabilidad_RepBalanceGeneralHorizontal2" %> + + + + + + + + + + + + + +
  • + Generar Excel +
  • +
  • + Graficar +
  • +
    + + + + +
    +
    +
    + +
    +
    +
    +
      + + +
      + + +
      + + +
      + + +
      + + +
      + + + + + + + + + + + + + + +
      + + + +
      + + +
      + + +
      + + + + + +
      + + +
      + + NO + Trimestre + Cuatrimestre + +
      + +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + <%-- --%> + + + + + + + + <%-- --%> + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + +
    +

    Resultados del Ejercicio:

    +
    + + + +
    +
    +
    + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%----%> + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%-- --%> + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + + + + +
    + + + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%-- --%> + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + <%-- --%> + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%----%> + + + + + + + <%----%> + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%-- --%> + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + +
    +
    +
    + + + + + + + +
    + + + + + + + + + + + diff --git a/Finanzas/RepBalanceGeneralHorizontal2.aspx.vb b/Finanzas/RepBalanceGeneralHorizontal2.aspx.vb new file mode 100644 index 000000000..3a01281cf --- /dev/null +++ b/Finanzas/RepBalanceGeneralHorizontal2.aspx.vb @@ -0,0 +1,2295 @@ +Option Explicit On +Option Strict On + +Imports System.Data +Imports System.Drawing +Imports System.IO +Imports Extensiones +Imports GemBox.Spreadsheet +Imports Microsoft.Reporting.WebForms + +Partial Class Contabilidad_RepBalanceGeneralHorizontal2 + Inherits ClsPaginas + +#Region "PROPIEDADES" + + + Private Property DtDatosMes As DataTable + Get + DtDatosMes = DirectCast(ViewState("DtDatosMes"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosMes") = value + End Set + End Property + + Private Property DtIngresosMes As DataTable + Get + DtIngresosMes = DirectCast(ViewState("DtIngresosMes"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosMes") = value + End Set + End Property + Private Property DtGastosMes As DataTable + Get + DtGastosMes = DirectCast(ViewState("DtGastosMes"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosMes") = value + End Set + End Property + Private Property TotalActualMes As Double + Get + TotalActualMes = ViewState("TotalActualMes").ToString.ToDouble + End Get + Set(value As Double) + ViewState("TotalActualMes") = value + End Set + End Property + Private Property TotalAnteriorMes As Double + Get + TotalAnteriorMes = ViewState("TotalAnteriorMes").ToString.ToDouble + End Get + Set(value As Double) + ViewState("TotalAnteriorMes") = value + End Set + End Property + Private Property FechaIMes As String + Get + Return ViewState("FechaIMes").ToString + End Get + Set(value As String) + ViewState("FechaIMes") = value + End Set + End Property + Private Property FechaFMes As String + Get + Return ViewState("FechaFMes").ToString + End Get + Set(value As String) + ViewState("FechaFMes") = value + End Set + End Property + + Private Property listacolores As List(Of String) + Get + Return DirectCast(ViewState("listacolores"), List(Of String)) + End Get + Set(value As List(Of String)) + ViewState("listacolores") = value + End Set + End Property + + Private Property listaCampos As List(Of String()) + Get + Return DirectCast(ViewState("listaCampos"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCampos") = value + End Set + End Property + Private Property listaCamposanios As List(Of String()) + Get + Return DirectCast(ViewState("listaCamposanios"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCamposanios") = value + End Set + End Property + Private Property listaCamposaniosGastos As List(Of String()) + Get + Return DirectCast(ViewState("listaCamposaniosGastos"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCamposaniosGastos") = value + End Set + End Property + Private Property listaCamposaniosTotal As List(Of String()) + Get + Return DirectCast(ViewState("listaCamposaniosTotal"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCamposaniosTotal") = 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 " M E S H O R I Z O N T A L " + + Private Property DtDatosMesH As DataTable + Get + DtDatosMesH = DirectCast(ViewState("DtDatosMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosMesH") = value + End Set + End Property + + Private Property DtIngresosMesH As DataTable + Get + DtIngresosMesH = DirectCast(ViewState("DtIngresosMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosMesH") = value + End Set + End Property + + Private Property DtGastosMesH As DataTable + Get + DtGastosMesH = DirectCast(ViewState("DtGastosMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosMesH") = value + End Set + End Property + + Private Property DTTotalesMesH As DataTable + Get + DTTotalesMesH = DirectCast(ViewState("DTTotalesMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTTotalesMesH") = value + End Set + End Property + +#End Region + + +#Region " A N U A L H O R I Z O N T A L " + + Private Property DtDatosAnualH As DataTable + Get + DtDatosAnualH = DirectCast(ViewState("DtDatosAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosAnualH") = value + End Set + End Property + + Private Property DtIngresosAnualH As DataTable + Get + DtIngresosAnualH = DirectCast(ViewState("DtIngresosAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosAnualH") = value + End Set + End Property + + Private Property DtGastosAnualH As DataTable + Get + DtGastosAnualH = DirectCast(ViewState("DtGastosAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosAnualH") = value + End Set + End Property + + Private Property DTTotalesAnualH As DataTable + Get + DTTotalesAnualH = DirectCast(ViewState("DTTotalesAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTTotalesAnualH") = value + End Set + End Property + + + Private Property CountDinamicoAnual As Integer + + Get + If ViewState("CountDinamicoAnual") Is Nothing Then + Return 0 + Else + Return ViewState("CountDinamicoAnual").ToString.ToEntero + End If + + End Get + Set(value As Integer) + ViewState("CountDinamicoAnual") = value + End Set + End Property + +#End Region + +#Region " S U B P R O Y E C T O H O R I Z O N T A L " + + Private Property DtDatosSubProyectoH As DataTable + Get + DtDatosSubProyectoH = DirectCast(ViewState("DtDatosSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosSubProyectoH") = value + End Set + End Property + + Private Property DtIngresosSubProyectoH As DataTable + Get + DtIngresosSubProyectoH = DirectCast(ViewState("DtIngresosSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosSubProyectoH") = value + End Set + End Property + + Private Property DtGastosSubProyectoH As DataTable + Get + DtGastosSubProyectoH = DirectCast(ViewState("DtGastosSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosSubProyectoH") = value + End Set + End Property + + Private Property DTTotalesSubProyectoH As DataTable + Get + DTTotalesSubProyectoH = DirectCast(ViewState("DTTotalesSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTTotalesSubProyectoH") = value + End Set + End Property + + Private Property DTSubProyectosCabecerasH As DataTable + + Get + DTSubProyectosCabecerasH = DirectCast(ViewState("DTSubProyectosCabecerasH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTSubProyectosCabecerasH") = value + End Set + + End Property + + + Private Property CountDinamicoSubProyecto As Integer + + Get + If ViewState("CountDinamicoSubProyecto") Is Nothing Then + Return 0 + Else + Return ViewState("CountDinamicoSubProyecto").ToString.ToEntero + End If + + End Get + Set(value As Integer) + ViewState("CountDinamicoSubProyecto") = 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 + listacolores = New List(Of String) + listaCampos = New List(Of String()) + listaCamposanios = New List(Of String()) + listaCamposaniosGastos = New List(Of String()) + listaCamposaniosTotal = New List(Of String()) + listacolores.Add("#FF0F00") + listacolores.Add("#FF6600") + listacolores.Add("#F8FF01") + listacolores.Add("#04D215") + listacolores.Add("#2A0CD0") + listacolores.Add("#8A0CCF") + listacolores.Add("#CD0D74") + listacolores.Add("#754DEB") + listacolores.Add("#DDDDDD") + listacolores.Add("#999999") + listacolores.Add("#000000") + listacolores.Add("#FF0F00") + + TotalActualMes = 0 + TotalAnteriorMes = 0 + + CargaEjercicios() + + CargarCentrosDeCosto(Nothing, DdlSubproyecto, Nothing, LblSubProyecto) + TabSubProyecto.HeaderText = LblSubProyecto.Text & " " + + + + DdlEjercicio.SelectedValueExist(UsuarioActual.Empresa.EjercicioActual) + ValidaEjercicios() + + End If + End Sub + + Protected Sub Tab_ActiveTabChanged(sender As Object, e As EventArgs) + + If TAB.ActiveTabIndex = 0 Then + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = False + LiEjercicioLbl2.Visible = False + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + LblTri.Visible = False + DVTri.Visible = False + End If + + If TAB.ActiveTabIndex = 1 Then + + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = False + LiEjercicioLbl2.Visible = False + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + DdlPeriodo.SelectedValueExist(12) + + LblTri.Visible = True + DVTri.Visible = True + + + End If + + If TAB.ActiveTabIndex = 2 Then + + ValidaEjercicios() + + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = True + LiEjercicioLbl2.Visible = True + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + LblTri.Visible = False + DVTri.Visible = False + + End If + + If TAB.ActiveTabIndex = 3 Then + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = False + LiEjercicioLbl2.Visible = False + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + LblTri.Visible = False + DVTri.Visible = False + + End If + + UpFiltros.Update() + End Sub + + + Protected Sub DdlEjercicio_SelectedIndexChanged(sender As Object, e As EventArgs) + ValidaEjercicios() + End Sub + + Protected Sub DdlEjercicio2_SelectedIndexChanged(sender As Object, e As EventArgs) + ValidaEjercicios() + End Sub + + Private Sub ValidaEjercicios() + + + Dim EInicio As Integer = DdlEjercicio.SelectedValue.ToEntero + + + If EInicio > DdlEjercicio2.SelectedValue.ToEntero Then + + If DdlEjercicio2.Items.Count > 0 Then + DdlEjercicio2.SelectedIndex = DdlEjercicio2.Items.Count - 1 + End If + + Dim Fejerciosio As Integer = DdlEjercicio2.SelectedValue.ToEntero + + If Not EInicio + 1 > Fejerciosio Then + DdlEjercicio2.SelectedValueExist(EInicio + 1) + End If + + End If + + + UpFiltros.Update() + End Sub + + Private Sub CargaEjercicios() + 'Dim ClsConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ClsConta As New ClsContabilidad + If ClsConta.GetEjercicios(UsuarioActual.CveEmpresa) Then + DdlEjercicio.DataSource = ClsConta.DtResultados + DdlEjercicio2.DataSource = ClsConta.DtResultados + Else + DdlEjercicio.DataSource = Nothing + DdlEjercicio2.DataSource = Nothing + End If + ClsConta.Dispose() + DdlEjercicio.DataBind() + DdlEjercicio2.DataBind() + + DdlEjercicio.SelectedValueExist(UsuarioActual.Empresa.EjercicioActual.ToString) + If DdlEjercicio.Items.Count = 0 Then + DdlEjercicio.Items.Add(New ListItem(Now.Year.ToString, Now.Year.ToString)) + End If + DdlPeriodo.SelectedValue = Now.Month.ToString + End Sub + + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) + TotalActualMes = 0 + TotalAnteriorMes = 0 + + 'Mes + If TAB.ActiveTabIndex = 0 Then + CargaDatosMes() + End If + + 'MES HORIZONTAL + If TAB.ActiveTabIndex = 1 Then + CargaDatosMesH() + End If + + 'AÑO HORIZONTAL + If TAB.ActiveTabIndex = 2 Then + + If DdlEjercicio.SelectedValue.ToEntero > DdlEjercicio2.SelectedValue.ToEntero Then + Alert("El ejercicio inicio no debe ser mayor al ejercicio fin.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + CargaDatosAnualH() + End If + + 'SUBPROYECTO + If TAB.ActiveTabIndex = 3 Then + CargaDatosSubProyectoH() + End If + + + + + End Sub + + +#Region "MES" + + + + + + Private Sub CargaDatosMes() + + + FechaIMes = String.Format("01/{0}/{1}", DdlPeriodo.SelectedValue.PadLeft(2, CChar("0")), DdlEjercicio.SelectedValue) + FechaFMes = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, CDate(FechaIMes))).ToString("dd/MM/yyyy") + 'Dim TipoReporte = DdlTipoReporte.SelectedValue.ToEntero 'If(ReporteComplementario, DdlTipoReporte.SelectedValue.ToEntero, 1) + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + 'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosMensual(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then + DtDatosMes = ObjConta.DtResultados.FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosMes = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosMes IsNot Nothing Then + CargaGridsMes() + SumaTotales() + End If + + End Sub + Private Sub CargaGridsMes() + DtIngresosMes = DtDatosMes.FiltraParametros("Tipo ='H' ") + DtGastosMes = DtDatosMes.FiltraParametros("Tipo ='G' ") + Dim Row As DataRow = DtIngresosMes.NewRow + + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + If DtIngresosMes.Rows.Count > 0 Then + + For Each dr As DataRow In DtIngresosMes.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + DtIngresosMes.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosMes.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosMes.NewRow + If DtGastosMes.Rows.Count > 0 Then + + For Each dr As DataRow In DtGastosMes.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + Row.Item("Nombre") = "TOTAL GASTOS" + 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") = -1 + DtGastosMes.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosMes.Rows.Add(Row) + End If + + + GvIngresosMes.DataSource = DtIngresosMes + GvIngresosMes.DataBind() + + GvGastosMes.DataSource = DtGastosMes + GvGastosMes.DataBind() + + UpDatos.Update() + + End Sub + + + + Private Sub SumaTotales() + 'Llena Lb´s Totales + + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + LbTotalActual.Text = TotalActualMes.ToString("###,###,##0") + LbTotalAnterior.Text = TotalAnteriorMes.ToString("###,###,##0") + Else + LbTotalActual.Text = TotalActualMes.ToString("###,###,##0.00") + LbTotalAnterior.Text = TotalAnteriorMes.ToString("###,###,##0.00") + End If + + + + LbTotalActual.ForeColor = If(TotalActualMes < 0, Drawing.Color.Red, Color.Black) + + LbTotalAnterior.ForeColor = If(TotalAnteriorMes < 0, Drawing.Color.Red, Color.Black) + + + End Sub + +#Region "GV´S ROW DATA BOUND" + + Protected Sub GvIngresos_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf 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("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToEntero.ToString("###,###,##0") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToEntero.ToString("###,###,##0").ToString + Else + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToDecimal.ToString("###,###,##0.00").ToString + End If + + 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 + 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 + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + e.Row.FCHyperLink("HLActual").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + End If + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToEntero.ToString("###,###,##0") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToEntero.ToString("###,###,##0").ToString + Else + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToDecimal.ToString("###,###,##0.00").ToString + 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 + End If + End Sub + +#End Region + + + + +#End Region + + + +#Region "M E S H O R I Z O N T A L" + + Private Sub CargaDatosMesH() + + + FechaIMes = $"01/01/{DdlEjercicio.SelectedValue}" + Dim FechaFin As Date = $"01/{DdlPeriodo.SelectedValue.ToEntero.ToString("00")}/{DdlEjercicio.SelectedValue}".ToDate + FechaFMes = $"{FechaFin.LastDayOfMonth.Day.ToString("00")}/{DdlPeriodo.SelectedValue.ToEntero.ToString("00")}/{DdlEjercicio.SelectedValue}" + + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + 'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosMensualHorizontal(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then + DtDatosMesH = ObjConta.DtResultados.FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosMesH = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosMesH IsNot Nothing Then + CargaGridsMesH() + Else + + End If + + End Sub + + Private Sub CargaGridsMesH() + + DtIngresosMesH = DtDatosMesH.FiltraParametros("Tipo ='H' ") + DtGastosMesH = DtDatosMesH.FiltraParametros("Tipo ='G' ") + DTTotalesMesH = DtDatosMesH.Clone() + + Dim Row As DataRow = DtIngresosMesH.NewRow + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + + If DtIngresosMesH.Rows.Count > 0 Then + + For Each dr As DataRow In DtIngresosMesH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + Row.Item("Enero") = DtIngresosMesH.SUM("Enero", "NOT CtaMayor in (3,4)") + Row.Item("Febrero") = DtIngresosMesH.SUM("Febrero", "NOT CtaMayor in (3,4)") + Row.Item("Marzo") = DtIngresosMesH.SUM("Marzo", "NOT CtaMayor in (3,4)") + Row.Item("Abril") = DtIngresosMesH.SUM("Abril", "NOT CtaMayor in (3,4)") + Row.Item("Mayo") = DtIngresosMesH.SUM("Mayo", "NOT CtaMayor in (3,4)") + Row.Item("Junio") = DtIngresosMesH.SUM("Junio", "NOT CtaMayor in (3,4)") + Row.Item("Julio") = DtIngresosMesH.SUM("Julio", "NOT CtaMayor in (3,4)") + Row.Item("Agosto") = DtIngresosMesH.SUM("Agosto", "NOT CtaMayor in (3,4)") + Row.Item("Septiembre") = DtIngresosMesH.SUM("Septiembre", "NOT CtaMayor in (3,4)") + Row.Item("Octubre") = DtIngresosMesH.SUM("Octubre", "NOT CtaMayor in (3,4)") + Row.Item("Noviembre") = DtIngresosMesH.SUM("Noviembre", "NOT CtaMayor in (3,4)") + Row.Item("Diciembre") = DtIngresosMesH.SUM("Diciembre", "NOT CtaMayor in (3,4)") + + Row.Item("Tri1") = DtIngresosMesH.SUM("Tri1", "NOT CtaMayor in (3,4)") + Row.Item("Tri2") = DtIngresosMesH.SUM("Tri2", "NOT CtaMayor in (3,4)") + Row.Item("Tri3") = DtIngresosMesH.SUM("Tri3", "NOT CtaMayor in (3,4)") + Row.Item("Tri4") = DtIngresosMesH.SUM("Tri4", "NOT CtaMayor in (3,4)") + + Row.Item("Cua1") = DtIngresosMesH.SUM("Cua1", "NOT CtaMayor in (3,4)") + Row.Item("Cua2") = DtIngresosMesH.SUM("Cua2", "NOT CtaMayor in (3,4)") + Row.Item("Cua3") = DtIngresosMesH.SUM("Cua3", "NOT CtaMayor in (3,4)") + + + Row.Item("Nombre") = "TOTAL INGRESOS" + Row.Item("ImporteActual") = TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + + DtIngresosMesH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosMesH.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosMesH.NewRow + If DtGastosMesH.Rows.Count > 0 Then + + For Each dr As DataRow In DtGastosMesH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + + Row.Item("Enero") = DtGastosMesH.SUM("Enero", "NOT CtaMayor in (3,4)") + Row.Item("Febrero") = DtGastosMesH.SUM("Febrero", "NOT CtaMayor in (3,4)") + Row.Item("Marzo") = DtGastosMesH.SUM("Marzo", "NOT CtaMayor in (3,4)") + Row.Item("Abril") = DtGastosMesH.SUM("Abril", "NOT CtaMayor in (3,4)") + Row.Item("Mayo") = DtGastosMesH.SUM("Mayo", "NOT CtaMayor in (3,4)") + Row.Item("Junio") = DtGastosMesH.SUM("Junio", "NOT CtaMayor in (3,4)") + Row.Item("Julio") = DtGastosMesH.SUM("Julio", "NOT CtaMayor in (3,4)") + Row.Item("Agosto") = DtGastosMesH.SUM("Agosto", "NOT CtaMayor in (3,4)") + Row.Item("Septiembre") = DtGastosMesH.SUM("Septiembre", "NOT CtaMayor in (3,4)") + Row.Item("Octubre") = DtGastosMesH.SUM("Octubre", "NOT CtaMayor in (3,4)") + Row.Item("Noviembre") = DtGastosMesH.SUM("Noviembre", "NOT CtaMayor in (3,4)") + Row.Item("Diciembre") = DtGastosMesH.SUM("Diciembre", "NOT CtaMayor in (3,4)") + + Row.Item("Tri1") = DtGastosMesH.SUM("Tri1", "NOT CtaMayor in (3,4)") + Row.Item("Tri2") = DtGastosMesH.SUM("Tri2", "NOT CtaMayor in (3,4)") + Row.Item("Tri3") = DtGastosMesH.SUM("Tri3", "NOT CtaMayor in (3,4)") + Row.Item("Tri4") = DtGastosMesH.SUM("Tri4", "NOT CtaMayor in (3,4)") + + Row.Item("Cua1") = DtGastosMesH.SUM("Cua1", "NOT CtaMayor in (3,4)") + Row.Item("Cua2") = DtGastosMesH.SUM("Cua2", "NOT CtaMayor in (3,4)") + Row.Item("Cua3") = DtGastosMesH.SUM("Cua3", "NOT CtaMayor in (3,4)") + + Row.Item("Nombre") = "TOTAL GASTOS" + 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") = -1 + DtGastosMesH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosMesH.Rows.Add(Row) + End If + + If DtIngresosMesH.Rows.Count > 0 Then + + Row = DTTotalesMesH.NewRow + + Row.Item("Enero") = DtIngresosMesH.SUM("Enero", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Enero", "NOT CtaMayor in (-1,3,4)") + Row.Item("Febrero") = DtIngresosMesH.SUM("Febrero", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Febrero", "NOT CtaMayor in (-1,3,4)") + Row.Item("Marzo") = DtIngresosMesH.SUM("Marzo", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Marzo", "NOT CtaMayor in (-1,3,4)") + Row.Item("Abril") = DtIngresosMesH.SUM("Abril", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Abril", "NOT CtaMayor in (-1,3,4)") + Row.Item("Mayo") = DtIngresosMesH.SUM("Mayo", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Mayo", "NOT CtaMayor in (-1,3,4)") + Row.Item("Junio") = DtIngresosMesH.SUM("Junio", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Junio", "NOT CtaMayor in (-1,3,4)") + Row.Item("Julio") = DtIngresosMesH.SUM("Julio", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Julio", "NOT CtaMayor in (-1,3,4)") + Row.Item("Agosto") = DtIngresosMesH.SUM("Agosto", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Agosto", "NOT CtaMayor in (-1,3,4)") + Row.Item("Septiembre") = DtIngresosMesH.SUM("Septiembre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Septiembre", "NOT CtaMayor in (-1,3,4)") + Row.Item("Octubre") = DtIngresosMesH.SUM("Octubre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Octubre", "NOT CtaMayor in (-1,3,4)") + Row.Item("Noviembre") = DtIngresosMesH.SUM("Noviembre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Noviembre", "NOT CtaMayor in (-1,3,4)") + Row.Item("Diciembre") = DtIngresosMesH.SUM("Diciembre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Diciembre", "NOT CtaMayor in (-1,3,4)") + + Row.Item("Tri1") = DtIngresosMesH.SUM("Tri1", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri1", "NOT CtaMayor in (-1,3,4)") + Row.Item("Tri2") = DtIngresosMesH.SUM("Tri2", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri2", "NOT CtaMayor in (-1,3,4)") + Row.Item("Tri3") = DtIngresosMesH.SUM("Tri3", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri3", "NOT CtaMayor in (-1,3,4)") + Row.Item("Tri4") = DtIngresosMesH.SUM("Tri4", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri4", "NOT CtaMayor in (-1,3,4)") + + Row.Item("Cua1") = DtIngresosMesH.SUM("Cua1", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Cua1", "NOT CtaMayor in (-1,3,4)") + Row.Item("Cua2") = DtIngresosMesH.SUM("Cua2", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Cua2", "NOT CtaMayor in (-1,3,4)") + Row.Item("Cua3") = DtIngresosMesH.SUM("Cua3", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Cua3", "NOT CtaMayor in (-1,3,4)") + + Row.Item("Nombre") = "Resultados del Ejercicio:" + 'Row.Item("ImporteActual") = TotalActual.ToString + 'Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = DtIngresosMesH.SUM("ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") ' TotalAnterior.ToString + 'Row.Item("PorcentajeAcumulado") = "100.00" + 'Row.Item("CtaMayor") = -1 + + DTTotalesMesH.Rows.Add(Row) + + End If + + GvIngresosMesH.DataSource = DtIngresosMesH + GvIngresosMesH.DataBind() + + GvGastosMesH.DataSource = DtGastosMesH + GvGastosMesH.DataBind() + + GvTotalesMesH.DataSource = DTTotalesMesH + GvTotalesMesH.DataBind() + + + If DdlTri.SelectedValue.ToEntero = 0 Then 'ocultar trimestre cuatrimestre + + GvIngresosMesH.Columns(4).Visible = False + GvIngresosMesH.Columns(9).Visible = False + GvIngresosMesH.Columns(14).Visible = False + GvIngresosMesH.Columns(18).Visible = False + + GvGastosMesH.Columns(4).Visible = False + GvGastosMesH.Columns(9).Visible = False + GvGastosMesH.Columns(14).Visible = False + GvGastosMesH.Columns(18).Visible = False + + GvTotalesMesH.Columns(4).Visible = False + GvTotalesMesH.Columns(9).Visible = False + GvTotalesMesH.Columns(14).Visible = False + GvTotalesMesH.Columns(18).Visible = False + + GvIngresosMesH.Columns(6).Visible = False + GvIngresosMesH.Columns(12).Visible = False + GvIngresosMesH.Columns(19).Visible = False + + GvGastosMesH.Columns(6).Visible = False + GvGastosMesH.Columns(12).Visible = False + GvGastosMesH.Columns(19).Visible = False + + GvTotalesMesH.Columns(6).Visible = False + GvTotalesMesH.Columns(12).Visible = False + GvTotalesMesH.Columns(19).Visible = False + + + ElseIf DdlTri.SelectedValue.ToEntero = 1 Then 'Mostrar Trimestre + + + GvIngresosMesH.Columns(4).Visible = True + GvIngresosMesH.Columns(9).Visible = True + GvIngresosMesH.Columns(14).Visible = True + GvIngresosMesH.Columns(18).Visible = True + + GvGastosMesH.Columns(4).Visible = True + GvGastosMesH.Columns(9).Visible = True + GvGastosMesH.Columns(14).Visible = True + GvGastosMesH.Columns(18).Visible = True + + GvTotalesMesH.Columns(4).Visible = True + GvTotalesMesH.Columns(9).Visible = True + GvTotalesMesH.Columns(14).Visible = True + GvTotalesMesH.Columns(18).Visible = True + + GvIngresosMesH.Columns(6).Visible = False + GvIngresosMesH.Columns(12).Visible = False + GvIngresosMesH.Columns(19).Visible = False + + GvGastosMesH.Columns(6).Visible = False + GvGastosMesH.Columns(12).Visible = False + GvGastosMesH.Columns(19).Visible = False + + GvTotalesMesH.Columns(6).Visible = False + GvTotalesMesH.Columns(12).Visible = False + GvTotalesMesH.Columns(19).Visible = False + + ElseIf DdlTri.SelectedValue.ToEntero = 2 Then 'Mostrar Cuatrimestre + + GvIngresosMesH.Columns(4).Visible = False + GvIngresosMesH.Columns(9).Visible = False + GvIngresosMesH.Columns(14).Visible = False + GvIngresosMesH.Columns(18).Visible = False + + GvGastosMesH.Columns(4).Visible = False + GvGastosMesH.Columns(9).Visible = False + GvGastosMesH.Columns(14).Visible = False + GvGastosMesH.Columns(18).Visible = False + + GvTotalesMesH.Columns(4).Visible = False + GvTotalesMesH.Columns(9).Visible = False + GvTotalesMesH.Columns(14).Visible = False + GvTotalesMesH.Columns(18).Visible = False + + + GvIngresosMesH.Columns(6).Visible = True + GvIngresosMesH.Columns(12).Visible = True + GvIngresosMesH.Columns(19).Visible = True + + GvGastosMesH.Columns(6).Visible = True + GvGastosMesH.Columns(12).Visible = True + GvGastosMesH.Columns(19).Visible = True + + GvTotalesMesH.Columns(6).Visible = True + GvTotalesMesH.Columns(12).Visible = True + GvTotalesMesH.Columns(19).Visible = True + + End If + + + UpDatosMesH.Update() + + End Sub + + + Protected Sub GvIngresosMesH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + e.Row.ControlStyle.Font.Bold = True + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + + 'e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensualHorizontal.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&FF=31/12/{DdlEjercicio.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1" + + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}&TRCU={DdlTri.SelectedValue}" + + e.Row.FCHyperLink("HLEnero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/01/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLFebrero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/02/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/02/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMarzo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/03/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAbril").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMayo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/05/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJunio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/06/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJulio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/07/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAgosto").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/08/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLSeptiembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLOctubre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/10/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLNoviembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/11/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/11/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLDiciembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/12/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLTri1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri4").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLCua1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + + ' e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Or e.Row.DBCampo("Nombre") = "TOTAL INGRESOS" Then + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0") + Else + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0.00") + End If + + End If + + setgrafica(e) + + + + + e.Row.FCHyperLink("HLEnero").ForeColor = If(e.Row.DataKey("Enero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLEnero").ForeColor) + e.Row.FCHyperLink("HLFebrero").ForeColor = If(e.Row.DataKey("Febrero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLFebrero").ForeColor) + e.Row.FCHyperLink("HLMarzo").ForeColor = If(e.Row.DataKey("Marzo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMarzo").ForeColor) + e.Row.FCHyperLink("HLAbril").ForeColor = If(e.Row.DataKey("Abril").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLMayo").ForeColor = If(e.Row.DataKey("Mayo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLJunio").ForeColor = If(e.Row.DataKey("Junio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMayo").ForeColor) + e.Row.FCHyperLink("HLJulio").ForeColor = If(e.Row.DataKey("Julio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLJulio").ForeColor) + e.Row.FCHyperLink("HLAgosto").ForeColor = If(e.Row.DataKey("Agosto").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAgosto").ForeColor) + e.Row.FCHyperLink("HLSeptiembre").ForeColor = If(e.Row.DataKey("Septiembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLSeptiembre").ForeColor) + e.Row.FCHyperLink("HLOctubre").ForeColor = If(e.Row.DataKey("Octubre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLOctubre").ForeColor) + e.Row.FCHyperLink("HLNoviembre").ForeColor = If(e.Row.DataKey("Noviembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLNoviembre").ForeColor) + e.Row.FCHyperLink("HLDiciembre").ForeColor = If(e.Row.DataKey("Diciembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLDiciembre").ForeColor) + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + + End If + + End Sub + + Protected Sub GvGastosMesH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + + 'e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensualHorizontal.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&FF=31/12/{DdlEjercicio.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1" + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}&TRCU={DdlTri.SelectedValue}" + + e.Row.FCHyperLink("HLEnero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/01/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLFebrero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/02/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/02/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMarzo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/03/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAbril").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMayo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/05/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJunio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/06/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJulio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/07/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAgosto").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/08/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLSeptiembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLOctubre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/10/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLNoviembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/11/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/11/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLDiciembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/12/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLTri1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri4").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLCua1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + 'e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + End If + + + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Or e.Row.DBCampo("Nombre") = "TOTAL GASTOS" Then + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + + 'Enero,Febrero,Marzo,Abril,Mayo,Junio,Julio,Agosto,Septiembre,Octubre,Noviembre,Diciembre,PorcentajeAcumulado + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0") + + Else + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0.00") + End If + End If + + + setgrafica(e) + + + e.Row.FCHyperLink("HLEnero").ForeColor = If(e.Row.DataKey("Enero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLEnero").ForeColor) + e.Row.FCHyperLink("HLFebrero").ForeColor = If(e.Row.DataKey("Febrero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLFebrero").ForeColor) + e.Row.FCHyperLink("HLMarzo").ForeColor = If(e.Row.DataKey("Marzo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMarzo").ForeColor) + e.Row.FCHyperLink("HLAbril").ForeColor = If(e.Row.DataKey("Abril").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLMayo").ForeColor = If(e.Row.DataKey("Mayo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLJunio").ForeColor = If(e.Row.DataKey("Junio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMayo").ForeColor) + e.Row.FCHyperLink("HLJulio").ForeColor = If(e.Row.DataKey("Julio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLJulio").ForeColor) + e.Row.FCHyperLink("HLAgosto").ForeColor = If(e.Row.DataKey("Agosto").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAgosto").ForeColor) + e.Row.FCHyperLink("HLSeptiembre").ForeColor = If(e.Row.DataKey("Septiembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLSeptiembre").ForeColor) + e.Row.FCHyperLink("HLOctubre").ForeColor = If(e.Row.DataKey("Octubre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLOctubre").ForeColor) + e.Row.FCHyperLink("HLNoviembre").ForeColor = If(e.Row.DataKey("Noviembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLNoviembre").ForeColor) + e.Row.FCHyperLink("HLDiciembre").ForeColor = If(e.Row.DataKey("Diciembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLDiciembre").ForeColor) + + + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvTotalesMesH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.Header Then + e.Row.Attributes.Add("style", "display:none") + End If + + If e.Row.RowType = DataControlRowType.DataRow Then + + e.Row.Attributes.Add("style", "Font-weight: bold") + + + If DdlDivisor.SelectedValue.ToEntero > 0 Then + + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0") + + Else + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0.00") + End If + + setgrafica(e) + + e.Row.FCHyperLink("HLEnero").ForeColor = If(e.Row.DataKey("Enero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLEnero").ForeColor) + e.Row.FCHyperLink("HLFebrero").ForeColor = If(e.Row.DataKey("Febrero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLFebrero").ForeColor) + e.Row.FCHyperLink("HLMarzo").ForeColor = If(e.Row.DataKey("Marzo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMarzo").ForeColor) + e.Row.FCHyperLink("HLAbril").ForeColor = If(e.Row.DataKey("Abril").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLMayo").ForeColor = If(e.Row.DataKey("Mayo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLJunio").ForeColor = If(e.Row.DataKey("Junio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMayo").ForeColor) + e.Row.FCHyperLink("HLJulio").ForeColor = If(e.Row.DataKey("Julio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLJulio").ForeColor) + e.Row.FCHyperLink("HLAgosto").ForeColor = If(e.Row.DataKey("Agosto").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAgosto").ForeColor) + e.Row.FCHyperLink("HLSeptiembre").ForeColor = If(e.Row.DataKey("Septiembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLSeptiembre").ForeColor) + e.Row.FCHyperLink("HLOctubre").ForeColor = If(e.Row.DataKey("Octubre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLOctubre").ForeColor) + e.Row.FCHyperLink("HLNoviembre").ForeColor = If(e.Row.DataKey("Noviembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLNoviembre").ForeColor) + e.Row.FCHyperLink("HLDiciembre").ForeColor = If(e.Row.DataKey("Diciembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLDiciembre").ForeColor) + + + End If + + End Sub + + Public Sub setgrafica(e As GridViewRowEventArgs) + + Dim lista As New List(Of Object) + lista.Add(New With {.Texto = "Enero", .Valor = e.Row.DataKey("Enero").ToDecimal(), .Color = "#FF0F00"}) + lista.Add(New With {.Texto = "Febrero", .Valor = e.Row.DataKey("Febrero").ToDecimal(), .Color = "#FF6600"}) + lista.Add(New With {.Texto = "Marzo", .Valor = e.Row.DataKey("Marzo").ToDecimal(), .Color = "#F8FF01"}) + lista.Add(New With {.Texto = "Abril", .Valor = e.Row.DataKey("Abril").ToDecimal(), .Color = "#04D215"}) + lista.Add(New With {.Texto = "Mayo", .Valor = e.Row.DataKey("Mayo").ToDecimal(), .Color = "#2A0CD0"}) + lista.Add(New With {.Texto = "Junio", .Valor = e.Row.DataKey("Junio").ToDecimal(), .Color = "#8A0CCF"}) + lista.Add(New With {.Texto = "Julio", .Valor = e.Row.DataKey("Julio").ToDecimal(), .Color = "#CD0D74"}) + lista.Add(New With {.Texto = "Agosto", .Valor = e.Row.DataKey("Agosto").ToDecimal(), .Color = "#754DEB"}) + lista.Add(New With {.Texto = "Septiembre", .Valor = e.Row.DataKey("Septiembre").ToDecimal(), .Color = "#DDDDDD"}) + lista.Add(New With {.Texto = "Octubre", .Valor = e.Row.DataKey("Octubre").ToDecimal(), .Color = "#999999"}) + lista.Add(New With {.Texto = "Noviembre", .Valor = e.Row.DataKey("Noviembre").ToDecimal(), .Color = "#000000"}) + lista.Add(New With {.Texto = "Diciembre", .Valor = e.Row.DataKey("Diciembre").ToDecimal(), .Color = "#FF0F00"}) + e.Row.FCHyperLink("Hypgrafica").Attributes.Add("data-values", Newtonsoft.Json.JsonConvert.SerializeObject(lista)) + End Sub +#End Region + + + +#Region "Anual H O R I Z O N T A L" + + Private Sub CargaDatosAnualH() + + + FechaIMes = $"01/01/{DdlEjercicio.SelectedValue}" + FechaFMes = $"31/12/{DdlEjercicio2.SelectedValue}" + + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + 'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosAnualHorizontal(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, DdlPeriodo.SelectedValue.ToEntero, Periodo:=DdlPeriodo.SelectedValue.ToEntero) Then + DtDatosAnualH = ObjConta.DtResultados.FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosAnualH = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosAnualH IsNot Nothing Then + CargaGridsAnualH() + + End If + + End Sub + + Private Sub CargaGridsAnualH() + + DtIngresosAnualH = DtDatosAnualH.FiltraParametros("Tipo ='H' ") + DtGastosAnualH = DtDatosAnualH.FiltraParametros("Tipo ='G' ") + DTTotalesAnualH = DtDatosAnualH.Clone() + + Dim Row As DataRow = DtIngresosAnualH.NewRow + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + + + Dim IndexData As Integer = 0 + Dim IndexGv As Integer = 1 + Dim IndexMax As Integer = 1 + + + Dim IDX_LIMPIAR As Integer = 1 + + For IDX_LIMPIAR = 1 To 25 + + GvIngresosAnualH.Columns(IDX_LIMPIAR).Visible = False + GvGastosAnualH.Columns(IDX_LIMPIAR).Visible = False + GvTotalesAnualH.Columns(IDX_LIMPIAR).Visible = False + Next + listaCamposanios.Clear() + listaCamposaniosGastos.Clear() + listaCamposaniosTotal.Clear() + + If DtIngresosAnualH.Rows.Count > 0 Then + + + + + For Each dCoumn As DataColumn In DtIngresosAnualH.Columns + + If IndexData >= 13 Then + + If dCoumn.ColumnName.ToEntero > 0 And dCoumn.ColumnName.ToEntero <= DdlEjercicio2.SelectedValue.ToEntero Then + + CType(GvIngresosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + CType(GvIngresosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + + + listaCamposanios.Add(New String() {dCoumn.ColumnName.ToString(), dCoumn.ColumnName.ToString()}) + + listaCamposaniosTotal.Add(New String() {dCoumn.ColumnName.ToString(), dCoumn.ColumnName.ToString()}) + 'CType(GvIngresosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + 'CType(GvIngresosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + GvIngresosAnualH.Columns(IndexGv).Visible = True + + + CType(GvTotalesAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + CType(GvTotalesAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + 'CType(GvTotalesAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + 'CType(GvTotalesAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + GvTotalesAnualH.Columns(IndexGv).Visible = True + + IndexMax = IndexData + Else + GvIngresosAnualH.Columns(IndexGv).Visible = False + GvTotalesAnualH.Columns(IndexGv).Visible = False + End If + + + + IndexGv = IndexGv + 1 + End If + + IndexData = IndexData + 1 + + Next + + + For Each dr As DataRow In DtIngresosAnualH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + + Next + + IndexData = 13 + For IndexData = 13 To IndexMax + Row.Item(IndexData) = DtIngresosAnualH.SUM($"[{DtIngresosAnualH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (3,4)") + Next + + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = DtIngresosAnualH.SUM("ImporteActual", "NOT CtaMayor in (3,4)") 'TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = DtIngresosAnualH.SUM("ImporteAcumulado", "NOT CtaMayor in (3,4)") 'TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + Row.Item("CountDinamico") = DtGastosAnualH.MAX("CountDinamico") + CountDinamicoAnual = DtGastosAnualH.MAX("CountDinamico").ToEntero + DtIngresosAnualH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosAnualH.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosAnualH.NewRow + + If DtGastosAnualH.Rows.Count > 0 Then + + + IndexData = 0 + IndexGv = 1 + IndexMax = 0 + + For Each dCoumn As DataColumn In DtGastosAnualH.Columns + + If IndexData >= 13 Then + + If dCoumn.ColumnName.ToEntero > 0 And dCoumn.ColumnName.ToEntero <= DdlEjercicio2.SelectedValue.ToEntero Then + 'HyperLinkField + + CType(GvGastosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + CType(GvGastosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + listaCamposaniosGastos.Add(New String() {dCoumn.ColumnName.ToString(), dCoumn.ColumnName.ToString()}) + + 'CType(GvGastosAnualH.Columns(IndexGv), HyperLinkField).DataNavigateUrlFields = {"CveCuenta", "FechaInicial", "FechaFActual", "CveSubProyecto"} + 'CType(GvGastosAnualH.Columns(IndexGv), HyperLinkField).DataNavigateUrlFormatString = "/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1&CveSubProyecto{3}" + + 'CType(GvGastosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + 'CType(GvGastosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + + GvGastosAnualH.Columns(IndexGv).Visible = True + IndexMax = IndexData + Else + GvGastosAnualH.Columns(IndexGv).Visible = False + End If + + + + IndexGv = IndexGv + 1 + End If + + IndexData = IndexData + 1 + + Next + + + For Each dr As DataRow In DtGastosAnualH.FiltraParametros("Not CtaMayor In (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + IndexData = 13 + For IndexData = 13 To IndexMax + + Row.Item(IndexData) = DtGastosAnualH.SUM($"[{DtIngresosAnualH.Columns(IndexData).ColumnName}]", "Not CtaMayor In (3,4)") + + Next + + Row.Item("Nombre") = "TOTAL GASTOS" + 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") = -1 + Row.Item("CountDinamico") = DtGastosAnualH.MAX("CountDinamico") + DtGastosAnualH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosAnualH.Rows.Add(Row) + End If + + If DtIngresosAnualH.Rows.Count > 0 Then + + Row = DTTotalesAnualH.NewRow + + + IndexData = 13 + For IndexData = 13 To IndexMax + Row.Item(IndexData) = DtIngresosAnualH.SUM($"[{DtIngresosAnualH.Columns(IndexData).ColumnName}]", "Not CtaMayor In (-1,3,4)") - DtGastosAnualH.SUM($"[{DtGastosAnualH.Columns(IndexData).ColumnName}]", "Not CtaMayor In (-1,3,4)") + Next + + Row.Item("Nombre") = "Resultados del Ejercicio" + Row.Item("ImporteAcumulado") = DtIngresosAnualH.SUM($"ImporteAcumulado", "Not CtaMayor in (-1,3,4)") - DtGastosAnualH.SUM($"ImporteAcumulado", "Not CtaMayor in (-1,3,4)") + + + DTTotalesAnualH.Rows.Add(Row) + + End If + + GvIngresosAnualH.DataSource = DtIngresosAnualH + GvIngresosAnualH.DataBind() + + GvGastosAnualH.DataSource = DtGastosAnualH + GvGastosAnualH.DataBind() + + GvTotalesAnualH.DataSource = DTTotalesAnualH + GvTotalesAnualH.DataBind() + + UpDatosAnualH.Update() + + End Sub + + + + Protected Sub GvIngresosAnualH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCCAnual(e, listaCamposanios) + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales3" + e.Row.ControlStyle.Font.Bold = True + End If + + + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + Dim CveSubProyecto As Integer = e.Row.DataKey("CveSubProyecto").ToEntero + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + Dim Anio As String = CType(GvGastosAnualH.Columns(IndiceInicio), BoundField).DataField + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + 'e.Row.Cells(IndiceInicio).ForeColor = If(Importe < 0, Drawing.Color.Red, e.Row.Cells(IndiceInicio).ForeColor) + Next IndiceInicio + + 'e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogo.aspx?CveCuenta={CveCuenta}&FF=31/12/{DdlEjercicio2.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1&CveSubProyecto={CveSubProyecto}" + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + + Next IndiceInicio + + + End If + + + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvGastosAnualH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCCAnual(e, listaCamposaniosGastos) + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + Dim CveSubProyecto As Integer = e.Row.DataKey("CveSubProyecto").ToEntero + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + 'e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto=-1&EjercicioFinal={DdlEjercicio2.SelectedValue}" + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + For IndiceInicio = 1 To IndiceMax + Dim Anio As String = CType(GvGastosAnualH.Columns(IndiceInicio), BoundField).DataField + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00"))}" + 'e.Row.Cells(IndiceInicio).ForeColor = If(Importe < 0, Drawing.Color.Red, e.Row.Cells(IndiceInicio).ForeColor) + Next IndiceInicio + + 'e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogo.aspx?CveCuenta={CveCuenta}&FF=31/12/{DdlEjercicio2.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1&CveSubProyecto={CveSubProyecto}" + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + + Next IndiceInicio + + End If + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvTotalesAnualH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.Header Then + e.Row.Attributes.Add("style", "display:none") + End If + + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCCAnual(e, listaCamposaniosTotal) + e.Row.Attributes.Add("style", "Font-weight: bold") + End If + + End Sub + + Public Sub setgraficaCCAnual(e As GridViewRowEventArgs, listaCampos As List(Of String())) + Dim lista As New List(Of Object) + Dim colorindex As Integer = 0 + For Each campo As String() In listaCampos + lista.Add(New With {.Texto = campo(1), .Valor = e.Row.DBCampo(campo(0)).ToDecimal(), .Color = listacolores(colorindex)}) + colorindex = colorindex + 1 + If colorindex >= listacolores.Count Then + colorindex = 0 + End If + Next + e.Row.FCHyperLink("Hypgrafica").Attributes.Add("data-values", Newtonsoft.Json.JsonConvert.SerializeObject(lista)) + End Sub +#End Region + + +#Region "S U B P R O Y E C T O H O R I Z O N T A L" + + Private Sub CargaDatosSubProyectoH() + + + FechaIMes = $"01/01/{DdlEjercicio.SelectedValue}" + FechaFMes = $"01/{DdlPeriodo.SelectedValue.ToEntero.ToString("00")}/{DdlEjercicio.SelectedValue}" + FechaFMes = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, CDate(FechaFMes))).ToString("dd/MM/yyyy") + + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosSubProyectoHorizontal(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then + DTSubProyectosCabecerasH = ObjConta.DSResultados.Tables(0) + DtDatosSubProyectoH = ObjConta.DSResultados.Tables(1).FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosSubProyectoH = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosSubProyectoH IsNot Nothing And DTSubProyectosCabecerasH IsNot Nothing Then + CargaGridsSubProyectoH() + End If + + End Sub + + Private Sub CargaGridsSubProyectoH() + + DtIngresosSubProyectoH = DtDatosSubProyectoH.FiltraParametros("Tipo ='H' ") + DtGastosSubProyectoH = DtDatosSubProyectoH.FiltraParametros("Tipo ='G' ") + DTTotalesSubProyectoH = DtDatosSubProyectoH.Clone() + + Dim Row As DataRow = DtIngresosSubProyectoH.NewRow + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + + + Dim IndexData As Integer = 0 + Dim IndexGv As Integer = 1 + Dim IndexMax As Integer = 1 + Dim IndexSubProyecto = 0 + Dim IndexSubProyectoMAx As Integer = DTSubProyectosCabecerasH.Rows.Count - 1 + Dim IndexTotatles As Integer = 13 + IndexSubProyectoMAx + + '34 + Dim IDX_LIMPIAR As Integer = 1 + + For IDX_LIMPIAR = 1 To 35 + CType(GvIngresosSubProyectoH.Columns(IDX_LIMPIAR), BoundField).DataField = Nothing + CType(GvIngresosSubProyectoH.Columns(IDX_LIMPIAR), BoundField).HeaderText = "" + GvIngresosSubProyectoH.Columns(IDX_LIMPIAR).Visible = False + Next + listaCampos.Clear() + + + If DtIngresosSubProyectoH.Rows.Count > 0 Then + + For Each dCoumn As DataColumn In DtIngresosSubProyectoH.Columns + + If IndexData >= 13 Then + + If IndexSubProyecto <= IndexSubProyectoMAx Then + + CType(GvIngresosSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvIngresosSubProyectoH.Columns(IndexGv).Visible = True + + CType(GvTotalesSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvTotalesSubProyectoH.Columns(IndexGv).Visible = True + + If IndexSubProyecto <= IndexSubProyectoMAx Then + CType(GvIngresosSubProyectoH.Columns(IndexGv), BoundField).HeaderText = DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString + CType(GvTotalesSubProyectoH.Columns(IndexGv), BoundField).HeaderText = DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString + CType(GvGastosSubProyectoH.Columns(IndexGv), BoundField).HeaderText = DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString + End If + listaCampos.Add(New String() {dCoumn.ColumnName.ToString(), DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString()}) + Else + GvIngresosSubProyectoH.Columns(IndexGv).Visible = False + GvTotalesSubProyectoH.Columns(IndexGv).Visible = False + End If + + IndexGv = IndexGv + 1 + IndexSubProyecto = IndexSubProyecto + 1 + IndexMax = IndexMax + 1 + + End If + IndexData = IndexData + 1 + Next + + + For Each dr As DataRow In DtIngresosSubProyectoH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + IndexData = 13 + For IndexData = 13 To IndexTotatles + Row.Item(IndexData) = DtIngresosSubProyectoH.SUM($"[{DtIngresosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (3,4)") + Next + + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = DtIngresosSubProyectoH.SUM("ImporteActual", "NOT CtaMayor in (3,4)") 'TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = DtIngresosSubProyectoH.SUM("ImporteAcumulado", "NOT CtaMayor in (3,4)") 'TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + Row.Item("CountDinamico") = DtIngresosSubProyectoH.MAX("CountDinamico") + CountDinamicoSubProyecto = DtIngresosSubProyectoH.MAX("CountDinamico").ToEntero + DtIngresosSubProyectoH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosSubProyectoH.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosSubProyectoH.NewRow + + If DtGastosSubProyectoH.Rows.Count > 0 Then + + + IndexData = 0 + IndexGv = 1 + IndexMax = 0 + IndexSubProyecto = 0 + + For Each dCoumn As DataColumn In DtIngresosSubProyectoH.Columns + If IndexData >= 13 Then + If IndexSubProyecto <= IndexSubProyectoMAx Then + CType(GvGastosSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvGastosSubProyectoH.Columns(IndexGv).Visible = True + CType(GvTotalesSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvTotalesSubProyectoH.Columns(IndexGv).Visible = True + Else + GvIngresosSubProyectoH.Columns(IndexGv).Visible = False + GvTotalesSubProyectoH.Columns(IndexGv).Visible = False + End If + + IndexGv = IndexGv + 1 + IndexSubProyecto = IndexSubProyecto + 1 + End If + IndexData = IndexData + 1 + Next + + + + For Each dr As DataRow In DtGastosSubProyectoH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + IndexData = 13 + For IndexData = 13 To IndexTotatles + Row.Item(IndexData) = DtGastosSubProyectoH.SUM($"[{DtIngresosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (3,4)") + Next + + Row.Item("Nombre") = "TOTAL GASTOS" + 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") = -1 + Row.Item("CountDinamico") = DtGastosSubProyectoH.MAX("CountDinamico") + + DtGastosSubProyectoH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosSubProyectoH.Rows.Add(Row) + End If + + If DtIngresosSubProyectoH.Rows.Count > 0 Then + + Row = DTTotalesSubProyectoH.NewRow + + IndexData = 13 + For IndexData = 13 To IndexTotatles + Row.Item(IndexData) = DtIngresosSubProyectoH.SUM($"[{DtIngresosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (-1,3,4)") - DtGastosSubProyectoH.SUM($"[{DtGastosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (-1,3,4)") + Next + + Row.Item("Nombre") = "Resultado del ejercicio" + Row.Item("ImporteAcumulado") = DtIngresosSubProyectoH.SUM($"ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") - DtGastosSubProyectoH.SUM($"ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") + Row.Item("CtaMayor") = -2 + Row.Item("CountDinamico") = DtIngresosSubProyectoH.MAX("CountDinamico") + + DTTotalesSubProyectoH.Rows.Add(Row) + + End If + + DtIngresosSubProyectoH.Merge(DtGastosSubProyectoH) + DtIngresosSubProyectoH.Merge(DTTotalesSubProyectoH) + + + GvIngresosSubProyectoH.DataSource = DtIngresosSubProyectoH + GvIngresosSubProyectoH.DataBind() + + + + UpDatosSubProyectoH.Update() + + End Sub + + 'Private Sub SumaTotalesSubProyectoH() + ' ''Llena Lb´s Totales + ' ''********************************************************************************* + ' 'LbTotalActual.Text = TotalActualMes.ToString.FormatoNumero + ' 'LbTotalAnterior.Text = TotalAnteriorMes.ToString.FormatoNumero + + ' 'LbTotalActual.ForeColor = If(TotalActualMes < 0, Drawing.Color.Red, Color.Black) + ' 'LbTotalAnterior.ForeColor = If(TotalAnteriorMes < 0, Drawing.Color.Red, Color.Black) + + + 'End Sub + + Protected Sub GvIngresosSubProyectoH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales3" + e.Row.ControlStyle.Font.Bold = True + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -2 Then + + e.Row.ControlStyle.Font.Bold = True + e.Row.ControlStyle.Font.Size = 13 + End If + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + setgraficaCC(e) + 'Dim CveSubProyecto As Integer = e.Row.DataKey("CveSubProyecto").ToEntero + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoCC.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + Dim FEchaMesFinal As Date = New Date(DdlEjercicio.SelectedValue.ToEntero, DdlPeriodo.SelectedValue.ToEntero, 1).LastDayOfMonth + + For IndiceInicio = 1 To IndiceMax + + Dim CveSubProyectoIntermo As String = CType(GvGastosSubProyectoH.Columns(IndiceInicio), BoundField).DataField + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + + + If CveSubProyectoIntermo.ToEntero > 0 Then + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + End If + + + + Next IndiceInicio + + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoCC.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"
    { If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }
    " + Next IndiceInicio + + + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -2 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"
    { If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }
    " + + Next IndiceInicio + + + End If + e.Row.FCHyperLink("HLAnterior").Text = If(DdlDivisor.SelectedValue.ToEntero > 1, e.Row.DBCampo("ImporteAcumulado").ToString.ToDecimal.ToString("###,###,##0"), e.Row.DBCampo("ImporteAcumulado").ToString.ToDecimal.ToString("###,###,##0.00")) + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + + End If + + End Sub + + Protected Sub GvGastosSubProyectoH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCC(e) + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvTotalesSubProyectoH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.Header Then + ' e.Row.Attributes.Add("style", "display:none") + End If + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCC(e) + e.Row.Attributes.Add("style", "Font-weight: bold") + End If + End Sub + + Public Sub setgraficaCC(e As GridViewRowEventArgs) + Dim lista As New List(Of Object) + Dim colorindex As Integer = 0 + For Each campo As String() In listaCampos + lista.Add(New With {.Texto = campo(1), .Valor = e.Row.DBCampo(campo(0)).ToDecimal(), .Color = listacolores(colorindex)}) + colorindex = colorindex + 1 + If colorindex >= listacolores.Count Then + colorindex = 0 + End If + Next + e.Row.FCHyperLink("Hypgrafica").Attributes.Add("data-values", Newtonsoft.Json.JsonConvert.SerializeObject(lista)) + End Sub +#End Region + + + + + +#Region "DESCARGA EXCEL" + + Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click + Imprimir("Excel") + End Sub + + Private Sub Imprimir(Optional reporte As String = "PDF") + + + If TAB.ActiveTabIndex = 0 AndAlso GvIngresosMes.Rows.Count > 0 Then + ExportToExcelG(GvIngresosMes, GvGastosMes, TMesT1, "Reporte_Mensual", UsuarioActual, "Mensual") + ElseIf TAB.ActiveTabIndex = 1 AndAlso GvIngresosMesH.Rows.Count > 0 Then + ExportToExcelG(GvIngresosMesH, GvGastosMesH, TMesT1, "Reporte_Mensual_Horizontal", UsuarioActual, "Mensual Horizontal", Gv3:=GvTotalesMesH) + ElseIf TAB.ActiveTabIndex = 2 AndAlso GvIngresosAnualH.Rows.Count > 0 Then + ExportToExcelG(GvIngresosAnualH, GvGastosAnualH, TMesT1, "Reporte_Anual_Horizontal", UsuarioActual, "Anual Horizontal", Gv3:=GvTotalesAnualH) + + ElseIf TAB.ActiveTabIndex = 3 AndAlso GvIngresosSubProyectoH.Rows.Count > 0 Then + + ExportToExcelG(GvIngresosSubProyectoH, GvGastosSubProyectoH, TMesT1, "Reporte_Proyecto_Horizontal", UsuarioActual, $"Estado de Resultados Horizontal por {LblSubProyecto.Text}", Gv3:=GvTotalesSubProyectoH, EsPorSubProtyecto:=True) + + End If + + + End Sub + + 'Public Sub ExportToExcelG(Gv1 As GridView, Gv2 As GridView, NombreArchivoXLSx As String, Optional Titulo As String = "Reporte", Optional Usuario As Usuario = Nothing, Optional Filtros As String = "", Optional AlturaImagen As Double = 100, Optional AnchoImagen As Double = 100) + Public Sub ExportToExcelG(Gv1 As GridView, Gv2 As GridView, TablaResultados As HtmlTable, NombreArchivoXLSx As String, Usuario As Usuario, Titulo As String, Optional AlturaImagen As Double = 100, Optional AnchoImagen As Double = 100, Optional Gv3 As GridView = Nothing, Optional EsPorSubProtyecto As Boolean = False) + + Dim sw1 As New StringWriter() + Dim htw1 As New HtmlTextWriter(sw1) + Gv1.RenderControl(htw1) + + Dim sw2 As New StringWriter() + Dim htw2 As New HtmlTextWriter(sw2) + Gv2.RenderControl(htw2) + + + TablaResultados.Width = Gv2.Width.ToString + + Dim sw3 As New StringWriter() + Dim htw3 As New HtmlTextWriter(sw3) + TablaResultados.RenderControl(htw3) + + Dim options = GemBox.Spreadsheet.LoadOptions.HtmlDefault + + Dim htmlStream1 = New MemoryStream(options.Encoding.GetBytes(sw1.ToString())) + Dim htmlStream2 = New MemoryStream(options.Encoding.GetBytes(sw2.ToString())) + Dim htmlStream3 = New MemoryStream(options.Encoding.GetBytes(sw3.ToString())) + + htmlStream1.Position = 0 + Dim sr1 As New StreamReader(htmlStream1) + + htmlStream2.Position = 0 + Dim sr2 As New StreamReader(htmlStream2) + + htmlStream3.Position = 0 + Dim sr3 As New StreamReader(htmlStream3) + + + Dim myStr1 = sr1.ReadToEnd() + Dim myStr2 = sr2.ReadToEnd() + Dim myStr3 = sr3.ReadToEnd() + + sr1.Dispose() + sr2.Dispose() + sr3.Dispose() + + htmlStream1.Dispose() + htmlStream2.Dispose() + htmlStream3.Dispose() + + sw1.Dispose() + sw2.Dispose() + sw3.Dispose() + + If Gv3 IsNot Nothing Then + + Gv3.ShowHeader = False + + Dim sw4 As New StringWriter() + Dim htw4 As New HtmlTextWriter(sw4) + Gv3.RenderControl(htw4) + Dim htmlStream4 = New MemoryStream(options.Encoding.GetBytes(sw4.ToString())) + htmlStream4.Position = 0 + Dim sr4 As New StreamReader(htmlStream4) + myStr3 = sr4.ReadToEnd() + + sr4.Dispose() + htmlStream2.Dispose() + sw4.Dispose() + + End If + + + Dim HtmlCompleto As String = myStr1 & "
    " & myStr2 & "
    " & myStr3 + + + HtmlCompleto = Regex.Replace(HtmlCompleto, "\<[\/]*a[^\>]*\>", "") + + + Dim htmlStream5 = New MemoryStream(options.Encoding.GetBytes(HtmlCompleto)) + + GemBox.Spreadsheet.SpreadsheetInfo.SetLicense(SerialGemBoxSpreadsheet) + + Dim excel As GemBox.Spreadsheet.ExcelFile + + excel = GemBox.Spreadsheet.ExcelFile.Load(htmlStream5, options) + + If Usuario IsNot Nothing Then + + Dim TotalRowHeader As Integer = 8 + Dim TotalRowFooter As Integer = 2 + + + Dim worksheet = excel.Worksheets(0) + worksheet.Rows.InsertEmpty(0, TotalRowHeader) + Dim celdasConTexto = worksheet.GetUsedCellRange(True) + celdasConTexto.Style.Font.Name = "Calibri Light" + + Dim RangoNombreEmpresa = worksheet.Cells.GetSubrangeAbsolute(1, celdasConTexto.FirstColumnIndex, 1, celdasConTexto.LastColumnIndex) + RangoNombreEmpresa.Merged = True + RangoNombreEmpresa.Value = Usuario.Empresa.Empresa + RangoNombreEmpresa.Style.Font.Size = 18 * 20 + RangoNombreEmpresa.Style.Font.Name = "Calibri Light" + RangoNombreEmpresa.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoNombreEmpresa.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + + Dim RangoTitulo = worksheet.Cells.GetSubrangeAbsolute(3, celdasConTexto.FirstColumnIndex, 3, celdasConTexto.LastColumnIndex) + RangoTitulo.Merged = True + RangoTitulo.Value = Titulo + RangoTitulo.Style.Font.Size = 20 * 20 + RangoTitulo.Style.Font.Name = "Calibri Light" + RangoTitulo.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoTitulo.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + Dim RangoFechas = worksheet.Cells.GetSubrangeAbsolute(4, celdasConTexto.FirstColumnIndex, 4, celdasConTexto.LastColumnIndex) + RangoFechas.Merged = True + RangoFechas.Value = $"Fechas: {FechaIMes} a {FechaFMes}" + RangoFechas.Style.Font.Size = 15 * 20 + RangoFechas.Style.Font.Name = "Calibri Light" + RangoFechas.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoFechas.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + + If EsPorSubProtyecto And DdlSubproyecto.SelectedValue.ToEntero > 0 Then + Dim RangoSubProyecto = worksheet.Cells.GetSubrangeAbsolute(5, celdasConTexto.FirstColumnIndex, 5, celdasConTexto.LastColumnIndex) + RangoSubProyecto.Merged = True + RangoSubProyecto.Value = DdlSubproyecto.SelectedItem.Text + RangoSubProyecto.Style.Font.Size = 20 * 20 + RangoSubProyecto.Style.Font.Name = "Calibri Light" + RangoSubProyecto.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoSubProyecto.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + End If + + For i = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex + + worksheet.Rows(8).Cells(i).Style.Font.Size = 12 * 20 + worksheet.Rows(8).Cells(i).Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + worksheet.Rows(8).Cells(i).Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + worksheet.Rows(8).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(8).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255) + + + + If Not EsPorSubProtyecto Then + worksheet.Rows(8 + Gv1.Rows.Count + 2).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(8 + Gv1.Rows.Count + 2).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255) + Else + worksheet.Rows(18).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(18).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255) + End If + + + + If i > 0 Then + Try + worksheet.Columns(i).AutoFit(1) + Catch ex As Exception + End Try + End If + Next + + Dim IndexEndTable As Integer = Gv1.Rows.Count + Gv2.Rows.Count + 4 + TotalRowHeader + TotalRowFooter + + worksheet.Rows(IndexEndTable).Cells(0).Value = "Usuario Imprimió" + worksheet.Rows(IndexEndTable + 1).Cells(0).Value = Usuario.Nombre + + worksheet.Rows(IndexEndTable).Cells(2).Value = "Fecha Impresión" + worksheet.Rows(IndexEndTable + 1).Cells(2).Value = DateTime.Now.ToString("dd/MM/yyyy") + + Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", Usuario.Empresa.Ruta)) + + If Imagen.Exists Then + Dim Ruta As String = String.Format("{0}/Logo.png", Usuario.Empresa.Ruta) + Using sr As New StreamReader(Ruta) + Dim ms As New MemoryStream() + sr.BaseStream.CopyTo(ms) + worksheet.Pictures.Add(ms, ExcelPictureFormat.Png, "A1", AnchoImagen, AlturaImagen, LengthUnit.Pixel) + End Using + End If + + + + + + + For I = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex + + If I > 0 Then + + If DdlDivisor.SelectedValue.ToEntero = 1 Then + worksheet.Columns(I + 1).Style.NumberFormat = "#,##0.00" + Else + worksheet.Columns(I + 1).Style.NumberFormat = "#,##" + End If + + Try + worksheet.Columns(I).AutoFit(1) + Catch ex As Exception + End Try + + End If + Next + + End If + + excel.Save(HttpContext.Current.Response, $"{NombreArchivoXLSx}.xlsx") + + + End Sub + + Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) + End Sub + +#End Region + + + + + +End Class + diff --git a/vwd.webinfo b/vwd.webinfo index 10e72764b..62e975e28 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -110,6 +110,8 @@ + +