244 lines
10 KiB
VB.net
244 lines
10 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 AC_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
|
|
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 = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", Date.Now, TxtFechaDel.Text.ToDate)
|
|
Dim FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", Date.Now, TxtFechaAl.Text.ToDate)
|
|
FechaAl = TxtFechaAl.Text
|
|
If ObjConta.GetFlujoEfectivo(FechaInicio, FechaFin, DdlUnidad.SelectedValue.ToEntero) 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()
|
|
|
|
'OBTENEMOS TOTALES NETOS DE OPERACIONES PARA INSERTAR DIRECTO
|
|
If DtDatos IsNot Nothing Then
|
|
If UsuarioActual.CveEmpresa.Contiene(120) Then
|
|
TotalActual = DtDatos.FiltraParametros("Codigo = '040000000000000000'").Rows(0)("ImporteActual").ToString.ToDouble - DtDatos.FiltraParametros("Codigo = '050000000000000000'").Rows(0)("ImporteActual").ToString.ToDouble
|
|
TotalAnterior = DtDatos.FiltraParametros("Codigo = '040000000000000000'").Rows(0)("ImporteAnterior").ToString.ToDouble - DtDatos.FiltraParametros("Codigo = '050000000000000000'").Rows(0)("ImporteAnterior").ToString.ToDouble
|
|
Else
|
|
TotalActual = DtDatos.FiltraParametros("Codigo = '000040000000000000'").Rows(0)("ImporteActual").ToString.ToDouble - DtDatos.FiltraParametros("Codigo = '000050000000000000'").Rows(0)("ImporteActual").ToString.ToDouble
|
|
TotalAnterior = DtDatos.FiltraParametros("Codigo = '000040000000000000'").Rows(0)("ImporteAnterior").ToString.ToDouble - DtDatos.FiltraParametros("Codigo = '000050000000000000'").Rows(0)("ImporteAnterior").ToString.ToDouble
|
|
End If
|
|
End If
|
|
|
|
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 Flujo de Efectivo<br/>Al {1}</div>", UsuarioActual.Empresa.Empresa, TxtFechaAl.Text)
|
|
|
|
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
|
|
|
|
Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs) Handles BtnImprimir.Click
|
|
If Not IsNothing(DtDatos) Then
|
|
ImprimirReporte()
|
|
Else
|
|
Alert("Primero debe consultar el Estado de Flujo de Efectivo", 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 Flujo de Efectivo<br/>Al {1}</div>", UsuarioActual.Empresa.Empresa, FechaAl)
|
|
' 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
|
|
'GvDatos.ExportToExcel("ReporteFlujoEfectivo" & Now.ToShortDateString)
|
|
If Not IsNothing(DtDatos) Then
|
|
ImprimirReporte("Excel")
|
|
Else
|
|
Alert("Primero debe consultar el Estado de Flujo de Efectivo", 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))
|
|
params.Add(New ReportParameter("pImg", New Uri(Server.MapPath(String.Format("~/Empresas/{0}/Logo.png", UsuarioActual.CveEmpresa))).AbsoluteUri))
|
|
params.Add(New ReportParameter("pAl", FechaAl))
|
|
params.Add(New ReportParameter("pTotalActual", TotalActual.ToString.FormatoNumero))
|
|
params.Add(New ReportParameter("pTotalAnterior", TotalAnterior.ToString.FormatoNumero))
|
|
params.Add(New ReportParameter("pFirma1", String.Format("C.P. Izelda Angulo Peraza{0} Subdirector de Contabilidad", vbCrLf)))
|
|
params.Add(New ReportParameter("pFirma2", String.Format("Lic. Juan Fortino Leon Robinson{0} Director General", vbCrLf)))
|
|
ImprimirPDF("AC/Reportes/RepFlujoEfectivo.rdlc", DtDatos, params, "EdoFlujoEfectivo", Formato)
|
|
End Sub
|
|
|
|
End Class
|