Files
SIG/Contabilidad/RepEstadoResultados.aspx.vb

1156 lines
49 KiB
VB.net
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Imports GemBox.Spreadsheet
Imports System.IO
Partial Class Contabilidad_RepEstadoResultados
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
Private Property DtIngresos As DataTable
Get
DtIngresos = DirectCast(ViewState("DtIngresos"), DataTable)
End Get
Set(ByVal value As DataTable)
ViewState("DtIngresos") = value
End Set
End Property
Private Property DtGastos As DataTable
Get
DtGastos = DirectCast(ViewState("DtGastos"), DataTable)
End Get
Set(ByVal value As DataTable)
ViewState("DtGastos") = value
End Set
End Property
Private Property TotalActual As Double
Get
TotalActual = ViewState("TotalActual").ToString.ToDouble
End Get
Set(value As Double)
ViewState("TotalActual") = value
End Set
End Property
Private Property TotalAnterior As Double
Get
TotalAnterior = ViewState("TotalAnterior").ToString.ToDouble
End Get
Set(value As Double)
ViewState("TotalAnterior") = value
End Set
End Property
Private Property PorcentajeActual As String
Get
PorcentajeActual = ViewState("PorcentajeActual").ToString
End Get
Set(value As String)
ViewState("PorcentajeActual") = value
End Set
End Property
Private Property PorcentajeAcumulado As String
Get
PorcentajeAcumulado = ViewState("PorcentajeAcumulado").ToString
End Get
Set(value As String)
ViewState("PorcentajeAcumulado") = value
End Set
End Property
Private Property FechaI As String
Get
Return ViewState("FechaI").ToString
End Get
Set(value As String)
ViewState("FechaI") = value
End Set
End Property
Private Property FechaF As String
Get
Return ViewState("FechaF").ToString
End Get
Set(value As String)
ViewState("FechaF") = 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 " PROPIEDADES MENSUAL "
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
#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
#End Region
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
If UsuarioActual.Empresa.TipoContabilidad = 1 Then
Response.Redirect($"/Contabilidad2/RepEstadoActividades.aspx")
End If
If UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC Then
BtnConsultar.Enabled = True
TabNormal.Enabled = True
TabMensual.Enabled = True
TabAnual.Enabled = True
CargaSegmentosNegocio()
If UsuarioActual.Empresa.UsaAC Then
TipoReporte = -1
Else
TipoReporte = 1
tdTipoReporte.Visible = True
End If
CargaDatosGenerales()
DdlEjercicio.SelectedValue = NowADS().Year.ToString
Anos = 0
'Normal
TotalActual = 0
TotalAnterior = 0
DdlPeriodo.SelectedValue = NowADS().Month.ToString
TabContainer_ActiveTabChanged(TabContainer, EventArgs.Empty)
Else
Alert("La empresa no usa Contabilidad ni Armonización Contable", TipoMensaje.MsgError)
End If
End If
End Sub
Private Sub CargaDatosGenerales()
Dim ClsConta As New ClsContPAQi(UsuarioActual.Empresa)
If ClsConta.GetEjercicios() Then
DdlEjercicio.DataSource = ClsConta.DtResultados
Else
DdlEjercicio.DataSource = Nothing
End If
ClsConta.Dispose()
DdlEjercicio.DataBind()
End Sub
Private Sub CargaSegmentosNegocio()
Dim ObjContpaq As New ClsContPAQi(UsuarioActual.Empresa)
Dim strGlobal As String = ""
If ObjContpaq.GetSegmentosNegocio(-1, "-1") Then
DdlSegmentoNegocio.DataSource = ObjContpaq.DtResultados
DdlSegmentoNegocio.DataBind()
End If
ObjContpaq.Dispose()
DdlSegmentoNegocio.Items.Insert(0, New ListItem("Todos", "-1"))
DdlSegmentoNegocio.SelectedValue = "-1"
End Sub
#Region " NORMAL "
Private Sub CargaDatos()
FechaI = String.Format("01/{0}/{1}", DdlPeriodo.SelectedValue.PadLeft(2, CChar("0")), DdlEjercicio.SelectedValue)
FechaF = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, CDate(FechaI))).ToString("dd/MM/yyyy")
TipoReporte = If(TipoReporte = -1, -1, DdlTipoReporte.SelectedValue.ToEntero)
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
If ObjConta.GetEstadoActividades(FechaI.ToDate, FechaF.ToDate, TipoReporte, UsuarioActual.Empresa.UsaAC, DdlSegmentoNegocio.SelectedValue.ToEntero) Then
DtDatos = ObjConta.DtResultados.FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)")
Else
DtDatos = Nothing
Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError)
End If
ObjConta.Dispose()
If DtDatos IsNot Nothing Then
CargaGrids()
SumaTotales()
End If
End Sub
Private Sub CargaGrids()
DtIngresos = DtDatos.FiltraParametros("Orden Like '0004%' OR Tipo = 'H'")
DtGastos = DtDatos.FiltraParametros("Orden Like '0005%' OR Tipo = 'G'")
Dim Row As DataRow = DtIngresos.NewRow
Dim TotalActualLocal = 0.0, TotalAnteriorLocal = 0.0
If DtIngresos.Rows.Count > 0 Then
For Each dr As DataRow In DtIngresos.FiltraParametros("CtaMayor = 1").Rows
TotalActualLocal += dr("ImporteActual").ToString.ToDouble
TotalAnteriorLocal += dr("ImporteAcumulado").ToString.ToDouble
Next
Row.Item("Nombre") = "TOTAL INGRESOS "
Row.Item("ImporteActual") = TotalActualLocal.ToString
Row.Item("PorcentajeActual") = If(TotalActualLocal > 0, (TotalActualLocal * 100 / TotalActualLocal).ToString, "0").FormatoNumero
Row.Item("ImporteAcumulado") = TotalAnteriorLocal.ToString
Row.Item("PorcentajeAcumulado") = If(TotalAnteriorLocal > 0, (TotalAnteriorLocal * 100 / TotalAnteriorLocal).ToString, "0").FormatoNumero
Row.Item("CtaMayor") = -1
DtIngresos.Rows.Add(Row)
Else
Row.Item("Nombre") = "TOTAL INGRESOS "
Row.Item("ImporteActual") = "0.00"
Row.Item("ImporteAcumulado") = "0.00"
Row.Item("CtaMayor") = -1
DtIngresos.Rows.Add(Row)
End If
Dim T1 = TotalActualLocal, T2 = TotalAnteriorLocal
TotalActual = TotalActualLocal
TotalAnterior = TotalAnteriorLocal
TotalActualLocal = 0
TotalAnteriorLocal = 0
Row = DtGastos.NewRow
If DtGastos.Rows.Count > 0 Then
For Each dr As DataRow In DtGastos.FiltraParametros("CtaMayor = 1").Rows
TotalActualLocal += dr("ImporteActual").ToString.ToDouble
TotalAnteriorLocal += dr("ImporteAcumulado").ToString.ToDouble
Next
Row.Item("Nombre") = "TOTAL GASTOS"
Row.Item("ImporteActual") = TotalActualLocal
Row.Item("PorcentajeActual") = If(T1 > 0, (TotalActualLocal * 100 / T1).ToString, "0").FormatoNumero
Row.Item("ImporteAcumulado") = TotalAnteriorLocal.ToString
Row.Item("PorcentajeAcumulado") = If(T2 > 0, (TotalAnteriorLocal * 100 / T2).ToString, "0").FormatoNumero
Row.Item("CtaMayor") = -1
DtGastos.Rows.Add(Row)
Else
Row.Item("Nombre") = "TOTAL GASTOS"
Row.Item("ImporteActual") = "0.00"
Row.Item("ImporteAcumulado") = "0.00"
Row.Item("CtaMayor") = -1
DtGastos.Rows.Add(Row)
End If
TotalActual -= TotalActualLocal
TotalAnterior -= TotalAnteriorLocal
'INSERTA UTILIDAD
Row = DtGastos.NewRow
Row.Item("Nombre") = "Utilidad (o Pérdida)"
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") = -2
DtGastos.Rows.Add(Row)
GvIngresos.DataSource = DtIngresos
GvIngresos.DataBind()
GvGastos.DataSource = DtGastos
GvGastos.DataBind()
UpDatos.Update()
PorcentajeActual = Row.Item("PorcentajeActual").ToString
PorcentajeAcumulado = Row.Item("PorcentajeAcumulado").ToString
DtGastos.Rows.Remove(Row)
End Sub
Private Sub SumaTotales()
'Llena Lb´s Totales
LbTotalActual.Text = TotalActual.ToString.FormatoNumero
LbTotalAnterior.Text = TotalAnterior.ToString.FormatoNumero
LbTotalActual.ForeColor = If(TotalActual < 0, Drawing.Color.Red, Drawing.Color.Black)
LbTotalAnterior.ForeColor = If(TotalAnterior < 0, Drawing.Color.Red, Drawing.Color.Black)
End Sub
#Region "GV´S ROW DATA BOUND"
Protected Sub GvNormal_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.Header Then
e.Row.ControlStyle.Font.Bold = True
e.Row.Attributes.Add("style", "border-top:2px solid black;")
End If
If e.Row.RowType = DataControlRowType.DataRow Then
If 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("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&CM=1", e.Row.DBCampo("Id"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString)
e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&CM=1&FI=01/01/{2}", e.Row.DBCampo("Id"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaFActual").ToDate.Year)
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
'UTILIDAD
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = -2 Then
e.Row.ControlStyle.Font.Bold = True
e.Row.Cells(0).Attributes.Add("style", "padding-top:50px;")
e.Row.Cells(1).Attributes.Add("style", "padding-top:50px;")
e.Row.Cells(2).Attributes.Add("style", "padding-top:50px;")
e.Row.Cells(3).Attributes.Add("style", "padding-top:50px;")
e.Row.Cells(4).Attributes.Add("style", "padding-top:50px;")
e.Row.Font.Size = 12
End If
'TOTALES
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then
e.Row.ControlStyle.Font.Bold = True
e.Row.Attributes.Add("style", "border-top:2px solid black;")
End If
End If
'If e.Row.DBCampo("Nombre").ToString.Contiene("INGRESOS", "EGRESOS") Then
' e.Row.ControlStyle.BackColor = Drawing.Color.LightGray
' e.Row.ControlStyle.Font.Bold = True
' asdasdasdsadasd
'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
'METODO ANTERIOR
'TotalActual -= e.Row.DBCampo("ImporteActual").ToString.ToDouble
'TotalAnterior -= 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
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = -2 Then
'e.Row.CssClass = "SubTotales"
e.Row.ControlStyle.BackColor = Drawing.Color.LightGray
End If
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("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&CM=1", e.Row.DBCampo("Id"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString)
e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&CM=1", e.Row.DBCampo("Id"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString)
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 " MENSUAL "
Private Sub CargaDatosMensual()
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
TipoReporte = If(TipoReporte = -1, -1, DdlTipoReporte.SelectedValue.ToEntero)
If ObjConta.GetEstadoResultadosMensual(DdlEjercicio.SelectedValue.ToEntero, TipoReporte, DdlSegmentoNegocio.SelectedValue.ToEntero) Then
DtDatosMensual = ObjConta.DtResultados
Else
DtDatosMensual = Nothing
Alert("Ocurrio un error al cargar los datos del estado de resultados", TipoMensaje.MsgError)
End If
ObjConta.Dispose()
EscondeSubtotales()
If DtDatosMensual IsNot Nothing Then
CargaGridMensual()
End If
End Sub
Private Sub EscondeSubtotales()
'Esconde Trimestral
GvDatosMensual.Columns(7).Visible = False
GvDatosMensual.Columns(8).Visible = False
GvDatosMensual.Columns(17).Visible = False
GvDatosMensual.Columns(18).Visible = False
GvDatosMensual.Columns(27).Visible = False
GvDatosMensual.Columns(28).Visible = False
GvDatosMensual.Columns(35).Visible = False
GvDatosMensual.Columns(36).Visible = False
'Esconde Cuatrimestral
GvDatosMensual.Columns(11).Visible = False
GvDatosMensual.Columns(12).Visible = False
GvDatosMensual.Columns(23).Visible = False
GvDatosMensual.Columns(24).Visible = False
GvDatosMensual.Columns(37).Visible = False
GvDatosMensual.Columns(38).Visible = False
If DdlSubtotales.SelectedValue = "2" Then
GvDatosMensual.Columns(7).Visible = True
GvDatosMensual.Columns(8).Visible = True
GvDatosMensual.Columns(17).Visible = True
GvDatosMensual.Columns(18).Visible = True
GvDatosMensual.Columns(27).Visible = True
GvDatosMensual.Columns(28).Visible = True
GvDatosMensual.Columns(35).Visible = True
GvDatosMensual.Columns(36).Visible = True
ElseIf DdlSubtotales.SelectedValue = "3" Then
GvDatosMensual.Columns(11).Visible = True
GvDatosMensual.Columns(12).Visible = True
GvDatosMensual.Columns(23).Visible = True
GvDatosMensual.Columns(24).Visible = True
GvDatosMensual.Columns(37).Visible = True
GvDatosMensual.Columns(38).Visible = True
End If
'Esconde Trimestral
GvDatosMensual2.Columns(7).Visible = False
GvDatosMensual2.Columns(8).Visible = False
GvDatosMensual2.Columns(17).Visible = False
GvDatosMensual2.Columns(18).Visible = False
GvDatosMensual2.Columns(27).Visible = False
GvDatosMensual2.Columns(28).Visible = False
GvDatosMensual2.Columns(35).Visible = False
GvDatosMensual2.Columns(36).Visible = False
'Esconde Cuatrimestral
GvDatosMensual2.Columns(11).Visible = False
GvDatosMensual2.Columns(12).Visible = False
GvDatosMensual2.Columns(23).Visible = False
GvDatosMensual2.Columns(24).Visible = False
GvDatosMensual2.Columns(37).Visible = False
GvDatosMensual2.Columns(38).Visible = False
If DdlSubtotales.SelectedValue = "2" Then
GvDatosMensual2.Columns(7).Visible = True
GvDatosMensual2.Columns(8).Visible = True
GvDatosMensual2.Columns(17).Visible = True
GvDatosMensual2.Columns(18).Visible = True
GvDatosMensual2.Columns(27).Visible = True
GvDatosMensual2.Columns(28).Visible = True
GvDatosMensual2.Columns(35).Visible = True
GvDatosMensual2.Columns(36).Visible = True
ElseIf DdlSubtotales.SelectedValue = "3" Then
GvDatosMensual2.Columns(11).Visible = True
GvDatosMensual2.Columns(12).Visible = True
GvDatosMensual2.Columns(23).Visible = True
GvDatosMensual2.Columns(24).Visible = True
GvDatosMensual2.Columns(37).Visible = True
GvDatosMensual2.Columns(38).Visible = True
End If
End Sub
Private Sub CargaGridMensual()
GvDatosMensual.DataSource = DtDatosMensual
GvDatosMensual2.DataSource = DtDatosMensual
GvDatosMensual.DataBind()
GvDatosMensual2.DataBind()
FechasReporte()
For Each GVRow As GridViewRow In GvDatosMensual.Rows
If GVRow.DataKey("IntSubOrden").ToEntero = 2 Then
GVRow.Attributes.Add("style", "border-top:2px solid black")
End If
Next
UpDatosMensual.Update()
UpDatosExelRederMensualidad.Update()
'Fix visual tabla GvDatosMensual
RegistraScript("setTimeout(function() {
$('.adsCol > div').height(29); $('.ADSRow').height(0);
$('#C_TabContainer_TabMensual_GvDatosMensual > tbody > tr.ADSRow > td.adsCol > div').height(0);
$('#C_TabContainer_TabMensual_GvDatosMensual > tbody > tr:nth-child(2) > td.adsCol > div').height(0);
$('#ADColC_TabContainer_TabMensual_GvDatosMensual > tbody > tr.ADSRow').height(1);
$('#ADColC_TabContainer_TabMensual_GvDatosMensual > tbody > tr.ADSRow > td:nth-child(1) > div').height(0);
$('#ADColC_TabContainer_TabMensual_GvDatosMensual > tbody > tr.ADSRow > td.adsCol > div').height(0);
$('.UtilidadPerdida').parent().attr('align', 'right');
$('#ADColC_TabContainer_TabMensual_GvDatosMensual > tbody > tr:nth-child(35) > td:nth-child(1)').attr('align', 'center');
}, 1000); ", "FixTables")
End Sub
Protected Sub GvDatosMensual_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosMensual.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 4 Then
e.Row.FCHyperLink("HLEnero").Text = ""
e.Row.FCHyperLink("HLFebrero").Text = ""
e.Row.FCHyperLink("HLMarzo").Text = ""
e.Row.FCHyperLink("HLAbril").Text = ""
e.Row.FCHyperLink("HLMayo").Text = ""
e.Row.FCHyperLink("HLJunio").Text = ""
e.Row.FCHyperLink("HLJulio").Text = ""
e.Row.FCHyperLink("HLAgosto").Text = ""
e.Row.FCHyperLink("HLSeptiembre").Text = ""
e.Row.FCHyperLink("HLOctubre").Text = ""
e.Row.FCHyperLink("HLNoviembre").Text = ""
e.Row.FCHyperLink("HLDiciembre").Text = ""
e.Row.Cells(2).Text = ""
e.Row.Cells(4).Text = ""
e.Row.Cells(6).Text = ""
e.Row.Cells(8).Text = ""
e.Row.Cells(10).Text = ""
e.Row.Cells(12).Text = ""
e.Row.Cells(14).Text = ""
e.Row.Cells(16).Text = ""
e.Row.Cells(18).Text = ""
e.Row.Cells(20).Text = ""
e.Row.Cells(22).Text = ""
e.Row.Cells(24).Text = ""
End If
'AGRUPADOR DE CUENTAS
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 4 Then
e.Row.FCHyperLink("HlNombre").Font.Bold = True
End If
'TITULO DE CUENTAS
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then
e.Row.FCHyperLink("HlNombre").Attributes.Add("style", "padding-left: 10px;")
End If
'CUENTAS
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 1 Then
e.Row.FCHyperLink("HlNombre").Attributes.Add("style", "padding-left: 20px;")
e.Row.FCHyperLink("HlNombre").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogoMes.aspx?ID={0}&Ejercicio={1}", e.Row.DBCampo("Id"), DdlEjercicio.SelectedValue)
End If
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 1 Or e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then
e.Row.FCHyperLink("HLEnero").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&TP={2}&CM=1", e.Row.DBCampo("Id"), String.Format("01/01/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLFebrero").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&TP={2}&CM=1", e.Row.DBCampo("Id"), String.Format("01/02/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLMarzo").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&TP={2}&CM=1", e.Row.DBCampo("Id"), String.Format("01/03/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLAbril").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&TP={2}&CM=1", e.Row.DBCampo("Id"), String.Format("01/04/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLMayo").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&TP={2}&CM=1", e.Row.DBCampo("Id"), String.Format("01/05/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLJunio").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&TP={2}&CM=1", e.Row.DBCampo("Id"), String.Format("01/06/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLJulio").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&TP={2}&CM=1", e.Row.DBCampo("Id"), String.Format("01/07/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLAgosto").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&TP={2}&CM=1", e.Row.DBCampo("Id"), String.Format("01/08/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLSeptiembre").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&TP={2}&CM=1", e.Row.DBCampo("Id"), String.Format("09/01/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLOctubre").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&TP={2}&CM=1", e.Row.DBCampo("Id"), String.Format("01/10/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLNoviembre").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&TP={2}&CM=1", e.Row.DBCampo("Id"), String.Format("01/11/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLDiciembre").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FF={1}&TP={2}&CM=1", e.Row.DBCampo("Id"), String.Format("01/12/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLTrimestral1").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FI={1}&FF={2}&TP={3}&CM=1", e.Row.DBCampo("Id"), String.Format("01/01/{0}", DdlEjercicio.SelectedValue.ToString), String.Format("01/03/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLTrimestral2").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FI={1}&FF={2}&TP={3}&CM=1", e.Row.DBCampo("Id"), String.Format("01/04/{0}", DdlEjercicio.SelectedValue.ToString), String.Format("01/06/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLTrimestral3").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FI={1}&FF={2}&TP={3}&CM=1", e.Row.DBCampo("Id"), String.Format("01/07/{0}", DdlEjercicio.SelectedValue.ToString), String.Format("01/09/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLTrimestral4").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FI={1}&FF={2}&TP={3}&CM=1", e.Row.DBCampo("Id"), String.Format("01/10/{0}", DdlEjercicio.SelectedValue.ToString), String.Format("01/12/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLCuatrimestral1").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FI={1}&FF={2}&TP={3}&CM=1", e.Row.DBCampo("Id"), String.Format("01/01/{0}", DdlEjercicio.SelectedValue.ToString), String.Format("01/04/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLCuatrimestral2").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FI={1}&FF={2}&TP={3}&CM=1", e.Row.DBCampo("Id"), String.Format("01/05/{0}", DdlEjercicio.SelectedValue.ToString), String.Format("01/08/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
e.Row.FCHyperLink("HLCuatrimestral3").NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FI={1}&FF={2}&TP={3}&CM=1", e.Row.DBCampo("Id"), String.Format("01/09/{0}", DdlEjercicio.SelectedValue.ToString), String.Format("01/12/{0}", DdlEjercicio.SelectedValue.ToString).ToDate.LastDayOfMonth.ToShortDateString, TipoReporte)
End If
''TOTALES
If e.Row.DBCampo("IntSubOrden").ToString.ToEntero.Contiene(0, 3) And e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then
e.Row.Attributes.Add("style", "Height:29px")
e.Row.Cells(1).Text = ""
e.Row.Cells(2).Text = ""
e.Row.Cells(3).Text = ""
e.Row.Cells(4).Text = ""
e.Row.Cells(5).Text = ""
e.Row.Cells(6).Text = ""
e.Row.Cells(7).Text = ""
e.Row.Cells(8).Text = ""
e.Row.Cells(9).Text = ""
e.Row.Cells(10).Text = ""
e.Row.Cells(11).Text = ""
e.Row.Cells(12).Text = ""
e.Row.Cells(13).Text = ""
e.Row.Cells(14).Text = ""
e.Row.Cells(15).Text = ""
e.Row.Cells(16).Text = ""
e.Row.Cells(17).Text = ""
e.Row.Cells(18).Text = ""
e.Row.Cells(19).Text = ""
e.Row.Cells(20).Text = ""
e.Row.Cells(21).Text = ""
e.Row.Cells(22).Text = ""
e.Row.Cells(23).Text = ""
e.Row.Cells(24).Text = ""
e.Row.Cells(25).Text = ""
e.Row.Cells(26).Text = ""
e.Row.Cells(27).Text = ""
e.Row.Cells(28).Text = ""
e.Row.Cells(29).Text = ""
e.Row.Cells(30).Text = ""
e.Row.Cells(31).Text = ""
e.Row.Cells(32).Text = ""
e.Row.Cells(33).Text = ""
e.Row.Cells(34).Text = ""
End If
If e.Row.DBCampo("IntSubOrden").ToString.ToEntero.Contiene(2, 0) Then
e.Row.Font.Bold = True
End If
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 And e.Row.DBCampo("Nombre").ToString.Length > 0 Then
e.Row.ControlStyle.BackColor = Drawing.Color.LightGray
End If
End If
If e.Row.RowType = DataControlRowType.Footer Then
e.Row.Font.Bold = True
e.Row.Font.Size = 12
e.Row.FCLabel("LblUtiEnero").Text = (DtDatosMensual.SUM("Enero", "CtaMayor = 1 AND Tipo = 'H' ") - DtDatosMensual.SUM("Enero", "CtaMayor = 1 AND Tipo = 'G' ")).ToString("###,###,###.00")
e.Row.FCLabel("LblUtiFebrero").Text = (DtDatosMensual.SUM("Febrero", "CtaMayor = 1 AND Tipo = 'H' ") - DtDatosMensual.SUM("Febrero", "CtaMayor = 1 AND Tipo = 'G' ")).ToString("###,###,###.00")
e.Row.FCLabel("LblUtiMarzo").Text = (DtDatosMensual.SUM("Marzo", "CtaMayor = 1 AND Tipo = 'H' ") - DtDatosMensual.SUM("Marzo", "CtaMayor = 1 AND Tipo = 'G' ")).ToString("###,###,###.00")
e.Row.FCLabel("LblUtiAbril").Text = (DtDatosMensual.SUM("Abril", "CtaMayor = 1 AND Tipo = 'H' ") - DtDatosMensual.SUM("Abril", "CtaMayor = 1 AND Tipo = 'G' ")).ToString("###,###,###.00")
e.Row.FCLabel("LblUtiMayo").Text = (DtDatosMensual.SUM("Mayo", "CtaMayor = 1 AND Tipo = 'H' ") - DtDatosMensual.SUM("Mayo", "CtaMayor = 1 AND Tipo = 'G' ")).ToString("###,###,###.00")
e.Row.FCLabel("LblUtiJunio").Text = (DtDatosMensual.SUM("Junio", "CtaMayor = 1 AND Tipo = 'H' ") - DtDatosMensual.SUM("Junio", "CtaMayor = 1 AND Tipo = 'G' ")).ToString("###,###,###.00")
e.Row.FCLabel("LblUtiJulio").Text = (DtDatosMensual.SUM("Julio", "CtaMayor = 1 AND Tipo = 'H' ") - DtDatosMensual.SUM("Julio", "CtaMayor = 1 AND Tipo = 'G' ")).ToString("###,###,###.00")
e.Row.FCLabel("LblUtiAgosto").Text = (DtDatosMensual.SUM("Agosto", "CtaMayor = 1 AND Tipo = 'H' ") - DtDatosMensual.SUM("Agosto", "CtaMayor = 1 AND Tipo = 'G' ")).ToString("###,###,###.00")
e.Row.FCLabel("LblUtiSeptiembre").Text = (DtDatosMensual.SUM("Septiembre", "CtaMayor = 1 AND Tipo = 'H' ") - DtDatosMensual.SUM("Septiembre", "CtaMayor = 1 AND Tipo = 'G' ")).ToString("###,###,###.00")
e.Row.FCLabel("LblUtiOctubre").Text = (DtDatosMensual.SUM("Octubre", "CtaMayor = 1 AND Tipo = 'H' ") - DtDatosMensual.SUM("Octubre", "CtaMayor = 1 AND Tipo = 'G' ")).ToString("###,###,###.00")
e.Row.FCLabel("LblUtiNoviembre").Text = (DtDatosMensual.SUM("Noviembre", "CtaMayor = 1 AND Tipo = 'H' ") - DtDatosMensual.SUM("Noviembre", "CtaMayor = 1 AND Tipo = 'G' ")).ToString("###,###,###.00")
e.Row.FCLabel("LblUtiDiciembre").Text = (DtDatosMensual.SUM("Diciembre", "CtaMayor = 1 AND Tipo = 'H' ") - DtDatosMensual.SUM("Diciembre", "CtaMayor = 1 AND Tipo = 'G' ")).ToString("###,###,###.00")
End If
End Sub
Private Sub FechasReporte()
Dim FechaInicio As Date
Dim FechaFin As Date
'' If DdlTipoConsulta.SelectedValue.ToEntero = 1 Then
'FechaInicio = New Date(DdlEjercicio.SelectedValue.ToEntero, DdlPeriodo.SelectedValue.ToEntero, 1)
' FechaFin = FechaInicio.LastDayOfMonth()
''Else
'FechaInicio = New Date(DdlEjercicio.SelectedValue.ToEntero, 1, 1)
' FechaFin = New Date(DdlEjercicio.SelectedValue.ToEntero, DdlPeriodo.SelectedValue.ToEntero, 1).LastDayOfMonth
'End If
Dim UrlImagen = $"http://{ HttpContext.Current.Request.Url.Host}:{HttpContext.Current.Request.Url.Port}/Empresas/{UsuarioActual.CveEmpresa}/Logo.png"
If File.Exists($"{UsuarioActual.Empresa.Ruta}Logo.png") Then
ImgLogoReporte.Attributes.Add("src", UrlImagen)
Else
ImgLogoReporte.Attributes.Add("src", "")
End If
LblTituloAniosRango.Text = $"{ UsuarioActual.Empresa.Empresa }"
LblFechas.Text = $"{FechaInicio.ToString("dd/MMMM/yyyy")} al {FechaFin.ToString("dd/MMMM/yyyy")}"
LblFechaReporte.Text = NowADS().ToString("dd/MMMM/yyyy")
End Sub
Protected Sub LnkDescarPersonalizados_Click(sender As Object, e As EventArgs)
DescargaReporte()
End Sub
Private Sub DescargaReporte()
Dim htmlFuente As String = txtDatos.Text
Dim RutaLogo As String = $"{Server.MapPath("~")}\Empresas\{UsuarioActual.CveEmpresa}\logo.png"
htmlFuente = htmlFuente.Replace("<table ", "<table border='1' ")
htmlFuente = htmlFuente.Replace("<a ", "<label ")
htmlFuente = htmlFuente.Replace("</a ", "</label ")
htmlFuente = htmlFuente.Replace("<th ", "<th style='background-color:#ddd!important'; ")
' htmlFuente = Cabera + htmlFuente
'Dim buffer As Byte()
'Dim memoryStream = New System.IO.MemoryStream()
SpreadsheetInfo.SetLicense(SerialGemBoxSpreadsheet)
Dim excel As ExcelFile
Dim options = LoadOptions.HtmlDefault
Using htmlStream = New MemoryStream(options.Encoding.GetBytes(htmlFuente))
excel = ExcelFile.Load(htmlStream, options)
End Using
Dim ws = excel.Worksheets(0)
ws.Name = "Estado Resultado por Segmento"
Dim columnCount = ws.CalculateMaxUsedColumns()
For i As Integer = 0 To columnCount - 1
If i = 0 Then
ws.Columns(i).Width = 10000
Else
ws.Columns(i).Width = 6000
End If
Next
excel.Save(Me.Response, $"RepEstadoResultadosMensual_{NowADS().ToString("yyyyMMddhhmmss")}.xlsx")
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.GetEstadoResultadosAnual(DdlEjercicio.SelectedValue.ToEntero, TipoReporte, DdlSegmentoNegocio.SelectedValue.ToEntero) Then
DtDatosAnual = ObjConta.DtResultados
Else
DtDatosAnual = Nothing
Alert("Ocurrio un error al cargar los datos del balance general anual", TipoMensaje.MsgError)
End If
ObjConta.Dispose()
Anos = (Year(NowADS()) - DdlEjercicio.SelectedValue.ToEntero) + 1
'Esconde todo
For index = 1 To 40 Step 2
GvDatosAnual.Columns(index).Visible = False
GvDatosAnual.Columns(index + 1).Visible = False
Next
Dim i = 0
For index = 1 To Anos * 2 Step 2
GvDatosAnual.Columns(index).Visible = True
GvDatosAnual.Columns(index + 1).Visible = True
GvDatosAnual.Columns(index).HeaderText = (DdlEjercicio.SelectedValue.ToEntero + i).ToString
i = i + 1
Next
If DtDatosAnual IsNot Nothing Then
CargaGridAnual()
End If
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
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 4 Then
For index = 1 To Anos
e.Row.FCHyperLink("HLAno" + index.ToString).Text = ""
e.Row.Cells(index + index).Text = ""
Next
End If
'AGRUPADOR DE CUENTAS
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 4 Then
e.Row.FCLabel("LbNombre").Font.Bold = True
End If
'TITULO DE CUENTAS
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then
e.Row.FCLabel("LbNombre").Attributes.Add("style", "padding-left: 10px;")
e.Row.FCLabel("LbNombre").Font.Italic = 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
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 1 Or e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then
For index = 1 To Anos
e.Row.FCHyperLink("HLAno" + index.ToString).NavigateUrl = String.Format("/Contabilidad/RepAnexoCatalogo.aspx?ID={0}&FI={1}&FF={2}&TP={3}&CM=1", e.Row.DBCampo("Id"), String.Format("01/01/{0}", (DdlEjercicio.SelectedValue.ToEntero + index - 1).ToString), String.Format("31/12/{0}", (DdlEjercicio.SelectedValue.ToEntero + index - 1).ToString), TipoReporte)
Next
End If
'TOTALES
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 5 Then
e.Row.Attributes.Add("style", "border-top: 1px solid;")
e.Row.FCLabel("LbNombre").Attributes.Add("style", "padding-left: 10px;")
e.Row.FCLabel("LbNombre").Font.Italic = True
End If
'SUMAS
If e.Row.DBCampo("CtaMayor").ToString.ToEntero = 6 Then
e.Row.FCLabel("LbNombre").Font.Bold = True
End If
End If
End Sub
#End Region
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
'Nota:
' 0 = Normal
' 1 = Mensual
' 2 = Anual
If TabContainer.ActiveTabIndex = 0 Then
CargaDatos()
ImgExcel.Visible = True
Imprimir.Visible = True
liLnkDescarPersonalizado.Visible = False
ElseIf TabContainer.ActiveTabIndex = 1 Then
CargaDatosMensual()
ImgExcel.Visible = False
Imprimir.Visible = False
liLnkDescarPersonalizado.Visible = True
ElseIf TabContainer.ActiveTabIndex = 2 Then
CargaDatosAnual()
ImgExcel.Visible = True
Imprimir.Visible = True
liLnkDescarPersonalizado.Visible = False
End If
UpAcciones.Update()
End Sub
#Region " IMPRESION "
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
If TabContainer.ActiveTabIndex = 0 Then
If Not IsNothing(DtDatos) Then
CargaDatos()
ImprimirReporte("Excel")
Else
Alert("No se encontró información para el reporte.", TipoMensaje.MsgAdvertencia)
End If
ElseIf TabContainer.ActiveTabIndex = 1 Then
If Not IsNothing(DtDatosMensual) Then
CargaDatosMensual()
ImprimirReporteMensual("Excel")
Else
Alert("No se encontró información para el reporte.", TipoMensaje.MsgAdvertencia)
End If
ElseIf TabContainer.ActiveTabIndex = 2 Then
If Not IsNothing(DtDatosAnual) Then
CargaDatosAnual()
ImprimirReporteAnual("Excel")
Else
Alert("No se encontró información para el reporte.", TipoMensaje.MsgAdvertencia)
End If
End If
End Sub
Protected Sub Imprimir_click(sender As Object, e As EventArgs) Handles Imprimir.Click
If TabContainer.ActiveTabIndex = 0 Then
If Not IsNothing(DtDatos) Then
CargaDatos()
ImprimirReporte()
Else
Alert("No se encontró información para el reporte.", TipoMensaje.MsgAdvertencia)
End If
ElseIf TabContainer.ActiveTabIndex = 1 Then
If Not IsNothing(DtDatosMensual) Then
CargaDatosMensual()
ImprimirReporteMensual()
Else
Alert("No se encontró información para el reporte.", TipoMensaje.MsgAdvertencia)
End If
ElseIf TabContainer.ActiveTabIndex = 2 Then
If Not IsNothing(DtDatosAnual) Then
CargaDatosAnual()
ImprimirReporteAnual()
Else
Alert("No se encontró información para el reporte.", TipoMensaje.MsgAdvertencia)
End If
End If
End Sub
Private Sub ProcesaImpresion()
Dim FechaI = String.Format("01/{0}/{1}", DdlPeriodo.SelectedValue.PadLeft(2, CChar("0")), If(DdlEjercicio.SelectedValue.Length = 0, NowADS().Year.ToString, DdlEjercicio.SelectedValue)).ToDate
Dim FechaF = FechaI.ToDate.LastDayOfMonth
TipoReporte = If(TipoReporte = -1, -1, DdlTipoReporte.SelectedValue.ToEntero)
Dim IdCuentaAhorroDesahorro = If(UsuarioActual.CveEmpresa = 48, 87, 9999)
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
If ObjConta.GetEstadoActividades(FechaI.ToDate, FechaF.ToDate, TipoReporte, UsuarioActual.Empresa.UsaAC) Then
DtDatos = ObjConta.DtResultados
Else
DtDatos = Nothing
Alert("Ocurrio un error al cargar los datos del estado de resultados", TipoMensaje.MsgError)
End If
ObjConta.Dispose()
If DtDatos Is Nothing Then
Exit Sub
End If
'ProcesaDTImprimir(FiltroActivoCirculante, "AC", DtDatos)
'ProcesaDTImprimir(FiltroActivoNoCirculante, "ANC", DtDatos)
'ProcesaDTImprimir(FiltroActivoDiferido, "AD", DtDatos)
'ProcesaDTImprimir(FiltroPasivoCirculante, "PC", DtDatos)
'ProcesaDTImprimir(FiltroPasivoNoCirculante, "PNC", DtDatos)
'ProcesaDTImprimir(FiltroPasivoDiferido, "PD", DtDatos)
'ProcesaDTImprimir(FiltroCapital, "C", DtDatos)
'ProcesaDTImprimir(FiltroUtilidad, "C", DtDatos)
For Each Row As DataRow In DtDatos.Select("CtaMayor=3")
DtDatos.Rows.Remove(Row)
Next
End Sub
Private Sub ProcesaDTImprimir(Filtro As String, Sup As String, ByRef Dt As DataTable)
For Each Row As DataRow In Dt.Select(Filtro)
Row("Sup") = Sup
Next
Dt.AcceptChanges()
End Sub
Private Sub ImprimirReporte(Optional Formato As String = "PDF")
ProcesaImpresion()
'nombre del archivo a generar
Dim fileName As String = "EstadoResultados"
'ubicacion del rdlc
Dim reportpath As String = "Contabilidad/Reportes/RepEstadoResultados.rdlc"
Dim FechaI = String.Format("01/{0}/{1}", DdlPeriodo.SelectedValue.PadLeft(2, CChar("0")), DdlEjercicio.SelectedValue)
Dim FechaF = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, CDate(FechaI))).ToString("dd/MM/yyyy")
'parametros a enviar al reporte
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa))
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
params.Add(New ReportParameter("pImg", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
params.Add(New ReportParameter("pFirma1", ""))
params.Add(New ReportParameter("pFirma2", ""))
params.Add(New ReportParameter("pFechaFin", FechaF))
params.Add(New ReportParameter("lbTotalActual", TotalActual.ToString))
params.Add(New ReportParameter("lbTotalAcumulado", TotalAnterior.ToString))
params.Add(New ReportParameter("TPorcentajeActual", PorcentajeActual))
params.Add(New ReportParameter("TPorcentajeAcumulado", PorcentajeAcumulado))
Dim lrds As New List(Of ReportDataSource)
Dim rds1 As New ReportDataSource With {.Name = "DataSet1", .Value = If(DtIngresos IsNot Nothing, DtIngresos, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte
Dim rds2 As New ReportDataSource With {.Name = "DataSet2", .Value = If(DtGastos IsNot Nothing, DtGastos, New DataTable)}
lrds.Add(rds1)
lrds.Add(rds2)
ImprimirPDF(reportpath, lrds, params, fileName, Formato)
End Sub
Private Sub ImprimirReporteMensual(Optional Formato As String = "PDF")
ProcesaImpresion()
'nombre del archivo a generar
Dim fileName As String = "EstadoResultadosMensual"
'ubicacion del rdlc
Dim reportpath As String = Server.MapPath("~/Empresas/Grales/Formatos/RepEstadoResultadosMensual.rdlc")
'Dim FechaI = String.Format("01/{0}/{1}", 12, DdlEjercicio.SelectedValue)
Dim FechaF = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, CDate(String.Format("01/{0}/{1}", 12, DdlEjercicio.SelectedValue)))).ToString("dd/MM/yyyy")
'parametros a enviar al reporte
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa))
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
params.Add(New ReportParameter("pImg", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
params.Add(New ReportParameter("pFechaFin", FechaF))
params.Add(New ReportParameter("pSubtotal", DdlSubtotales.SelectedValue.ToString))
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario))
params.Add(New ReportParameter("FechaImpresion", NowADS().ToShortDateString))
ImprimirPDF(reportpath, DtDatosMensual, params, fileName, Formato)
End Sub
Private Sub ImprimirReporteAnual(Optional Formato As String = "PDF")
ProcesaImpresion()
'nombre del archivo a generar
Dim fileName As String = "EstadoResultadosAnual"
'ubicacion del rdlc
Dim reportpath As String = Server.MapPath("~/Empresas/Grales/Formatos/RepEstadoResultadosAnual.rdlc")
'Dim FechaI = String.Format("01/{0}/{1}", DdlPeriodo.SelectedValue.PadLeft(2, CChar("0")), DdlEjercicio.SelectedValue)
'Dim FechaF = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, CDate(FechaI))).ToString("dd/MM/yyyy")
'parametros a enviar al reporte
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa))
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
params.Add(New ReportParameter("pImg", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
params.Add(New ReportParameter("pFechaI", DdlEjercicio.SelectedValue))
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario))
params.Add(New ReportParameter("FechaImpresion", NowADS().ToShortDateString))
ImprimirPDF(reportpath, DtDatosAnual, params, fileName, Formato)
End Sub
#End Region
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
TdPeriodo.Visible = False
If TabContainer.ActiveTabIndex = 0 Then
TdPeriodo.Visible = True
ElseIf TabContainer.ActiveTabIndex = 1 Then
TdSubTotales.Visible = True
ElseIf TabContainer.ActiveTabIndex = 2 Then
End If
UpFiltros.Update()
BtnConsultar_Click(BtnConsultar, EventArgs.Empty)
End Sub
End Class