Files
SIG/Contabilidad/RepFlujoEfectivo.aspx.vb
2023-10-09 11:55:07 -07:00

179 lines
5.4 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.html.simpleparser
Imports iTextSharp.text.pdf
Partial Class Contabilidad_RepFlujoEfectivo
Inherits ClsPaginas
#Region "PROPIEDADES"
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 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 FechaAl As String
Get
FechaAl = ViewState("FechaAl").ToString
End Get
Set(value As String)
ViewState("FechaAl") = 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
'TxtFechaDel.Text = DateSerial(Year(NowADS()), Month(NowADS()), 1).ToShortDateString
TxtFechaAl.Text = NowADS().ToShortDateString
CargaDatos()
BtnConsultar.Enabled = True
End If
End Sub
#Region "CARGA DATOS Y GRID"
Private Sub CargaDatos()
Dim ObjConta As New ClsContabilidad
'Dim FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", NowADS(), TxtFechaDel.Text.ToDate)
Dim FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", NowADS(), TxtFechaAl.Text.ToDate)
FechaAl = TxtFechaAl.Text
If ObjConta.GetFlujoEfectivo2(FechaFin, DdlTipo.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
DtDatos = ObjConta.DtResultados
Else
DtDatos = Nothing
Alert("Ocurrio un error al cargar los datos del Estado de Flujo de Efectivo", TipoMensaje.MsgError)
End If
ObjConta.Dispose()
GvDatos.DataSource = DtDatos
GvDatos.DataBind()
UpDatos.Update()
End Sub
#End Region
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
CargaDatos()
End Sub
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
'PARA PONER AÑO EN HEADER
If e.Row.RowIndex = 0 Then
GvDatos.HeaderRow.FCLabel("LbPeriodoActual").Text = e.Row.DBCampo("Actual")
GvDatos.HeaderRow.FCLabel("LbPeriodoAnterior").Text = e.Row.DBCampo("Anterior")
End If
'TITULO DE BLOQUE (CABECERAS Y TOTALES)
If e.Row.DBCampo("Level") = "-1" Then
CType(e.Row.FindControl("Concepto"), HtmlControl).Attributes.Add("style", "margin-top:20px; ")
e.Row.Font.Bold = True
'CABCERA
If e.Row.DBCampo("Id") = "12" Then
e.Row.FCLabel("LbActual").Text = ""
e.Row.FCLabel("LbAnterior").Text = ""
End If
'TOTAL OPERACIONES
If e.Row.DBCampo("Id") = "123" Then
e.Row.FCLabel("LbActual").Text = TotalActual.ToString.FormatoNumero
e.Row.FCLabel("LbAnterior").Text = TotalAnterior.ToString.FormatoNumero
End If
End If
'ORIGEN Y APLICACION
If e.Row.DBCampo("Level") = "0" Then
CType(e.Row.FindControl("Concepto"), HtmlControl).Attributes.Add("style", "margin-left:30px; margin-top:15px")
e.Row.Font.Bold = True
End If
'PAPAS
If e.Row.DBCampo("Level") = "2" Then
CType(e.Row.FindControl("Concepto"), HtmlControl).Attributes.Add("style", "margin-left: 60px; margin-top:5px;")
End If
'HIJOS
If e.Row.DBCampo("Level") = "3" Then
CType(e.Row.FindControl("Concepto"), HtmlControl).Attributes.Add("style", "margin-left:90px;")
End If
'INGRESOS -> ORIGEN
If e.Row.DBCampo("Codigo").ToString.Substring(0, 5) = "00004" Then e.Row.FCLiteral("LtNombre").Text = "ORIGEN"
'GASTOS -> APLICACION
If e.Row.DBCampo("Codigo").ToString.Substring(0, 5) = "00005" Then e.Row.FCLiteral("LtNombre").Text = "APLICACION"
'ACTIVIDADES DE OPERACION
If e.Row.DBCampo("Sup").ToString <> "" Then
If e.Row.DBCampo("ImporteAnterior").ToString.ToDecimal = 0 Then
e.Row.FCLabel("LbAnterior").Text = ""
End If
If e.Row.DBCampo("ImporteActual").ToString.ToDecimal = 0 Then
e.Row.FCLabel("LbActual").Text = ""
End If
End If
End If
End Sub
Public Overrides Sub VerifyRenderingInServerForm(control As Control)
End Sub
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
GvDatos.ExportToExcel2("RepFlujosDeEfectivo.xlsx")
End Sub
End Class