274 lines
14 KiB
VB.net
274 lines
14 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports Extensiones
|
|
Imports System.Data
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class AC_RepPresupuestoEgresos
|
|
Inherits ClsPaginas
|
|
|
|
#Region " PROPIEDADES "
|
|
Private Property DtPresupuestoEgresos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtPresupuestoEgresos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtPresupuestoEgresos") = value
|
|
End Set
|
|
End Property
|
|
Private Property EjercicioAC As Integer
|
|
Get
|
|
Return ViewState("EjercicioAC").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("EjercicioAC") = 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
|
|
txtFechaF.Text = Now.ToShortDateString
|
|
CargaCombos()
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#Region " VALORES INICIALES "
|
|
Private Sub CargaCombos()
|
|
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()
|
|
|
|
DdlEjercicio.SelectedValueExist(UsuarioActual.Empresa.EjercicioActual.ToString)
|
|
|
|
DdlCapituloClasificaciones.DataSource = GlobalDTACClasificadorObjetoGasto(UsuarioActual.CveEmpresa).FiltraParametros("NivelClasificacion = 1", "Codigo")
|
|
DdlCapituloClasificaciones.DataBind()
|
|
|
|
DdlClasificaciones.DataSource = GlobalDTACClasificadorObjetoGasto(UsuarioActual.CveEmpresa).FiltraParametros("NivelClasificacion = 4", "Codigo")
|
|
DdlClasificaciones.DataBind()
|
|
|
|
DdlFuenteFinanciamiento.DataSource = GlobalDTAC_FuentesFinanciamiento.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
DdlFuenteFinanciamiento.DataBind()
|
|
|
|
DdlProgramaOperativo.DataSource = GlobalDTAC_ProgramaOperativo(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("Ejercicio = {0}", DdlEjercicio.SelectedValue))
|
|
DdlProgramaOperativo.DataBind()
|
|
|
|
DdlUnidadAdministrativa.DataSource = GlobalDTAC_UnidadesAdministrativas(UsuarioActual.CveEmpresa)
|
|
DdlUnidadAdministrativa.DataBind()
|
|
|
|
DdlTipoGasto.DataSource = GlobalDTAC_TipoGasto '.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
DdlTipoGasto.DataBind()
|
|
|
|
DdlEjercicio_SelectedIndexChanged(DdlEjercicio, EventArgs.Empty)
|
|
End Sub
|
|
Protected Sub DdlEjercicio_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
DdlProgramaOperativo.Items.Clear()
|
|
|
|
DdlProgramaOperativo.DataSource = GlobalDTAC_ProgramaOperativo(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("Ejercicio = {0}", DdlEjercicio.SelectedValue))
|
|
DdlProgramaOperativo.DataBind()
|
|
|
|
DdlProgramaOperativo.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
LimitaFechaCorte()
|
|
|
|
UPFiltros.Update()
|
|
End Sub
|
|
Private Sub LimitaFechaCorte()
|
|
If DdlEjercicio.SelectedValue.ToEntero = Year(Now) Then
|
|
Calendario2.EndDate = Now
|
|
RVFechaFinal.MaximumValue = Now.ToShortDateString
|
|
txtFechaF.Text = Now.ToShortDateString
|
|
Else
|
|
Calendario2.EndDate = String.Format("31/12/{0}", DdlEjercicio.SelectedValue.ToEntero).ToDate
|
|
RVFechaFinal.MaximumValue = String.Format("31/12/{0}", DdlEjercicio.SelectedValue.ToEntero)
|
|
txtFechaF.Text = String.Format("31/12/{0}", DdlEjercicio.SelectedValue.ToEntero)
|
|
End If
|
|
End Sub
|
|
Protected Sub DdlCapituloClasificaciones_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
DdlClasificaciones.Items.Clear()
|
|
|
|
If DdlCapituloClasificaciones.SelectedValue.ToEntero > 1 Then
|
|
DdlClasificaciones.DataSource = GlobalDTACClasificadorObjetoGasto(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("NivelClasificacion = 4 AND CodigoClasificacion LIKE '{0}%'", DdlCapituloClasificaciones.SelectedItem.Text.Substring(0, 1)), "Codigo")
|
|
Else
|
|
DdlClasificaciones.DataSource = GlobalDTACClasificadorObjetoGasto(UsuarioActual.CveEmpresa).FiltraParametros("NivelClasificacion = 4", "Codigo")
|
|
End If
|
|
|
|
DdlClasificaciones.Items.Insert(0, New ListItem("Todas", "-1"))
|
|
DdlClasificaciones.DataBind()
|
|
UPFiltros.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " CARGA DATOS "
|
|
Protected Sub consultar_Click(sender As Object, e As EventArgs)
|
|
CargaDatos()
|
|
End Sub
|
|
Private Sub CargaDatos()
|
|
Dim objAC As New ClsContPAQi(UsuarioActual.Empresa)
|
|
Dim FechaF As Date = txtFechaF.Text.ToDate
|
|
Dim Capitulo As String = If(DdlCapituloClasificaciones.SelectedValue.ToEntero = -1, "-1", GlobalDTACClasificadorObjetoGasto.FiltraParametros(String.Format("CveClasificacion = {0}", DdlCapituloClasificaciones.SelectedValue.ToEntero)).Rows(0)("Codigo").ToString.Substring(0, 1))
|
|
|
|
If objAC.GetRepPresupuestosEgresosSaldos(DdlEjercicio.SelectedValue.ToEntero, FechaF, Capitulo, DdlClasificaciones.SelectedValue.ToEntero, DdlFuenteFinanciamiento.SelectedValue.ToEntero, DdlProgramaOperativo.SelectedValue.ToEntero, DdlUnidadAdministrativa.SelectedValue.ToEntero, DdlTipoGasto.SelectedValue.ToEntero, DdlOrden.SelectedValue.ToEntero) Then
|
|
DtPresupuestoEgresos = objAC.DtResultados
|
|
|
|
If Not (DdlOrden.SelectedValue.ToEntero = 1 OrElse DdlOrden.SelectedValue.ToEntero = 6 OrElse DdlOrden.SelectedValue.ToEntero = 8) Then
|
|
DtPresupuestoEgresos.Rows.RemoveAt(0)
|
|
DtPresupuestoEgresos.Rows.RemoveAt(0)
|
|
DtPresupuestoEgresos.Rows.RemoveAt(0)
|
|
End If
|
|
|
|
Gv.DataSource = DtPresupuestoEgresos
|
|
Else
|
|
Gv.DataSource = Nothing
|
|
DtPresupuestoEgresos = Nothing
|
|
End If
|
|
|
|
objAC.Dispose()
|
|
|
|
'Carga Grid
|
|
Gv.DataBind()
|
|
UPPDatos.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaDatosANT()
|
|
Dim AC As New ClsContPAQi(UsuarioActual.Empresa)
|
|
Dim Ejercicio As Integer = DdlEjercicio.SelectedValue.ToEntero
|
|
UPPDatos.Update()
|
|
Gv.DataBind()
|
|
|
|
If AC.RepPresupuestoEgresosGet(Ejercicio) Then
|
|
Gv.DataSource = AC.DtResultados
|
|
Gv.DataBind()
|
|
End If
|
|
|
|
AC.Dispose()
|
|
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.DBCampo("CodigoClasificacion") = "8" Then
|
|
'CLASIFICACION FUNCIONAL
|
|
Select Case e.Row.DBCampo("Nivel")
|
|
Case "5" : e.Row.Font.Bold = True
|
|
|
|
End Select
|
|
Else
|
|
If e.Row.DBCampo("Nivel") = "5" Then
|
|
e.Row.CssClass = "Totales"
|
|
ElseIf e.Row.DBCampo("Nivel") = "4" Then
|
|
e.Row.FCLiteral("LtlGrupo").Text = e.Row.DBCampo("Clasificacion1")
|
|
e.Row.CssClass = "SubTotales2"
|
|
ElseIf e.Row.DBCampo("Nivel") = "3" Then
|
|
e.Row.FCLiteral("LtlGrupo").Text = e.Row.DBCampo("Clasificacion2")
|
|
e.Row.CssClass = "SubTotales3"
|
|
ElseIf e.Row.DBCampo("Nivel") = "2" Then
|
|
e.Row.FCLiteral("LtlGrupo").Text = e.Row.DBCampo("Clasificacion3")
|
|
e.Row.Font.Bold = True
|
|
End If
|
|
|
|
End If
|
|
|
|
If e.Row.DBCampo("Comprometido").ToDecimal > e.Row.DBCampo("Vigente").ToDecimal Then e.Row.FCHyperLink("HLComprometido").ForeColor = Drawing.Color.Red
|
|
If e.Row.DBCampo("Devengado").ToDecimal > e.Row.DBCampo("Comprometido").ToDecimal Then e.Row.FCHyperLink("HLDevengado").ForeColor = Drawing.Color.Red
|
|
If e.Row.DBCampo("Ejercido").ToDecimal > e.Row.DBCampo("Devengado").ToDecimal Then e.Row.FCHyperLink("HLEjercido").ForeColor = Drawing.Color.Red
|
|
If e.Row.DBCampo("Pagado").ToDecimal > e.Row.DBCampo("Ejercido").ToDecimal Then e.Row.FCHyperLink("HLPagado").ForeColor = Drawing.Color.Red
|
|
|
|
e.Row.FCHyperLink("HLComprometido").NavigateUrl = String.Format("/AC/RepPresupuestoEgresosDetalle.aspx?MM=1&PO={0}&FF={1}&TG={2}&UA={3}&C={4}&COG={5}&FeI={6}&FeF={7}&Ej={8}", e.Row.DBCampo("CveProgramaOperativo").ToEntero, e.Row.DBCampo("CveFuenteFinanciamiento").ToEntero, e.Row.DBCampo("CveTipoGasto").ToEntero, e.Row.DBCampo("CveUnidadAdministrativa").ToEntero, e.Row.DBCampo("CveClasificacion").ToEntero, e.Row.DBCampo("CodigoOG").ToEntero, String.Format("01/01/{0}", DdlEjercicio.SelectedItem.Text), If(txtFechaF.Text <> "", txtFechaF.Text, Date.Now.ToString("dd/MM/yyyy")), DdlEjercicio.SelectedValue)
|
|
e.Row.FCHyperLink("HLComprometido").CssClass = "Texto"
|
|
e.Row.FCHyperLink("HLDevengado").NavigateUrl = String.Format("/AC/RepPresupuestoEgresosDetalle.aspx?MM=2&PO={0}&FF={1}&TG={2}&UA={3}&C={4}&COG={5}&FeI={6}&FeF={7}&Ej={8}", e.Row.DBCampo("CveProgramaOperativo").ToEntero, e.Row.DBCampo("CveFuenteFinanciamiento").ToEntero, e.Row.DBCampo("CveTipoGasto").ToEntero, e.Row.DBCampo("CveUnidadAdministrativa").ToEntero, e.Row.DBCampo("CveClasificacion").ToEntero, e.Row.DBCampo("CodigoOG").ToEntero, String.Format("01/01/{0}", DdlEjercicio.SelectedItem.Text), If(txtFechaF.Text <> "", txtFechaF.Text, Date.Now.ToString("dd/MM/yyyy")), DdlEjercicio.SelectedValue)
|
|
e.Row.FCHyperLink("HLDevengado").CssClass = "Texto"
|
|
e.Row.FCHyperLink("HLEjercido").NavigateUrl = String.Format("/AC/RepPresupuestoEgresosDetalle.aspx?MM=3&PO={0}&FF={1}&TG={2}&UA={3}&C={4}&COG={5}&FeI={6}&FeF={7}&Ej={8}", e.Row.DBCampo("CveProgramaOperativo").ToEntero, e.Row.DBCampo("CveFuenteFinanciamiento").ToEntero, e.Row.DBCampo("CveTipoGasto").ToEntero, e.Row.DBCampo("CveUnidadAdministrativa").ToEntero, e.Row.DBCampo("CveClasificacion").ToEntero, e.Row.DBCampo("CodigoOG").ToEntero, String.Format("01/01/{0}", DdlEjercicio.SelectedItem.Text), If(txtFechaF.Text <> "", txtFechaF.Text, Date.Now.ToString("dd/MM/yyyy")), DdlEjercicio.SelectedValue)
|
|
e.Row.FCHyperLink("HLEjercido").CssClass = "Texto"
|
|
e.Row.FCHyperLink("HLPagado").NavigateUrl = String.Format("/AC/RepPresupuestoEgresosDetalle.aspx?MM=4&PO={0}&FF={1}&TG={2}&UA={3}&C={4}&COG={5}&FeI={6}&FeF={7}&Ej={8}", e.Row.DBCampo("CveProgramaOperativo").ToEntero, e.Row.DBCampo("CveFuenteFinanciamiento").ToEntero, e.Row.DBCampo("CveTipoGasto").ToEntero, e.Row.DBCampo("CveUnidadAdministrativa").ToEntero, e.Row.DBCampo("CveClasificacion").ToEntero, e.Row.DBCampo("CodigoOG").ToEntero, String.Format("01/01/{0}", DdlEjercicio.SelectedItem.Text), If(txtFechaF.Text <> "", txtFechaF.Text, Date.Now.ToString("dd/MM/yyyy")), DdlEjercicio.SelectedValue)
|
|
e.Row.FCHyperLink("HLPagado").CssClass = "Texto"
|
|
'End If
|
|
'End If
|
|
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
|
|
#Region " EXPORTAR - PDF - EXCEL "
|
|
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs)
|
|
'Tbl.ExportToExcel("Estado del Ejercicio del Presupuesto de Egresos ")
|
|
ImprimiReporte("Excel")
|
|
End Sub
|
|
|
|
Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs)
|
|
'Tbl.ExportToPDF("Estado del Ejercicio del Presupuesto de Egresos ")
|
|
ImprimiReporte()
|
|
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
|
|
#End Region
|
|
|
|
#Region "I M P R I M I R "
|
|
Protected Sub ImprimiReporte(Optional Formato As String = "PDF")
|
|
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
|
|
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("pImg", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
|
|
params.Add(New ReportParameter("pEjercicio", DdlEjercicio.SelectedValue.ToString))
|
|
params.Add(New ReportParameter("pFechaCorte", txtFechaF.Text))
|
|
|
|
ImprimirPDF("AC/Reportes/RepPresupuestoEgresos.rdlc", DtPresupuestoEgresos, params, "ReportePresupuestoEgresos", Formato)
|
|
|
|
'Dim rds As New ReportDataSource
|
|
'rds.Name = "DataSet1"
|
|
'rds.Value = DtPresupuestoEgresos
|
|
'Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
|
|
|
|
'MasterReporteador.LocalReport.DataSources.Clear()
|
|
'MasterReporteador.LocalReport.DataSources.Add(rds)
|
|
'MasterReporteador.LocalReport.ReportPath = "AC/Reportes/RepPresupuestoEgresos.rdlc"
|
|
'MasterReporteador.ProcessingMode = ProcessingMode.Local
|
|
'MasterReporteador.LocalReport.EnableExternalImages = True
|
|
|
|
'Dim params As New List(Of ReportParameter)
|
|
'params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa))
|
|
'params.Add(New ReportParameter("pImg", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
|
|
|
|
'MasterReporteador.LocalReport.SetParameters(params)
|
|
'MasterReporteador.LocalReport.Refresh()
|
|
|
|
'Dim warnings As Warning() = Nothing
|
|
'Dim streamids As String() = Nothing
|
|
'Dim mimeType As String = Nothing
|
|
'Dim encoding As String = Nothing
|
|
'Dim extension As String = Nothing
|
|
'Dim fileName As String = "ReportePresupuestoEgresos"
|
|
'Dim bytes As Byte()
|
|
'Try
|
|
' bytes = MasterReporteador.LocalReport.Render("PDF", Nothing, mimeType, encoding, extension, streamids, warnings)
|
|
|
|
' Response.Buffer = True
|
|
' Response.Clear()
|
|
' Response.ContentType = mimeType
|
|
' Response.AddHeader("content-disposition", String.Format("attachment; filename={0}.{1}", fileName, extension))
|
|
' Response.BinaryWrite(bytes) ' create the file
|
|
' Response.Flush() ' send it to the client to download
|
|
' Response.End()
|
|
'Catch ex As Exception
|
|
|
|
'End Try
|
|
End Sub
|
|
#End Region
|
|
|
|
End Class
|