Files
SIG/AC/RepCambiosSituacionFinanciera.aspx.vb

264 lines
10 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Imports System.IO
Imports Microsoft.Reporting.WebForms
Imports iTextSharp.text
Imports iTextSharp.text.html.simpleparser
Imports iTextSharp.text.pdf
Partial Class AC_RepCambiosSituacionFinanciera
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 TotalActivoActual As Double
Get
TotalActivoActual = ViewState("TotalActivoActual").ToString.ToDouble
End Get
Set(value As Double)
ViewState("TotalActivoActual") = value
End Set
End Property
Private Property TotalActivoAnterior As Double
Get
TotalActivoAnterior = ViewState("TotalActivoAnterior").ToString.ToDouble
End Get
Set(value As Double)
ViewState("TotalActivoAnterior") = value
End Set
End Property
Private Property TotalPasivoActual As Double
Get
TotalPasivoActual = ViewState("TotalPasivoActual").ToString.ToDouble
End Get
Set(value As Double)
ViewState("TotalPasivoActual") = value
End Set
End Property
Private Property TotalPasivoAnterior As Double
Get
TotalPasivoAnterior = ViewState("TotalPasivoAnterior").ToString.ToDouble
End Get
Set(value As Double)
ViewState("TotalPasivoAnterior") = value
End Set
End Property
Private Property TotalPatrimonioActual As Double
Get
TotalPatrimonioActual = ViewState("TotalPatrimonioActual").ToString.ToDouble
End Get
Set(value As Double)
ViewState("TotalPatrimonioActual") = value
End Set
End Property
Private Property TotalPatrimonioAnterior As Double
Get
TotalPatrimonioAnterior = ViewState("TotalPatrimonioAnterior").ToString.ToDouble
End Get
Set(value As Double)
ViewState("TotalPatrimonioAnterior") = value
End Set
End Property
Private Property TotalPasivoPatrimonioActual As Double
Get
TotalPasivoPatrimonioActual = ViewState("TotalPasivoPatrimonioActual").ToString.ToDouble
End Get
Set(value As Double)
ViewState("TotalPasivoPatrimonioActual") = value
End Set
End Property
Private Property TotalPasivoPatrimonioAnterior As Double
Get
TotalPasivoPatrimonioAnterior = ViewState("TotalPasivoPatrimonioAnterior").ToString.ToDouble
End Get
Set(value As Double)
ViewState("TotalPasivoPatrimonioAnterior") = value
End Set
End Property
Private Property FechaInicioActual As Date
Get
FechaInicioActual = ViewState("FechaInicioActual").ToString.ToDate
End Get
Set(value As Date)
ViewState("FechaInicioActual") = value
End Set
End Property
Private Property FechaFinActual As Date
Get
FechaFinActual = ViewState("FechaFinActual").ToString.ToDate
End Get
Set(value As Date)
ViewState("FechaFinActual") = value
End Set
End Property
Private Property FechaInicioAnterior As Date
Get
FechaInicioAnterior = ViewState("FechaInicioAnterior").ToString.ToDate
End Get
Set(value As Date)
ViewState("FechaInicioAnterior") = value
End Set
End Property
Private Property FechaFinAnterior As Date
Get
FechaFinAnterior = ViewState("FechaFinAnterior").ToString.ToDate
End Get
Set(value As Date)
ViewState("FechaFinAnterior") = 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
'TxtFechaDel.Text = DateSerial(Year(Now), Month(Now), 1).ToShortDateString
'TxtFechaAl.Text = Date.Now.ToShortDateString
CargaDatos()
BtnConsultar.Enabled = True
Else
Alert("La empresa no usa Armonización Contable", TipoMensaje.MsgError)
End If
End If
End Sub
#Region "CARGA DATOS Y GRID"
Private Sub CargaDatos()
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
Dim FechaInicio = String.Format("01/01/{0}", DdlEjercicio.SelectedValue).ToDate
Dim FechaFin = String.Format("31/12/{0}", DdlEjercicio.SelectedValue).ToDate
If ObjConta.GetCambioSituacionFinanciera(FechaInicio, FechaFin, DdlUnidad.SelectedValue.ToEntero) Then
DtDatos = ObjConta.DtResultados
Else
DtDatos = Nothing
Alert("Ocurrio un error al cargar los datos del Estado de Cambio de Situación Financiera.", TipoMensaje.MsgError)
End If
ObjConta.Dispose()
CargaGrid()
End Sub
Private Sub CargaGrid()
GvDatos.DataSource = DtDatos
GvDatos.DataBind()
UpDatos.Update()
' GvDatos.Caption = String.Format("<div class='Titulos' style='width:100%; height:45px;'>{0}<br/>Estado de Cambios en la Situación Financiera<br/>Al {1}</div>", UsuarioActual.Empresa.Empresa, DdlEjercicio.SelectedValue)
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
If e.Row.DBCampo("Level") = "1" Then
CType(e.Row.FindControl("Concepto"), HtmlControl).Attributes.Add("style", "font-weight: bold;")
e.Row.FCLiteral("LtNombre").Text = String.Format("<br/><br/>{0}", e.Row.DBCampo("Nombre"))
End If
If e.Row.DBCampo("Level") = "2" Then
CType(e.Row.FindControl("Concepto"), HtmlControl).Attributes.Add("style", "font-weight: bold;")
e.Row.FCLiteral("LtNombre").Text = String.Format("<br/>{0}{0}{0}{1}", "&nbsp;", e.Row.DBCampo("Nombre"))
End If
If e.Row.DBCampo("Level") = "1" Or e.Row.DBCampo("Level") = "2" Then
e.Row.FCLabel("LbActual").Font.Bold = True
e.Row.FCLabel("LbAnterior").Font.Bold = True
End If
If e.Row.DBCampo("Level") = "3" Then
'CType(e.Row.FindControl("Concepto"), HtmlControl).Attributes.Add("style", "margin-left:60px;")
e.Row.FCLiteral("LtNombre").Text = String.Format("{0}{0}{0}{0}{0}{0}{0}{0}{1}", "&nbsp;", e.Row.DBCampo("Nombre"))
End If
End If
End Sub
Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs) Handles BtnImprimir.Click
If Not IsNothing(DtDatos) Then
ImprimirReporte()
Else
Alert("No se ha encontrado información para el reporte", TipoMensaje.MsgAdvertencia)
End If
End Sub
'No quitar porque no funciona el exporta PDF
Public Overrides Sub VerifyRenderingInServerForm(control As Control)
' Verifies that the control is rendered
End Sub
'Protected Sub GvDatos_RowCreated(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowCreated
' If (e.Row.RowType = DataControlRowType.Header) Then
' Dim HeaderGrid As GridView = DirectCast(sender, GridView)
' Dim HeaderGridRow As GridViewRow = New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert)
' Dim HeaderCell As TableCell = New TableCell()
' HeaderCell.Text = String.Format("<div class='Titulos' style='width:100%; height:45px;'>{0}<br/>Estado de Cambios en la Situación Financiera<br/>Al {1}</div>", UsuarioActual.Empresa.Empresa, DdlEjercicio.SelectedValue)
' HeaderCell.ColumnSpan = GvDatos.Columns.Count
' HeaderCell.HorizontalAlign = HorizontalAlign.Center
' HeaderGridRow.Cells.Add(HeaderCell)
' GvDatos.Controls(0).Controls.AddAt(0, HeaderGridRow)
' End If
' If (e.Row.RowType = DataControlRowType.Footer) Then
' Dim HeaderGrid As GridView = DirectCast(sender, GridView)
' Dim HeaderGridRow As GridViewRow = New GridViewRow(0, 0, DataControlRowType.Footer, DataControlRowState.Insert)
' Dim HeaderCell As TableCell = New TableCell()
' HeaderCell.Text = "<table><tr> <td colspan='3' style='height:30px;'> <br/><br/><br/><br/></td></tr><tr><td >_________________________________<br/>C.P. Izelda Angulo Peraza</td><td style='width:75px'> </td><td > _________________________________<br/>Lic. Juan Fortino Leon Robinson</td></tr><tr><td>Subdirector de Contabilidad</td><td style='width:75px'> </td><td>Director General</td></table>"
' HeaderCell.ColumnSpan = GvDatos.Columns.Count
' HeaderCell.HorizontalAlign = HorizontalAlign.Center
' HeaderGridRow.Cells.Add(HeaderCell)
' e.Row.Cells.Clear()
' e.Row.Cells.Add(HeaderCell)
' End If
'End Sub
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
If Not IsNothing(DtDatos) Then
ImprimirReporte("Excel")
Else
Alert("No se ha encontrado información para el reporte", TipoMensaje.MsgAdvertencia)
End If
End Sub
Private Sub ImprimirReporte(Optional Formato As String = "PDF")
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("pEjercicio", DdlEjercicio.SelectedValue.ToString))
params.Add(New ReportParameter("pFirma1", String.Format("Lic. Damian A. Benitez Alcantar{0} Director Administrativo", vbCrLf)))
params.Add(New ReportParameter("pFirma2", String.Format("ING. Soraida Mesinas Reyes{0} Director General", vbCrLf)))
ImprimirPDF("AC/Reportes/RepCambiosSituacionFinanciera.rdlc", DtDatos, params, "EdoCambiosSituacionFinanciera", Formato)
End Sub
End Class