Option Explicit On Option Strict On Imports System.Data Imports Extensiones Imports Microsoft.Reporting.WebForms Partial Class Contabilidad_RepOrigenAplicacion Inherits ClsPaginas #Region " PROPIEDADES NORMAL " Private Property DtDatos As DataTable Get DtDatos = DirectCast(ViewState("DtDatos"), DataTable) End Get Set(ByVal value As DataTable) ViewState("DtDatos") = value End Set End Property #End Region #Region " PROPIEDADES ANUAL " Private Property DtDatosAnual As DataTable Get DtDatosAnual = DirectCast(ViewState("DtDatosAnual"), DataTable) End Get Set(ByVal value As DataTable) ViewState("DtDatosAnual") = value End Set End Property Private Property Anos As Integer Get Anos = ViewState("Anos").ToString.ToEntero End Get Set(value As Integer) ViewState("Anos") = value End Set End Property #End Region #Region " PROPIEDADES " Private Property TipoReporte As Integer Get TipoReporte = ViewState("TipoReporte").ToString.ToEntero End Get Set(value As Integer) ViewState("TipoReporte") = value End Set End Property Private Property DtDatosMensual As DataTable Get DtDatosMensual = DirectCast(ViewState("DtDatosMensual"), DataTable) End Get Set(ByVal value As DataTable) ViewState("DtDatosMensual") = value End Set End Property #End Region Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then If UsuarioActual.Empresa.UsaAC Then TipoReporte = -1 Else TipoReporte = 1 tdTipoReporte.Visible = True End If 'Normal TxtFechaDel.Text = DateSerial(Year(Now), Month(Now), 1).ToShortDateString TxtFechaAl.Text = Date.Now.ToShortDateString 'Anual Anos = 0 DdlEjercicio.SelectedValue = Now.Year.ToString TabContainer_ActiveTabChanged(TabContainer, EventArgs.Empty) End If End Sub Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) 'Nota: ' 0 = Normal ' 1 = Mensual ' 2 = Anual If TabContainer.ActiveTabIndex = 0 Then CargaDatos() ElseIf TabContainer.ActiveTabIndex = 1 Then CargaDatosMensual() ElseIf TabContainer.ActiveTabIndex = 2 Then CargaDatosAnual() End If End Sub Protected Sub TabContainer_ActiveTabChanged(sender As Object, e As EventArgs) 'Nota: ' 0 = Normal ' 1 = Mensual ' 2 = Anual 'Esconde Todo de lo variable de Filtros TdSubTotales.Visible = False TdEjercicio.Visible = False TdFI.Visible = False TdFF.Visible = False If TabContainer.ActiveTabIndex = 0 Then TdFI.Visible = True TdFF.Visible = True ElseIf TabContainer.ActiveTabIndex = 1 Then TdEjercicio.Visible = True TdSubTotales.Visible = True ElseIf TabContainer.ActiveTabIndex = 2 Then TdEjercicio.Visible = True End If UpFiltros.Update() BtnConsultar_Click(BtnConsultar, EventArgs.Empty) End Sub #Region " NORMAL " Private Sub CargaDatos() Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) Dim FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", Date.Now, TxtFechaDel.Text.ToDate) Dim FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", Date.Now, TxtFechaAl.Text.ToDate) If ObjConta.GetOrigenAplicacion(FechaInicio, FechaFin) Then DtDatos = ObjConta.DtResultados Else DtDatos = Nothing Alert("Ocurrio un error al cargar los datos de origen y aplicación", TipoMensaje.MsgError) End If ObjConta.Dispose() If DtDatos IsNot Nothing Then CargaGrid() End If End Sub Private Sub CargaGrid() GvDatos.DataSource = DtDatos GvDatos.DataBind() UpDatos.Update() End Sub Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then 'Titulo y Sumatoria de cambios If e.Row.DBCampo("Orden3").ToString.ToEntero = 10 Or e.Row.DBCampo("Orden3").ToString.ToEntero = 30 Then e.Row.FCLabel("LbNombre").Font.Bold = True End If 'CUENTAS If e.Row.DBCampo("Orden3").ToString.ToEntero = 20 Then e.Row.FCLabel("LbNombre").Attributes.Add("style", "padding-left: 20px;") End If 'TOTAL If e.Row.DBCampo("Nombre").ToString.Trim = "" Then e.Row.Attributes.Add("style", "border-top: 1px solid; margin-top:10px;") e.Row.FCLabel("LbNombre").Font.Bold = True e.Row.FCLabel("LbNombre").Font.Italic = True e.Row.FCLabel("LbNombre").Text = "TOTAL" End If End If End Sub #End Region #Region " MENSUAL " Private Sub CargaDatosMensual() Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) TipoReporte = If(TipoReporte = -1, -1, DdlTipoReporte.SelectedValue.ToEntero) If ObjConta.GetOrigenAplicacionMensual(DdlEjercicio.SelectedValue.ToEntero, TipoReporte) Then DtDatosMensual = ObjConta.DtResultados Else DtDatosMensual = Nothing Alert("Ocurrio un error al cargar los datos del estado de origen y aplicación de recursos", TipoMensaje.MsgError) End If ObjConta.Dispose() EscondeSubtotales() If DtDatosMensual IsNot Nothing Then CargaGridMensual() End If End Sub Private Sub EscondeSubtotales() 'Esconde Trimestral GvDatosMensual.Columns(4).Visible = False GvDatosMensual.Columns(9).Visible = False GvDatosMensual.Columns(14).Visible = False GvDatosMensual.Columns(18).Visible = False 'Esconde Cuatrimestral GvDatosMensual.Columns(6).Visible = False GvDatosMensual.Columns(12).Visible = False GvDatosMensual.Columns(19).Visible = False If DdlSubtotales.SelectedValue = "2" Then GvDatosMensual.Columns(4).Visible = True GvDatosMensual.Columns(9).Visible = True GvDatosMensual.Columns(14).Visible = True GvDatosMensual.Columns(18).Visible = True ElseIf DdlSubtotales.SelectedValue = "3" Then GvDatosMensual.Columns(6).Visible = True GvDatosMensual.Columns(12).Visible = True GvDatosMensual.Columns(19).Visible = True End If End Sub Private Sub CargaGridMensual() GvDatosMensual.DataSource = DtDatosMensual GvDatosMensual.DataBind() UpDatosMensual.Update() End Sub Protected Sub GvDatosMensual_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosMensual.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then 'AGRUPADOR DE CUENTAS If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 2 Then e.Row.FCLabel("LbNombre").Font.Bold = True End If 'CUENTAS If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 1 Then e.Row.FCLabel("LbNombre").Attributes.Add("style", "padding-left: 20px;") End If 'TOTALES If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then e.Row.Attributes.Add("style", "border-top: 1px solid;") e.Row.FCLabel("LbNombre").Font.Bold = True e.Row.FCLabel("LbNombre").Font.Italic = True End If End If End Sub #End Region #Region " ANUAL " Private Sub CargaDatosAnual() Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) TipoReporte = If(TipoReporte = -1, -1, DdlTipoReporte.SelectedValue.ToEntero) If ObjConta.GetOrigenAplicacionAnual(DdlEjercicio.SelectedValue.ToEntero, TipoReporte) Then DtDatosAnual = ObjConta.DtResultados Else DtDatosAnual = Nothing Alert("Ocurrio un error al cargar los datos del estado de origen y aplicación de recursos", TipoMensaje.MsgError) End If ObjConta.Dispose() Anos = (Year(Date.Now) - DdlEjercicio.SelectedValue.ToEntero) + 1 If DtDatosAnual IsNot Nothing Then CargaGridAnual() End If 'Esconde todo For index = 1 To 12 GvDatosAnual.Columns(index).Visible = False Next For index = 1 To Anos GvDatosAnual.Columns(index).Visible = True GvDatosAnual.HeaderRow.FCLabel("LbAno" + index.ToString).Text = (DdlEjercicio.SelectedValue.ToEntero + index - 1).ToString Next End Sub Private Sub CargaGridAnual() GvDatosAnual.DataSource = DtDatosAnual GvDatosAnual.DataBind() UpDatosAnual.Update() End Sub Protected Sub GvDatosAnual_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosAnual.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then 'AGRUPADOR DE CUENTAS If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 2 Then e.Row.FCLabel("LbNombre").Font.Bold = True End If 'CUENTAS If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 1 Then e.Row.FCLabel("LbNombre").Attributes.Add("style", "padding-left: 20px;") End If 'TOTALES If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then e.Row.Attributes.Add("style", "border-top: 1px solid;") e.Row.FCLabel("LbNombre").Font.Bold = True e.Row.FCLabel("LbNombre").Font.Italic = True End If End If End Sub #End Region End Class