diff --git a/Acumuladores/CatFoliosGarantia.aspx b/Acumuladores/CatFoliosGarantia.aspx index 4f7dc67ac..fde6379a1 100644 --- a/Acumuladores/CatFoliosGarantia.aspx +++ b/Acumuladores/CatFoliosGarantia.aspx @@ -247,35 +247,35 @@ -
+ <%--
--%> -
- SubProyecto: - +
+ SubProyecto:
+
-
+ <%--
--%>
-   +
-   - + Tipo Folio:
+ General Optima Motobateria
-
+ <%--
--%>
@@ -283,8 +283,8 @@
-   - + Área:
+ Piso Almacén diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index ee571bfd0..ff7e79fa5 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -341,7 +341,7 @@ Public Class ClsVentas Optional CveFormaPago33 As Integer = -1, Optional CveMetodoPago33 As Integer = -1, Optional CveUsoCFDI As Integer = -1, Optional OrdenCompra As String = "-1", Optional CveCuentaTerminal As Integer = -1, Optional CveTipoRelacion As Integer = -1, Optional ImpuestoLocal As Double = 0, Optional CveTipoAmortizacionAnticipo As Integer = -1, Optional CveVentaRelacion As Integer = -1, Optional ImporteRelacion As Decimal = -1, Optional CveEmpresaCRM As Integer = -1, Optional EsInterno As Integer = -1, Optional CveAcercamientoCRM As Integer = -1, Optional DiasCredito As Integer = 0, Optional EsDiasCreditoFijo As Boolean = False, Optional AnticipoEspecial As Boolean = False, Optional Kilometraje As Double = 0, Optional EsAmortizacion As Boolean = False, Optional CveTipoRetencion As Integer = 0, - Optional CorreoNotificacion As String = "", Optional FormaPaqueteria As Integer = 1, Optional FacturarSucursal As Boolean = False) As Boolean + Optional CorreoNotificacion As String = "", Optional FormaPaqueteria As Integer = 1, Optional FacturarSucursal As Boolean = False, Optional VentaDesglosaIEPS As Boolean = False) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_VentasAdd") @@ -433,6 +433,7 @@ Public Class ClsVentas .Add("@CorreoNotificacion", SqlDbType.VarChar).Value = CorreoNotificacion .Add("@FormaPaqueteria", SqlDbType.Int).Value = FormaPaqueteria .Add("@FacturarSucursal", SqlDbType.Bit).Value = FacturarSucursal + .Add("@VentaDesglosaIEPS", SqlDbType.Bit).Value = VentaDesglosaIEPS .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue End With diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 4ca5dafc2..6df233d4e 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -6094,6 +6094,8 @@ Namespace Modelos Public Property CveTipoRetencion As Integer + Public Property VentaDesglosaIEPS As Boolean + #End Region diff --git a/Bancos/FluctuacionCambiaria.aspx b/Bancos/FluctuacionCambiaria.aspx index c74d540a3..3ecd068fa 100644 --- a/Bancos/FluctuacionCambiaria.aspx +++ b/Bancos/FluctuacionCambiaria.aspx @@ -149,13 +149,7 @@
-
- -
-
- - -
+
@@ -230,10 +224,37 @@ -
- -
-
+
+ + +
+ + +
+ + + + +
+ +
+ + + + + +
+ +
+ +
+ +
+ + + +
-
- + + +
+
+ +
+ + + + +
+ +
+ + + + + +
+ + + +
+ +
+
-
-
+ +
+ + + @@ -333,10 +382,37 @@ -
- + +
+
+ + +
+ + + + +
+ +
+ + + + + +
+ + + +
+ +
+
-
+ + +
-
- -
-
-
+ + + + + +
+
+ +
+ + + + +
+ +
+ + + + + +
+ + +
+ +
+
+ +
+ +
+ + -
- -
-
-
+
+
+ +
+ + + + +
+ +
+ + + + + +
+ + + +
+ +
+
+
+ + + +
+
+ +
+ + + + +
+ +
+ + + + + +
+ + +
+ +
+
+ +
+ +
- +
-
-
+ + + + + +   + + +
diff --git a/Bancos/PopIEVentas.aspx.vb b/Bancos/PopIEVentas.aspx.vb index 3d83cb0b4..ef4f28551 100644 --- a/Bancos/PopIEVentas.aspx.vb +++ b/Bancos/PopIEVentas.aspx.vb @@ -736,11 +736,16 @@ Partial Class Bancos_PopIEVentas SerieFolio = dr("SerieFolio").ToString TipoCambioOriginal = dr("TipoCambio").ToString.ToDecimal CveSubProyectoVenta = dr("CveSubProyecto").ToString.ToEntero - 'Configuración de Modalidad Update - - 'Dim RFCCliente As String = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimeroValor("RFC", $"CveCliente = {CveCliente} ") - + LblMetodoPAgo.Text = $"{dr("ClaveMetodoPagoSATStr").ToString() }" + + + + 'Configuración de Modalidad Update + + 'Dim RFCCliente As String = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltroPrimeroValor("RFC", $"CveCliente = {CveCliente} ") + + If Not UsuarioActual.Empresa.Funcionalidad(536) = "1" Then If dr("TipoDocto").ToString = "Rem" Then Alert("Los documentos de tipo Remisión no se permite realizar el pago", TipoMensaje.MsgAdvertencia) diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 0cbaee78a..d7ef591ea 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -29,6 +29,24 @@ Partial Class Compras_Compras End Set End Property + Private Property EstaAsociadoACajaChica() As Boolean + Get + Return If(IsNothing(ViewState("EstaAsociadoACajaChica")), False, CBool(ViewState("EstaAsociadoACajaChica"))) + End Get + Set + ViewState("EstaAsociadoACajaChica") = Value + End Set + End Property + + Private Property EstaAsociadoAPersonal() As Boolean + Get + Return If(IsNothing(ViewState("EstaAsociadoAPersonal")), False, CBool(ViewState("EstaAsociadoAPersonal"))) + End Get + Set + ViewState("EstaAsociadoAPersonal") = Value + End Set + End Property + Private Property CveUsuarioEvaluador() As Integer Get Return If(IsNothing(ViewState("CveUsuarioEvaluador")), -1, CInt(ViewState("CveUsuarioEvaluador"))) @@ -848,6 +866,14 @@ Partial Class Compras_Compras ViewState("PopUpOC") = value End Set End Property + Private Property CompraEstaVinculadaOC As Boolean + Get + Return CBool(ViewState("CompraEstaVinculadaOC")) + End Get + Set(value As Boolean) + ViewState("CompraEstaVinculadaOC") = value + End Set + End Property #End Region #Region "PROPIEDADES ALMACEN" 'Charlie @@ -1307,6 +1333,9 @@ Partial Class Compras_Compras ViewState("CveFactura") = Request("CveFactura").ToEntero Dim RFC As String = CargaFactura(CveFactura) + If Not VerificarProductosSATPS() Then + Exit Sub + End If If RFC.Trim <> String.Empty Then DdlProveedor.Visible = False HplProveedor.Visible = True @@ -1734,6 +1763,7 @@ Partial Class Compras_Compras 'TmpDT.Columns.Add("IEPSPSIVAPorcentaje") SubTotalConceptos = Math.Round(TmpDT.SUM("Total"), 2).ToDecimal AddPS2(False) + End If Else CargaConceptosXML(XMLDoc) @@ -3971,6 +4001,17 @@ Partial Class Compras_Compras DtNoEncontrados.Dispose() End If + 'Verifica funcionalidad 702 "Require orden de compra para factura de compra" + + If UsuarioActual.Empresa.Funcionalidad(702) = "1" Then + If Not EstaAsociadoACajaChica And Not EstaAsociadoAPersonal Then + If Not CompraEstaVinculadaOC Then + Alert("Debe de vincular una orden de compra para realizar esta factura") + Exit Sub + End If + End If + End If + 'Si se marcó No Deducible en el encabezado mínimo se debe registrar un No Deducible en el Detalle Dim GuardaNoDeducibles As Boolean = False If ChkEsNoDeducible.Checked Then @@ -12712,6 +12753,7 @@ Partial Class Compras_Compras CveMoneda = dr("CveMoneda").ToString.ToEntero IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero + EstaAsociadoACajaChica = True End If If UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then @@ -12740,7 +12782,7 @@ Partial Class Compras_Compras ObjMovtos.Dispose() DDlCheques.DataBind() - + EstaAsociadoAPersonal = True DDlCheques_SelectedIndexChanged(DDlCheques, EventArgs.Empty) Else @@ -13751,6 +13793,9 @@ Partial Class Compras_Compras #Region " REEMBOLSOS NO USA AC " Protected Sub DdlPersonal2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPersonalReembolso.SelectedIndexChanged ViewState("CvePersonal") = DdlPersonalReembolso.SelectedValue + If DdlPersonalReembolso.SelectedValue.ToEntero > 0 Then + EstaAsociadoAPersonal = True + End If End Sub Protected Sub DdlCajaChica2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuentaCajaChicaReembolso.SelectedIndexChanged Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveCuenta = " & DdlCuentaCajaChicaReembolso.SelectedValue) @@ -13759,6 +13804,7 @@ Partial Class Compras_Compras CveMoneda = dr("CveMoneda").ToString.ToEntero IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero CveCuentaBancaria = dr("IdCtaContableSIG").ToString.ToEntero + EstaAsociadoACajaChica = True End If ViewState("CveCajaChica") = DdlCuentaCajaChicaReembolso.SelectedValue End Sub @@ -15051,13 +15097,11 @@ Partial Class Compras_Compras End If 'SI PUEDE RECIBIR POR OC Y COMPRA - If UsuarioActual.CveEmpresa.Contiene(119) Then - If UsuarioActual.Empresa.UsaInventarios And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 And Not UsuarioActual.Empresa.Funcionalidad(153).ToEntero > 0 Then - DivOCVinculaInv.Visible = True - End If + ' si usa almacen, si tiene activado que reciba por OC, y que si la compra tipo Proveedor. que lo muestre + If UsuarioActual.Empresa.UsaInventarios And UsuarioActual.Empresa.Funcionalidad(131).ToEntero > 0 AndAlso CveTipoConcepto = 1 Then + DivOCVinculaInv.Visible = True End If - 'TIPO CAMBIO If CveCompra > 0 Then DivTipoCambioOC.Visible = False @@ -15383,27 +15427,27 @@ Partial Class Compras_Compras Dim SubTotalCompra As Decimal = Amortizacion Dim DiferenciaPermitida = 1 Dim Cont = 0 - Dim ProductosCodigoSATNoPermitidos As New StringBuilder("") - For Each gvr As GridViewRow In GvOC1.Rows - SubTotalGV += gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal - If Cont = 0 Then DdlProveedorSucursal.SelectedValueExist(gvr.DataKey("CveProveedorSucursal").ToEntero()) - Cont = 1 - If GvOC1.Columns(6).Visible Then - Dim SatPS As String = gvr.FCDropDownLost("DdlSATPS").SelectedText() - Dim NombreProducto As String = gvr.FCLabel("LbProductoServicio").Text - If SatPS.Contains("01010101") Then - ProductosCodigoSATNoPermitidos.AppendFormat("{0}
", NombreProducto) - 'Dim mensajeAdvertencia As String = String.Format("Al vincular una Orden de Compra no se permiten productos con Producto/Servicio SAT igual a '{0}', revise el producto '{1}' en Orden(es) de Compra Vinculada(s)", SatPS, NombreProducto) - 'Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia) + 'Dim ProductosCodigoSATNoPermitidos As New StringBuilder("") + 'For Each gvr As GridViewRow In GvOC1.Rows + ' SubTotalGV += gvr.FCTextBox("TxtTotalOC1").Text.ToDecimal + ' If Cont = 0 Then DdlProveedorSucursal.SelectedValueExist(gvr.DataKey("CveProveedorSucursal").ToEntero()) + ' Cont = 1 + ' If GvOC1.Columns(6).Visible Then + ' Dim SatPS As String = gvr.FCDropDownLost("DdlSATPS").SelectedText() + ' Dim NombreProducto As String = gvr.FCLabel("LbProductoServicio").Text + ' If SatPS.Contains("01010101") Then + ' ProductosCodigoSATNoPermitidos.AppendFormat("{0}
", NombreProducto) + ' 'Dim mensajeAdvertencia As String = String.Format("Al vincular una Orden de Compra no se permiten productos con Producto/Servicio SAT igual a '{0}', revise el producto '{1}' en Orden(es) de Compra Vinculada(s)", SatPS, NombreProducto) + ' 'Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia) - End If - End If - Next - If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then - Dim mensajeAdvertencia As String = String.Format("No se permite vinculación de productos con código SAT '01010101', revise los productos:

{0}", ProductosCodigoSATNoPermitidos.ToString) - Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia) - Exit Sub - End If + ' End If + ' End If + 'Next + 'If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then + ' Dim mensajeAdvertencia As String = String.Format("No se permite vinculación de productos con código SAT '01010101', revise los productos:

{0}", ProductosCodigoSATNoPermitidos.ToString) + ' Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia) + ' Exit Sub + 'End If If Math.Abs(SubTotalGV - SubTotalCompra) < DiferenciaPermitida Then LbSubTotalDif.Visible = False @@ -15641,6 +15685,7 @@ Partial Class Compras_Compras End If CalculaTotales() + CompraEstaVinculadaOC = True End Sub @@ -20158,7 +20203,35 @@ Partial Class Compras_Compras End Sub + Private Function VerificarProductosSATPS() As Boolean + Dim CvePSGRuposAux As New StringBuilder("") + For Each gvr As GridViewRow In GvPS.Rows + Dim CvePSIndividual As String = gvr.DataKey("CvePS") + CvePSGRuposAux.AppendFormat("{0},", CvePSIndividual) + Next + Dim CvePSGRupos As String = Left(CvePSGRuposAux.ToString, CvePSGRuposAux.Length - 1) + + Dim PSSat As DataTable = GlobalDTPS(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CvePS IN ({0})", CvePSGRuposAux)) + + Dim ProductosCodigoSATNoPermitidos As New StringBuilder("") + For Each PS As GridViewRow In GvPS.Rows + Dim PSIndividual As String = PS.DataKey("PS") + Dim ClavePSSAT As String = PSSat.FiltroPrimeroValor("CveSATPS", String.Format("PS = '{0}'", PSIndividual)) + If ClavePSSAT = "46920" Then + ProductosCodigoSATNoPermitidos.AppendFormat("{0}
", PSIndividual) + End If + Next + + If ProductosCodigoSATNoPermitidos.ToString.Length > 0 Then + Dim mensajeAdvertencia As String = String.Format("No se permite vinculación de productos con código SAT '01010101', revise los productos:

{0}", ProductosCodigoSATNoPermitidos.ToString) + Alert(mensajeAdvertencia, TipoMensaje.MsgAdvertencia) + Return False + End If + + Return True + + End Function End Class diff --git a/Compras/PopUpVerFactura.aspx.vb b/Compras/PopUpVerFactura.aspx.vb index 482e6026a..49ae7b3d6 100644 --- a/Compras/PopUpVerFactura.aspx.vb +++ b/Compras/PopUpVerFactura.aspx.vb @@ -1238,6 +1238,7 @@ Partial Class PopUpVerFactura Dim Observaciones As String = ObjInventarios.Observaciones Dim ObservacionesSolicitud As String = ObjInventarios.DtResultados.FiltroPrimeroValor("ObservacionesSolicitud") Dim NombreCapturo As String = ObjInventarios.NombreCapturo + Dim NombreEntrego As String = ObjInventarios.DtResultados.FiltroPrimeroValor("Entrego") Dim CveAlmacen As Integer = ObjInventarios.CveAlmacen Dim Recibio As String = ObjInventarios.Recibio Dim PuestoRecibio As String = ObjInventarios.PuestoRecibio @@ -1341,7 +1342,7 @@ Partial Class PopUpVerFactura EstadoOrigen, PaisOrigen, CPOrigen, CalleDestino, NoExtDestino, ColoniaDestino, LocalidadDestino, MunicipioDestino, EstadoDestino, PaisDestino, CPDestino, FechaMovimiento, NombreCapturo, PuestoRecibio, PuestoEnrego, RazonSocial, ResponsableCarga, ResponsableRecibio, NombreCliente, - CantidadProductos:=CantidadProductos, CantidadUsados:=CantidadUsados, CveTipoAlmacen:=CveTipoAlmacen) + CantidadProductos:=CantidadProductos, CantidadUsados:=CantidadUsados, CveTipoAlmacen:=CveTipoAlmacen, NombreEntrego:=NombreEntrego) End Sub Private Sub PUanacExtr(CveMoneda As Integer) 'preciounitario a moneda nacional o extranjera @@ -1358,7 +1359,7 @@ Partial Class PopUpVerFactura Remision As String, Proveedor As String, CalleOrigen As String, NoExtOrigen As String, ColoniaOrigen As String, LocalidadOrigen As String, MunicipioOrigen As String, EstadoOrigen As String, PaisOrigen As String, CPOrigen As String, CalleDestino As String, NoExtDestino As String, ColoniaDestino As String, LocalidadDestino As String, MunicipioDestino As String, EstadoDestino As String, PaisDestino As String, CPDestino As String, FechaMovimiento As Date, NombreCapturo As String, PuestoRecibio As String, PuestoEntrego As String, - RazonSocial As String, ResponsableCarga As String, ResponsableRecibio As String, NombreCliente As String, Optional CantidadProductos As Decimal = 0, Optional CantidadUsados As Decimal = 0, Optional CveTipoAlmacen As Integer = -1) + RazonSocial As String, ResponsableCarga As String, ResponsableRecibio As String, NombreCliente As String, Optional CantidadProductos As Decimal = 0, Optional CantidadUsados As Decimal = 0, Optional CveTipoAlmacen As Integer = -1, Optional NombreEntrego As String = "") Select Case CveConcepto @@ -2704,7 +2705,7 @@ Partial Class PopUpVerFactura End If Dim DepartamentoRecibe As String = GlobalDTRHPersonal(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Departamento", String.Format("NombreCompleto = '{0}'", Recibio)) - Dim DepartamentoEntrego As String = GlobalDTRHPersonal(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Departamento", String.Format("NombreCompleto = '{0}'", Capturo)) + Dim DepartamentoEntrego As String = GlobalDTRHPersonal(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Departamento", String.Format("NombreCompleto = '{0}'", NombreEntrego)) params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa)) params.Add(New ReportParameter("Concepto", "Salida por resguardo")) @@ -2715,7 +2716,7 @@ Partial Class PopUpVerFactura params.Add(New ReportParameter("Descuentos", "")) params.Add(New ReportParameter("IVA", "")) params.Add(New ReportParameter("Total", "")) - params.Add(New ReportParameter("NombreEntrego", String.Format("ENTREGÓ{0}{1}", vbCrLf, Capturo))) + params.Add(New ReportParameter("NombreEntrego", NombreEntrego)) params.Add(New ReportParameter("NombreRecibio", Recibio)) params.Add(New ReportParameter("PuestoRecibio", PuestoEntrego)) params.Add(New ReportParameter("PuestoEntrego", PuestoRecibio)) @@ -2727,7 +2728,7 @@ Partial Class PopUpVerFactura End If params.Add(New ReportParameter("FechaMovimiento", FechaMovimiento.ToString("dd/MM/yyyy"))) - params.Add(New ReportParameter("UsuarioImprimio", NombreCapturo)) + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) params.Add(New ReportParameter("Observaciones", Observaciones)) diff --git a/Compras/ReembolsosComprobaciones.aspx b/Compras/ReembolsosComprobaciones.aspx index 3f432ff33..760c32799 100644 --- a/Compras/ReembolsosComprobaciones.aspx +++ b/Compras/ReembolsosComprobaciones.aspx @@ -291,7 +291,8 @@ - + diff --git a/Compras/ReembolsosComprobaciones.aspx.vb b/Compras/ReembolsosComprobaciones.aspx.vb index 7b60c10d5..36b4176d3 100644 --- a/Compras/ReembolsosComprobaciones.aspx.vb +++ b/Compras/ReembolsosComprobaciones.aspx.vb @@ -1036,7 +1036,7 @@ Partial Class Compras_ReembolsosComprobaciones 'Otros Ingresos If ChkAjusteOI.Checked Then - If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaExcedente, True, gvr.FCTextBox("TxtComision").Text.ToDecimal, Referencia, 78, ConceptoMovimiento, gvr.FCLiteral("LtlFecha").Text.ToDate, IdCtaProveedor, -1, CveIE:=CveIERegistrado, CvePersonal:=CvePersonal, CveCompra:=gvr.FCHyperLink("HplF2").Text.ToEntero, CveProveedor:=gvr.FCHyperLink("HLProv").Text.ToEntero, ImporteME:=If(tipoCambio = 1, 0, gvr.FCTextBox("TxtComision").Text.ToDecimal), ImporteMX:=gvr.FCTextBox("TxtComision").Text.ToDecimal * tipoCambio, CveCuenta:=CveCuentaProveedor) Then + If Not ObjMov.AddPrePolizasDetalle(CvePrePolizaExcedente, True, gvr.FCTextBox("TxtComision").Text.ToDecimal, Referencia, 78, ConceptoMovimiento, gvr.FCLiteral("LtlFecha").Text.ToDate, IdCtaProveedor, -1, CveIE:=CveIERegistrado, CvePersonal:=CvePersonal, CveCompra:=gvr.FCHyperLink("HplF2").Text.ToEntero, CveSubProyecto:=gvr.DataKey("CveSubProyecto").ToEntero, CveProveedor:=gvr.FCHyperLink("HLProv").Text.ToEntero, ImporteME:=If(tipoCambio = 1, 0, gvr.FCTextBox("TxtComision").Text.ToDecimal), ImporteMX:=gvr.FCTextBox("TxtComision").Text.ToDecimal * tipoCambio, CveCuenta:=CveCuentaProveedor) Then MsgError = "no se pudo insertar el detalle de la poliza de otros ingresos" End If End If diff --git a/Contabilidad2/RepEstadoResultadosHorizontal - Copy.aspx b/Contabilidad2/RepEstadoResultadosHorizontal - Copy.aspx new file mode 100644 index 000000000..32123d23c --- /dev/null +++ b/Contabilidad2/RepEstadoResultadosHorizontal - Copy.aspx @@ -0,0 +1,1593 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepEstadoResultadosHorizontal - Copy.aspx.vb" Inherits="Contabilidad_RepEstadoResultadosHorizontal" %> + + + + + + + + + + + + + +
  • + Generar Excel +
  • +
  • + Graficar +
  • +
    + + + + +
    +
    +
    + +
    +
    +
    +
      + + +
      + + +
      + + +
      + + +
      + + +
      + + + + + + + + + + + + + + +
      + + + +
      + + +
      + + +
      + + + + + +
      + + +
      + + NO + Trimestre + Cuatrimestre + +
      + +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + <%-- --%> + + + + + + + + <%-- --%> + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + +
    +

    Resultados del Ejercicio:

    +
    + + + +
    +
    +
    + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%----%> + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%-- --%> + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + + + + +
    + + + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%-- --%> + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + <%-- --%> + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%----%> + + + + + + + <%----%> + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%-- --%> + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + +
    +
    +
    + + + + + + + +
    + + + + + + + + + + + diff --git a/Contabilidad2/RepEstadoResultadosHorizontal - Copy.aspx.vb b/Contabilidad2/RepEstadoResultadosHorizontal - Copy.aspx.vb new file mode 100644 index 000000000..bb9bbfec4 --- /dev/null +++ b/Contabilidad2/RepEstadoResultadosHorizontal - Copy.aspx.vb @@ -0,0 +1,2295 @@ +Option Explicit On +Option Strict On + +Imports System.Data +Imports System.Drawing +Imports System.IO +Imports Extensiones +Imports GemBox.Spreadsheet +Imports Microsoft.Reporting.WebForms + +Partial Class Contabilidad_RepEstadoResultadosHorizontal + Inherits ClsPaginas + +#Region "PROPIEDADES" + + + Private Property DtDatosMes As DataTable + Get + DtDatosMes = DirectCast(ViewState("DtDatosMes"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosMes") = value + End Set + End Property + + Private Property DtIngresosMes As DataTable + Get + DtIngresosMes = DirectCast(ViewState("DtIngresosMes"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosMes") = value + End Set + End Property + Private Property DtGastosMes As DataTable + Get + DtGastosMes = DirectCast(ViewState("DtGastosMes"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosMes") = value + End Set + End Property + Private Property TotalActualMes As Double + Get + TotalActualMes = ViewState("TotalActualMes").ToString.ToDouble + End Get + Set(value As Double) + ViewState("TotalActualMes") = value + End Set + End Property + Private Property TotalAnteriorMes As Double + Get + TotalAnteriorMes = ViewState("TotalAnteriorMes").ToString.ToDouble + End Get + Set(value As Double) + ViewState("TotalAnteriorMes") = value + End Set + End Property + Private Property FechaIMes As String + Get + Return ViewState("FechaIMes").ToString + End Get + Set(value As String) + ViewState("FechaIMes") = value + End Set + End Property + Private Property FechaFMes As String + Get + Return ViewState("FechaFMes").ToString + End Get + Set(value As String) + ViewState("FechaFMes") = value + End Set + End Property + + Private Property listacolores As List(Of String) + Get + Return DirectCast(ViewState("listacolores"), List(Of String)) + End Get + Set(value As List(Of String)) + ViewState("listacolores") = value + End Set + End Property + + Private Property listaCampos As List(Of String()) + Get + Return DirectCast(ViewState("listaCampos"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCampos") = value + End Set + End Property + Private Property listaCamposanios As List(Of String()) + Get + Return DirectCast(ViewState("listaCamposanios"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCamposanios") = value + End Set + End Property + Private Property listaCamposaniosGastos As List(Of String()) + Get + Return DirectCast(ViewState("listaCamposaniosGastos"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCamposaniosGastos") = value + End Set + End Property + Private Property listaCamposaniosTotal As List(Of String()) + Get + Return DirectCast(ViewState("listaCamposaniosTotal"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCamposaniosTotal") = value + End Set + End Property + + 'Private Property ReporteComplementario As Boolean + ' Get + ' ReporteComplementario = CBool(ViewState("ReporteComplementario").ToString) + ' End Get + ' Set(value As Boolean) + ' ViewState("ReporteComplementario") = value + ' End Set + 'End Property + +#End Region + + +#Region " M E S H O R I Z O N T A L " + + Private Property DtDatosMesH As DataTable + Get + DtDatosMesH = DirectCast(ViewState("DtDatosMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosMesH") = value + End Set + End Property + + Private Property DtIngresosMesH As DataTable + Get + DtIngresosMesH = DirectCast(ViewState("DtIngresosMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosMesH") = value + End Set + End Property + + Private Property DtGastosMesH As DataTable + Get + DtGastosMesH = DirectCast(ViewState("DtGastosMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosMesH") = value + End Set + End Property + + Private Property DTTotalesMesH As DataTable + Get + DTTotalesMesH = DirectCast(ViewState("DTTotalesMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTTotalesMesH") = value + End Set + End Property + +#End Region + + +#Region " A N U A L H O R I Z O N T A L " + + Private Property DtDatosAnualH As DataTable + Get + DtDatosAnualH = DirectCast(ViewState("DtDatosAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosAnualH") = value + End Set + End Property + + Private Property DtIngresosAnualH As DataTable + Get + DtIngresosAnualH = DirectCast(ViewState("DtIngresosAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosAnualH") = value + End Set + End Property + + Private Property DtGastosAnualH As DataTable + Get + DtGastosAnualH = DirectCast(ViewState("DtGastosAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosAnualH") = value + End Set + End Property + + Private Property DTTotalesAnualH As DataTable + Get + DTTotalesAnualH = DirectCast(ViewState("DTTotalesAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTTotalesAnualH") = value + End Set + End Property + + + Private Property CountDinamicoAnual As Integer + + Get + If ViewState("CountDinamicoAnual") Is Nothing Then + Return 0 + Else + Return ViewState("CountDinamicoAnual").ToString.ToEntero + End If + + End Get + Set(value As Integer) + ViewState("CountDinamicoAnual") = value + End Set + End Property + +#End Region + +#Region " S U B P R O Y E C T O H O R I Z O N T A L " + + Private Property DtDatosSubProyectoH As DataTable + Get + DtDatosSubProyectoH = DirectCast(ViewState("DtDatosSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosSubProyectoH") = value + End Set + End Property + + Private Property DtIngresosSubProyectoH As DataTable + Get + DtIngresosSubProyectoH = DirectCast(ViewState("DtIngresosSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosSubProyectoH") = value + End Set + End Property + + Private Property DtGastosSubProyectoH As DataTable + Get + DtGastosSubProyectoH = DirectCast(ViewState("DtGastosSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosSubProyectoH") = value + End Set + End Property + + Private Property DTTotalesSubProyectoH As DataTable + Get + DTTotalesSubProyectoH = DirectCast(ViewState("DTTotalesSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTTotalesSubProyectoH") = value + End Set + End Property + + Private Property DTSubProyectosCabecerasH As DataTable + + Get + DTSubProyectosCabecerasH = DirectCast(ViewState("DTSubProyectosCabecerasH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTSubProyectosCabecerasH") = value + End Set + + End Property + + + Private Property CountDinamicoSubProyecto As Integer + + Get + If ViewState("CountDinamicoSubProyecto") Is Nothing Then + Return 0 + Else + Return ViewState("CountDinamicoSubProyecto").ToString.ToEntero + End If + + End Get + Set(value As Integer) + ViewState("CountDinamicoSubProyecto") = 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 + listacolores = New List(Of String) + listaCampos = New List(Of String()) + listaCamposanios = New List(Of String()) + listaCamposaniosGastos = New List(Of String()) + listaCamposaniosTotal = New List(Of String()) + listacolores.Add("#FF0F00") + listacolores.Add("#FF6600") + listacolores.Add("#F8FF01") + listacolores.Add("#04D215") + listacolores.Add("#2A0CD0") + listacolores.Add("#8A0CCF") + listacolores.Add("#CD0D74") + listacolores.Add("#754DEB") + listacolores.Add("#DDDDDD") + listacolores.Add("#999999") + listacolores.Add("#000000") + listacolores.Add("#FF0F00") + + TotalActualMes = 0 + TotalAnteriorMes = 0 + + CargaEjercicios() + + CargarCentrosDeCosto(Nothing, DdlSubproyecto, Nothing, LblSubProyecto) + TabSubProyecto.HeaderText = LblSubProyecto.Text & " " + + + + DdlEjercicio.SelectedValueExist(UsuarioActual.Empresa.EjercicioActual) + ValidaEjercicios() + + End If + End Sub + + Protected Sub Tab_ActiveTabChanged(sender As Object, e As EventArgs) + + If TAB.ActiveTabIndex = 0 Then + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = False + LiEjercicioLbl2.Visible = False + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + LblTri.Visible = False + DVTri.Visible = False + End If + + If TAB.ActiveTabIndex = 1 Then + + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = False + LiEjercicioLbl2.Visible = False + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + DdlPeriodo.SelectedValueExist(12) + + LblTri.Visible = True + DVTri.Visible = True + + + End If + + If TAB.ActiveTabIndex = 2 Then + + ValidaEjercicios() + + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = True + LiEjercicioLbl2.Visible = True + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + LblTri.Visible = False + DVTri.Visible = False + + End If + + If TAB.ActiveTabIndex = 3 Then + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = False + LiEjercicioLbl2.Visible = False + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + LblTri.Visible = False + DVTri.Visible = False + + End If + + UpFiltros.Update() + End Sub + + + Protected Sub DdlEjercicio_SelectedIndexChanged(sender As Object, e As EventArgs) + ValidaEjercicios() + End Sub + + Protected Sub DdlEjercicio2_SelectedIndexChanged(sender As Object, e As EventArgs) + ValidaEjercicios() + End Sub + + Private Sub ValidaEjercicios() + + + Dim EInicio As Integer = DdlEjercicio.SelectedValue.ToEntero + + + If EInicio > DdlEjercicio2.SelectedValue.ToEntero Then + + If DdlEjercicio2.Items.Count > 0 Then + DdlEjercicio2.SelectedIndex = DdlEjercicio2.Items.Count - 1 + End If + + Dim Fejerciosio As Integer = DdlEjercicio2.SelectedValue.ToEntero + + If Not EInicio + 1 > Fejerciosio Then + DdlEjercicio2.SelectedValueExist(EInicio + 1) + End If + + End If + + + UpFiltros.Update() + End Sub + + Private Sub CargaEjercicios() + 'Dim ClsConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ClsConta As New ClsContabilidad + If ClsConta.GetEjercicios(UsuarioActual.CveEmpresa) Then + DdlEjercicio.DataSource = ClsConta.DtResultados + DdlEjercicio2.DataSource = ClsConta.DtResultados + Else + DdlEjercicio.DataSource = Nothing + DdlEjercicio2.DataSource = Nothing + End If + ClsConta.Dispose() + DdlEjercicio.DataBind() + DdlEjercicio2.DataBind() + + DdlEjercicio.SelectedValueExist(UsuarioActual.Empresa.EjercicioActual.ToString) + If DdlEjercicio.Items.Count = 0 Then + DdlEjercicio.Items.Add(New ListItem(Now.Year.ToString, Now.Year.ToString)) + End If + DdlPeriodo.SelectedValue = Now.Month.ToString + End Sub + + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) + TotalActualMes = 0 + TotalAnteriorMes = 0 + + 'Mes + If TAB.ActiveTabIndex = 0 Then + CargaDatosMes() + End If + + 'MES HORIZONTAL + If TAB.ActiveTabIndex = 1 Then + CargaDatosMesH() + End If + + 'AÑO HORIZONTAL + If TAB.ActiveTabIndex = 2 Then + + If DdlEjercicio.SelectedValue.ToEntero > DdlEjercicio2.SelectedValue.ToEntero Then + Alert("El ejercicio inicio no debe ser mayor al ejercicio fin.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + CargaDatosAnualH() + End If + + 'SUBPROYECTO + If TAB.ActiveTabIndex = 3 Then + CargaDatosSubProyectoH() + End If + + + + + End Sub + + +#Region "MES" + + + + + + Private Sub CargaDatosMes() + + + FechaIMes = String.Format("01/{0}/{1}", DdlPeriodo.SelectedValue.PadLeft(2, CChar("0")), DdlEjercicio.SelectedValue) + FechaFMes = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, CDate(FechaIMes))).ToString("dd/MM/yyyy") + 'Dim TipoReporte = DdlTipoReporte.SelectedValue.ToEntero 'If(ReporteComplementario, DdlTipoReporte.SelectedValue.ToEntero, 1) + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + 'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosMensual(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then + DtDatosMes = ObjConta.DtResultados.FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosMes = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosMes IsNot Nothing Then + CargaGridsMes() + SumaTotales() + End If + + End Sub + Private Sub CargaGridsMes() + DtIngresosMes = DtDatosMes.FiltraParametros("Tipo ='H' ") + DtGastosMes = DtDatosMes.FiltraParametros("Tipo ='G' ") + Dim Row As DataRow = DtIngresosMes.NewRow + + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + If DtIngresosMes.Rows.Count > 0 Then + + For Each dr As DataRow In DtIngresosMes.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + DtIngresosMes.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosMes.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosMes.NewRow + If DtGastosMes.Rows.Count > 0 Then + + For Each dr As DataRow In DtGastosMes.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = TotalActual + Row.Item("PorcentajeActual") = If(T1 > 0, (TotalActual * 100 / T1).ToString, "0").FormatoNumero + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = If(T2 > 0, (TotalAnterior * 100 / T2).ToString, "0").FormatoNumero + Row.Item("CtaMayor") = -1 + DtGastosMes.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosMes.Rows.Add(Row) + End If + + + GvIngresosMes.DataSource = DtIngresosMes + GvIngresosMes.DataBind() + + GvGastosMes.DataSource = DtGastosMes + GvGastosMes.DataBind() + + UpDatos.Update() + + End Sub + + + + Private Sub SumaTotales() + 'Llena Lb´s Totales + + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + LbTotalActual.Text = TotalActualMes.ToString("###,###,##0") + LbTotalAnterior.Text = TotalAnteriorMes.ToString("###,###,##0") + Else + LbTotalActual.Text = TotalActualMes.ToString("###,###,##0.00") + LbTotalAnterior.Text = TotalAnteriorMes.ToString("###,###,##0.00") + End If + + + + LbTotalActual.ForeColor = If(TotalActualMes < 0, Drawing.Color.Red, Color.Black) + + LbTotalAnterior.ForeColor = If(TotalAnteriorMes < 0, Drawing.Color.Red, Color.Black) + + + End Sub + +#Region "GV´S ROW DATA BOUND" + + Protected Sub GvIngresos_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales3" + e.Row.ControlStyle.Font.Bold = True + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + e.Row.FCHyperLink("HLActual").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToEntero.ToString("###,###,##0") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToEntero.ToString("###,###,##0").ToString + Else + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToDecimal.ToString("###,###,##0.00").ToString + End If + + End If + + + If e.Row.DBCampo("ImporteActual").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLActual").ForeColor = Drawing.Color.Red + End If + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvGastos_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + e.Row.FCHyperLink("HLActual").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + End If + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToEntero.ToString("###,###,##0") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToEntero.ToString("###,###,##0").ToString + Else + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToDecimal.ToString("###,###,##0.00").ToString + End If + + If e.Row.DBCampo("ImporteActual").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLActual").ForeColor = Drawing.Color.Red + End If + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + +#End Region + + + + +#End Region + + + +#Region "M E S H O R I Z O N T A L" + + Private Sub CargaDatosMesH() + + + FechaIMes = $"01/01/{DdlEjercicio.SelectedValue}" + Dim FechaFin As Date = $"01/{DdlPeriodo.SelectedValue.ToEntero.ToString("00")}/{DdlEjercicio.SelectedValue}".ToDate + FechaFMes = $"{FechaFin.LastDayOfMonth.Day.ToString("00")}/{DdlPeriodo.SelectedValue.ToEntero.ToString("00")}/{DdlEjercicio.SelectedValue}" + + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + 'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosMensualHorizontal(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then + DtDatosMesH = ObjConta.DtResultados.FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosMesH = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosMesH IsNot Nothing Then + CargaGridsMesH() + Else + + End If + + End Sub + + Private Sub CargaGridsMesH() + + DtIngresosMesH = DtDatosMesH.FiltraParametros("Tipo ='H' ") + DtGastosMesH = DtDatosMesH.FiltraParametros("Tipo ='G' ") + DTTotalesMesH = DtDatosMesH.Clone() + + Dim Row As DataRow = DtIngresosMesH.NewRow + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + + If DtIngresosMesH.Rows.Count > 0 Then + + For Each dr As DataRow In DtIngresosMesH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + Row.Item("Enero") = DtIngresosMesH.SUM("Enero", "NOT CtaMayor in (3,4)") + Row.Item("Febrero") = DtIngresosMesH.SUM("Febrero", "NOT CtaMayor in (3,4)") + Row.Item("Marzo") = DtIngresosMesH.SUM("Marzo", "NOT CtaMayor in (3,4)") + Row.Item("Abril") = DtIngresosMesH.SUM("Abril", "NOT CtaMayor in (3,4)") + Row.Item("Mayo") = DtIngresosMesH.SUM("Mayo", "NOT CtaMayor in (3,4)") + Row.Item("Junio") = DtIngresosMesH.SUM("Junio", "NOT CtaMayor in (3,4)") + Row.Item("Julio") = DtIngresosMesH.SUM("Julio", "NOT CtaMayor in (3,4)") + Row.Item("Agosto") = DtIngresosMesH.SUM("Agosto", "NOT CtaMayor in (3,4)") + Row.Item("Septiembre") = DtIngresosMesH.SUM("Septiembre", "NOT CtaMayor in (3,4)") + Row.Item("Octubre") = DtIngresosMesH.SUM("Octubre", "NOT CtaMayor in (3,4)") + Row.Item("Noviembre") = DtIngresosMesH.SUM("Noviembre", "NOT CtaMayor in (3,4)") + Row.Item("Diciembre") = DtIngresosMesH.SUM("Diciembre", "NOT CtaMayor in (3,4)") + + Row.Item("Tri1") = DtIngresosMesH.SUM("Tri1", "NOT CtaMayor in (3,4)") + Row.Item("Tri2") = DtIngresosMesH.SUM("Tri2", "NOT CtaMayor in (3,4)") + Row.Item("Tri3") = DtIngresosMesH.SUM("Tri3", "NOT CtaMayor in (3,4)") + Row.Item("Tri4") = DtIngresosMesH.SUM("Tri4", "NOT CtaMayor in (3,4)") + + Row.Item("Cua1") = DtIngresosMesH.SUM("Cua1", "NOT CtaMayor in (3,4)") + Row.Item("Cua2") = DtIngresosMesH.SUM("Cua2", "NOT CtaMayor in (3,4)") + Row.Item("Cua3") = DtIngresosMesH.SUM("Cua3", "NOT CtaMayor in (3,4)") + + + Row.Item("Nombre") = "TOTAL INGRESOS" + Row.Item("ImporteActual") = TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + + DtIngresosMesH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosMesH.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosMesH.NewRow + If DtGastosMesH.Rows.Count > 0 Then + + For Each dr As DataRow In DtGastosMesH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + + Row.Item("Enero") = DtGastosMesH.SUM("Enero", "NOT CtaMayor in (3,4)") + Row.Item("Febrero") = DtGastosMesH.SUM("Febrero", "NOT CtaMayor in (3,4)") + Row.Item("Marzo") = DtGastosMesH.SUM("Marzo", "NOT CtaMayor in (3,4)") + Row.Item("Abril") = DtGastosMesH.SUM("Abril", "NOT CtaMayor in (3,4)") + Row.Item("Mayo") = DtGastosMesH.SUM("Mayo", "NOT CtaMayor in (3,4)") + Row.Item("Junio") = DtGastosMesH.SUM("Junio", "NOT CtaMayor in (3,4)") + Row.Item("Julio") = DtGastosMesH.SUM("Julio", "NOT CtaMayor in (3,4)") + Row.Item("Agosto") = DtGastosMesH.SUM("Agosto", "NOT CtaMayor in (3,4)") + Row.Item("Septiembre") = DtGastosMesH.SUM("Septiembre", "NOT CtaMayor in (3,4)") + Row.Item("Octubre") = DtGastosMesH.SUM("Octubre", "NOT CtaMayor in (3,4)") + Row.Item("Noviembre") = DtGastosMesH.SUM("Noviembre", "NOT CtaMayor in (3,4)") + Row.Item("Diciembre") = DtGastosMesH.SUM("Diciembre", "NOT CtaMayor in (3,4)") + + Row.Item("Tri1") = DtGastosMesH.SUM("Tri1", "NOT CtaMayor in (3,4)") + Row.Item("Tri2") = DtGastosMesH.SUM("Tri2", "NOT CtaMayor in (3,4)") + Row.Item("Tri3") = DtGastosMesH.SUM("Tri3", "NOT CtaMayor in (3,4)") + Row.Item("Tri4") = DtGastosMesH.SUM("Tri4", "NOT CtaMayor in (3,4)") + + Row.Item("Cua1") = DtGastosMesH.SUM("Cua1", "NOT CtaMayor in (3,4)") + Row.Item("Cua2") = DtGastosMesH.SUM("Cua2", "NOT CtaMayor in (3,4)") + Row.Item("Cua3") = DtGastosMesH.SUM("Cua3", "NOT CtaMayor in (3,4)") + + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = TotalActual + Row.Item("PorcentajeActual") = If(T1 > 0, (TotalActual * 100 / T1).ToString, "0").FormatoNumero + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = If(T2 > 0, (TotalAnterior * 100 / T2).ToString, "0").FormatoNumero + Row.Item("CtaMayor") = -1 + DtGastosMesH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosMesH.Rows.Add(Row) + End If + + If DtIngresosMesH.Rows.Count > 0 Then + + Row = DTTotalesMesH.NewRow + + Row.Item("Enero") = DtIngresosMesH.SUM("Enero", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Enero", "NOT CtaMayor in (-1,3,4)") + Row.Item("Febrero") = DtIngresosMesH.SUM("Febrero", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Febrero", "NOT CtaMayor in (-1,3,4)") + Row.Item("Marzo") = DtIngresosMesH.SUM("Marzo", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Marzo", "NOT CtaMayor in (-1,3,4)") + Row.Item("Abril") = DtIngresosMesH.SUM("Abril", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Abril", "NOT CtaMayor in (-1,3,4)") + Row.Item("Mayo") = DtIngresosMesH.SUM("Mayo", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Mayo", "NOT CtaMayor in (-1,3,4)") + Row.Item("Junio") = DtIngresosMesH.SUM("Junio", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Junio", "NOT CtaMayor in (-1,3,4)") + Row.Item("Julio") = DtIngresosMesH.SUM("Julio", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Julio", "NOT CtaMayor in (-1,3,4)") + Row.Item("Agosto") = DtIngresosMesH.SUM("Agosto", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Agosto", "NOT CtaMayor in (-1,3,4)") + Row.Item("Septiembre") = DtIngresosMesH.SUM("Septiembre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Septiembre", "NOT CtaMayor in (-1,3,4)") + Row.Item("Octubre") = DtIngresosMesH.SUM("Octubre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Octubre", "NOT CtaMayor in (-1,3,4)") + Row.Item("Noviembre") = DtIngresosMesH.SUM("Noviembre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Noviembre", "NOT CtaMayor in (-1,3,4)") + Row.Item("Diciembre") = DtIngresosMesH.SUM("Diciembre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Diciembre", "NOT CtaMayor in (-1,3,4)") + + Row.Item("Tri1") = DtIngresosMesH.SUM("Tri1", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri1", "NOT CtaMayor in (-1,3,4)") + Row.Item("Tri2") = DtIngresosMesH.SUM("Tri2", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri2", "NOT CtaMayor in (-1,3,4)") + Row.Item("Tri3") = DtIngresosMesH.SUM("Tri3", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri3", "NOT CtaMayor in (-1,3,4)") + Row.Item("Tri4") = DtIngresosMesH.SUM("Tri4", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri4", "NOT CtaMayor in (-1,3,4)") + + Row.Item("Cua1") = DtIngresosMesH.SUM("Cua1", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Cua1", "NOT CtaMayor in (-1,3,4)") + Row.Item("Cua2") = DtIngresosMesH.SUM("Cua2", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Cua2", "NOT CtaMayor in (-1,3,4)") + Row.Item("Cua3") = DtIngresosMesH.SUM("Cua3", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Cua3", "NOT CtaMayor in (-1,3,4)") + + Row.Item("Nombre") = "Resultados del Ejercicio:" + 'Row.Item("ImporteActual") = TotalActual.ToString + 'Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = DtIngresosMesH.SUM("ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") ' TotalAnterior.ToString + 'Row.Item("PorcentajeAcumulado") = "100.00" + 'Row.Item("CtaMayor") = -1 + + DTTotalesMesH.Rows.Add(Row) + + End If + + GvIngresosMesH.DataSource = DtIngresosMesH + GvIngresosMesH.DataBind() + + GvGastosMesH.DataSource = DtGastosMesH + GvGastosMesH.DataBind() + + GvTotalesMesH.DataSource = DTTotalesMesH + GvTotalesMesH.DataBind() + + + If DdlTri.SelectedValue.ToEntero = 0 Then 'ocultar trimestre cuatrimestre + + GvIngresosMesH.Columns(4).Visible = False + GvIngresosMesH.Columns(9).Visible = False + GvIngresosMesH.Columns(14).Visible = False + GvIngresosMesH.Columns(18).Visible = False + + GvGastosMesH.Columns(4).Visible = False + GvGastosMesH.Columns(9).Visible = False + GvGastosMesH.Columns(14).Visible = False + GvGastosMesH.Columns(18).Visible = False + + GvTotalesMesH.Columns(4).Visible = False + GvTotalesMesH.Columns(9).Visible = False + GvTotalesMesH.Columns(14).Visible = False + GvTotalesMesH.Columns(18).Visible = False + + GvIngresosMesH.Columns(6).Visible = False + GvIngresosMesH.Columns(12).Visible = False + GvIngresosMesH.Columns(19).Visible = False + + GvGastosMesH.Columns(6).Visible = False + GvGastosMesH.Columns(12).Visible = False + GvGastosMesH.Columns(19).Visible = False + + GvTotalesMesH.Columns(6).Visible = False + GvTotalesMesH.Columns(12).Visible = False + GvTotalesMesH.Columns(19).Visible = False + + + ElseIf DdlTri.SelectedValue.ToEntero = 1 Then 'Mostrar Trimestre + + + GvIngresosMesH.Columns(4).Visible = True + GvIngresosMesH.Columns(9).Visible = True + GvIngresosMesH.Columns(14).Visible = True + GvIngresosMesH.Columns(18).Visible = True + + GvGastosMesH.Columns(4).Visible = True + GvGastosMesH.Columns(9).Visible = True + GvGastosMesH.Columns(14).Visible = True + GvGastosMesH.Columns(18).Visible = True + + GvTotalesMesH.Columns(4).Visible = True + GvTotalesMesH.Columns(9).Visible = True + GvTotalesMesH.Columns(14).Visible = True + GvTotalesMesH.Columns(18).Visible = True + + GvIngresosMesH.Columns(6).Visible = False + GvIngresosMesH.Columns(12).Visible = False + GvIngresosMesH.Columns(19).Visible = False + + GvGastosMesH.Columns(6).Visible = False + GvGastosMesH.Columns(12).Visible = False + GvGastosMesH.Columns(19).Visible = False + + GvTotalesMesH.Columns(6).Visible = False + GvTotalesMesH.Columns(12).Visible = False + GvTotalesMesH.Columns(19).Visible = False + + ElseIf DdlTri.SelectedValue.ToEntero = 2 Then 'Mostrar Cuatrimestre + + GvIngresosMesH.Columns(4).Visible = False + GvIngresosMesH.Columns(9).Visible = False + GvIngresosMesH.Columns(14).Visible = False + GvIngresosMesH.Columns(18).Visible = False + + GvGastosMesH.Columns(4).Visible = False + GvGastosMesH.Columns(9).Visible = False + GvGastosMesH.Columns(14).Visible = False + GvGastosMesH.Columns(18).Visible = False + + GvTotalesMesH.Columns(4).Visible = False + GvTotalesMesH.Columns(9).Visible = False + GvTotalesMesH.Columns(14).Visible = False + GvTotalesMesH.Columns(18).Visible = False + + + GvIngresosMesH.Columns(6).Visible = True + GvIngresosMesH.Columns(12).Visible = True + GvIngresosMesH.Columns(19).Visible = True + + GvGastosMesH.Columns(6).Visible = True + GvGastosMesH.Columns(12).Visible = True + GvGastosMesH.Columns(19).Visible = True + + GvTotalesMesH.Columns(6).Visible = True + GvTotalesMesH.Columns(12).Visible = True + GvTotalesMesH.Columns(19).Visible = True + + End If + + + UpDatosMesH.Update() + + End Sub + + + Protected Sub GvIngresosMesH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + e.Row.ControlStyle.Font.Bold = True + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + + 'e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensualHorizontal.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&FF=31/12/{DdlEjercicio.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1" + + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}&TRCU={DdlTri.SelectedValue}" + + e.Row.FCHyperLink("HLEnero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/01/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLFebrero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/02/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/02/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMarzo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/03/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAbril").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMayo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/05/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJunio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/06/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJulio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/07/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAgosto").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/08/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLSeptiembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLOctubre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/10/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLNoviembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/11/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/11/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLDiciembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/12/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLTri1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri4").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLCua1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + + ' e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Or e.Row.DBCampo("Nombre") = "TOTAL INGRESOS" Then + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0") + Else + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0.00") + End If + + End If + + setgrafica(e) + + + + + e.Row.FCHyperLink("HLEnero").ForeColor = If(e.Row.DataKey("Enero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLEnero").ForeColor) + e.Row.FCHyperLink("HLFebrero").ForeColor = If(e.Row.DataKey("Febrero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLFebrero").ForeColor) + e.Row.FCHyperLink("HLMarzo").ForeColor = If(e.Row.DataKey("Marzo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMarzo").ForeColor) + e.Row.FCHyperLink("HLAbril").ForeColor = If(e.Row.DataKey("Abril").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLMayo").ForeColor = If(e.Row.DataKey("Mayo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLJunio").ForeColor = If(e.Row.DataKey("Junio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMayo").ForeColor) + e.Row.FCHyperLink("HLJulio").ForeColor = If(e.Row.DataKey("Julio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLJulio").ForeColor) + e.Row.FCHyperLink("HLAgosto").ForeColor = If(e.Row.DataKey("Agosto").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAgosto").ForeColor) + e.Row.FCHyperLink("HLSeptiembre").ForeColor = If(e.Row.DataKey("Septiembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLSeptiembre").ForeColor) + e.Row.FCHyperLink("HLOctubre").ForeColor = If(e.Row.DataKey("Octubre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLOctubre").ForeColor) + e.Row.FCHyperLink("HLNoviembre").ForeColor = If(e.Row.DataKey("Noviembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLNoviembre").ForeColor) + e.Row.FCHyperLink("HLDiciembre").ForeColor = If(e.Row.DataKey("Diciembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLDiciembre").ForeColor) + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + + End If + + End Sub + + Protected Sub GvGastosMesH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + + 'e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensualHorizontal.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&FF=31/12/{DdlEjercicio.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1" + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}&TRCU={DdlTri.SelectedValue}" + + e.Row.FCHyperLink("HLEnero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/01/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLFebrero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/02/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/02/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMarzo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/03/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAbril").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMayo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/05/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJunio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/06/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJulio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/07/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAgosto").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/08/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLSeptiembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLOctubre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/10/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLNoviembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/11/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/11/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLDiciembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/12/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLTri1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri4").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLCua1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + 'e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + End If + + + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Or e.Row.DBCampo("Nombre") = "TOTAL GASTOS" Then + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + + 'Enero,Febrero,Marzo,Abril,Mayo,Junio,Julio,Agosto,Septiembre,Octubre,Noviembre,Diciembre,PorcentajeAcumulado + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0") + + Else + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0.00") + End If + End If + + + setgrafica(e) + + + e.Row.FCHyperLink("HLEnero").ForeColor = If(e.Row.DataKey("Enero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLEnero").ForeColor) + e.Row.FCHyperLink("HLFebrero").ForeColor = If(e.Row.DataKey("Febrero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLFebrero").ForeColor) + e.Row.FCHyperLink("HLMarzo").ForeColor = If(e.Row.DataKey("Marzo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMarzo").ForeColor) + e.Row.FCHyperLink("HLAbril").ForeColor = If(e.Row.DataKey("Abril").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLMayo").ForeColor = If(e.Row.DataKey("Mayo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLJunio").ForeColor = If(e.Row.DataKey("Junio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMayo").ForeColor) + e.Row.FCHyperLink("HLJulio").ForeColor = If(e.Row.DataKey("Julio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLJulio").ForeColor) + e.Row.FCHyperLink("HLAgosto").ForeColor = If(e.Row.DataKey("Agosto").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAgosto").ForeColor) + e.Row.FCHyperLink("HLSeptiembre").ForeColor = If(e.Row.DataKey("Septiembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLSeptiembre").ForeColor) + e.Row.FCHyperLink("HLOctubre").ForeColor = If(e.Row.DataKey("Octubre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLOctubre").ForeColor) + e.Row.FCHyperLink("HLNoviembre").ForeColor = If(e.Row.DataKey("Noviembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLNoviembre").ForeColor) + e.Row.FCHyperLink("HLDiciembre").ForeColor = If(e.Row.DataKey("Diciembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLDiciembre").ForeColor) + + + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvTotalesMesH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.Header Then + e.Row.Attributes.Add("style", "display:none") + End If + + If e.Row.RowType = DataControlRowType.DataRow Then + + e.Row.Attributes.Add("style", "Font-weight: bold") + + + If DdlDivisor.SelectedValue.ToEntero > 0 Then + + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0") + + Else + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0.00") + End If + + setgrafica(e) + + e.Row.FCHyperLink("HLEnero").ForeColor = If(e.Row.DataKey("Enero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLEnero").ForeColor) + e.Row.FCHyperLink("HLFebrero").ForeColor = If(e.Row.DataKey("Febrero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLFebrero").ForeColor) + e.Row.FCHyperLink("HLMarzo").ForeColor = If(e.Row.DataKey("Marzo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMarzo").ForeColor) + e.Row.FCHyperLink("HLAbril").ForeColor = If(e.Row.DataKey("Abril").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLMayo").ForeColor = If(e.Row.DataKey("Mayo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLJunio").ForeColor = If(e.Row.DataKey("Junio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMayo").ForeColor) + e.Row.FCHyperLink("HLJulio").ForeColor = If(e.Row.DataKey("Julio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLJulio").ForeColor) + e.Row.FCHyperLink("HLAgosto").ForeColor = If(e.Row.DataKey("Agosto").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAgosto").ForeColor) + e.Row.FCHyperLink("HLSeptiembre").ForeColor = If(e.Row.DataKey("Septiembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLSeptiembre").ForeColor) + e.Row.FCHyperLink("HLOctubre").ForeColor = If(e.Row.DataKey("Octubre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLOctubre").ForeColor) + e.Row.FCHyperLink("HLNoviembre").ForeColor = If(e.Row.DataKey("Noviembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLNoviembre").ForeColor) + e.Row.FCHyperLink("HLDiciembre").ForeColor = If(e.Row.DataKey("Diciembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLDiciembre").ForeColor) + + + End If + + End Sub + + Public Sub setgrafica(e As GridViewRowEventArgs) + + Dim lista As New List(Of Object) + lista.Add(New With {.Texto = "Enero", .Valor = e.Row.DataKey("Enero").ToDecimal(), .Color = "#FF0F00"}) + lista.Add(New With {.Texto = "Febrero", .Valor = e.Row.DataKey("Febrero").ToDecimal(), .Color = "#FF6600"}) + lista.Add(New With {.Texto = "Marzo", .Valor = e.Row.DataKey("Marzo").ToDecimal(), .Color = "#F8FF01"}) + lista.Add(New With {.Texto = "Abril", .Valor = e.Row.DataKey("Abril").ToDecimal(), .Color = "#04D215"}) + lista.Add(New With {.Texto = "Mayo", .Valor = e.Row.DataKey("Mayo").ToDecimal(), .Color = "#2A0CD0"}) + lista.Add(New With {.Texto = "Junio", .Valor = e.Row.DataKey("Junio").ToDecimal(), .Color = "#8A0CCF"}) + lista.Add(New With {.Texto = "Julio", .Valor = e.Row.DataKey("Julio").ToDecimal(), .Color = "#CD0D74"}) + lista.Add(New With {.Texto = "Agosto", .Valor = e.Row.DataKey("Agosto").ToDecimal(), .Color = "#754DEB"}) + lista.Add(New With {.Texto = "Septiembre", .Valor = e.Row.DataKey("Septiembre").ToDecimal(), .Color = "#DDDDDD"}) + lista.Add(New With {.Texto = "Octubre", .Valor = e.Row.DataKey("Octubre").ToDecimal(), .Color = "#999999"}) + lista.Add(New With {.Texto = "Noviembre", .Valor = e.Row.DataKey("Noviembre").ToDecimal(), .Color = "#000000"}) + lista.Add(New With {.Texto = "Diciembre", .Valor = e.Row.DataKey("Diciembre").ToDecimal(), .Color = "#FF0F00"}) + e.Row.FCHyperLink("Hypgrafica").Attributes.Add("data-values", Newtonsoft.Json.JsonConvert.SerializeObject(lista)) + End Sub +#End Region + + + +#Region "Anual H O R I Z O N T A L" + + Private Sub CargaDatosAnualH() + + + FechaIMes = $"01/01/{DdlEjercicio.SelectedValue}" + FechaFMes = $"31/12/{DdlEjercicio2.SelectedValue}" + + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + 'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosAnualHorizontal(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, DdlPeriodo.SelectedValue.ToEntero, Periodo:=DdlPeriodo.SelectedValue.ToEntero) Then + DtDatosAnualH = ObjConta.DtResultados.FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosAnualH = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosAnualH IsNot Nothing Then + CargaGridsAnualH() + + End If + + End Sub + + Private Sub CargaGridsAnualH() + + DtIngresosAnualH = DtDatosAnualH.FiltraParametros("Tipo ='H' ") + DtGastosAnualH = DtDatosAnualH.FiltraParametros("Tipo ='G' ") + DTTotalesAnualH = DtDatosAnualH.Clone() + + Dim Row As DataRow = DtIngresosAnualH.NewRow + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + + + Dim IndexData As Integer = 0 + Dim IndexGv As Integer = 1 + Dim IndexMax As Integer = 1 + + + Dim IDX_LIMPIAR As Integer = 1 + + For IDX_LIMPIAR = 1 To 25 + + GvIngresosAnualH.Columns(IDX_LIMPIAR).Visible = False + GvGastosAnualH.Columns(IDX_LIMPIAR).Visible = False + GvTotalesAnualH.Columns(IDX_LIMPIAR).Visible = False + Next + listaCamposanios.Clear() + listaCamposaniosGastos.Clear() + listaCamposaniosTotal.Clear() + + If DtIngresosAnualH.Rows.Count > 0 Then + + + + + For Each dCoumn As DataColumn In DtIngresosAnualH.Columns + + If IndexData >= 13 Then + + If dCoumn.ColumnName.ToEntero > 0 And dCoumn.ColumnName.ToEntero <= DdlEjercicio2.SelectedValue.ToEntero Then + + CType(GvIngresosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + CType(GvIngresosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + + + listaCamposanios.Add(New String() {dCoumn.ColumnName.ToString(), dCoumn.ColumnName.ToString()}) + + listaCamposaniosTotal.Add(New String() {dCoumn.ColumnName.ToString(), dCoumn.ColumnName.ToString()}) + 'CType(GvIngresosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + 'CType(GvIngresosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + GvIngresosAnualH.Columns(IndexGv).Visible = True + + + CType(GvTotalesAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + CType(GvTotalesAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + 'CType(GvTotalesAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + 'CType(GvTotalesAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + GvTotalesAnualH.Columns(IndexGv).Visible = True + + IndexMax = IndexData + Else + GvIngresosAnualH.Columns(IndexGv).Visible = False + GvTotalesAnualH.Columns(IndexGv).Visible = False + End If + + + + IndexGv = IndexGv + 1 + End If + + IndexData = IndexData + 1 + + Next + + + For Each dr As DataRow In DtIngresosAnualH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + + Next + + IndexData = 13 + For IndexData = 13 To IndexMax + Row.Item(IndexData) = DtIngresosAnualH.SUM($"[{DtIngresosAnualH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (3,4)") + Next + + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = DtIngresosAnualH.SUM("ImporteActual", "NOT CtaMayor in (3,4)") 'TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = DtIngresosAnualH.SUM("ImporteAcumulado", "NOT CtaMayor in (3,4)") 'TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + Row.Item("CountDinamico") = DtGastosAnualH.MAX("CountDinamico") + CountDinamicoAnual = DtGastosAnualH.MAX("CountDinamico").ToEntero + DtIngresosAnualH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosAnualH.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosAnualH.NewRow + + If DtGastosAnualH.Rows.Count > 0 Then + + + IndexData = 0 + IndexGv = 1 + IndexMax = 0 + + For Each dCoumn As DataColumn In DtGastosAnualH.Columns + + If IndexData >= 13 Then + + If dCoumn.ColumnName.ToEntero > 0 And dCoumn.ColumnName.ToEntero <= DdlEjercicio2.SelectedValue.ToEntero Then + 'HyperLinkField + + CType(GvGastosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + CType(GvGastosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + listaCamposaniosGastos.Add(New String() {dCoumn.ColumnName.ToString(), dCoumn.ColumnName.ToString()}) + + 'CType(GvGastosAnualH.Columns(IndexGv), HyperLinkField).DataNavigateUrlFields = {"CveCuenta", "FechaInicial", "FechaFActual", "CveSubProyecto"} + 'CType(GvGastosAnualH.Columns(IndexGv), HyperLinkField).DataNavigateUrlFormatString = "/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1&CveSubProyecto{3}" + + 'CType(GvGastosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + 'CType(GvGastosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + + GvGastosAnualH.Columns(IndexGv).Visible = True + IndexMax = IndexData + Else + GvGastosAnualH.Columns(IndexGv).Visible = False + End If + + + + IndexGv = IndexGv + 1 + End If + + IndexData = IndexData + 1 + + Next + + + For Each dr As DataRow In DtGastosAnualH.FiltraParametros("Not CtaMayor In (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + IndexData = 13 + For IndexData = 13 To IndexMax + + Row.Item(IndexData) = DtGastosAnualH.SUM($"[{DtIngresosAnualH.Columns(IndexData).ColumnName}]", "Not CtaMayor In (3,4)") + + Next + + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = TotalActual + Row.Item("PorcentajeActual") = If(T1 > 0, (TotalActual * 100 / T1).ToString, "0").FormatoNumero + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = If(T2 > 0, (TotalAnterior * 100 / T2).ToString, "0").FormatoNumero + Row.Item("CtaMayor") = -1 + Row.Item("CountDinamico") = DtGastosAnualH.MAX("CountDinamico") + DtGastosAnualH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosAnualH.Rows.Add(Row) + End If + + If DtIngresosAnualH.Rows.Count > 0 Then + + Row = DTTotalesAnualH.NewRow + + + IndexData = 13 + For IndexData = 13 To IndexMax + Row.Item(IndexData) = DtIngresosAnualH.SUM($"[{DtIngresosAnualH.Columns(IndexData).ColumnName}]", "Not CtaMayor In (-1,3,4)") - DtGastosAnualH.SUM($"[{DtGastosAnualH.Columns(IndexData).ColumnName}]", "Not CtaMayor In (-1,3,4)") + Next + + Row.Item("Nombre") = "Resultados del Ejercicio" + Row.Item("ImporteAcumulado") = DtIngresosAnualH.SUM($"ImporteAcumulado", "Not CtaMayor in (-1,3,4)") - DtGastosAnualH.SUM($"ImporteAcumulado", "Not CtaMayor in (-1,3,4)") + + + DTTotalesAnualH.Rows.Add(Row) + + End If + + GvIngresosAnualH.DataSource = DtIngresosAnualH + GvIngresosAnualH.DataBind() + + GvGastosAnualH.DataSource = DtGastosAnualH + GvGastosAnualH.DataBind() + + GvTotalesAnualH.DataSource = DTTotalesAnualH + GvTotalesAnualH.DataBind() + + UpDatosAnualH.Update() + + End Sub + + + + Protected Sub GvIngresosAnualH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCCAnual(e, listaCamposanios) + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales3" + e.Row.ControlStyle.Font.Bold = True + End If + + + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + Dim CveSubProyecto As Integer = e.Row.DataKey("CveSubProyecto").ToEntero + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + Dim Anio As String = CType(GvGastosAnualH.Columns(IndiceInicio), BoundField).DataField + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + 'e.Row.Cells(IndiceInicio).ForeColor = If(Importe < 0, Drawing.Color.Red, e.Row.Cells(IndiceInicio).ForeColor) + Next IndiceInicio + + 'e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogo.aspx?CveCuenta={CveCuenta}&FF=31/12/{DdlEjercicio2.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1&CveSubProyecto={CveSubProyecto}" + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + + Next IndiceInicio + + + End If + + + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvGastosAnualH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCCAnual(e, listaCamposaniosGastos) + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + Dim CveSubProyecto As Integer = e.Row.DataKey("CveSubProyecto").ToEntero + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + 'e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto=-1&EjercicioFinal={DdlEjercicio2.SelectedValue}" + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + For IndiceInicio = 1 To IndiceMax + Dim Anio As String = CType(GvGastosAnualH.Columns(IndiceInicio), BoundField).DataField + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00"))}" + 'e.Row.Cells(IndiceInicio).ForeColor = If(Importe < 0, Drawing.Color.Red, e.Row.Cells(IndiceInicio).ForeColor) + Next IndiceInicio + + 'e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogo.aspx?CveCuenta={CveCuenta}&FF=31/12/{DdlEjercicio2.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1&CveSubProyecto={CveSubProyecto}" + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + + Next IndiceInicio + + End If + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvTotalesAnualH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.Header Then + e.Row.Attributes.Add("style", "display:none") + End If + + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCCAnual(e, listaCamposaniosTotal) + e.Row.Attributes.Add("style", "Font-weight: bold") + End If + + End Sub + + Public Sub setgraficaCCAnual(e As GridViewRowEventArgs, listaCampos As List(Of String())) + Dim lista As New List(Of Object) + Dim colorindex As Integer = 0 + For Each campo As String() In listaCampos + lista.Add(New With {.Texto = campo(1), .Valor = e.Row.DBCampo(campo(0)).ToDecimal(), .Color = listacolores(colorindex)}) + colorindex = colorindex + 1 + If colorindex >= listacolores.Count Then + colorindex = 0 + End If + Next + e.Row.FCHyperLink("Hypgrafica").Attributes.Add("data-values", Newtonsoft.Json.JsonConvert.SerializeObject(lista)) + End Sub +#End Region + + +#Region "S U B P R O Y E C T O H O R I Z O N T A L" + + Private Sub CargaDatosSubProyectoH() + + + FechaIMes = $"01/01/{DdlEjercicio.SelectedValue}" + FechaFMes = $"01/{DdlPeriodo.SelectedValue.ToEntero.ToString("00")}/{DdlEjercicio.SelectedValue}" + FechaFMes = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, CDate(FechaFMes))).ToString("dd/MM/yyyy") + + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosSubProyectoHorizontal(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then + DTSubProyectosCabecerasH = ObjConta.DSResultados.Tables(0) + DtDatosSubProyectoH = ObjConta.DSResultados.Tables(1).FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosSubProyectoH = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosSubProyectoH IsNot Nothing And DTSubProyectosCabecerasH IsNot Nothing Then + CargaGridsSubProyectoH() + End If + + End Sub + + Private Sub CargaGridsSubProyectoH() + + DtIngresosSubProyectoH = DtDatosSubProyectoH.FiltraParametros("Tipo ='H' ") + DtGastosSubProyectoH = DtDatosSubProyectoH.FiltraParametros("Tipo ='G' ") + DTTotalesSubProyectoH = DtDatosSubProyectoH.Clone() + + Dim Row As DataRow = DtIngresosSubProyectoH.NewRow + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + + + Dim IndexData As Integer = 0 + Dim IndexGv As Integer = 1 + Dim IndexMax As Integer = 1 + Dim IndexSubProyecto = 0 + Dim IndexSubProyectoMAx As Integer = DTSubProyectosCabecerasH.Rows.Count - 1 + Dim IndexTotatles As Integer = 13 + IndexSubProyectoMAx + + '34 + Dim IDX_LIMPIAR As Integer = 1 + + For IDX_LIMPIAR = 1 To 35 + CType(GvIngresosSubProyectoH.Columns(IDX_LIMPIAR), BoundField).DataField = Nothing + CType(GvIngresosSubProyectoH.Columns(IDX_LIMPIAR), BoundField).HeaderText = "" + GvIngresosSubProyectoH.Columns(IDX_LIMPIAR).Visible = False + Next + listaCampos.Clear() + + + If DtIngresosSubProyectoH.Rows.Count > 0 Then + + For Each dCoumn As DataColumn In DtIngresosSubProyectoH.Columns + + If IndexData >= 13 Then + + If IndexSubProyecto <= IndexSubProyectoMAx Then + + CType(GvIngresosSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvIngresosSubProyectoH.Columns(IndexGv).Visible = True + + CType(GvTotalesSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvTotalesSubProyectoH.Columns(IndexGv).Visible = True + + If IndexSubProyecto <= IndexSubProyectoMAx Then + CType(GvIngresosSubProyectoH.Columns(IndexGv), BoundField).HeaderText = DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString + CType(GvTotalesSubProyectoH.Columns(IndexGv), BoundField).HeaderText = DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString + CType(GvGastosSubProyectoH.Columns(IndexGv), BoundField).HeaderText = DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString + End If + listaCampos.Add(New String() {dCoumn.ColumnName.ToString(), DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString()}) + Else + GvIngresosSubProyectoH.Columns(IndexGv).Visible = False + GvTotalesSubProyectoH.Columns(IndexGv).Visible = False + End If + + IndexGv = IndexGv + 1 + IndexSubProyecto = IndexSubProyecto + 1 + IndexMax = IndexMax + 1 + + End If + IndexData = IndexData + 1 + Next + + + For Each dr As DataRow In DtIngresosSubProyectoH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + IndexData = 13 + For IndexData = 13 To IndexTotatles + Row.Item(IndexData) = DtIngresosSubProyectoH.SUM($"[{DtIngresosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (3,4)") + Next + + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = DtIngresosSubProyectoH.SUM("ImporteActual", "NOT CtaMayor in (3,4)") 'TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = DtIngresosSubProyectoH.SUM("ImporteAcumulado", "NOT CtaMayor in (3,4)") 'TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + Row.Item("CountDinamico") = DtIngresosSubProyectoH.MAX("CountDinamico") + CountDinamicoSubProyecto = DtIngresosSubProyectoH.MAX("CountDinamico").ToEntero + DtIngresosSubProyectoH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosSubProyectoH.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosSubProyectoH.NewRow + + If DtGastosSubProyectoH.Rows.Count > 0 Then + + + IndexData = 0 + IndexGv = 1 + IndexMax = 0 + IndexSubProyecto = 0 + + For Each dCoumn As DataColumn In DtIngresosSubProyectoH.Columns + If IndexData >= 13 Then + If IndexSubProyecto <= IndexSubProyectoMAx Then + CType(GvGastosSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvGastosSubProyectoH.Columns(IndexGv).Visible = True + CType(GvTotalesSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvTotalesSubProyectoH.Columns(IndexGv).Visible = True + Else + GvIngresosSubProyectoH.Columns(IndexGv).Visible = False + GvTotalesSubProyectoH.Columns(IndexGv).Visible = False + End If + + IndexGv = IndexGv + 1 + IndexSubProyecto = IndexSubProyecto + 1 + End If + IndexData = IndexData + 1 + Next + + + + For Each dr As DataRow In DtGastosSubProyectoH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + IndexData = 13 + For IndexData = 13 To IndexTotatles + Row.Item(IndexData) = DtGastosSubProyectoH.SUM($"[{DtIngresosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (3,4)") + Next + + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = TotalActual + Row.Item("PorcentajeActual") = If(T1 > 0, (TotalActual * 100 / T1).ToString, "0").FormatoNumero + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = If(T2 > 0, (TotalAnterior * 100 / T2).ToString, "0").FormatoNumero + Row.Item("CtaMayor") = -1 + Row.Item("CountDinamico") = DtGastosSubProyectoH.MAX("CountDinamico") + + DtGastosSubProyectoH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosSubProyectoH.Rows.Add(Row) + End If + + If DtIngresosSubProyectoH.Rows.Count > 0 Then + + Row = DTTotalesSubProyectoH.NewRow + + IndexData = 13 + For IndexData = 13 To IndexTotatles + Row.Item(IndexData) = DtIngresosSubProyectoH.SUM($"[{DtIngresosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (-1,3,4)") - DtGastosSubProyectoH.SUM($"[{DtGastosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (-1,3,4)") + Next + + Row.Item("Nombre") = "Resultado del ejercicio" + Row.Item("ImporteAcumulado") = DtIngresosSubProyectoH.SUM($"ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") - DtGastosSubProyectoH.SUM($"ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") + Row.Item("CtaMayor") = -2 + Row.Item("CountDinamico") = DtIngresosSubProyectoH.MAX("CountDinamico") + + DTTotalesSubProyectoH.Rows.Add(Row) + + End If + + DtIngresosSubProyectoH.Merge(DtGastosSubProyectoH) + DtIngresosSubProyectoH.Merge(DTTotalesSubProyectoH) + + + GvIngresosSubProyectoH.DataSource = DtIngresosSubProyectoH + GvIngresosSubProyectoH.DataBind() + + + + UpDatosSubProyectoH.Update() + + End Sub + + 'Private Sub SumaTotalesSubProyectoH() + ' ''Llena Lb´s Totales + ' ''********************************************************************************* + ' 'LbTotalActual.Text = TotalActualMes.ToString.FormatoNumero + ' 'LbTotalAnterior.Text = TotalAnteriorMes.ToString.FormatoNumero + + ' 'LbTotalActual.ForeColor = If(TotalActualMes < 0, Drawing.Color.Red, Color.Black) + ' 'LbTotalAnterior.ForeColor = If(TotalAnteriorMes < 0, Drawing.Color.Red, Color.Black) + + + 'End Sub + + Protected Sub GvIngresosSubProyectoH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales3" + e.Row.ControlStyle.Font.Bold = True + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -2 Then + + e.Row.ControlStyle.Font.Bold = True + e.Row.ControlStyle.Font.Size = 13 + End If + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + setgraficaCC(e) + 'Dim CveSubProyecto As Integer = e.Row.DataKey("CveSubProyecto").ToEntero + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoCC.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + Dim FEchaMesFinal As Date = New Date(DdlEjercicio.SelectedValue.ToEntero, DdlPeriodo.SelectedValue.ToEntero, 1).LastDayOfMonth + + For IndiceInicio = 1 To IndiceMax + + Dim CveSubProyectoIntermo As String = CType(GvGastosSubProyectoH.Columns(IndiceInicio), BoundField).DataField + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + + + If CveSubProyectoIntermo.ToEntero > 0 Then + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + End If + + + + Next IndiceInicio + + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoCC.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"
    { If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }
    " + Next IndiceInicio + + + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -2 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"
    { If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }
    " + + Next IndiceInicio + + + End If + e.Row.FCHyperLink("HLAnterior").Text = If(DdlDivisor.SelectedValue.ToEntero > 1, e.Row.DBCampo("ImporteAcumulado").ToString.ToDecimal.ToString("###,###,##0"), e.Row.DBCampo("ImporteAcumulado").ToString.ToDecimal.ToString("###,###,##0.00")) + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + + End If + + End Sub + + Protected Sub GvGastosSubProyectoH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCC(e) + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvTotalesSubProyectoH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.Header Then + ' e.Row.Attributes.Add("style", "display:none") + End If + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCC(e) + e.Row.Attributes.Add("style", "Font-weight: bold") + End If + End Sub + + Public Sub setgraficaCC(e As GridViewRowEventArgs) + Dim lista As New List(Of Object) + Dim colorindex As Integer = 0 + For Each campo As String() In listaCampos + lista.Add(New With {.Texto = campo(1), .Valor = e.Row.DBCampo(campo(0)).ToDecimal(), .Color = listacolores(colorindex)}) + colorindex = colorindex + 1 + If colorindex >= listacolores.Count Then + colorindex = 0 + End If + Next + e.Row.FCHyperLink("Hypgrafica").Attributes.Add("data-values", Newtonsoft.Json.JsonConvert.SerializeObject(lista)) + End Sub +#End Region + + + + + +#Region "DESCARGA EXCEL" + + Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click + Imprimir("Excel") + End Sub + + Private Sub Imprimir(Optional reporte As String = "PDF") + + + If TAB.ActiveTabIndex = 0 AndAlso GvIngresosMes.Rows.Count > 0 Then + ExportToExcelG(GvIngresosMes, GvGastosMes, TMesT1, "Reporte_Mensual", UsuarioActual, "Mensual") + ElseIf TAB.ActiveTabIndex = 1 AndAlso GvIngresosMesH.Rows.Count > 0 Then + ExportToExcelG(GvIngresosMesH, GvGastosMesH, TMesT1, "Reporte_Mensual_Horizontal", UsuarioActual, "Mensual Horizontal", Gv3:=GvTotalesMesH) + ElseIf TAB.ActiveTabIndex = 2 AndAlso GvIngresosAnualH.Rows.Count > 0 Then + ExportToExcelG(GvIngresosAnualH, GvGastosAnualH, TMesT1, "Reporte_Anual_Horizontal", UsuarioActual, "Anual Horizontal", Gv3:=GvTotalesAnualH) + + ElseIf TAB.ActiveTabIndex = 3 AndAlso GvIngresosSubProyectoH.Rows.Count > 0 Then + + ExportToExcelG(GvIngresosSubProyectoH, GvGastosSubProyectoH, TMesT1, "Reporte_Proyecto_Horizontal", UsuarioActual, $"Estado de Resultados Horizontal por {LblSubProyecto.Text}", Gv3:=GvTotalesSubProyectoH, EsPorSubProtyecto:=True) + + End If + + + End Sub + + 'Public Sub ExportToExcelG(Gv1 As GridView, Gv2 As GridView, NombreArchivoXLSx As String, Optional Titulo As String = "Reporte", Optional Usuario As Usuario = Nothing, Optional Filtros As String = "", Optional AlturaImagen As Double = 100, Optional AnchoImagen As Double = 100) + Public Sub ExportToExcelG(Gv1 As GridView, Gv2 As GridView, TablaResultados As HtmlTable, NombreArchivoXLSx As String, Usuario As Usuario, Titulo As String, Optional AlturaImagen As Double = 100, Optional AnchoImagen As Double = 100, Optional Gv3 As GridView = Nothing, Optional EsPorSubProtyecto As Boolean = False) + + Dim sw1 As New StringWriter() + Dim htw1 As New HtmlTextWriter(sw1) + Gv1.RenderControl(htw1) + + Dim sw2 As New StringWriter() + Dim htw2 As New HtmlTextWriter(sw2) + Gv2.RenderControl(htw2) + + + TablaResultados.Width = Gv2.Width.ToString + + Dim sw3 As New StringWriter() + Dim htw3 As New HtmlTextWriter(sw3) + TablaResultados.RenderControl(htw3) + + Dim options = GemBox.Spreadsheet.LoadOptions.HtmlDefault + + Dim htmlStream1 = New MemoryStream(options.Encoding.GetBytes(sw1.ToString())) + Dim htmlStream2 = New MemoryStream(options.Encoding.GetBytes(sw2.ToString())) + Dim htmlStream3 = New MemoryStream(options.Encoding.GetBytes(sw3.ToString())) + + htmlStream1.Position = 0 + Dim sr1 As New StreamReader(htmlStream1) + + htmlStream2.Position = 0 + Dim sr2 As New StreamReader(htmlStream2) + + htmlStream3.Position = 0 + Dim sr3 As New StreamReader(htmlStream3) + + + Dim myStr1 = sr1.ReadToEnd() + Dim myStr2 = sr2.ReadToEnd() + Dim myStr3 = sr3.ReadToEnd() + + sr1.Dispose() + sr2.Dispose() + sr3.Dispose() + + htmlStream1.Dispose() + htmlStream2.Dispose() + htmlStream3.Dispose() + + sw1.Dispose() + sw2.Dispose() + sw3.Dispose() + + If Gv3 IsNot Nothing Then + + Gv3.ShowHeader = False + + Dim sw4 As New StringWriter() + Dim htw4 As New HtmlTextWriter(sw4) + Gv3.RenderControl(htw4) + Dim htmlStream4 = New MemoryStream(options.Encoding.GetBytes(sw4.ToString())) + htmlStream4.Position = 0 + Dim sr4 As New StreamReader(htmlStream4) + myStr3 = sr4.ReadToEnd() + + sr4.Dispose() + htmlStream2.Dispose() + sw4.Dispose() + + End If + + + Dim HtmlCompleto As String = myStr1 & "
    " & myStr2 & "
    " & myStr3 + + + HtmlCompleto = Regex.Replace(HtmlCompleto, "\<[\/]*a[^\>]*\>", "") + + + Dim htmlStream5 = New MemoryStream(options.Encoding.GetBytes(HtmlCompleto)) + + GemBox.Spreadsheet.SpreadsheetInfo.SetLicense(SerialGemBoxSpreadsheet) + + Dim excel As GemBox.Spreadsheet.ExcelFile + + excel = GemBox.Spreadsheet.ExcelFile.Load(htmlStream5, options) + + If Usuario IsNot Nothing Then + + Dim TotalRowHeader As Integer = 8 + Dim TotalRowFooter As Integer = 2 + + + Dim worksheet = excel.Worksheets(0) + worksheet.Rows.InsertEmpty(0, TotalRowHeader) + Dim celdasConTexto = worksheet.GetUsedCellRange(True) + celdasConTexto.Style.Font.Name = "Calibri Light" + + Dim RangoNombreEmpresa = worksheet.Cells.GetSubrangeAbsolute(1, celdasConTexto.FirstColumnIndex, 1, celdasConTexto.LastColumnIndex) + RangoNombreEmpresa.Merged = True + RangoNombreEmpresa.Value = Usuario.Empresa.Empresa + RangoNombreEmpresa.Style.Font.Size = 18 * 20 + RangoNombreEmpresa.Style.Font.Name = "Calibri Light" + RangoNombreEmpresa.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoNombreEmpresa.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + + Dim RangoTitulo = worksheet.Cells.GetSubrangeAbsolute(3, celdasConTexto.FirstColumnIndex, 3, celdasConTexto.LastColumnIndex) + RangoTitulo.Merged = True + RangoTitulo.Value = Titulo + RangoTitulo.Style.Font.Size = 20 * 20 + RangoTitulo.Style.Font.Name = "Calibri Light" + RangoTitulo.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoTitulo.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + Dim RangoFechas = worksheet.Cells.GetSubrangeAbsolute(4, celdasConTexto.FirstColumnIndex, 4, celdasConTexto.LastColumnIndex) + RangoFechas.Merged = True + RangoFechas.Value = $"Fechas: {FechaIMes} a {FechaFMes}" + RangoFechas.Style.Font.Size = 15 * 20 + RangoFechas.Style.Font.Name = "Calibri Light" + RangoFechas.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoFechas.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + + If EsPorSubProtyecto And DdlSubproyecto.SelectedValue.ToEntero > 0 Then + Dim RangoSubProyecto = worksheet.Cells.GetSubrangeAbsolute(5, celdasConTexto.FirstColumnIndex, 5, celdasConTexto.LastColumnIndex) + RangoSubProyecto.Merged = True + RangoSubProyecto.Value = DdlSubproyecto.SelectedItem.Text + RangoSubProyecto.Style.Font.Size = 20 * 20 + RangoSubProyecto.Style.Font.Name = "Calibri Light" + RangoSubProyecto.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoSubProyecto.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + End If + + For i = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex + + worksheet.Rows(8).Cells(i).Style.Font.Size = 12 * 20 + worksheet.Rows(8).Cells(i).Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + worksheet.Rows(8).Cells(i).Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + worksheet.Rows(8).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(8).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255) + + + + If Not EsPorSubProtyecto Then + worksheet.Rows(8 + Gv1.Rows.Count + 2).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(8 + Gv1.Rows.Count + 2).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255) + Else + worksheet.Rows(18).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(18).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255) + End If + + + + If i > 0 Then + Try + worksheet.Columns(i).AutoFit(1) + Catch ex As Exception + End Try + End If + Next + + Dim IndexEndTable As Integer = Gv1.Rows.Count + Gv2.Rows.Count + 4 + TotalRowHeader + TotalRowFooter + + worksheet.Rows(IndexEndTable).Cells(0).Value = "Usuario Imprimió" + worksheet.Rows(IndexEndTable + 1).Cells(0).Value = Usuario.Nombre + + worksheet.Rows(IndexEndTable).Cells(2).Value = "Fecha Impresión" + worksheet.Rows(IndexEndTable + 1).Cells(2).Value = DateTime.Now.ToString("dd/MM/yyyy") + + Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", Usuario.Empresa.Ruta)) + + If Imagen.Exists Then + Dim Ruta As String = String.Format("{0}/Logo.png", Usuario.Empresa.Ruta) + Using sr As New StreamReader(Ruta) + Dim ms As New MemoryStream() + sr.BaseStream.CopyTo(ms) + worksheet.Pictures.Add(ms, ExcelPictureFormat.Png, "A1", AnchoImagen, AlturaImagen, LengthUnit.Pixel) + End Using + End If + + + + + + + For I = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex + + If I > 0 Then + + If DdlDivisor.SelectedValue.ToEntero = 1 Then + worksheet.Columns(I + 1).Style.NumberFormat = "#,##0.00" + Else + worksheet.Columns(I + 1).Style.NumberFormat = "#,##" + End If + + Try + worksheet.Columns(I).AutoFit(1) + Catch ex As Exception + End Try + + End If + Next + + End If + + excel.Save(HttpContext.Current.Response, $"{NombreArchivoXLSx}.xlsx") + + + End Sub + + Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) + End Sub + +#End Region + + + + + +End Class + diff --git a/Finanzas/RepBalanceGeneralHorizontal.aspx.vb b/Finanzas/RepBalanceGeneralHorizontal.aspx.vb index a893e59c8..4a65d9fd7 100644 --- a/Finanzas/RepBalanceGeneralHorizontal.aspx.vb +++ b/Finanzas/RepBalanceGeneralHorizontal.aspx.vb @@ -278,8 +278,8 @@ Partial Class Contabilidad_RepBalanceGeneralHorizontal 'LIGA SOLO EN DETALLE POR CAMPO CVECUENTA - TEMPORAL - If e.Row.DBCampo("CtaMayor").ToString = "1" Then - e.Row.FCHyperLink("HLNombre").NavigateUrl = $"/Contabilidad2/RepAnexoCatalogoMensual.aspx?C={e.Row.DBCampo("CveCuenta")}&E={DdlEjercicio.SelectedValue}&S={DdlSubProyecto.SelectedValue}&D={DdlDivisor.SelectedValue}" + If e.Row.DBCampo("CtaMayor").ToString = "1" Then + ' e.Row.FCHyperLink("HLNombre").NavigateUrl = $"/Contabilidad2/RepAnexoCatalogoMensual.aspx?C={e.Row.DBCampo("CveCuenta")}&E={DdlEjercicio.SelectedValue}&S={DdlSubProyecto.SelectedValue}&D={DdlDivisor.SelectedValue}" End If diff --git a/Finanzas/RepBalanceGeneralHorizontal2.aspx b/Finanzas/RepBalanceGeneralHorizontal2.aspx new file mode 100644 index 000000000..cb5a8067e --- /dev/null +++ b/Finanzas/RepBalanceGeneralHorizontal2.aspx @@ -0,0 +1,1592 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepBalanceGeneralHorizontal2.aspx.vb" Inherits="Contabilidad_RepBalanceGeneralHorizontal2" %> + + + + + + + + + + + + + +
  • + Generar Excel +
  • +
  • + Graficar +
  • +
    + + + + +
    +
    +
    + +
    +
    +
    +
      + + +
      + + +
      + + +
      + + +
      + + +
      + + + + + + + + + + + + + + +
      + + + +
      + + +
      + + +
      + + + + + +
      + + +
      + + NO + Trimestre + Cuatrimestre + +
      + +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + <%-- --%> + + + + + + + + <%-- --%> + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + +
    +

    Resultados del Ejercicio:

    +
    + + + +
    +
    +
    + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%----%> + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%-- --%> + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + + + + +
    + + + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + + + + + + <%----%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%-- --%> + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + <%-- --%> + + + + + + + + + + + +
    +
    +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%----%> + + + + + + + <%----%> + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- + + + + + --%> + + <%-- --%> + + + + + + + + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + + + + + + + +
    +
    +
    + + + + + + + +
    + + + + + + + + + + + diff --git a/Finanzas/RepBalanceGeneralHorizontal2.aspx.vb b/Finanzas/RepBalanceGeneralHorizontal2.aspx.vb new file mode 100644 index 000000000..3a01281cf --- /dev/null +++ b/Finanzas/RepBalanceGeneralHorizontal2.aspx.vb @@ -0,0 +1,2295 @@ +Option Explicit On +Option Strict On + +Imports System.Data +Imports System.Drawing +Imports System.IO +Imports Extensiones +Imports GemBox.Spreadsheet +Imports Microsoft.Reporting.WebForms + +Partial Class Contabilidad_RepBalanceGeneralHorizontal2 + Inherits ClsPaginas + +#Region "PROPIEDADES" + + + Private Property DtDatosMes As DataTable + Get + DtDatosMes = DirectCast(ViewState("DtDatosMes"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosMes") = value + End Set + End Property + + Private Property DtIngresosMes As DataTable + Get + DtIngresosMes = DirectCast(ViewState("DtIngresosMes"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosMes") = value + End Set + End Property + Private Property DtGastosMes As DataTable + Get + DtGastosMes = DirectCast(ViewState("DtGastosMes"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosMes") = value + End Set + End Property + Private Property TotalActualMes As Double + Get + TotalActualMes = ViewState("TotalActualMes").ToString.ToDouble + End Get + Set(value As Double) + ViewState("TotalActualMes") = value + End Set + End Property + Private Property TotalAnteriorMes As Double + Get + TotalAnteriorMes = ViewState("TotalAnteriorMes").ToString.ToDouble + End Get + Set(value As Double) + ViewState("TotalAnteriorMes") = value + End Set + End Property + Private Property FechaIMes As String + Get + Return ViewState("FechaIMes").ToString + End Get + Set(value As String) + ViewState("FechaIMes") = value + End Set + End Property + Private Property FechaFMes As String + Get + Return ViewState("FechaFMes").ToString + End Get + Set(value As String) + ViewState("FechaFMes") = value + End Set + End Property + + Private Property listacolores As List(Of String) + Get + Return DirectCast(ViewState("listacolores"), List(Of String)) + End Get + Set(value As List(Of String)) + ViewState("listacolores") = value + End Set + End Property + + Private Property listaCampos As List(Of String()) + Get + Return DirectCast(ViewState("listaCampos"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCampos") = value + End Set + End Property + Private Property listaCamposanios As List(Of String()) + Get + Return DirectCast(ViewState("listaCamposanios"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCamposanios") = value + End Set + End Property + Private Property listaCamposaniosGastos As List(Of String()) + Get + Return DirectCast(ViewState("listaCamposaniosGastos"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCamposaniosGastos") = value + End Set + End Property + Private Property listaCamposaniosTotal As List(Of String()) + Get + Return DirectCast(ViewState("listaCamposaniosTotal"), List(Of String())) + End Get + Set(value As List(Of String())) + ViewState("listaCamposaniosTotal") = value + End Set + End Property + + 'Private Property ReporteComplementario As Boolean + ' Get + ' ReporteComplementario = CBool(ViewState("ReporteComplementario").ToString) + ' End Get + ' Set(value As Boolean) + ' ViewState("ReporteComplementario") = value + ' End Set + 'End Property + +#End Region + + +#Region " M E S H O R I Z O N T A L " + + Private Property DtDatosMesH As DataTable + Get + DtDatosMesH = DirectCast(ViewState("DtDatosMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosMesH") = value + End Set + End Property + + Private Property DtIngresosMesH As DataTable + Get + DtIngresosMesH = DirectCast(ViewState("DtIngresosMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosMesH") = value + End Set + End Property + + Private Property DtGastosMesH As DataTable + Get + DtGastosMesH = DirectCast(ViewState("DtGastosMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosMesH") = value + End Set + End Property + + Private Property DTTotalesMesH As DataTable + Get + DTTotalesMesH = DirectCast(ViewState("DTTotalesMesH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTTotalesMesH") = value + End Set + End Property + +#End Region + + +#Region " A N U A L H O R I Z O N T A L " + + Private Property DtDatosAnualH As DataTable + Get + DtDatosAnualH = DirectCast(ViewState("DtDatosAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosAnualH") = value + End Set + End Property + + Private Property DtIngresosAnualH As DataTable + Get + DtIngresosAnualH = DirectCast(ViewState("DtIngresosAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosAnualH") = value + End Set + End Property + + Private Property DtGastosAnualH As DataTable + Get + DtGastosAnualH = DirectCast(ViewState("DtGastosAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosAnualH") = value + End Set + End Property + + Private Property DTTotalesAnualH As DataTable + Get + DTTotalesAnualH = DirectCast(ViewState("DTTotalesAnualH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTTotalesAnualH") = value + End Set + End Property + + + Private Property CountDinamicoAnual As Integer + + Get + If ViewState("CountDinamicoAnual") Is Nothing Then + Return 0 + Else + Return ViewState("CountDinamicoAnual").ToString.ToEntero + End If + + End Get + Set(value As Integer) + ViewState("CountDinamicoAnual") = value + End Set + End Property + +#End Region + +#Region " S U B P R O Y E C T O H O R I Z O N T A L " + + Private Property DtDatosSubProyectoH As DataTable + Get + DtDatosSubProyectoH = DirectCast(ViewState("DtDatosSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatosSubProyectoH") = value + End Set + End Property + + Private Property DtIngresosSubProyectoH As DataTable + Get + DtIngresosSubProyectoH = DirectCast(ViewState("DtIngresosSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtIngresosSubProyectoH") = value + End Set + End Property + + Private Property DtGastosSubProyectoH As DataTable + Get + DtGastosSubProyectoH = DirectCast(ViewState("DtGastosSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtGastosSubProyectoH") = value + End Set + End Property + + Private Property DTTotalesSubProyectoH As DataTable + Get + DTTotalesSubProyectoH = DirectCast(ViewState("DTTotalesSubProyectoH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTTotalesSubProyectoH") = value + End Set + End Property + + Private Property DTSubProyectosCabecerasH As DataTable + + Get + DTSubProyectosCabecerasH = DirectCast(ViewState("DTSubProyectosCabecerasH"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DTSubProyectosCabecerasH") = value + End Set + + End Property + + + Private Property CountDinamicoSubProyecto As Integer + + Get + If ViewState("CountDinamicoSubProyecto") Is Nothing Then + Return 0 + Else + Return ViewState("CountDinamicoSubProyecto").ToString.ToEntero + End If + + End Get + Set(value As Integer) + ViewState("CountDinamicoSubProyecto") = 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 + listacolores = New List(Of String) + listaCampos = New List(Of String()) + listaCamposanios = New List(Of String()) + listaCamposaniosGastos = New List(Of String()) + listaCamposaniosTotal = New List(Of String()) + listacolores.Add("#FF0F00") + listacolores.Add("#FF6600") + listacolores.Add("#F8FF01") + listacolores.Add("#04D215") + listacolores.Add("#2A0CD0") + listacolores.Add("#8A0CCF") + listacolores.Add("#CD0D74") + listacolores.Add("#754DEB") + listacolores.Add("#DDDDDD") + listacolores.Add("#999999") + listacolores.Add("#000000") + listacolores.Add("#FF0F00") + + TotalActualMes = 0 + TotalAnteriorMes = 0 + + CargaEjercicios() + + CargarCentrosDeCosto(Nothing, DdlSubproyecto, Nothing, LblSubProyecto) + TabSubProyecto.HeaderText = LblSubProyecto.Text & " " + + + + DdlEjercicio.SelectedValueExist(UsuarioActual.Empresa.EjercicioActual) + ValidaEjercicios() + + End If + End Sub + + Protected Sub Tab_ActiveTabChanged(sender As Object, e As EventArgs) + + If TAB.ActiveTabIndex = 0 Then + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = False + LiEjercicioLbl2.Visible = False + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + LblTri.Visible = False + DVTri.Visible = False + End If + + If TAB.ActiveTabIndex = 1 Then + + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = False + LiEjercicioLbl2.Visible = False + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + DdlPeriodo.SelectedValueExist(12) + + LblTri.Visible = True + DVTri.Visible = True + + + End If + + If TAB.ActiveTabIndex = 2 Then + + ValidaEjercicios() + + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = True + LiEjercicioLbl2.Visible = True + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + LblTri.Visible = False + DVTri.Visible = False + + End If + + If TAB.ActiveTabIndex = 3 Then + LiSubProyectoDdl.Visible = True + LiSubProyectoLbl.Visible = True + + LiEjercicioDdl.Visible = True + LiEjercicioLbl.Visible = True + + LiEjercicioDdl2.Visible = False + LiEjercicioLbl2.Visible = False + + LiPeriodoDdl.Visible = True + LiPeriodoLbl.Visible = True + + LiDivisorDdl.Visible = True + LiDivisorLbl.Visible = True + + LblTri.Visible = False + DVTri.Visible = False + + End If + + UpFiltros.Update() + End Sub + + + Protected Sub DdlEjercicio_SelectedIndexChanged(sender As Object, e As EventArgs) + ValidaEjercicios() + End Sub + + Protected Sub DdlEjercicio2_SelectedIndexChanged(sender As Object, e As EventArgs) + ValidaEjercicios() + End Sub + + Private Sub ValidaEjercicios() + + + Dim EInicio As Integer = DdlEjercicio.SelectedValue.ToEntero + + + If EInicio > DdlEjercicio2.SelectedValue.ToEntero Then + + If DdlEjercicio2.Items.Count > 0 Then + DdlEjercicio2.SelectedIndex = DdlEjercicio2.Items.Count - 1 + End If + + Dim Fejerciosio As Integer = DdlEjercicio2.SelectedValue.ToEntero + + If Not EInicio + 1 > Fejerciosio Then + DdlEjercicio2.SelectedValueExist(EInicio + 1) + End If + + End If + + + UpFiltros.Update() + End Sub + + Private Sub CargaEjercicios() + 'Dim ClsConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ClsConta As New ClsContabilidad + If ClsConta.GetEjercicios(UsuarioActual.CveEmpresa) Then + DdlEjercicio.DataSource = ClsConta.DtResultados + DdlEjercicio2.DataSource = ClsConta.DtResultados + Else + DdlEjercicio.DataSource = Nothing + DdlEjercicio2.DataSource = Nothing + End If + ClsConta.Dispose() + DdlEjercicio.DataBind() + DdlEjercicio2.DataBind() + + DdlEjercicio.SelectedValueExist(UsuarioActual.Empresa.EjercicioActual.ToString) + If DdlEjercicio.Items.Count = 0 Then + DdlEjercicio.Items.Add(New ListItem(Now.Year.ToString, Now.Year.ToString)) + End If + DdlPeriodo.SelectedValue = Now.Month.ToString + End Sub + + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) + TotalActualMes = 0 + TotalAnteriorMes = 0 + + 'Mes + If TAB.ActiveTabIndex = 0 Then + CargaDatosMes() + End If + + 'MES HORIZONTAL + If TAB.ActiveTabIndex = 1 Then + CargaDatosMesH() + End If + + 'AÑO HORIZONTAL + If TAB.ActiveTabIndex = 2 Then + + If DdlEjercicio.SelectedValue.ToEntero > DdlEjercicio2.SelectedValue.ToEntero Then + Alert("El ejercicio inicio no debe ser mayor al ejercicio fin.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + CargaDatosAnualH() + End If + + 'SUBPROYECTO + If TAB.ActiveTabIndex = 3 Then + CargaDatosSubProyectoH() + End If + + + + + End Sub + + +#Region "MES" + + + + + + Private Sub CargaDatosMes() + + + FechaIMes = String.Format("01/{0}/{1}", DdlPeriodo.SelectedValue.PadLeft(2, CChar("0")), DdlEjercicio.SelectedValue) + FechaFMes = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, CDate(FechaIMes))).ToString("dd/MM/yyyy") + 'Dim TipoReporte = DdlTipoReporte.SelectedValue.ToEntero 'If(ReporteComplementario, DdlTipoReporte.SelectedValue.ToEntero, 1) + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + 'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosMensual(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then + DtDatosMes = ObjConta.DtResultados.FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosMes = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosMes IsNot Nothing Then + CargaGridsMes() + SumaTotales() + End If + + End Sub + Private Sub CargaGridsMes() + DtIngresosMes = DtDatosMes.FiltraParametros("Tipo ='H' ") + DtGastosMes = DtDatosMes.FiltraParametros("Tipo ='G' ") + Dim Row As DataRow = DtIngresosMes.NewRow + + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + If DtIngresosMes.Rows.Count > 0 Then + + For Each dr As DataRow In DtIngresosMes.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + DtIngresosMes.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosMes.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosMes.NewRow + If DtGastosMes.Rows.Count > 0 Then + + For Each dr As DataRow In DtGastosMes.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = TotalActual + Row.Item("PorcentajeActual") = If(T1 > 0, (TotalActual * 100 / T1).ToString, "0").FormatoNumero + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = If(T2 > 0, (TotalAnterior * 100 / T2).ToString, "0").FormatoNumero + Row.Item("CtaMayor") = -1 + DtGastosMes.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosMes.Rows.Add(Row) + End If + + + GvIngresosMes.DataSource = DtIngresosMes + GvIngresosMes.DataBind() + + GvGastosMes.DataSource = DtGastosMes + GvGastosMes.DataBind() + + UpDatos.Update() + + End Sub + + + + Private Sub SumaTotales() + 'Llena Lb´s Totales + + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + LbTotalActual.Text = TotalActualMes.ToString("###,###,##0") + LbTotalAnterior.Text = TotalAnteriorMes.ToString("###,###,##0") + Else + LbTotalActual.Text = TotalActualMes.ToString("###,###,##0.00") + LbTotalAnterior.Text = TotalAnteriorMes.ToString("###,###,##0.00") + End If + + + + LbTotalActual.ForeColor = If(TotalActualMes < 0, Drawing.Color.Red, Color.Black) + + LbTotalAnterior.ForeColor = If(TotalAnteriorMes < 0, Drawing.Color.Red, Color.Black) + + + End Sub + +#Region "GV´S ROW DATA BOUND" + + Protected Sub GvIngresos_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales3" + e.Row.ControlStyle.Font.Bold = True + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + e.Row.FCHyperLink("HLActual").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToEntero.ToString("###,###,##0") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToEntero.ToString("###,###,##0").ToString + Else + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToDecimal.ToString("###,###,##0.00").ToString + End If + + End If + + + If e.Row.DBCampo("ImporteActual").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLActual").ForeColor = Drawing.Color.Red + End If + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvGastos_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + e.Row.FCHyperLink("HLActual").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + End If + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToEntero.ToString("###,###,##0") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToEntero.ToString("###,###,##0").ToString + Else + e.Row.FCHyperLink("HLActual").Text = e.Row.DataKey("ImporteActual").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAnterior").Text = e.Row.DataKey("ImporteAcumulado").ToDecimal.ToString("###,###,##0.00").ToString + End If + + If e.Row.DBCampo("ImporteActual").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLActual").ForeColor = Drawing.Color.Red + End If + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + +#End Region + + + + +#End Region + + + +#Region "M E S H O R I Z O N T A L" + + Private Sub CargaDatosMesH() + + + FechaIMes = $"01/01/{DdlEjercicio.SelectedValue}" + Dim FechaFin As Date = $"01/{DdlPeriodo.SelectedValue.ToEntero.ToString("00")}/{DdlEjercicio.SelectedValue}".ToDate + FechaFMes = $"{FechaFin.LastDayOfMonth.Day.ToString("00")}/{DdlPeriodo.SelectedValue.ToEntero.ToString("00")}/{DdlEjercicio.SelectedValue}" + + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + 'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosMensualHorizontal(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then + DtDatosMesH = ObjConta.DtResultados.FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosMesH = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosMesH IsNot Nothing Then + CargaGridsMesH() + Else + + End If + + End Sub + + Private Sub CargaGridsMesH() + + DtIngresosMesH = DtDatosMesH.FiltraParametros("Tipo ='H' ") + DtGastosMesH = DtDatosMesH.FiltraParametros("Tipo ='G' ") + DTTotalesMesH = DtDatosMesH.Clone() + + Dim Row As DataRow = DtIngresosMesH.NewRow + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + + If DtIngresosMesH.Rows.Count > 0 Then + + For Each dr As DataRow In DtIngresosMesH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + Row.Item("Enero") = DtIngresosMesH.SUM("Enero", "NOT CtaMayor in (3,4)") + Row.Item("Febrero") = DtIngresosMesH.SUM("Febrero", "NOT CtaMayor in (3,4)") + Row.Item("Marzo") = DtIngresosMesH.SUM("Marzo", "NOT CtaMayor in (3,4)") + Row.Item("Abril") = DtIngresosMesH.SUM("Abril", "NOT CtaMayor in (3,4)") + Row.Item("Mayo") = DtIngresosMesH.SUM("Mayo", "NOT CtaMayor in (3,4)") + Row.Item("Junio") = DtIngresosMesH.SUM("Junio", "NOT CtaMayor in (3,4)") + Row.Item("Julio") = DtIngresosMesH.SUM("Julio", "NOT CtaMayor in (3,4)") + Row.Item("Agosto") = DtIngresosMesH.SUM("Agosto", "NOT CtaMayor in (3,4)") + Row.Item("Septiembre") = DtIngresosMesH.SUM("Septiembre", "NOT CtaMayor in (3,4)") + Row.Item("Octubre") = DtIngresosMesH.SUM("Octubre", "NOT CtaMayor in (3,4)") + Row.Item("Noviembre") = DtIngresosMesH.SUM("Noviembre", "NOT CtaMayor in (3,4)") + Row.Item("Diciembre") = DtIngresosMesH.SUM("Diciembre", "NOT CtaMayor in (3,4)") + + Row.Item("Tri1") = DtIngresosMesH.SUM("Tri1", "NOT CtaMayor in (3,4)") + Row.Item("Tri2") = DtIngresosMesH.SUM("Tri2", "NOT CtaMayor in (3,4)") + Row.Item("Tri3") = DtIngresosMesH.SUM("Tri3", "NOT CtaMayor in (3,4)") + Row.Item("Tri4") = DtIngresosMesH.SUM("Tri4", "NOT CtaMayor in (3,4)") + + Row.Item("Cua1") = DtIngresosMesH.SUM("Cua1", "NOT CtaMayor in (3,4)") + Row.Item("Cua2") = DtIngresosMesH.SUM("Cua2", "NOT CtaMayor in (3,4)") + Row.Item("Cua3") = DtIngresosMesH.SUM("Cua3", "NOT CtaMayor in (3,4)") + + + Row.Item("Nombre") = "TOTAL INGRESOS" + Row.Item("ImporteActual") = TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + + DtIngresosMesH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosMesH.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosMesH.NewRow + If DtGastosMesH.Rows.Count > 0 Then + + For Each dr As DataRow In DtGastosMesH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + + Row.Item("Enero") = DtGastosMesH.SUM("Enero", "NOT CtaMayor in (3,4)") + Row.Item("Febrero") = DtGastosMesH.SUM("Febrero", "NOT CtaMayor in (3,4)") + Row.Item("Marzo") = DtGastosMesH.SUM("Marzo", "NOT CtaMayor in (3,4)") + Row.Item("Abril") = DtGastosMesH.SUM("Abril", "NOT CtaMayor in (3,4)") + Row.Item("Mayo") = DtGastosMesH.SUM("Mayo", "NOT CtaMayor in (3,4)") + Row.Item("Junio") = DtGastosMesH.SUM("Junio", "NOT CtaMayor in (3,4)") + Row.Item("Julio") = DtGastosMesH.SUM("Julio", "NOT CtaMayor in (3,4)") + Row.Item("Agosto") = DtGastosMesH.SUM("Agosto", "NOT CtaMayor in (3,4)") + Row.Item("Septiembre") = DtGastosMesH.SUM("Septiembre", "NOT CtaMayor in (3,4)") + Row.Item("Octubre") = DtGastosMesH.SUM("Octubre", "NOT CtaMayor in (3,4)") + Row.Item("Noviembre") = DtGastosMesH.SUM("Noviembre", "NOT CtaMayor in (3,4)") + Row.Item("Diciembre") = DtGastosMesH.SUM("Diciembre", "NOT CtaMayor in (3,4)") + + Row.Item("Tri1") = DtGastosMesH.SUM("Tri1", "NOT CtaMayor in (3,4)") + Row.Item("Tri2") = DtGastosMesH.SUM("Tri2", "NOT CtaMayor in (3,4)") + Row.Item("Tri3") = DtGastosMesH.SUM("Tri3", "NOT CtaMayor in (3,4)") + Row.Item("Tri4") = DtGastosMesH.SUM("Tri4", "NOT CtaMayor in (3,4)") + + Row.Item("Cua1") = DtGastosMesH.SUM("Cua1", "NOT CtaMayor in (3,4)") + Row.Item("Cua2") = DtGastosMesH.SUM("Cua2", "NOT CtaMayor in (3,4)") + Row.Item("Cua3") = DtGastosMesH.SUM("Cua3", "NOT CtaMayor in (3,4)") + + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = TotalActual + Row.Item("PorcentajeActual") = If(T1 > 0, (TotalActual * 100 / T1).ToString, "0").FormatoNumero + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = If(T2 > 0, (TotalAnterior * 100 / T2).ToString, "0").FormatoNumero + Row.Item("CtaMayor") = -1 + DtGastosMesH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosMesH.Rows.Add(Row) + End If + + If DtIngresosMesH.Rows.Count > 0 Then + + Row = DTTotalesMesH.NewRow + + Row.Item("Enero") = DtIngresosMesH.SUM("Enero", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Enero", "NOT CtaMayor in (-1,3,4)") + Row.Item("Febrero") = DtIngresosMesH.SUM("Febrero", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Febrero", "NOT CtaMayor in (-1,3,4)") + Row.Item("Marzo") = DtIngresosMesH.SUM("Marzo", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Marzo", "NOT CtaMayor in (-1,3,4)") + Row.Item("Abril") = DtIngresosMesH.SUM("Abril", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Abril", "NOT CtaMayor in (-1,3,4)") + Row.Item("Mayo") = DtIngresosMesH.SUM("Mayo", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Mayo", "NOT CtaMayor in (-1,3,4)") + Row.Item("Junio") = DtIngresosMesH.SUM("Junio", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Junio", "NOT CtaMayor in (-1,3,4)") + Row.Item("Julio") = DtIngresosMesH.SUM("Julio", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Julio", "NOT CtaMayor in (-1,3,4)") + Row.Item("Agosto") = DtIngresosMesH.SUM("Agosto", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Agosto", "NOT CtaMayor in (-1,3,4)") + Row.Item("Septiembre") = DtIngresosMesH.SUM("Septiembre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Septiembre", "NOT CtaMayor in (-1,3,4)") + Row.Item("Octubre") = DtIngresosMesH.SUM("Octubre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Octubre", "NOT CtaMayor in (-1,3,4)") + Row.Item("Noviembre") = DtIngresosMesH.SUM("Noviembre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Noviembre", "NOT CtaMayor in (-1,3,4)") + Row.Item("Diciembre") = DtIngresosMesH.SUM("Diciembre", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Diciembre", "NOT CtaMayor in (-1,3,4)") + + Row.Item("Tri1") = DtIngresosMesH.SUM("Tri1", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri1", "NOT CtaMayor in (-1,3,4)") + Row.Item("Tri2") = DtIngresosMesH.SUM("Tri2", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri2", "NOT CtaMayor in (-1,3,4)") + Row.Item("Tri3") = DtIngresosMesH.SUM("Tri3", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri3", "NOT CtaMayor in (-1,3,4)") + Row.Item("Tri4") = DtIngresosMesH.SUM("Tri4", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Tri4", "NOT CtaMayor in (-1,3,4)") + + Row.Item("Cua1") = DtIngresosMesH.SUM("Cua1", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Cua1", "NOT CtaMayor in (-1,3,4)") + Row.Item("Cua2") = DtIngresosMesH.SUM("Cua2", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Cua2", "NOT CtaMayor in (-1,3,4)") + Row.Item("Cua3") = DtIngresosMesH.SUM("Cua3", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("Cua3", "NOT CtaMayor in (-1,3,4)") + + Row.Item("Nombre") = "Resultados del Ejercicio:" + 'Row.Item("ImporteActual") = TotalActual.ToString + 'Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = DtIngresosMesH.SUM("ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") - DtGastosMesH.SUM("ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") ' TotalAnterior.ToString + 'Row.Item("PorcentajeAcumulado") = "100.00" + 'Row.Item("CtaMayor") = -1 + + DTTotalesMesH.Rows.Add(Row) + + End If + + GvIngresosMesH.DataSource = DtIngresosMesH + GvIngresosMesH.DataBind() + + GvGastosMesH.DataSource = DtGastosMesH + GvGastosMesH.DataBind() + + GvTotalesMesH.DataSource = DTTotalesMesH + GvTotalesMesH.DataBind() + + + If DdlTri.SelectedValue.ToEntero = 0 Then 'ocultar trimestre cuatrimestre + + GvIngresosMesH.Columns(4).Visible = False + GvIngresosMesH.Columns(9).Visible = False + GvIngresosMesH.Columns(14).Visible = False + GvIngresosMesH.Columns(18).Visible = False + + GvGastosMesH.Columns(4).Visible = False + GvGastosMesH.Columns(9).Visible = False + GvGastosMesH.Columns(14).Visible = False + GvGastosMesH.Columns(18).Visible = False + + GvTotalesMesH.Columns(4).Visible = False + GvTotalesMesH.Columns(9).Visible = False + GvTotalesMesH.Columns(14).Visible = False + GvTotalesMesH.Columns(18).Visible = False + + GvIngresosMesH.Columns(6).Visible = False + GvIngresosMesH.Columns(12).Visible = False + GvIngresosMesH.Columns(19).Visible = False + + GvGastosMesH.Columns(6).Visible = False + GvGastosMesH.Columns(12).Visible = False + GvGastosMesH.Columns(19).Visible = False + + GvTotalesMesH.Columns(6).Visible = False + GvTotalesMesH.Columns(12).Visible = False + GvTotalesMesH.Columns(19).Visible = False + + + ElseIf DdlTri.SelectedValue.ToEntero = 1 Then 'Mostrar Trimestre + + + GvIngresosMesH.Columns(4).Visible = True + GvIngresosMesH.Columns(9).Visible = True + GvIngresosMesH.Columns(14).Visible = True + GvIngresosMesH.Columns(18).Visible = True + + GvGastosMesH.Columns(4).Visible = True + GvGastosMesH.Columns(9).Visible = True + GvGastosMesH.Columns(14).Visible = True + GvGastosMesH.Columns(18).Visible = True + + GvTotalesMesH.Columns(4).Visible = True + GvTotalesMesH.Columns(9).Visible = True + GvTotalesMesH.Columns(14).Visible = True + GvTotalesMesH.Columns(18).Visible = True + + GvIngresosMesH.Columns(6).Visible = False + GvIngresosMesH.Columns(12).Visible = False + GvIngresosMesH.Columns(19).Visible = False + + GvGastosMesH.Columns(6).Visible = False + GvGastosMesH.Columns(12).Visible = False + GvGastosMesH.Columns(19).Visible = False + + GvTotalesMesH.Columns(6).Visible = False + GvTotalesMesH.Columns(12).Visible = False + GvTotalesMesH.Columns(19).Visible = False + + ElseIf DdlTri.SelectedValue.ToEntero = 2 Then 'Mostrar Cuatrimestre + + GvIngresosMesH.Columns(4).Visible = False + GvIngresosMesH.Columns(9).Visible = False + GvIngresosMesH.Columns(14).Visible = False + GvIngresosMesH.Columns(18).Visible = False + + GvGastosMesH.Columns(4).Visible = False + GvGastosMesH.Columns(9).Visible = False + GvGastosMesH.Columns(14).Visible = False + GvGastosMesH.Columns(18).Visible = False + + GvTotalesMesH.Columns(4).Visible = False + GvTotalesMesH.Columns(9).Visible = False + GvTotalesMesH.Columns(14).Visible = False + GvTotalesMesH.Columns(18).Visible = False + + + GvIngresosMesH.Columns(6).Visible = True + GvIngresosMesH.Columns(12).Visible = True + GvIngresosMesH.Columns(19).Visible = True + + GvGastosMesH.Columns(6).Visible = True + GvGastosMesH.Columns(12).Visible = True + GvGastosMesH.Columns(19).Visible = True + + GvTotalesMesH.Columns(6).Visible = True + GvTotalesMesH.Columns(12).Visible = True + GvTotalesMesH.Columns(19).Visible = True + + End If + + + UpDatosMesH.Update() + + End Sub + + + Protected Sub GvIngresosMesH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + e.Row.ControlStyle.Font.Bold = True + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + + 'e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensualHorizontal.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&FF=31/12/{DdlEjercicio.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1" + + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}&TRCU={DdlTri.SelectedValue}" + + e.Row.FCHyperLink("HLEnero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/01/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLFebrero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/02/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/02/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMarzo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/03/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAbril").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMayo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/05/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJunio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/06/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJulio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/07/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAgosto").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/08/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLSeptiembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLOctubre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/10/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLNoviembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/11/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/11/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLDiciembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/12/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLTri1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri4").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLCua1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + + ' e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Or e.Row.DBCampo("Nombre") = "TOTAL INGRESOS" Then + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0") + Else + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0.00") + End If + + End If + + setgrafica(e) + + + + + e.Row.FCHyperLink("HLEnero").ForeColor = If(e.Row.DataKey("Enero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLEnero").ForeColor) + e.Row.FCHyperLink("HLFebrero").ForeColor = If(e.Row.DataKey("Febrero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLFebrero").ForeColor) + e.Row.FCHyperLink("HLMarzo").ForeColor = If(e.Row.DataKey("Marzo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMarzo").ForeColor) + e.Row.FCHyperLink("HLAbril").ForeColor = If(e.Row.DataKey("Abril").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLMayo").ForeColor = If(e.Row.DataKey("Mayo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLJunio").ForeColor = If(e.Row.DataKey("Junio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMayo").ForeColor) + e.Row.FCHyperLink("HLJulio").ForeColor = If(e.Row.DataKey("Julio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLJulio").ForeColor) + e.Row.FCHyperLink("HLAgosto").ForeColor = If(e.Row.DataKey("Agosto").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAgosto").ForeColor) + e.Row.FCHyperLink("HLSeptiembre").ForeColor = If(e.Row.DataKey("Septiembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLSeptiembre").ForeColor) + e.Row.FCHyperLink("HLOctubre").ForeColor = If(e.Row.DataKey("Octubre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLOctubre").ForeColor) + e.Row.FCHyperLink("HLNoviembre").ForeColor = If(e.Row.DataKey("Noviembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLNoviembre").ForeColor) + e.Row.FCHyperLink("HLDiciembre").ForeColor = If(e.Row.DataKey("Diciembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLDiciembre").ForeColor) + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + + End If + + End Sub + + Protected Sub GvGastosMesH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + + 'e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensualHorizontal.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&FF=31/12/{DdlEjercicio.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1" + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}&TRCU={DdlTri.SelectedValue}" + + e.Row.FCHyperLink("HLEnero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/01/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLFebrero").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/02/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/02/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMarzo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/03/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAbril").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLMayo").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/05/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJunio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/06/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLJulio").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/07/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAgosto").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/08/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLSeptiembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLOctubre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/10/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLNoviembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/11/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/11/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLDiciembre").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/12/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLTri1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/03/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/06/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/04/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/09/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/07/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLTri4").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/10/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + e.Row.FCHyperLink("HLCua1").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/04/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/01/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua2").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/08/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/05/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + e.Row.FCHyperLink("HLCua3").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), $"01/12/{DdlEjercicio.SelectedValue}".ToDate.LastDayOfMonth.ToShortDateString, $"01/09/{DdlEjercicio.SelectedValue}".ToDate.ToShortDateString) + + 'e.Row.FCHyperLink("HLAnterior").NavigateUrl = String.Format("/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1", e.Row.DBCampo("CveCuenta"), e.Row.DBCampo("FechaFActual").ToDate.ToShortDateString, e.Row.DBCampo("FechaInicial").ToDate.ToShortDateString) + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoMensual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + End If + + + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Or e.Row.DBCampo("Nombre") = "TOTAL GASTOS" Then + + If DdlDivisor.SelectedValue.ToEntero > 1 Then + + 'Enero,Febrero,Marzo,Abril,Mayo,Junio,Julio,Agosto,Septiembre,Octubre,Noviembre,Diciembre,PorcentajeAcumulado + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0") + + Else + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0.00") + End If + End If + + + setgrafica(e) + + + e.Row.FCHyperLink("HLEnero").ForeColor = If(e.Row.DataKey("Enero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLEnero").ForeColor) + e.Row.FCHyperLink("HLFebrero").ForeColor = If(e.Row.DataKey("Febrero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLFebrero").ForeColor) + e.Row.FCHyperLink("HLMarzo").ForeColor = If(e.Row.DataKey("Marzo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMarzo").ForeColor) + e.Row.FCHyperLink("HLAbril").ForeColor = If(e.Row.DataKey("Abril").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLMayo").ForeColor = If(e.Row.DataKey("Mayo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLJunio").ForeColor = If(e.Row.DataKey("Junio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMayo").ForeColor) + e.Row.FCHyperLink("HLJulio").ForeColor = If(e.Row.DataKey("Julio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLJulio").ForeColor) + e.Row.FCHyperLink("HLAgosto").ForeColor = If(e.Row.DataKey("Agosto").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAgosto").ForeColor) + e.Row.FCHyperLink("HLSeptiembre").ForeColor = If(e.Row.DataKey("Septiembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLSeptiembre").ForeColor) + e.Row.FCHyperLink("HLOctubre").ForeColor = If(e.Row.DataKey("Octubre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLOctubre").ForeColor) + e.Row.FCHyperLink("HLNoviembre").ForeColor = If(e.Row.DataKey("Noviembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLNoviembre").ForeColor) + e.Row.FCHyperLink("HLDiciembre").ForeColor = If(e.Row.DataKey("Diciembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLDiciembre").ForeColor) + + + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvTotalesMesH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.Header Then + e.Row.Attributes.Add("style", "display:none") + End If + + If e.Row.RowType = DataControlRowType.DataRow Then + + e.Row.Attributes.Add("style", "Font-weight: bold") + + + If DdlDivisor.SelectedValue.ToEntero > 0 Then + + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0") + + Else + e.Row.FCHyperLink("HLEnero").Text = e.Row.DataKey("Enero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLFebrero").Text = e.Row.DataKey("Febrero").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMarzo").Text = e.Row.DataKey("Marzo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAbril").Text = e.Row.DataKey("Abril").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLMayo").Text = e.Row.DataKey("Mayo").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJunio").Text = e.Row.DataKey("Junio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLJulio").Text = e.Row.DataKey("Julio").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLAgosto").Text = e.Row.DataKey("Agosto").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLSeptiembre").Text = e.Row.DataKey("Septiembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLOctubre").Text = e.Row.DataKey("Octubre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLNoviembre").Text = e.Row.DataKey("Noviembre").ToDecimal.ToString("###,###,##0.00") + e.Row.FCHyperLink("HLDiciembre").Text = e.Row.DataKey("Diciembre").ToDecimal.ToString("###,###,##0.00") + End If + + setgrafica(e) + + e.Row.FCHyperLink("HLEnero").ForeColor = If(e.Row.DataKey("Enero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLEnero").ForeColor) + e.Row.FCHyperLink("HLFebrero").ForeColor = If(e.Row.DataKey("Febrero").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLFebrero").ForeColor) + e.Row.FCHyperLink("HLMarzo").ForeColor = If(e.Row.DataKey("Marzo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMarzo").ForeColor) + e.Row.FCHyperLink("HLAbril").ForeColor = If(e.Row.DataKey("Abril").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLMayo").ForeColor = If(e.Row.DataKey("Mayo").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAbril").ForeColor) + e.Row.FCHyperLink("HLJunio").ForeColor = If(e.Row.DataKey("Junio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLMayo").ForeColor) + e.Row.FCHyperLink("HLJulio").ForeColor = If(e.Row.DataKey("Julio").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLJulio").ForeColor) + e.Row.FCHyperLink("HLAgosto").ForeColor = If(e.Row.DataKey("Agosto").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLAgosto").ForeColor) + e.Row.FCHyperLink("HLSeptiembre").ForeColor = If(e.Row.DataKey("Septiembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLSeptiembre").ForeColor) + e.Row.FCHyperLink("HLOctubre").ForeColor = If(e.Row.DataKey("Octubre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLOctubre").ForeColor) + e.Row.FCHyperLink("HLNoviembre").ForeColor = If(e.Row.DataKey("Noviembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLNoviembre").ForeColor) + e.Row.FCHyperLink("HLDiciembre").ForeColor = If(e.Row.DataKey("Diciembre").ToDecimal < 0, Drawing.Color.Red, e.Row.FCHyperLink("HLDiciembre").ForeColor) + + + End If + + End Sub + + Public Sub setgrafica(e As GridViewRowEventArgs) + + Dim lista As New List(Of Object) + lista.Add(New With {.Texto = "Enero", .Valor = e.Row.DataKey("Enero").ToDecimal(), .Color = "#FF0F00"}) + lista.Add(New With {.Texto = "Febrero", .Valor = e.Row.DataKey("Febrero").ToDecimal(), .Color = "#FF6600"}) + lista.Add(New With {.Texto = "Marzo", .Valor = e.Row.DataKey("Marzo").ToDecimal(), .Color = "#F8FF01"}) + lista.Add(New With {.Texto = "Abril", .Valor = e.Row.DataKey("Abril").ToDecimal(), .Color = "#04D215"}) + lista.Add(New With {.Texto = "Mayo", .Valor = e.Row.DataKey("Mayo").ToDecimal(), .Color = "#2A0CD0"}) + lista.Add(New With {.Texto = "Junio", .Valor = e.Row.DataKey("Junio").ToDecimal(), .Color = "#8A0CCF"}) + lista.Add(New With {.Texto = "Julio", .Valor = e.Row.DataKey("Julio").ToDecimal(), .Color = "#CD0D74"}) + lista.Add(New With {.Texto = "Agosto", .Valor = e.Row.DataKey("Agosto").ToDecimal(), .Color = "#754DEB"}) + lista.Add(New With {.Texto = "Septiembre", .Valor = e.Row.DataKey("Septiembre").ToDecimal(), .Color = "#DDDDDD"}) + lista.Add(New With {.Texto = "Octubre", .Valor = e.Row.DataKey("Octubre").ToDecimal(), .Color = "#999999"}) + lista.Add(New With {.Texto = "Noviembre", .Valor = e.Row.DataKey("Noviembre").ToDecimal(), .Color = "#000000"}) + lista.Add(New With {.Texto = "Diciembre", .Valor = e.Row.DataKey("Diciembre").ToDecimal(), .Color = "#FF0F00"}) + e.Row.FCHyperLink("Hypgrafica").Attributes.Add("data-values", Newtonsoft.Json.JsonConvert.SerializeObject(lista)) + End Sub +#End Region + + + +#Region "Anual H O R I Z O N T A L" + + Private Sub CargaDatosAnualH() + + + FechaIMes = $"01/01/{DdlEjercicio.SelectedValue}" + FechaFMes = $"31/12/{DdlEjercicio2.SelectedValue}" + + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + 'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosAnualHorizontal(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario, DdlPeriodo.SelectedValue.ToEntero, Periodo:=DdlPeriodo.SelectedValue.ToEntero) Then + DtDatosAnualH = ObjConta.DtResultados.FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosAnualH = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosAnualH IsNot Nothing Then + CargaGridsAnualH() + + End If + + End Sub + + Private Sub CargaGridsAnualH() + + DtIngresosAnualH = DtDatosAnualH.FiltraParametros("Tipo ='H' ") + DtGastosAnualH = DtDatosAnualH.FiltraParametros("Tipo ='G' ") + DTTotalesAnualH = DtDatosAnualH.Clone() + + Dim Row As DataRow = DtIngresosAnualH.NewRow + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + + + Dim IndexData As Integer = 0 + Dim IndexGv As Integer = 1 + Dim IndexMax As Integer = 1 + + + Dim IDX_LIMPIAR As Integer = 1 + + For IDX_LIMPIAR = 1 To 25 + + GvIngresosAnualH.Columns(IDX_LIMPIAR).Visible = False + GvGastosAnualH.Columns(IDX_LIMPIAR).Visible = False + GvTotalesAnualH.Columns(IDX_LIMPIAR).Visible = False + Next + listaCamposanios.Clear() + listaCamposaniosGastos.Clear() + listaCamposaniosTotal.Clear() + + If DtIngresosAnualH.Rows.Count > 0 Then + + + + + For Each dCoumn As DataColumn In DtIngresosAnualH.Columns + + If IndexData >= 13 Then + + If dCoumn.ColumnName.ToEntero > 0 And dCoumn.ColumnName.ToEntero <= DdlEjercicio2.SelectedValue.ToEntero Then + + CType(GvIngresosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + CType(GvIngresosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + + + listaCamposanios.Add(New String() {dCoumn.ColumnName.ToString(), dCoumn.ColumnName.ToString()}) + + listaCamposaniosTotal.Add(New String() {dCoumn.ColumnName.ToString(), dCoumn.ColumnName.ToString()}) + 'CType(GvIngresosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + 'CType(GvIngresosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + GvIngresosAnualH.Columns(IndexGv).Visible = True + + + CType(GvTotalesAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + CType(GvTotalesAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + 'CType(GvTotalesAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + 'CType(GvTotalesAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + GvTotalesAnualH.Columns(IndexGv).Visible = True + + IndexMax = IndexData + Else + GvIngresosAnualH.Columns(IndexGv).Visible = False + GvTotalesAnualH.Columns(IndexGv).Visible = False + End If + + + + IndexGv = IndexGv + 1 + End If + + IndexData = IndexData + 1 + + Next + + + For Each dr As DataRow In DtIngresosAnualH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + + Next + + IndexData = 13 + For IndexData = 13 To IndexMax + Row.Item(IndexData) = DtIngresosAnualH.SUM($"[{DtIngresosAnualH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (3,4)") + Next + + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = DtIngresosAnualH.SUM("ImporteActual", "NOT CtaMayor in (3,4)") 'TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = DtIngresosAnualH.SUM("ImporteAcumulado", "NOT CtaMayor in (3,4)") 'TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + Row.Item("CountDinamico") = DtGastosAnualH.MAX("CountDinamico") + CountDinamicoAnual = DtGastosAnualH.MAX("CountDinamico").ToEntero + DtIngresosAnualH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosAnualH.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosAnualH.NewRow + + If DtGastosAnualH.Rows.Count > 0 Then + + + IndexData = 0 + IndexGv = 1 + IndexMax = 0 + + For Each dCoumn As DataColumn In DtGastosAnualH.Columns + + If IndexData >= 13 Then + + If dCoumn.ColumnName.ToEntero > 0 And dCoumn.ColumnName.ToEntero <= DdlEjercicio2.SelectedValue.ToEntero Then + 'HyperLinkField + + CType(GvGastosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + CType(GvGastosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + listaCamposaniosGastos.Add(New String() {dCoumn.ColumnName.ToString(), dCoumn.ColumnName.ToString()}) + + 'CType(GvGastosAnualH.Columns(IndexGv), HyperLinkField).DataNavigateUrlFields = {"CveCuenta", "FechaInicial", "FechaFActual", "CveSubProyecto"} + 'CType(GvGastosAnualH.Columns(IndexGv), HyperLinkField).DataNavigateUrlFormatString = "/Contabilidad2/RepAnexoCatalogo.aspx?CveCuenta={0}&FF={1}&FI={2}&ER=1&CveSubProyecto{3}" + + 'CType(GvGastosAnualH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + 'CType(GvGastosAnualH.Columns(IndexGv), BoundField).HeaderText = dCoumn.ColumnName + + GvGastosAnualH.Columns(IndexGv).Visible = True + IndexMax = IndexData + Else + GvGastosAnualH.Columns(IndexGv).Visible = False + End If + + + + IndexGv = IndexGv + 1 + End If + + IndexData = IndexData + 1 + + Next + + + For Each dr As DataRow In DtGastosAnualH.FiltraParametros("Not CtaMayor In (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + IndexData = 13 + For IndexData = 13 To IndexMax + + Row.Item(IndexData) = DtGastosAnualH.SUM($"[{DtIngresosAnualH.Columns(IndexData).ColumnName}]", "Not CtaMayor In (3,4)") + + Next + + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = TotalActual + Row.Item("PorcentajeActual") = If(T1 > 0, (TotalActual * 100 / T1).ToString, "0").FormatoNumero + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = If(T2 > 0, (TotalAnterior * 100 / T2).ToString, "0").FormatoNumero + Row.Item("CtaMayor") = -1 + Row.Item("CountDinamico") = DtGastosAnualH.MAX("CountDinamico") + DtGastosAnualH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosAnualH.Rows.Add(Row) + End If + + If DtIngresosAnualH.Rows.Count > 0 Then + + Row = DTTotalesAnualH.NewRow + + + IndexData = 13 + For IndexData = 13 To IndexMax + Row.Item(IndexData) = DtIngresosAnualH.SUM($"[{DtIngresosAnualH.Columns(IndexData).ColumnName}]", "Not CtaMayor In (-1,3,4)") - DtGastosAnualH.SUM($"[{DtGastosAnualH.Columns(IndexData).ColumnName}]", "Not CtaMayor In (-1,3,4)") + Next + + Row.Item("Nombre") = "Resultados del Ejercicio" + Row.Item("ImporteAcumulado") = DtIngresosAnualH.SUM($"ImporteAcumulado", "Not CtaMayor in (-1,3,4)") - DtGastosAnualH.SUM($"ImporteAcumulado", "Not CtaMayor in (-1,3,4)") + + + DTTotalesAnualH.Rows.Add(Row) + + End If + + GvIngresosAnualH.DataSource = DtIngresosAnualH + GvIngresosAnualH.DataBind() + + GvGastosAnualH.DataSource = DtGastosAnualH + GvGastosAnualH.DataBind() + + GvTotalesAnualH.DataSource = DTTotalesAnualH + GvTotalesAnualH.DataBind() + + UpDatosAnualH.Update() + + End Sub + + + + Protected Sub GvIngresosAnualH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCCAnual(e, listaCamposanios) + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales3" + e.Row.ControlStyle.Font.Bold = True + End If + + + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + Dim CveSubProyecto As Integer = e.Row.DataKey("CveSubProyecto").ToEntero + + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + Dim Anio As String = CType(GvGastosAnualH.Columns(IndiceInicio), BoundField).DataField + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + 'e.Row.Cells(IndiceInicio).ForeColor = If(Importe < 0, Drawing.Color.Red, e.Row.Cells(IndiceInicio).ForeColor) + Next IndiceInicio + + 'e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogo.aspx?CveCuenta={CveCuenta}&FF=31/12/{DdlEjercicio2.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1&CveSubProyecto={CveSubProyecto}" + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + + Next IndiceInicio + + + End If + + + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvGastosAnualH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCCAnual(e, listaCamposaniosGastos) + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + Dim CveSubProyecto As Integer = e.Row.DataKey("CveSubProyecto").ToEntero + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + 'e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto=-1&EjercicioFinal={DdlEjercicio2.SelectedValue}" + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + For IndiceInicio = 1 To IndiceMax + Dim Anio As String = CType(GvGastosAnualH.Columns(IndiceInicio), BoundField).DataField + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00"))}" + 'e.Row.Cells(IndiceInicio).ForeColor = If(Importe < 0, Drawing.Color.Red, e.Row.Cells(IndiceInicio).ForeColor) + Next IndiceInicio + + 'e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogo.aspx?CveCuenta={CveCuenta}&FF=31/12/{DdlEjercicio2.SelectedValue}&FI=01/01/{DdlEjercicio.SelectedValue}&ER=1&CveSubProyecto={CveSubProyecto}" + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoAnual.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&EjercicioFinal={DdlEjercicio2.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + + Next IndiceInicio + + End If + + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvTotalesAnualH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.Header Then + e.Row.Attributes.Add("style", "display:none") + End If + + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCCAnual(e, listaCamposaniosTotal) + e.Row.Attributes.Add("style", "Font-weight: bold") + End If + + End Sub + + Public Sub setgraficaCCAnual(e As GridViewRowEventArgs, listaCampos As List(Of String())) + Dim lista As New List(Of Object) + Dim colorindex As Integer = 0 + For Each campo As String() In listaCampos + lista.Add(New With {.Texto = campo(1), .Valor = e.Row.DBCampo(campo(0)).ToDecimal(), .Color = listacolores(colorindex)}) + colorindex = colorindex + 1 + If colorindex >= listacolores.Count Then + colorindex = 0 + End If + Next + e.Row.FCHyperLink("Hypgrafica").Attributes.Add("data-values", Newtonsoft.Json.JsonConvert.SerializeObject(lista)) + End Sub +#End Region + + +#Region "S U B P R O Y E C T O H O R I Z O N T A L" + + Private Sub CargaDatosSubProyectoH() + + + FechaIMes = $"01/01/{DdlEjercicio.SelectedValue}" + FechaFMes = $"01/{DdlPeriodo.SelectedValue.ToEntero.ToString("00")}/{DdlEjercicio.SelectedValue}" + FechaFMes = DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, CDate(FechaFMes))).ToString("dd/MM/yyyy") + + Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero + + + Dim ObjConta As New ClsContabilidad + If ObjConta.GetEstadosSubProyectoHorizontal(FechaIMes.ToDate, FechaFMes.ToDate, CveSubProyecto, DdlDivisor.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then + DTSubProyectosCabecerasH = ObjConta.DSResultados.Tables(0) + DtDatosSubProyectoH = ObjConta.DSResultados.Tables(1).FiltraParametros("(ImporteActual <> 0 OR ImporteAcumulado <> 0)") + Else + DtDatosSubProyectoH = Nothing + Alert("Ocurrio un error al cargar los datos del Estado de Actividades", TipoMensaje.MsgError) + End If + ObjConta.Dispose() + + If DtDatosSubProyectoH IsNot Nothing And DTSubProyectosCabecerasH IsNot Nothing Then + CargaGridsSubProyectoH() + End If + + End Sub + + Private Sub CargaGridsSubProyectoH() + + DtIngresosSubProyectoH = DtDatosSubProyectoH.FiltraParametros("Tipo ='H' ") + DtGastosSubProyectoH = DtDatosSubProyectoH.FiltraParametros("Tipo ='G' ") + DTTotalesSubProyectoH = DtDatosSubProyectoH.Clone() + + Dim Row As DataRow = DtIngresosSubProyectoH.NewRow + + Dim TotalActual = 0.0, TotalAnterior = 0.0 + + + Dim IndexData As Integer = 0 + Dim IndexGv As Integer = 1 + Dim IndexMax As Integer = 1 + Dim IndexSubProyecto = 0 + Dim IndexSubProyectoMAx As Integer = DTSubProyectosCabecerasH.Rows.Count - 1 + Dim IndexTotatles As Integer = 13 + IndexSubProyectoMAx + + '34 + Dim IDX_LIMPIAR As Integer = 1 + + For IDX_LIMPIAR = 1 To 35 + CType(GvIngresosSubProyectoH.Columns(IDX_LIMPIAR), BoundField).DataField = Nothing + CType(GvIngresosSubProyectoH.Columns(IDX_LIMPIAR), BoundField).HeaderText = "" + GvIngresosSubProyectoH.Columns(IDX_LIMPIAR).Visible = False + Next + listaCampos.Clear() + + + If DtIngresosSubProyectoH.Rows.Count > 0 Then + + For Each dCoumn As DataColumn In DtIngresosSubProyectoH.Columns + + If IndexData >= 13 Then + + If IndexSubProyecto <= IndexSubProyectoMAx Then + + CType(GvIngresosSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvIngresosSubProyectoH.Columns(IndexGv).Visible = True + + CType(GvTotalesSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvTotalesSubProyectoH.Columns(IndexGv).Visible = True + + If IndexSubProyecto <= IndexSubProyectoMAx Then + CType(GvIngresosSubProyectoH.Columns(IndexGv), BoundField).HeaderText = DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString + CType(GvTotalesSubProyectoH.Columns(IndexGv), BoundField).HeaderText = DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString + CType(GvGastosSubProyectoH.Columns(IndexGv), BoundField).HeaderText = DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString + End If + listaCampos.Add(New String() {dCoumn.ColumnName.ToString(), DTSubProyectosCabecerasH.Rows(IndexSubProyecto)(0).ToString()}) + Else + GvIngresosSubProyectoH.Columns(IndexGv).Visible = False + GvTotalesSubProyectoH.Columns(IndexGv).Visible = False + End If + + IndexGv = IndexGv + 1 + IndexSubProyecto = IndexSubProyecto + 1 + IndexMax = IndexMax + 1 + + End If + IndexData = IndexData + 1 + Next + + + For Each dr As DataRow In DtIngresosSubProyectoH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + IndexData = 13 + For IndexData = 13 To IndexTotatles + Row.Item(IndexData) = DtIngresosSubProyectoH.SUM($"[{DtIngresosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (3,4)") + Next + + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = DtIngresosSubProyectoH.SUM("ImporteActual", "NOT CtaMayor in (3,4)") 'TotalActual.ToString + Row.Item("PorcentajeActual") = "100.00" + Row.Item("ImporteAcumulado") = DtIngresosSubProyectoH.SUM("ImporteAcumulado", "NOT CtaMayor in (3,4)") 'TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = "100.00" + Row.Item("CtaMayor") = -1 + Row.Item("CountDinamico") = DtIngresosSubProyectoH.MAX("CountDinamico") + CountDinamicoSubProyecto = DtIngresosSubProyectoH.MAX("CountDinamico").ToEntero + DtIngresosSubProyectoH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL INGRESOS " + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtIngresosSubProyectoH.Rows.Add(Row) + End If + + Dim T1 = TotalActual, T2 = TotalAnterior + + TotalActual = 0 + TotalAnterior = 0 + + Row = DtGastosSubProyectoH.NewRow + + If DtGastosSubProyectoH.Rows.Count > 0 Then + + + IndexData = 0 + IndexGv = 1 + IndexMax = 0 + IndexSubProyecto = 0 + + For Each dCoumn As DataColumn In DtIngresosSubProyectoH.Columns + If IndexData >= 13 Then + If IndexSubProyecto <= IndexSubProyectoMAx Then + CType(GvGastosSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvGastosSubProyectoH.Columns(IndexGv).Visible = True + CType(GvTotalesSubProyectoH.Columns(IndexGv), BoundField).DataField = dCoumn.ColumnName + GvTotalesSubProyectoH.Columns(IndexGv).Visible = True + Else + GvIngresosSubProyectoH.Columns(IndexGv).Visible = False + GvTotalesSubProyectoH.Columns(IndexGv).Visible = False + End If + + IndexGv = IndexGv + 1 + IndexSubProyecto = IndexSubProyecto + 1 + End If + IndexData = IndexData + 1 + Next + + + + For Each dr As DataRow In DtGastosSubProyectoH.FiltraParametros("NOT CtaMayor in (3,4)").Rows + TotalActual += dr("ImporteActual").ToString.ToDouble + TotalAnterior += dr("ImporteAcumulado").ToString.ToDouble + Next + + IndexData = 13 + For IndexData = 13 To IndexTotatles + Row.Item(IndexData) = DtGastosSubProyectoH.SUM($"[{DtIngresosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (3,4)") + Next + + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = TotalActual + Row.Item("PorcentajeActual") = If(T1 > 0, (TotalActual * 100 / T1).ToString, "0").FormatoNumero + Row.Item("ImporteAcumulado") = TotalAnterior.ToString + Row.Item("PorcentajeAcumulado") = If(T2 > 0, (TotalAnterior * 100 / T2).ToString, "0").FormatoNumero + Row.Item("CtaMayor") = -1 + Row.Item("CountDinamico") = DtGastosSubProyectoH.MAX("CountDinamico") + + DtGastosSubProyectoH.Rows.Add(Row) + Else + Row.Item("Nombre") = "TOTAL GASTOS" + Row.Item("ImporteActual") = "0.00" + Row.Item("ImporteAcumulado") = "0.00" + Row.Item("CtaMayor") = -1 + DtGastosSubProyectoH.Rows.Add(Row) + End If + + If DtIngresosSubProyectoH.Rows.Count > 0 Then + + Row = DTTotalesSubProyectoH.NewRow + + IndexData = 13 + For IndexData = 13 To IndexTotatles + Row.Item(IndexData) = DtIngresosSubProyectoH.SUM($"[{DtIngresosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (-1,3,4)") - DtGastosSubProyectoH.SUM($"[{DtGastosSubProyectoH.Columns(IndexData).ColumnName}]", "NOT CtaMayor in (-1,3,4)") + Next + + Row.Item("Nombre") = "Resultado del ejercicio" + Row.Item("ImporteAcumulado") = DtIngresosSubProyectoH.SUM($"ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") - DtGastosSubProyectoH.SUM($"ImporteAcumulado", "NOT CtaMayor in (-1,3,4)") + Row.Item("CtaMayor") = -2 + Row.Item("CountDinamico") = DtIngresosSubProyectoH.MAX("CountDinamico") + + DTTotalesSubProyectoH.Rows.Add(Row) + + End If + + DtIngresosSubProyectoH.Merge(DtGastosSubProyectoH) + DtIngresosSubProyectoH.Merge(DTTotalesSubProyectoH) + + + GvIngresosSubProyectoH.DataSource = DtIngresosSubProyectoH + GvIngresosSubProyectoH.DataBind() + + + + UpDatosSubProyectoH.Update() + + End Sub + + 'Private Sub SumaTotalesSubProyectoH() + ' ''Llena Lb´s Totales + ' ''********************************************************************************* + ' 'LbTotalActual.Text = TotalActualMes.ToString.FormatoNumero + ' 'LbTotalAnterior.Text = TotalAnteriorMes.ToString.FormatoNumero + + ' 'LbTotalActual.ForeColor = If(TotalActualMes < 0, Drawing.Color.Red, Color.Black) + ' 'LbTotalAnterior.ForeColor = If(TotalAnteriorMes < 0, Drawing.Color.Red, Color.Black) + + + 'End Sub + + Protected Sub GvIngresosSubProyectoH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + TotalActualMes += e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes += e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + 'e.Row.ControlStyle.BackColor = Drawing.Color.LightGray + 'e.Row.ControlStyle.ForeColor = Drawing.Color.White + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales3" + e.Row.ControlStyle.Font.Bold = True + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -2 Then + + e.Row.ControlStyle.Font.Bold = True + e.Row.ControlStyle.Font.Size = 13 + End If + Dim CveCuenta As Integer = e.Row.DataKey("CveCuenta").ToEntero + setgraficaCC(e) + 'Dim CveSubProyecto As Integer = e.Row.DataKey("CveSubProyecto").ToEntero + If e.Row.DBCampo("CtaMayor").ToString.ToEntero > 0 Then + + e.Row.FCHyperLink("HLNombre").NavigateUrl = $"./RepAnexoCatalogoCC.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + Dim FEchaMesFinal As Date = New Date(DdlEjercicio.SelectedValue.ToEntero, DdlPeriodo.SelectedValue.ToEntero, 1).LastDayOfMonth + + For IndiceInicio = 1 To IndiceMax + + Dim CveSubProyectoIntermo As String = CType(GvGastosSubProyectoH.Columns(IndiceInicio), BoundField).DataField + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + + + If CveSubProyectoIntermo.ToEntero > 0 Then + e.Row.Cells(IndiceInicio).Text = $"{ If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }" + End If + + + + Next IndiceInicio + + e.Row.FCHyperLink("HLAnterior").NavigateUrl = $"./RepAnexoCatalogoCC.aspx?CveCuenta={e.Row.DBCampo("CveCuenta").ToString}&Ejercicio={DdlEjercicio.SelectedValue}&Divisor={DdlDivisor.SelectedValue}&CveSubProyecto={DdlSubproyecto.SelectedValue}&Periodo={DdlPeriodo.SelectedValue}" + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -1 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"
    { If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }
    " + Next IndiceInicio + + + + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = -2 Then + + Dim CountDinamico As Integer = e.Row.DataKey("CountDinamico").ToEntero + Dim IndiceInicio As Integer = 1 + Dim IndiceMax As Integer = 1 + CountDinamico + + For IndiceInicio = 1 To IndiceMax + + Dim Importe As Decimal = e.Row.Cells(IndiceInicio).Text.ToDecimal + e.Row.Cells(IndiceInicio).Text = $"
    { If(DdlDivisor.SelectedValue.ToEntero > 1, Importe.ToString("###,###,##0"), Importe.ToString("###,###,###.00")) }
    " + + Next IndiceInicio + + + End If + e.Row.FCHyperLink("HLAnterior").Text = If(DdlDivisor.SelectedValue.ToEntero > 1, e.Row.DBCampo("ImporteAcumulado").ToString.ToDecimal.ToString("###,###,##0"), e.Row.DBCampo("ImporteAcumulado").ToString.ToDecimal.ToString("###,###,##0.00")) + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + + End If + + End Sub + + Protected Sub GvGastosSubProyectoH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCC(e) + If e.Row.DBCampo("CtaMayor").ToString.ToEntero < 0 Then + TotalActualMes -= e.Row.DBCampo("ImporteActual").ToString.ToDouble + TotalAnteriorMes -= e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble + e.Row.ControlStyle.Font.Bold = True + ElseIf e.Row.DBCampo("CtaMayor").ToString.ToEntero = 3 Then + 'e.Row.CssClass = "SubTotales" + e.Row.ControlStyle.Font.Bold = True + End If + If e.Row.DBCampo("ImporteAcumulado").ToString.ToDouble < 0 Then + e.Row.FCHyperLink("HLAnterior").ForeColor = Drawing.Color.Red + End If + End If + End Sub + + Protected Sub GvTotalesSubProyectoH_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.Header Then + ' e.Row.Attributes.Add("style", "display:none") + End If + If e.Row.RowType = DataControlRowType.DataRow Then + setgraficaCC(e) + e.Row.Attributes.Add("style", "Font-weight: bold") + End If + End Sub + + Public Sub setgraficaCC(e As GridViewRowEventArgs) + Dim lista As New List(Of Object) + Dim colorindex As Integer = 0 + For Each campo As String() In listaCampos + lista.Add(New With {.Texto = campo(1), .Valor = e.Row.DBCampo(campo(0)).ToDecimal(), .Color = listacolores(colorindex)}) + colorindex = colorindex + 1 + If colorindex >= listacolores.Count Then + colorindex = 0 + End If + Next + e.Row.FCHyperLink("Hypgrafica").Attributes.Add("data-values", Newtonsoft.Json.JsonConvert.SerializeObject(lista)) + End Sub +#End Region + + + + + +#Region "DESCARGA EXCEL" + + Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click + Imprimir("Excel") + End Sub + + Private Sub Imprimir(Optional reporte As String = "PDF") + + + If TAB.ActiveTabIndex = 0 AndAlso GvIngresosMes.Rows.Count > 0 Then + ExportToExcelG(GvIngresosMes, GvGastosMes, TMesT1, "Reporte_Mensual", UsuarioActual, "Mensual") + ElseIf TAB.ActiveTabIndex = 1 AndAlso GvIngresosMesH.Rows.Count > 0 Then + ExportToExcelG(GvIngresosMesH, GvGastosMesH, TMesT1, "Reporte_Mensual_Horizontal", UsuarioActual, "Mensual Horizontal", Gv3:=GvTotalesMesH) + ElseIf TAB.ActiveTabIndex = 2 AndAlso GvIngresosAnualH.Rows.Count > 0 Then + ExportToExcelG(GvIngresosAnualH, GvGastosAnualH, TMesT1, "Reporte_Anual_Horizontal", UsuarioActual, "Anual Horizontal", Gv3:=GvTotalesAnualH) + + ElseIf TAB.ActiveTabIndex = 3 AndAlso GvIngresosSubProyectoH.Rows.Count > 0 Then + + ExportToExcelG(GvIngresosSubProyectoH, GvGastosSubProyectoH, TMesT1, "Reporte_Proyecto_Horizontal", UsuarioActual, $"Estado de Resultados Horizontal por {LblSubProyecto.Text}", Gv3:=GvTotalesSubProyectoH, EsPorSubProtyecto:=True) + + End If + + + End Sub + + 'Public Sub ExportToExcelG(Gv1 As GridView, Gv2 As GridView, NombreArchivoXLSx As String, Optional Titulo As String = "Reporte", Optional Usuario As Usuario = Nothing, Optional Filtros As String = "", Optional AlturaImagen As Double = 100, Optional AnchoImagen As Double = 100) + Public Sub ExportToExcelG(Gv1 As GridView, Gv2 As GridView, TablaResultados As HtmlTable, NombreArchivoXLSx As String, Usuario As Usuario, Titulo As String, Optional AlturaImagen As Double = 100, Optional AnchoImagen As Double = 100, Optional Gv3 As GridView = Nothing, Optional EsPorSubProtyecto As Boolean = False) + + Dim sw1 As New StringWriter() + Dim htw1 As New HtmlTextWriter(sw1) + Gv1.RenderControl(htw1) + + Dim sw2 As New StringWriter() + Dim htw2 As New HtmlTextWriter(sw2) + Gv2.RenderControl(htw2) + + + TablaResultados.Width = Gv2.Width.ToString + + Dim sw3 As New StringWriter() + Dim htw3 As New HtmlTextWriter(sw3) + TablaResultados.RenderControl(htw3) + + Dim options = GemBox.Spreadsheet.LoadOptions.HtmlDefault + + Dim htmlStream1 = New MemoryStream(options.Encoding.GetBytes(sw1.ToString())) + Dim htmlStream2 = New MemoryStream(options.Encoding.GetBytes(sw2.ToString())) + Dim htmlStream3 = New MemoryStream(options.Encoding.GetBytes(sw3.ToString())) + + htmlStream1.Position = 0 + Dim sr1 As New StreamReader(htmlStream1) + + htmlStream2.Position = 0 + Dim sr2 As New StreamReader(htmlStream2) + + htmlStream3.Position = 0 + Dim sr3 As New StreamReader(htmlStream3) + + + Dim myStr1 = sr1.ReadToEnd() + Dim myStr2 = sr2.ReadToEnd() + Dim myStr3 = sr3.ReadToEnd() + + sr1.Dispose() + sr2.Dispose() + sr3.Dispose() + + htmlStream1.Dispose() + htmlStream2.Dispose() + htmlStream3.Dispose() + + sw1.Dispose() + sw2.Dispose() + sw3.Dispose() + + If Gv3 IsNot Nothing Then + + Gv3.ShowHeader = False + + Dim sw4 As New StringWriter() + Dim htw4 As New HtmlTextWriter(sw4) + Gv3.RenderControl(htw4) + Dim htmlStream4 = New MemoryStream(options.Encoding.GetBytes(sw4.ToString())) + htmlStream4.Position = 0 + Dim sr4 As New StreamReader(htmlStream4) + myStr3 = sr4.ReadToEnd() + + sr4.Dispose() + htmlStream2.Dispose() + sw4.Dispose() + + End If + + + Dim HtmlCompleto As String = myStr1 & "
    " & myStr2 & "
    " & myStr3 + + + HtmlCompleto = Regex.Replace(HtmlCompleto, "\<[\/]*a[^\>]*\>", "") + + + Dim htmlStream5 = New MemoryStream(options.Encoding.GetBytes(HtmlCompleto)) + + GemBox.Spreadsheet.SpreadsheetInfo.SetLicense(SerialGemBoxSpreadsheet) + + Dim excel As GemBox.Spreadsheet.ExcelFile + + excel = GemBox.Spreadsheet.ExcelFile.Load(htmlStream5, options) + + If Usuario IsNot Nothing Then + + Dim TotalRowHeader As Integer = 8 + Dim TotalRowFooter As Integer = 2 + + + Dim worksheet = excel.Worksheets(0) + worksheet.Rows.InsertEmpty(0, TotalRowHeader) + Dim celdasConTexto = worksheet.GetUsedCellRange(True) + celdasConTexto.Style.Font.Name = "Calibri Light" + + Dim RangoNombreEmpresa = worksheet.Cells.GetSubrangeAbsolute(1, celdasConTexto.FirstColumnIndex, 1, celdasConTexto.LastColumnIndex) + RangoNombreEmpresa.Merged = True + RangoNombreEmpresa.Value = Usuario.Empresa.Empresa + RangoNombreEmpresa.Style.Font.Size = 18 * 20 + RangoNombreEmpresa.Style.Font.Name = "Calibri Light" + RangoNombreEmpresa.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoNombreEmpresa.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + + Dim RangoTitulo = worksheet.Cells.GetSubrangeAbsolute(3, celdasConTexto.FirstColumnIndex, 3, celdasConTexto.LastColumnIndex) + RangoTitulo.Merged = True + RangoTitulo.Value = Titulo + RangoTitulo.Style.Font.Size = 20 * 20 + RangoTitulo.Style.Font.Name = "Calibri Light" + RangoTitulo.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoTitulo.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + Dim RangoFechas = worksheet.Cells.GetSubrangeAbsolute(4, celdasConTexto.FirstColumnIndex, 4, celdasConTexto.LastColumnIndex) + RangoFechas.Merged = True + RangoFechas.Value = $"Fechas: {FechaIMes} a {FechaFMes}" + RangoFechas.Style.Font.Size = 15 * 20 + RangoFechas.Style.Font.Name = "Calibri Light" + RangoFechas.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoFechas.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + + If EsPorSubProtyecto And DdlSubproyecto.SelectedValue.ToEntero > 0 Then + Dim RangoSubProyecto = worksheet.Cells.GetSubrangeAbsolute(5, celdasConTexto.FirstColumnIndex, 5, celdasConTexto.LastColumnIndex) + RangoSubProyecto.Merged = True + RangoSubProyecto.Value = DdlSubproyecto.SelectedItem.Text + RangoSubProyecto.Style.Font.Size = 20 * 20 + RangoSubProyecto.Style.Font.Name = "Calibri Light" + RangoSubProyecto.Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + RangoSubProyecto.Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + End If + + For i = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex + + worksheet.Rows(8).Cells(i).Style.Font.Size = 12 * 20 + worksheet.Rows(8).Cells(i).Style.HorizontalAlignment = GemBox.Spreadsheet.HorizontalAlignmentStyle.Center + worksheet.Rows(8).Cells(i).Style.VerticalAlignment = GemBox.Spreadsheet.VerticalAlignmentStyle.Center + + worksheet.Rows(8).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(8).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255) + + + + If Not EsPorSubProtyecto Then + worksheet.Rows(8 + Gv1.Rows.Count + 2).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(8 + Gv1.Rows.Count + 2).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255) + Else + worksheet.Rows(18).Cells(i).Style.FillPattern.SetPattern(GemBox.Spreadsheet.FillPatternStyle.Solid, GemBox.Spreadsheet.SpreadsheetColor.FromArgb(75, 119, 190), GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255)) + worksheet.Rows(18).Cells(i).Style.Font.Color = GemBox.Spreadsheet.SpreadsheetColor.FromArgb(255, 255, 255) + End If + + + + If i > 0 Then + Try + worksheet.Columns(i).AutoFit(1) + Catch ex As Exception + End Try + End If + Next + + Dim IndexEndTable As Integer = Gv1.Rows.Count + Gv2.Rows.Count + 4 + TotalRowHeader + TotalRowFooter + + worksheet.Rows(IndexEndTable).Cells(0).Value = "Usuario Imprimió" + worksheet.Rows(IndexEndTable + 1).Cells(0).Value = Usuario.Nombre + + worksheet.Rows(IndexEndTable).Cells(2).Value = "Fecha Impresión" + worksheet.Rows(IndexEndTable + 1).Cells(2).Value = DateTime.Now.ToString("dd/MM/yyyy") + + Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", Usuario.Empresa.Ruta)) + + If Imagen.Exists Then + Dim Ruta As String = String.Format("{0}/Logo.png", Usuario.Empresa.Ruta) + Using sr As New StreamReader(Ruta) + Dim ms As New MemoryStream() + sr.BaseStream.CopyTo(ms) + worksheet.Pictures.Add(ms, ExcelPictureFormat.Png, "A1", AnchoImagen, AlturaImagen, LengthUnit.Pixel) + End Using + End If + + + + + + + For I = celdasConTexto.FirstColumnIndex To celdasConTexto.LastColumnIndex + + If I > 0 Then + + If DdlDivisor.SelectedValue.ToEntero = 1 Then + worksheet.Columns(I + 1).Style.NumberFormat = "#,##0.00" + Else + worksheet.Columns(I + 1).Style.NumberFormat = "#,##" + End If + + Try + worksheet.Columns(I).AutoFit(1) + Catch ex As Exception + End Try + + End If + Next + + End If + + excel.Save(HttpContext.Current.Response, $"{NombreArchivoXLSx}.xlsx") + + + End Sub + + Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) + End Sub + +#End Region + + + + + +End Class + diff --git a/Inventarios/RecepcionAlmacen.aspx.vb b/Inventarios/RecepcionAlmacen.aspx.vb index 53d9e0acb..5022d6ebb 100644 --- a/Inventarios/RecepcionAlmacen.aspx.vb +++ b/Inventarios/RecepcionAlmacen.aspx.vb @@ -732,7 +732,7 @@ Partial Class Inventarios_RecepcionAlmacen ObjInventarios.Dispose() DdlIndirectoFactura.DataBind() - DdlIndirectoFactura.Items.Insert(0, New ListItem("Todos", "-1")) + 'DdlIndirectoFactura.Items.Insert(0, New ListItem("Todos", "-1")) End Sub @@ -2270,6 +2270,10 @@ Partial Class Inventarios_RecepcionAlmacen Dim ObjContaContPAQ As ClsContPAQi = Nothing 'ENTREGA DIRECTA + + Dim MovtosEntradaExA As New List(Of Integer) + Dim FoliosEntradaExA As New List(Of Integer) + Dim MovtosSalidaDirecta As New List(Of Integer) Dim FoliosSalidaDirecta As New List(Of Integer) @@ -2548,36 +2552,42 @@ Partial Class Inventarios_RecepcionAlmacen Dim CveVenta As Integer = DrVenta("CveVenta").ToString().ToEntero() - CveMovtoSalidaDirecta = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 3, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, - CveVenta, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, TipoCambio:=If(DdlMonedaTC.SelectedValue.ToEntero = 1, -1, TipoCambio), - MovimientoFijo:=True, CveMovimientoRelacionado:=CveMovimiento, Remision:=TxtRemision.Text, CveVendedor:=CveVendedor, CveCliente:=CveCliente, Modulo:="RA/G2") - FolioSalidaDirecta = ObjInventario.Folio + Dim ObjFactura As New Modelos.Factura(UsuarioActual, CveVenta, UsuarioActual.CveEmpresa) - If Not CveMovtoSalidaDirecta > 0 Then - ErrorMovInv = True - Exit For - End If + Dim DtDetalleMovimiento As DataTable = Dt.FiltraParametros($"CveVenta={ObjFactura.CveVenta}") - If Not ErrorMovInv AndAlso Dt IsNot Nothing Then - For Each Dr As DataRow In Dt.FiltraParametros($"CveVenta={CveVenta}").Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovtoSalidaDirecta, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then - ErrorMovInv = True - Exit For - End If - Next - End If + If ObjFactura.TipoDocto = "Ing" Then + Dim MovSalida = GenerarMovimientoAlmacenVenta(DdlAlmacen.SelectedValue.ToEntero(), 3, ObjFactura.CveVenta, CveMovimiento, DtDetalleMovimiento, ObjInventario, ObjConta, ObjContaContPAQ, EsContabilizable, "RA/G2") - If Not ErrorMovInv Then - If Not GeneraPrePolizaSalidaEntregaDirecta(CveMovtoSalidaDirecta, ObjInventario, ObjConta, ObjContaContPAQ, EsContabilizable) Then - ErrorMovInv = True - Exit For + ErrorMovInv = MovSalida.CveMovimiento <= 0 + + If Not ErrorMovInv Then + MovtosSalidaDirecta.Add(MovSalida.CveMovimiento) + FoliosSalidaDirecta.Add(MovSalida.Folio) End If + + ElseIf ObjFactura.TipoDocto = "Rem" Then + Dim MovSalidaExA = GenerarMovimientoAlmacenVenta(DdlAlmacen.SelectedValue.ToEntero(), 8, ObjFactura.CveVenta, -1, DtDetalleMovimiento, ObjInventario, ObjConta, ObjContaContPAQ, False, "RA/G2R1") + + ErrorMovInv = MovSalidaExA.CveMovimiento <= 0 + + If Not ErrorMovInv Then + MovtosSalidaDirecta.Add(MovSalidaExA.CveMovimiento) + FoliosSalidaDirecta.Add(MovSalidaExA.Folio) + + Dim MovEntradaExA = GenerarMovimientoAlmacenVenta(ObjFactura.CveAlmacenTraspasoDestino, 9, ObjFactura.CveVenta, MovSalidaExA.CveMovimiento, DtDetalleMovimiento, ObjInventario, ObjConta, ObjContaContPAQ, False, "RA/G2R2") + + ErrorMovInv = MovEntradaExA.CveMovimiento <= 0 + + If Not ErrorMovInv Then + MovtosEntradaExA.Add(MovEntradaExA.CveMovimiento) + FoliosEntradaExA.Add(MovEntradaExA.Folio) + End If + + End If + End If - If Not ErrorMovInv Then - MovtosSalidaDirecta.Add(CveMovtoSalidaDirecta) - FoliosSalidaDirecta.Add(FolioSalidaDirecta) - End If Next If Not ErrorMovInv Then @@ -3307,6 +3317,14 @@ Partial Class Inventarios_RecepcionAlmacen 'ENTREGA DIRECTA If MovtosSalidaDirecta.Count > 0 Then Msg.AppendFormat("

    Movimientos de control:
    ") + + If MovtosEntradaExA.Count > 0 Then + For index = 0 To MovtosEntradaExA.Count - 1 + link = String.Format("{1}", MovtosEntradaExA(index), FoliosEntradaExA(index)) + Msg.AppendFormat("
    Movimiento de Entrada Folio: {0}", link) + Next + End If + For index = 0 To MovtosSalidaDirecta.Count - 1 link = String.Format("{1}", MovtosSalidaDirecta(index), FoliosSalidaDirecta(index)) Msg.AppendFormat("
    Movimiento de Salida Folio: {0}", link) @@ -3355,6 +3373,45 @@ Partial Class Inventarios_RecepcionAlmacen If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose() If ObjContaContPAQ IsNot Nothing Then ObjContaContPAQ.Dispose() End Sub + + Private Function GenerarMovimientoAlmacenVenta(CveAlmacen As Integer, CveConceptoAlmacen As Integer, CveVenta As Integer, CveMovimientoRelacionado As Integer, DtDetalle As DataTable, ObjInventario As ClsInventarios, ObjConta As ClsContabilidad, ObjContaContPAQ As ClsContPAQi, EsContabilizable As Boolean, Modulo As String) As MMovimientoAlmacen + Dim ErrorMovInv As Boolean = False + Dim Retorno As New MMovimientoAlmacen + + Dim CveMovtoSalidaDirecta As Integer = -1 + Dim FolioSalidaDirecta As Integer = -1 + + CveMovtoSalidaDirecta = ObjInventario.AddMovimiento(CveAlmacen, CveConceptoAlmacen, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, + CveVenta, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, TipoCambio:=If(DdlMonedaTC.SelectedValue.ToEntero = 1, -1, TipoCambio), + MovimientoFijo:=True, CveMovimientoRelacionado:=CveMovimientoRelacionado, Remision:=TxtRemision.Text, CveVendedor:=CveVendedor, CveCliente:=CveCliente, Modulo:=Modulo) + FolioSalidaDirecta = ObjInventario.Folio + + If Not CveMovtoSalidaDirecta > 0 Then + ErrorMovInv = True + End If + + If Not ErrorMovInv AndAlso DtDetalle IsNot Nothing Then + For Each Dr As DataRow In DtDetalle.Rows + If Not ObjInventario.AddMovimientoDetalle(CveMovtoSalidaDirecta, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, CveAF:=Dr("CveAF").ToString.ToEntero, CveSeccionAlmacen:=Dr("CveSeccionAlmacen").ToString.ToEntero, Serie:=Dr("Serie").ToString, Lote:=Dr("Lote").ToString, FechaCaducidad:=Dr("FechaCaducidad").ToString.ToDate, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then + ErrorMovInv = True + Exit For + End If + Next + End If + + If Not ErrorMovInv AndAlso CveConceptoAlmacen = 3 Then + If Not GeneraPrePolizaSalidaEntregaDirecta(CveMovtoSalidaDirecta, ObjInventario, ObjConta, ObjContaContPAQ, EsContabilizable) Then + ErrorMovInv = True + End If + End If + + If Not ErrorMovInv Then + Retorno.CveMovimiento = CveMovtoSalidaDirecta + Retorno.Folio = FolioSalidaDirecta + End If + + Return Retorno + End Function Private Sub GuardaImportacionFlete() Dim CveMovimiento As Integer Dim InvFolio As String = "" @@ -4283,3 +4340,9 @@ Partial Class Inventarios_RecepcionAlmacen End Class + +Public Class MMovimientoAlmacen + Public Property CveMovimiento As Integer + Public Property Folio As Integer + +End Class diff --git a/Inventarios/TrasladoSolicitud.aspx b/Inventarios/TrasladoSolicitud.aspx index 5e5b351c2..ea4114667 100644 --- a/Inventarios/TrasladoSolicitud.aspx +++ b/Inventarios/TrasladoSolicitud.aspx @@ -234,35 +234,39 @@
    - - -
    + + + -
    - +
    + +
    +
    - - - + + + -
    Estado :
    Usuario :
    Fecha :
    Estado :
    Usuario :
    Fecha :
    + +
    +
    -
    - - - -
    - +
    -
    - -
    -
    - -
    +
    + +
    +
    + +
    -
    +
    + + + + + diff --git a/Inventarios/TrasladoSolicitud.aspx.vb b/Inventarios/TrasladoSolicitud.aspx.vb index 13286849f..baf983a9c 100644 --- a/Inventarios/TrasladoSolicitud.aspx.vb +++ b/Inventarios/TrasladoSolicitud.aspx.vb @@ -285,6 +285,9 @@ Partial Class Inventarios_TrasladoSolicitud Else Alert("Ocurrió un error al obtener los datos del traspaso.", TipoMensaje.MsgError) End If + + UpAutorizaciones.Update() + End If ObjInventarios.Dispose() ObjClientes.Dispose() @@ -1034,6 +1037,9 @@ Partial Class Inventarios_TrasladoSolicitud MandaCorreoRechazo(LbFolio.Text.ToEntero, CveTraspasoSolicitud, CveUsuarioSolicita, TxtMotivoRechazo.Text) CargaDatos() RegistraScript("$('#ModalRechazarTraslado').modal('hide');") + + + End If End Sub diff --git a/Sistemas/Empresa.aspx b/Sistemas/Empresa.aspx index 65c1c9719..0c560e540 100644 --- a/Sistemas/Empresa.aspx +++ b/Sistemas/Empresa.aspx @@ -1327,6 +1327,11 @@ + + + + + diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx index 3c9ac4d86..391f5f8cb 100644 --- a/Ventas/Clientes.aspx +++ b/Ventas/Clientes.aspx @@ -1921,7 +1921,9 @@ - +
    + @@ -1931,6 +1933,9 @@ + + + @@ -1974,6 +1979,8 @@ +
    + @@ -2003,14 +2010,15 @@
    -
    +
    " style="display: inline-block; margin-right: -20px; width: 150px;" /> " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info">
    -
    +

    +
    @@ -2052,6 +2060,7 @@ +
    diff --git a/Ventas/ProductosServicios.aspx.vb b/Ventas/ProductosServicios.aspx.vb index e4ea4d42e..6a56b6f1a 100644 --- a/Ventas/ProductosServicios.aspx.vb +++ b/Ventas/ProductosServicios.aspx.vb @@ -911,7 +911,7 @@ Partial Class ProductosyServicios Public Sub CargaDdlSATPS() DdlSATPS.setEsWebService(True) - DdlSATPS.Attributes.Add("data-metodo", "getpssat") + DdlSATPS.ddlWS.Attributes.Add("data-metodo", "getpssat") End Sub Public Sub CargaDdlFraccionArancelaria() @@ -1123,6 +1123,10 @@ Partial Class ProductosyServicios End Sub Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click + If DdlSATPS.SelectedValue = "46920" Then + Alert("El Producto Servicio SAT con clave '01010101' no es valido, por favor seleccione otro", TipoMensaje.MsgAdvertencia) + Exit Sub + End If If TxtPS.Text.Trim.Length = 0 Or DdlTipoPS.SelectedValue.ToEntero <= 0 Or DdlUnidadMedida.SelectedValue.ToEntero <= 0 Or DdlClasificacion.SelectedValue.ToEntero <= 0 Then Alert("Los campos Producto/Servicio, Tipo, Unidad de medida, Clasificación Contable son requeridos por favor ingreselos.", TipoMensaje.MsgAdvertencia) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index c560d8455..f66c6c5ef 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -1782,6 +1782,15 @@ Partial Class Ventas End Set End Property + Private Property VentaDesglosaIEPS As Boolean + Get + Return CBool(IfNull(ViewState("VentaDesglosaIEPS"), "False", ViewState("VentaDesglosaIEPS"))) + End Get + Set(value As Boolean) + ViewState("VentaDesglosaIEPS") = value + End Set + End Property + #End Region '#Region "AuxiliarConta" @@ -5325,8 +5334,7 @@ Partial Class Ventas CargarAlmacenes() - If UsuarioActual.Empresa.FacturaProduccion Then - End If + CargaDocumentacionCliente() If UsuarioActual.CveEmpresa.Contiene(72, 80, 1, 119) Then @@ -8483,7 +8491,7 @@ Partial Class Ventas ObjFactura.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {DdlMoneda.SelectedValue}") ObjFactura.TipoDocto = If(IfNull(ViewState("CveRemision"), 0).ToString().ToEntero() > 0, "Ing", DdlTipoComprobante.SelectedValue) ObjFactura.FacturarSucursal = (Me.FacturarSucursal AndAlso DdlSucursalCliente.SelectedValue.ToEntero() > 0 AndAlso (Me.ClienteSucursal IsNot Nothing AndAlso Not String.IsNullOrEmpty(Me.ClienteSucursal.RFC))) - + ObjFactura.VentaDesglosaIEPS = Me.VentaDesglosaIEPS 'ObjFactura.RefDocto = TxtDocto.Text.Trim 'si es cancelacion, debe de conservar el folio actual If Not EsCancelacion Then ObjFactura.Folio = If(EstablecioFolio Or VistaPrevia Or (CveVenta > 0 And (NuevaFactura.Contiene(0, 2))), TxtFolio.Text.Trim.ToEntero(), -1) @@ -9868,16 +9876,23 @@ Partial Class Ventas ObjClientes.Dispose() + BtnEmitirImprimir.Text = "Facturar" + 'REGISTRAR UNA ENTREGA DIRECTA If TmpDT.COUNT("EntregaDirecta", "EntregaDirecta = 1") > 0 Then trPaqueteriaOpciones.Visible = False trPaqueteriOpcionesLabel.Visible = False trPaqueteriaDirectaLabel.Visible = True - End If - BtnEmitirImprimir.Text = "Facturar" - DdlTipoComprobante.SelectedValue = "Ing" - DdlTipoComprobante.Enabled = False + DdlTipoComprobante.Items.Clear() + DdlTipoComprobante.Items.Insert(0, New ListItem("Ingresos", "Ing")) + DdlTipoComprobante.Items.Insert(1, New ListItem("Remisión", "Rem")) + DdlTipoComprobante.Enabled = True + + Else + DdlTipoComprobante.SelectedValue = "Ing" + DdlTipoComprobante.Enabled = False + End If Tab.ActiveTab = TabGenerales TabGenerales.Enabled = True @@ -10048,7 +10063,8 @@ Partial Class Ventas CveVentaRelacion:=(If(factura.CveVentaRelacion.ToEntero() > 0, factura.CveVentaRelacion, -1)), ImporteRelacion:=(If(factura.ImporteRelacion <> Nothing, factura.ImporteRelacion, -1)), CveTipoAmortizacionAnticipo:=factura.CveTipoAmortizacionAnticipo, CveEmpresaCRM:=CveEmpresaCRM, EsInterno:=EsInterno, CveAcercamientoCRM:=CveAcercamientoCRM, DiasCredito:=factura.DiasCredito, EsDiasCreditoFijo:=factura.EsDiasCreditoFijo, AnticipoEspecial:=If(TrAntEspecial.Visible, ChkAntEspecial.Checked, False), - Kilometraje:=TxtKilometraje.Text.ToDouble, EsAmortizacion:=EsNCAmortizacion, CveTipoRetencion:=factura.CveTipoRetencion, CorreoNotificacion:=TxtCorreoNotificaciones.Text, FormaPaqueteria:=RblPaqueteria.SelectedValue.ToEntero, FacturarSucursal:=factura.FacturarSucursal) Then + Kilometraje:=TxtKilometraje.Text.ToDouble, EsAmortizacion:=EsNCAmortizacion, CveTipoRetencion:=factura.CveTipoRetencion, CorreoNotificacion:=TxtCorreoNotificaciones.Text, + FormaPaqueteria:=RblPaqueteria.SelectedValue.ToEntero, FacturarSucursal:=factura.FacturarSucursal, VentaDesglosaIEPS:=factura.VentaDesglosaIEPS) Then ErrorList.Add("Ocurrió un error al Generar la Venta.
    Revise su factura y cualquier detalle comuníquese a Soporte Técnico") Else If factura.TipoDocto.Contiene("Dev", "Egs") Or DtVentasNC IsNot Nothing Or CveEstatusRefacturacion = 1 Then @@ -14534,119 +14550,121 @@ Partial Class Ventas TxtPrecio.Enabled = True End If - If UsuarioActual.TienePermisoProceso(68) Then TxtPrecio.Enabled = False + Dim PSCodigoSAT As String = drPS("SATClavePS").ToString + + If UsuarioActual.TienePermisoProceso(68) AndAlso Not PSCodigoSAT.Contiene("84111506", "80141610") Then TxtPrecio.Enabled = False If TmpDT IsNot Nothing AndAlso TmpDT.Rows.Count = 0 Then - DdlMoneda.SelectedValueExist(drPS("CveMoneda").ToString()) - CambiaMoneda() - End If - - 'SUGIERE PRECIO - Dim PrecioSugerido = 0.0 - PrecioSugerido = drPS("Precio").ToString().ToDouble - - If UsuarioActual.CveEmpresa.Contiene(1) Then - Dim ObjPS As New ClsProductosServicios - If ObjPS.GetPorcentajeProductos(CveCliente) Then - Dim PrecioAplicado = ObjPS.DtResultados.FiltraParametros($"CvePS = {CvePSParametro}").FiltroPrimeroValor("PrecioA").ToDouble - If PrecioAplicado > 0 Then - PrecioSugerido = PrecioAplicado - End If - End If - ObjPS.Dispose() - End If - - If UsuarioActual.Empresa.Funcionalidad(404).ToEntero > 0 Then 'cuando el valor es 10.- secuencia Cliente/Sucursal, 20 - sucursal/cliente - Dim TipoPrecioLista As Integer = UsuarioActual.Empresa.Funcionalidad(404).ToEntero - ' si es 10. primero el cliente - Dim CvePrecioListaPS As Integer - Dim PorcentajePrecio As Double = 0 - - If TipoPrecioLista = 10 Then - - CvePrecioListaPS = GlobalDTCliente(UsuarioActual.CveEmpresa, Estatus:=-1, CveCliente:=CveCliente).FiltroPrimeroValor("CvePrecioLista").ToEntero() - If CvePrecioListaPS <= 0 Then - - CvePrecioListaPS = GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePrecioLista", "").ToEntero() - - End If - - Else - - CvePrecioListaPS = GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePrecioLista", "").ToEntero() - If CvePrecioListaPS <= 0 Then - - CvePrecioListaPS = GlobalDTCliente(UsuarioActual.CveEmpresa, Estatus:=-1, CveCliente:=CveCliente).FiltroPrimeroValor("CvePrecioLista").ToEntero() - - End If - + DdlMoneda.SelectedValueExist(drPS("CveMoneda").ToString()) + CambiaMoneda() End If - If CvePrecioListaPS > 0 Then + 'SUGIERE PRECIO + Dim PrecioSugerido = 0.0 + PrecioSugerido = drPS("Precio").ToString().ToDouble + + If UsuarioActual.CveEmpresa.Contiene(1) Then Dim ObjPS As New ClsProductosServicios - If ObjPS.GetPSPreciosLista(UsuarioActual.CveEmpresa, CvePrecioListaPS, CvePS:=CvePSParametro) Then - PrecioSugerido = ObjPS.DtResultados.FiltroPrimeroValor("PrecioLista").ToDouble - PorcentajePrecio = ObjPS.DtResultados.FiltroPrimeroValor("Porcentaje").ToDouble + If ObjPS.GetPorcentajeProductos(CveCliente) Then + Dim PrecioAplicado = ObjPS.DtResultados.FiltraParametros($"CvePS = {CvePSParametro}").FiltroPrimeroValor("PrecioA").ToDouble + If PrecioAplicado > 0 Then + PrecioSugerido = PrecioAplicado + End If End If ObjPS.Dispose() End If - If PrecioSugerido = 0 Then - Dim ObjInventarios As New ClsInventarios - Dim CostoPS = ObjInventarios.GetCostoPS(CvePSParametro, TxtCantidad.Text.Trim.ToDouble, -1, "-1", TxtFecha.Text.ToDate, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveTipoAlmacen:=1) - 'si el costo es cero, puede ser que no halla movimientos del producto, en esa sucursal. y se volverá a sacar sin especificar sucursal - If CostoPS = 0 Then CostoPS = ObjInventarios.GetCostoPS(CvePSParametro, TxtCantidad.Text.Trim.ToDouble, -1, "-1", TxtFecha.Text.ToDate, -1, CveTipoAlmacen:=1) - ObjInventarios.Dispose() - If CostoPS > 0 And PorcentajePrecio > 0 Then - PrecioSugerido = ((PorcentajePrecio / 100) + 1) * CostoPS + If UsuarioActual.Empresa.Funcionalidad(404).ToEntero > 0 Then 'cuando el valor es 10.- secuencia Cliente/Sucursal, 20 - sucursal/cliente + Dim TipoPrecioLista As Integer = UsuarioActual.Empresa.Funcionalidad(404).ToEntero + ' si es 10. primero el cliente + Dim CvePrecioListaPS As Integer + Dim PorcentajePrecio As Double = 0 + + If TipoPrecioLista = 10 Then + + CvePrecioListaPS = GlobalDTCliente(UsuarioActual.CveEmpresa, Estatus:=-1, CveCliente:=CveCliente).FiltroPrimeroValor("CvePrecioLista").ToEntero() + If CvePrecioListaPS <= 0 Then + + CvePrecioListaPS = GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePrecioLista", "").ToEntero() + + End If + + Else + + CvePrecioListaPS = GlobalDTSubProyectos(-1, CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero(), CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePrecioLista", "").ToEntero() + If CvePrecioListaPS <= 0 Then + + CvePrecioListaPS = GlobalDTCliente(UsuarioActual.CveEmpresa, Estatus:=-1, CveCliente:=CveCliente).FiltroPrimeroValor("CvePrecioLista").ToEntero() + + End If + End If + + If CvePrecioListaPS > 0 Then + Dim ObjPS As New ClsProductosServicios + If ObjPS.GetPSPreciosLista(UsuarioActual.CveEmpresa, CvePrecioListaPS, CvePS:=CvePSParametro) Then + PrecioSugerido = ObjPS.DtResultados.FiltroPrimeroValor("PrecioLista").ToDouble + PorcentajePrecio = ObjPS.DtResultados.FiltroPrimeroValor("Porcentaje").ToDouble + End If + ObjPS.Dispose() + End If + + If PrecioSugerido = 0 Then + Dim ObjInventarios As New ClsInventarios + Dim CostoPS = ObjInventarios.GetCostoPS(CvePSParametro, TxtCantidad.Text.Trim.ToDouble, -1, "-1", TxtFecha.Text.ToDate, DdlSubProyectoDatos.SelectedValue.ToEntero(), CveTipoAlmacen:=1) + 'si el costo es cero, puede ser que no halla movimientos del producto, en esa sucursal. y se volverá a sacar sin especificar sucursal + If CostoPS = 0 Then CostoPS = ObjInventarios.GetCostoPS(CvePSParametro, TxtCantidad.Text.Trim.ToDouble, -1, "-1", TxtFecha.Text.ToDate, -1, CveTipoAlmacen:=1) + ObjInventarios.Dispose() + If CostoPS > 0 And PorcentajePrecio > 0 Then + PrecioSugerido = ((PorcentajePrecio / 100) + 1) * CostoPS + End If + End If + CvePrecioLista = CvePrecioListaPS End If - CvePrecioLista = CvePrecioListaPS - End If - 'Dim ObjClasificaciones As New ClsClasificaciones - 'If ObjClasificaciones.GetClasificaciones() Then - ' PrecioBaseCosto = ObjClasificaciones.DtResultados.FiltroPrimeroValor("PrecioBaseCosto", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveClasificacion = {drPS("CveClasificacion")}").ToDecimal - 'End If + 'Dim ObjClasificaciones As New ClsClasificaciones + 'If ObjClasificaciones.GetClasificaciones() Then + ' PrecioBaseCosto = ObjClasificaciones.DtResultados.FiltroPrimeroValor("PrecioBaseCosto", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveClasificacion = {drPS("CveClasificacion")}").ToDecimal + 'End If - If PrecioSugerido > 0 Then - Dim PrecioBaseCosto As Decimal = 0 - PrecioBaseCosto = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=drPS("CveClasificacion").ToString().ToEntero()).FiltroPrimeroValor("PrecioBaseCosto", "").ToDecimal + If PrecioSugerido > 0 Then + Dim PrecioBaseCosto As Decimal = 0 + PrecioBaseCosto = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, CveClasificacion:=drPS("CveClasificacion").ToString().ToEntero()).FiltroPrimeroValor("PrecioBaseCosto", "").ToDecimal - If PrecioBaseCosto > 0 Then - PrecioSugerido = PrecioSugerido * ((PrecioBaseCosto / 100) + 1) + If PrecioBaseCosto > 0 Then + PrecioSugerido = PrecioSugerido * ((PrecioBaseCosto / 100) + 1) + End If + TxtPrecio.Text = PrecioSugerido.ToString("#,###.####") ' que muestre hasta los 4 digitos si lo requiere End If - TxtPrecio.Text = PrecioSugerido.ToString("#,###.####") ' que muestre hasta los 4 digitos si lo requiere - End If - If IsNumeric(TxtCantidad.Text.Trim) Then - LblTotalPS.Text = (TxtCantidad.Text.Trim.ToDouble * TxtPrecio.Text.ToDouble).ToString().FormatoNumero(2) - Else - LblTotalPS.Text = "0.00" - End If - LblPrecio1.Text = TxtPrecio.Text - UPPDescuento.Update() - - HdnIVAPS.Value = If(drPS("IVA").ToString() = "-1", ViewState("IVA"), drPS("IVA").ToString()).ToString() - HdnIVARetAPS.Value = drPS("RetIVA").ToString() - HdnAsientoContable.Value = drPS("AsientoContableVentas").ToString() - HdnCtaContable.Value = drPS("IdCtaContVentas").ToString() - HdnAplicaParaConcepto.Value = drPS("AplicaParaConcepto").ToString() - HdnCodigo.Value = drPS("Codigo").ToString() - If DdlClasificacion.SelectedIndex = 0 Then - If drPS("CveClasificacion").ToString() IsNot Nothing Then - DdlClasificacion.SelectedValueExist(drPS("CveClasificacion").ToString()) + If IsNumeric(TxtCantidad.Text.Trim) Then + LblTotalPS.Text = (TxtCantidad.Text.Trim.ToDouble * TxtPrecio.Text.ToDouble).ToString().FormatoNumero(2) Else - Alert("El Productos/Servicio no tiene asignada una Clasificación.", TipoMensaje.MsgInformacion) + LblTotalPS.Text = "0.00" + End If + LblPrecio1.Text = TxtPrecio.Text + UPPDescuento.Update() + + HdnIVAPS.Value = If(drPS("IVA").ToString() = "-1", ViewState("IVA"), drPS("IVA").ToString()).ToString() + HdnIVARetAPS.Value = drPS("RetIVA").ToString() + HdnAsientoContable.Value = drPS("AsientoContableVentas").ToString() + HdnCtaContable.Value = drPS("IdCtaContVentas").ToString() + HdnAplicaParaConcepto.Value = drPS("AplicaParaConcepto").ToString() + HdnCodigo.Value = drPS("Codigo").ToString() + If DdlClasificacion.SelectedIndex = 0 Then + If drPS("CveClasificacion").ToString() IsNot Nothing Then + DdlClasificacion.SelectedValueExist(drPS("CveClasificacion").ToString()) + Else + Alert("El Productos/Servicio no tiene asignada una Clasificación.", TipoMensaje.MsgInformacion) + End If + End If End If - End If - - ElseIf CvePSParametro = -2 Then + ElseIf CvePSParametro = -2 Then CargaPS(DdlClasificacion.SelectedValue.ToEntero(), Ddl) End If @@ -15668,13 +15686,10 @@ Partial Class Ventas ObjPS.Dispose() End Sub Private Function AgregarProductoServicio(Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String, - PU As Decimal, Descuento As Decimal, - CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String, - Optional Serie As String = "", Optional TiempoEntrega As String = "", Optional EntregaDirecta As Integer = 0, - Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0, - Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0, - Optional CuentaPredial As String = "", Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, - Optional SeActualiza As Boolean = False, Optional CvePromocionDetalle As Integer = -1, Optional EsCargo As Boolean = False) As Boolean + PU As Decimal, Descuento As Decimal, CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String, Optional Serie As String = "", Optional TiempoEntrega As String = "", + Optional EntregaDirecta As Integer = 0, Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0, + Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0, Optional CuentaPredial As String = "", + Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional SeActualiza As Boolean = False, Optional CvePromocionDetalle As Integer = -1, Optional EsCargo As Boolean = False) As Boolean Dim Retorno As Boolean = False If Not CvePS > 0 Then @@ -15758,12 +15773,21 @@ Partial Class Ventas End If End If + 'VERIFICA SI EN LA FACTURA PADRE SE DESGLOSO EL IEPS + Dim FacturaDesglosoIEPS As Boolean = ((CveDevolucion > 0 AndAlso NuevaFactura = 1) AndAlso (Me.ObjFacturaNC IsNot Nothing AndAlso Me.ObjFacturaNC.VentaDesglosaIEPS)) + If Not ClienteDesglosaIEPS Then - If Not RegeneraIEPS Then + If Not RegeneraIEPS AndAlso Not FacturaDesglosoIEPS Then PU = PU * (1 + DrPS("IEPSPorcentaje").ToString().ToDecimal) + VentaDesglosaIEPS = True End If DrPS("IEPSPorcentaje") = 0 End If + 'SI YA SE DESGLOSO EL IEPS SE GUARDA LA BANDERA EN ESTA FACTURA + If FacturaDesglosoIEPS Then + VentaDesglosaIEPS = True + End If + TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento TotalCalculableImpuestosIVA = TotalCalculableImpuestos * (1 + DrPS("IEPSPorcentaje").ToString().ToDecimal)