Files
SIG/AC/RepAnaliticoDeudaPublica.aspx.vb

230 lines
9.6 KiB
VB.net

Imports Extensiones
Imports Microsoft.Reporting.WebForms
Imports System.Data
Partial Class AC_RepAnaliticoDeudaPublica
Inherits ClsPaginas
#Region "propiedades"
Private Property FechaDel As String
Get
FechaDel = ViewState("FechaDel").ToString
End Get
Set(value As String)
ViewState("FechaDel") = 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
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
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
If UsuarioActual.Empresa.UsaAC Then
TxtFechaInicio.Text = String.Format("01/01/{0}", UsuarioActual.Empresa.EjercicioActual)
CalendarioInicio.StartDate = TxtFechaInicio.Text.ToDate
TxtFechaFin.Text = String.Format("{0}/{1}/{2}", Now.Day, Now.Month, UsuarioActual.Empresa.EjercicioActual)
CalendarioFin.EndDate = String.Format("31/12/{0}", UsuarioActual.Empresa.EjercicioActual).ToDate
CargaDatos()
BtnConsultar.Enabled = True
Else
Alert("La empresa no usa Armonización Contable", TipoMensaje.MsgError)
End If
End If
End Sub
Private Sub CargaDatos()
Dim AC As New ClsContPAQi(UsuarioActual.Empresa)
If AC.GetAnaliticoDeudaPublica(TxtFechaInicio.Text.ToDate, TxtFechaFin.Text.ToDate, DdlDivisor.SelectedValue.ToEntero) Then
Gv.DataSource = AC.DtResultados
DtDatos = AC.DtResultados
End If
AC.Dispose()
FechaDel = TxtFechaInicio.Text
FechaAl = TxtFechaFin.Text
' Gv.Caption = String.Format("<table class='Titulos' style='width:100%'><tr><td>Estado Analítico de la Deuda y Otros Pasivos<br/>Del {0} al {1}</td></table>", TxtFechaInicio.Text, TxtFechaFin.Text)
Gv.DataBind()
End Sub
Protected Sub Gv_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles Gv.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex = 0 Then
e.Row.FCLiteral("LtlEspacio").Text = "<b>DEUDA PÚBLICA:<br/><br/>Corto Plazo:<br/><br/></b>"
e.Row.Cells(3).Style.Add("vertical-align", "bottom")
e.Row.Cells(4).Style.Add("vertical-align", "bottom")
End If
If e.Row.DBCampo("Id") = "" Then
e.Row.Font.Bold = True
Else
If e.Row.DBCampo("Id") <> "" Then
e.Row.FCLiteral("LtlEspacio").Text = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
End If
End If
'subtotales
If e.Row.DBCampo("DPublica") = "" AndAlso e.Row.DBCampo("CP") <> "" Then
e.Row.Font.Italic = True
e.Row.FCLabel("Lbl").Text = String.Format("SubTotal {0}", e.Row.FCLabel("Lbl").Text)
e.Row.Cells(3).Style.Add("vertical-align", "top")
e.Row.Cells(4).Style.Add("vertical-align", "top")
If e.Row.DBCampo("CP") = "1" Then
e.Row.FCLiteral("LtlFin").Text = "<br/><br/><b>Largo Plazo</b><br/><br/>"
End If
End If
If e.Row.DBCampo("Plazo") = "" Then
'total general
e.Row.Height = Unit.Pixel(25)
End If
If e.Row.DBCampo("Cta").Contiene("02142", "02232") Then
e.Row.Height = Unit.Pixel(35)
e.Row.FCLiteral("LtlEspacio").Text = "Deuda Bilateral:<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
e.Row.Cells(3).Style.Add("vertical-align", "bottom")
e.Row.Cells(4).Style.Add("vertical-align", "bottom")
End If
End If
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
CargaDatos()
End Sub
Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs) Handles BtnImprimir.Click
If Not IsNothing(DtDatos) Then
ImprimirReporte() 'Descarga reporte en PDF
Else
Alert("No se ha encontrado información para el reporte", TipoMensaje.MsgAdvertencia)
End If
'MasterReporteador.Visible = True
'DirectCast(Master.FindControl("UpdatePanel1"), UpdatePanel).Update()
'showreport(reportpath, AC.DtResultados, params, True)
'Using sw As New StringWriter()
' Using hw As New HtmlTextWriter(sw)
' Dim style As StringBuilder = New StringBuilder()
' style.Append("<style> ")
' style.Append(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory & "Styles\EstilosExcel.css"))
' style.Append(" </style> ")
' 'To Export all pages
' 'Gv.AllowPaging = False
' 'Gv.DataBind()
' Tbl.RenderControl(hw)
' Dim sr As New StringReader(sw.ToString())
' Dim pdfDoc As New Document(PageSize.A2, 10.0F, 10.0F, 10.0F, 0.0F)
' Dim htmlparser As New HTMLWorker(pdfDoc)
' PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
' pdfDoc.Open()
' htmlparser.Parse(sr)
' pdfDoc.Close()
' Response.ContentType = "application/pdf"
' Response.AddHeader("content-disposition", "attachment;filename=FlujoDeEfectivo.pdf")
' Response.Cache.SetCacheability(HttpCacheability.NoCache)
' Response.Write(style.ToString)
' Response.Write(pdfDoc)
' Response.[End]()
' End Using
'End Using
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 Gv.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("<table class='Titulos' style='width:100%'><tr><td>Estado Analítico de la Deuda y Otros Pasivos<br/>Del {0} al {1}</td></table>", FechaDel, FechaAl)
' HeaderCell.ColumnSpan = Gv.Columns.Count
' HeaderCell.HorizontalAlign = HorizontalAlign.Center
' HeaderGridRow.Cells.Add(HeaderCell)
' Gv.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 = Gv.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
'Gv.ExportToExcel("Estado analitico" & Now.ToShortDateString)
If Not IsNothing(DtDatos) Then
ImprimirReporte("Excel") 'Descarga reporte en Excel
Else
Alert("No se ha encontrado información para el reporte", TipoMensaje.MsgAdvertencia)
End If
'MasterReporteador.Visible = True
'DirectCast(Master.FindControl("UpdatePanel1"), UpdatePanel).Update()
End Sub
Private Sub ImprimirReporte(Optional Formato As String = "PDF")
'ubicacion del rdlc
Dim reportpath As String = "AC/Reportes/RepAnaliticoDeudaPublica.rdlc"
Dim fileName As String = "EdoAnaliticoDeudaPublica"
'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("pFechaIni", FechaDel))
params.Add(New ReportParameter("pFechaFin", FechaAl))
params.Add(New ReportParameter("pFirma1", String.Format("ING. Soraida Mesinas Reyes{0} Subdirector de Contabilidad", vbCrLf)))
params.Add(New ReportParameter("pFirma2", String.Format("ING. Soraida Mesinas Reyes{0} Director General", vbCrLf)))
ImprimirPDF(reportpath, DtDatos, params, fileName, Formato)
End Sub
End Class