From be84bb2f7dc54d03857b1345d77e910c689e3d33 Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 1 Oct 2020 09:09:31 -0700 Subject: [PATCH 01/21] -- correccion de carga en gridview de solicitud de cancelaciones de proveedores --- Inicio.aspx | 10 +++++----- Inicio.aspx.vb | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Inicio.aspx b/Inicio.aspx index d7c9313e4..f1548a284 100644 --- a/Inicio.aspx +++ b/Inicio.aspx @@ -907,7 +907,7 @@ + CssClass="table table-striped table-advance table-hover Widthall ScrollAD" data-sort="true" GridLines="None" Width="99%"> @@ -916,10 +916,10 @@ - - - - + + + + <%-- diff --git a/Inicio.aspx.vb b/Inicio.aspx.vb index 657238190..d3b03624b 100644 --- a/Inicio.aspx.vb +++ b/Inicio.aspx.vb @@ -36,7 +36,7 @@ Partial Class Inicio If objventas.GetFacturasCanceladasPendientes(sb.ToString(), CveEmpresa) Then retorno = True End If - + gvCancelaPendiente.DataSource = objventas.DtResultados Else If showalert Then Alert("No se encontraron cancelaciones pendientes", ModExtensiones.TipoMensaje.MsgError) @@ -50,6 +50,7 @@ Partial Class Inicio retorno = False Me.OnError("Error al obtener cancelaciones pendientes: ", ex, "") End Try + gvCancelaPendiente.DataBind() Return retorno End Function From 9cf113c724621cb2663dd9e4e206e6e673d4c4b6 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 6 Oct 2020 09:58:12 -0700 Subject: [PATCH 02/21] cantidad minima --- App_Code/ClsProductosServicios.vb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/App_Code/ClsProductosServicios.vb b/App_Code/ClsProductosServicios.vb index b4e247486..d64de3153 100644 --- a/App_Code/ClsProductosServicios.vb +++ b/App_Code/ClsProductosServicios.vb @@ -56,10 +56,8 @@ Public Class ClsProductosServicios Public Property CveMetodoInventario As Integer Public Property CveTipoPS As Integer Public Property Estado2 As Integer - Public Property CveMarca As Integer - - Public Property AlmacenSeccion As String - + Public Property CveMarca As Integer + Public Property IEPSPorcentaje As Double Public Property AplicaIEPS As Boolean @@ -283,7 +281,7 @@ Public Class ClsProductosServicios Me.CveEmpresa = Data.Rows(0)("CveEmpresa").ToString.ToEntero CveMetodoInventario = Data.Rows(0)("Inv_CveMetodoInventario").ToString.ToEntero - 'VentaMinima = Data.Rows(0)("VentaMinima").ToString.ToDecimal + VentaMinima = Data.Rows(0)("VentaMinima").ToString.ToDecimal CveMoneda = Data.Rows(0)("CveMoneda").ToString.ToEntero RetISR = Data.Rows(0)("RetISR").ToString.ToDouble @@ -2112,13 +2110,14 @@ Public Class ClsProductosServicios Return Retorno End Function - Public Function UpdateProductosServiciosSAT(CvePS As Integer, CveSATPS As Integer, CveUsuario As Integer) As Boolean + Public Function UpdateProductosServiciosSAT(CvePS As Integer, CveSATPS As Integer, CveUsuario As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Gral_ProductosServiciosSATUpdate") With SqlAdapter.SelectCommand.Parameters .Add("@CvePS", SqlDbType.Int).Value = CvePS .Add("@CveSATPS", SqlDbType.Int).Value = CveSATPS .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa End With Try SqlAdapter.Fill(Data) From c0ba71fdd7f5b913bf5f4280b18a05ff482ee2d3 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 6 Oct 2020 09:58:35 -0700 Subject: [PATCH 03/21] global proveedores --- Compras/RepComprasDetalle.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Compras/RepComprasDetalle.aspx.vb b/Compras/RepComprasDetalle.aspx.vb index a4da96cb2..e7a5e5439 100644 --- a/Compras/RepComprasDetalle.aspx.vb +++ b/Compras/RepComprasDetalle.aspx.vb @@ -153,7 +153,7 @@ Partial Class Compras_RepComprasDetalle DdlGrupo.SelectedValueExist(Grupo) DdlProveedores.SelectedValue = Proveedor If DdlProveedores.SelectedValue.ToEntero > 0 Then - DdlProveedores.SelectedText = GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltraParametros($"CveProveedor = {Proveedor}").Rows(0)("RazonSocial").ToString + DdlProveedores.SelectedText = GlobalDTCompProveedores(UsuarioActual.CveEmpresa, CveProveedor:=DdlProveedores.SelectedValue.ToEntero).FiltroPrimeroValor("RazonSocial", "").ToString Else DdlProveedores.SelectedText = "Todos" End If From 94d3066c0991d841e5d5c39be312f6a2b488316b Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 6 Oct 2020 09:58:46 -0700 Subject: [PATCH 04/21] -- movimiento de prepolizas --- Inventarios/AjustesSeccionAlmacen.aspx | 2 +- Inventarios/AjustesSeccionAlmacen.aspx.vb | 41 +++++++++++++++++++---- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/Inventarios/AjustesSeccionAlmacen.aspx b/Inventarios/AjustesSeccionAlmacen.aspx index 11a13b4b6..f37b30df0 100644 --- a/Inventarios/AjustesSeccionAlmacen.aspx +++ b/Inventarios/AjustesSeccionAlmacen.aspx @@ -80,7 +80,7 @@ <%----%> - + diff --git a/Inventarios/AjustesSeccionAlmacen.aspx.vb b/Inventarios/AjustesSeccionAlmacen.aspx.vb index 171409d9b..9c78fc2d3 100644 --- a/Inventarios/AjustesSeccionAlmacen.aspx.vb +++ b/Inventarios/AjustesSeccionAlmacen.aspx.vb @@ -65,11 +65,13 @@ Partial Class Inventarios_AjustesSeccionAlmacen Private Sub BtnCambiarSeccion_Click(sender As Object, e As EventArgs) Handles BtnCambiarSeccion.Click Dim ObjInventario As New ClsInventarios Dim ObjPS As New ClsProductosServicios(ObjInventario.IniciaTransacSQL) + Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL) Dim Dtt As DataTable = Nothing Dim CveMovimientoEntrada As Integer = 0 Dim Folio = 0 Dim ErrorMovInv As Boolean = False Dim TextoError = "" + Dim Contador As Integer = 0 Dim CveAlmacen As Integer = DdlAlmacen.SelectedValue.ToEntero @@ -106,12 +108,13 @@ Partial Class Inventarios_AjustesSeccionAlmacen TextoError = "Ocurrió un error al guardar los movimientos de salida" Exit For End If + Contador += 1 End If Next - If Not ErrorMovInv Then + If Not ErrorMovInv AndAlso Contador > 0 Then If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then @@ -121,7 +124,7 @@ Partial Class Inventarios_AjustesSeccionAlmacen For Each Row As DataRow In resultado.Rows Dim CvePS = Row("CvePS").ToString().ToEntero() - Dim Cantidad As Decimal = Row("Cantidad").ToString().ToDecimal() + Cantidad = Row("Cantidad").ToString.ToDecimal() Dim PU As Decimal = Row("PUOriginal").ToString().ToDecimal() Dim CveUM As Integer = Row("CveUM").ToString().ToEntero() Dim CveSeccionAlmacen As Integer = Lista(Row("CvePS").ToString().ToEntero()) 'GvD.Rows(ind).FCDropDownList("DDlS").SelectedValue.ToEntero ' IfNull(Row("CveSeccionAlmacen"), "-1").ToString().ToEntero() @@ -143,8 +146,23 @@ Partial Class Inventarios_AjustesSeccionAlmacen End If ind += 1 Next - resultado.Dispose() + 'inserto la prepoliza + If CveMovimientoEntrada > 0 AndAlso CveMovimientoSalida > 0 Then + Dim Concepto As String = "Ajuste Sección" + Dim IdCtaContableOrigen As Integer = 0 + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/AjusteAlmacen", 53, 0, 0, 1, Fecha, Concepto, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim importe As Decimal = resultado.SUMD("Total").RoundSQL + Dim contabilizable As Boolean = False + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, importe, Concepto, 68, Concepto, Fecha, IdCtaContableOrigen, -1, CveMovimientoAlmacen:=CveMovimientoSalida, Contabilizable:=contabilizable, ImporteMX:=importe) Then + ErrorMovInv = True + End If + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, importe, Concepto, 68, Concepto, Fecha, IdCtaContableOrigen, -1, CveMovimientoAlmacen:=CveMovimientoEntrada, Contabilizable:=contabilizable, ImporteMX:=importe) Then + ErrorMovInv = True + End If + End If + + resultado.Dispose() Else TextoError = "No se pudo registrar el movimiento" ErrorMovInv = True @@ -155,16 +173,25 @@ Partial Class Inventarios_AjustesSeccionAlmacen End If If Not ErrorMovInv Then - ObjInventario.Commit() - GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, -1, -1) = Nothing - CargaDatos() - Alert("El Movimiento quede registrado correctamente", TipoMensaje.MsgInformacion) + + If Contador > 0 Then + ObjInventario.Commit() + GlobalDTInvPSSeccionesAlmacen(UsuarioActual.CveEmpresa, -1, -1) = Nothing + CargaDatos() + Alert("El Movimiento quede registrado correctamente", TipoMensaje.MsgInformacion) + Else + ObjInventario.RollBack() + Alert("No se especificaron productos", TipoMensaje.MsgError) + End If + Else ObjInventario.RollBack() Alert("Ocurrio un error al registrar el movimiento", TipoMensaje.MsgError) End If ObjInventario.Dispose() + ObjConta.Dispose() + ObjPS.Dispose() End Sub Protected Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles LbDescargarExcel.Click, BtnDescargar.Click From 94aafcae3637271c249ff4d4f0446124b23782a6 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 6 Oct 2020 09:59:10 -0700 Subject: [PATCH 05/21] -- pagos efectivo --- Bancos/DepositosCaja.aspx | 32 +++++++++++++++++++++----------- Bancos/DepositosCaja.aspx.vb | 8 +++++++- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Bancos/DepositosCaja.aspx b/Bancos/DepositosCaja.aspx index 830a6df54..7742f9710 100644 --- a/Bancos/DepositosCaja.aspx +++ b/Bancos/DepositosCaja.aspx @@ -23,17 +23,16 @@ -
+
-
- + +
- -
+
- +
@@ -43,7 +42,7 @@
- + @@ -58,7 +57,7 @@
- + @@ -76,13 +75,24 @@ + + + +
+ +
+ +
+
+ -
diff --git a/Bancos/DepositosCaja.aspx.vb b/Bancos/DepositosCaja.aspx.vb index d11da1c2f..fec2b767e 100644 --- a/Bancos/DepositosCaja.aspx.vb +++ b/Bancos/DepositosCaja.aspx.vb @@ -19,6 +19,8 @@ Partial Class Bancos_DepositosCaja If Not IsPostBack Then FacturasCheckadas = 0 TxtFecha.Text = Now.ToShortDateString + txtFechaI.Text = Now.AddDays(-1).ToShortDateString + txtFechaF.Text = Now.ToShortDateString CargaCuentas() End If End Sub @@ -29,6 +31,10 @@ Partial Class Bancos_DepositosCaja DdlCajaChica.DataSource = GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveTipoCuenta = 1", "", {"CveCuenta", "NumCuentaMoneda"}) DdlCajaChica.DataBind() + + DdlSubProyectos.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveEmpresa, -1, UsuarioActual.CveEmpresa) + DdlSubProyectos.DataBind() + DdlSubProyectos.Items.Insert(0, New ListItem("Todos", "-1")) End Sub Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click @@ -41,7 +47,7 @@ Partial Class Bancos_DepositosCaja FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1") FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1") - ObjBancos.GetPagosCajaChica(FechaI, FechaF, UsuarioActual.CveEmpresa, DdlCajaChica.SelectedValue.ToEntero, DdlTipoPago.SelectedValue.ToEntero) + ObjBancos.GetPagosCajaChica(FechaI, FechaF, UsuarioActual.CveEmpresa, DdlCajaChica.SelectedValue.ToEntero, DdlTipoPago.SelectedValue.ToEntero, CveSubProyecto:=DdlSubProyectos.SelectedValue.ToEntero) GvFacturas.DataSource = ObjBancos.DtResultados ObjBancos.Dispose() From 5a676054a73a38e521e4e5374eb978b0f108a80a Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 6 Oct 2020 09:59:49 -0700 Subject: [PATCH 06/21] complementarios --- Bancos/IE.aspx.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Bancos/IE.aspx.vb b/Bancos/IE.aspx.vb index 6f116c7a2..503feacc6 100644 --- a/Bancos/IE.aspx.vb +++ b/Bancos/IE.aspx.vb @@ -3626,7 +3626,7 @@ Partial Class Bancos_IE TipoMovimiento = False End If - If CveConceptoCompra = 10 AndAlso DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsuarioActual.CveEmpresa.Contiene(1, 119) Then + If CveConceptoCompra = 10 AndAlso DdlMoneda.SelectedValue.ToEntero > 1 AndAlso UsaComplementariaBancos Then IDCtaBeneficiario = IdCtaAnticipoExtranjera CveCuentaConta = 0 End If @@ -3634,7 +3634,7 @@ Partial Class Bancos_IE 'MOVIMIENTOS EGRESOS If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, TxtImporte.Text.ToDecimal, Ref, CveConceptoContable, Conc, Now, IDCtaContable, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveOC:=CveOrdenCompra, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=TxtImporte.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera, CveCuenta:=CveCuentaConta, CveIEDevolucion:=DDlCheques.SelectedValue.ToEntero) Then Dim IVA As Decimal = 0 ' TxtImporte.Text.ToDouble * HdnProvPorIVA.Value.ToDouble - If ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, TxtImporte.Text.ToDecimal - IVA - CIF, Ref, CveConceptoCompra, Conc, Now, IDCtaBeneficiario, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveOC:=CveOrdenCompra, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=tImporteMonedaExtranjera, ImporteME:=tImporteMonedaExtranjera, CveCuenta:=CveCuentaBeneficiario, CveIEDevolucion:=DdlIEAcreedor.SelectedValue.ToEntero) Then + If ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovimiento, TxtImporte.Text.ToDecimal - IVA - CIF, Ref, CveConceptoCompra, Conc, Now, IDCtaBeneficiario, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveOC:=CveOrdenCompra, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=If(UsaComplementariaBancos, TxtImporte.Text.ToDecimal, tImporteMonedaExtranjera), ImporteME:=TxtImporte.Text.ToDecimal, CveCuenta:=CveCuentaBeneficiario, CveIEDevolucion:=DdlIEAcreedor.SelectedValue.ToEntero) Then If IVA > 0 AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, IVA, Ref, 19, Conc, Now, IDCtaBeneficiario, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CveOC:=CveOrdenCompra, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle, CveCliente:=CveCliente, ImporteMX:=TxtImporte.Text.ToDecimal, ImporteME:=tImporteMonedaExtranjera, CveCuenta:=CveCuentaBeneficiario, CveIEDevolucion:=DDlCheques.SelectedValue.ToEntero) Then MsgError = "Detalle" End If From b60e85e7b596308db786646b01e3d7d3b2a8d3e4 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 6 Oct 2020 10:00:09 -0700 Subject: [PATCH 07/21] - codicioens apra ajustes de salidas, luz del mar --- Inventarios/EntradasSalidas.aspx.vb | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Inventarios/EntradasSalidas.aspx.vb b/Inventarios/EntradasSalidas.aspx.vb index 659934309..08040c50e 100644 --- a/Inventarios/EntradasSalidas.aspx.vb +++ b/Inventarios/EntradasSalidas.aspx.vb @@ -5,6 +5,7 @@ Imports System.Data Imports Extensiones Imports System.IO Imports Microsoft.Reporting.WebForms +Imports DocumentFormat.OpenXml.Drawing.Diagrams 'Imports DocumentFormat.OpenXml.Wordprocessing @@ -2033,8 +2034,8 @@ Partial Class Inventarios_EntradasSalidas DdlConcepto.Items.Insert(0, New ListItem("Entrada Almacen ", "2")) End If - - If UsuarioActual.CveEmpresa = 72 AndAlso (UsuarioActual.CveUsuario = 2185 OrElse UsuarioActual.CveRol = 1) Then + '2185 + If UsuarioActual.CveEmpresa = 72 AndAlso (UsuarioActual.CveUsuario = 1490 OrElse UsuarioActual.CveRol = 1) Then 'DdlConcepto.Items.Add(New ListItem("Seleccione", "-1")) DdlConcepto.Items.Add(New ListItem("Entrada por Ajuste", "32")) @@ -2043,6 +2044,24 @@ Partial Class Inventarios_EntradasSalidas DdlConcepto.Items.Add(New ListItem("Salida por Ajuste", "34")) End If + End If + + ''condicion de limpieza si es el usuario 1490, se dejan sino + If UsuarioActual.CveEmpresa.Contiene(72, 80, 146) Then + If UsuarioActual.CveUsuario <> 1490 Then + DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("1")) + DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("2")) + DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("3")) + DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("16")) + DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("17")) + DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("31")) + DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("32")) + DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("33")) + DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("34")) + DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("34")) 'si esta dos veces, se tiene que ejecutar 2 veces + DdlConcepto.Items.Remove(DdlConcepto.Items.FindByValue("35")) + + End If End If From dab2b1ab4141722fbbff39ec614e3ed3487bb882 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 6 Oct 2020 10:00:18 -0700 Subject: [PATCH 08/21] liga concepto --- Contabilidad/ContabilizacionVentas.aspx.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contabilidad/ContabilizacionVentas.aspx.cs b/Contabilidad/ContabilizacionVentas.aspx.cs index d73aa8739..0b85ddfa4 100644 --- a/Contabilidad/ContabilizacionVentas.aspx.cs +++ b/Contabilidad/ContabilizacionVentas.aspx.cs @@ -344,7 +344,7 @@ public partial class Contabilidad_ContabilizacionVentas : ClsPaginas { e.Row.FCHyperLink("HplC").NavigateUrl = string.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE")); } - if (CveConcepto.Contiene(2, 4, 13, 61, 38, 39, 1, 203, 207, 251)) + if (CveConcepto.Contiene(1, 2, 4, 13, 61, 38, 39, 150, 203, 207, 251)) { e.Row.FCHyperLink("HplC").NavigateUrl = string.Format("/Ventas/Ventas.aspx?CveVenta={0}", e.Row.DBCampo("CveVenta")); } From 29ed6068b8c999d6a64e3ce79b887936061c186f Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 6 Oct 2020 10:00:38 -0700 Subject: [PATCH 09/21] subproyecto ,caja chica --- App_Code/ClsBancos.vb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/App_Code/ClsBancos.vb b/App_Code/ClsBancos.vb index 04527b54e..41a2511cb 100644 --- a/App_Code/ClsBancos.vb +++ b/App_Code/ClsBancos.vb @@ -3475,7 +3475,7 @@ Public Class ClsBancos #End Region #Region "PagosCajaChica" - Public Function GetPagosCajaChica(FechaI As String, FechaF As String, CveEmpresa As Integer, CveCuenta As Integer, Optional TipoPago As Integer = -1) As Boolean + Public Function GetPagosCajaChica(FechaI As String, FechaF As String, CveEmpresa As Integer, CveCuenta As Integer, Optional TipoPago As Integer = -1, Optional CveSubProyecto As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_BancosCajaChicaPagosGet") @@ -3485,6 +3485,7 @@ Public Class ClsBancos .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveCuenta", SqlDbType.Int).Value = CveCuenta .Add("@TipoChequeEfectivo", SqlDbType.Int).Value = TipoPago + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto End With Try From 99046d3216537bc9d13e88a5f1addf5e25b29a94 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 6 Oct 2020 10:00:53 -0700 Subject: [PATCH 10/21] parametro subproyecto --- Compras/Compras.aspx.vb | 49 ++++++++++++++++++++++++-- Compras/eFacturas.aspx | 2 +- Inventarios/RepNotasSinAlmacen.aspx.vb | 2 +- Ventas/ActualizarPrecios.aspx.vb | 5 +-- Ventas/ProductosServicios.aspx.vb | 1 - Ventas/Ventas.aspx.vb | 12 +++++-- vwd.webinfo | 12 +++++++ 7 files changed, 72 insertions(+), 11 deletions(-) diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index e37fd5697..098f80b4c 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -5027,7 +5027,7 @@ Partial Class Compras_Compras 'ACTUALIZAR PRODUCTO/SERVICIO SAT If Version = "3.3" Then - If Not ObjProductosServicios.UpdateProductosServiciosSAT(Row("CvePS").ToString().ToEntero(), Row("CveSATPS").ToString().ToEntero(), UsuarioActual.CveUsuario) Then + If Not ObjProductosServicios.UpdateProductosServiciosSAT(Row("CvePS").ToString().ToEntero(), Row("CveSATPS").ToString().ToEntero(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then ErrorSATPS = True End If End If @@ -15973,6 +15973,46 @@ Partial Class Compras_Compras End Sub + Public Sub CargaIndirectosServicios() + If DtServicios Is Nothing Then CreaDTServicios() + DtServicios.Rows.Clear() + + Dim objps As New ClsProductosServicios + Dim dr As DataRow + dvFacturas.Visible = False + GvFacturas.Visible = False + + For Each DrGv As DataRow In TmpDT.Rows + If DrGv("CvePS").ToString.ToEntero > 0 Then + If objps.GetPS(DrGv("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) Then + If objps.DtResultados(0)("CveTipoPS").ToString.ToEntero = 1 Then + dr = DtServicios.NewRow() + dr("Consec") = DrGv("Consec").ToString.ToEntero + dr("Total") = DrGv("Total").ToString.ToDecimal + dr("CvePS") = DrGv("CvePS").ToString.ToEntero + dr("PS") = DrGv("PS").ToString + DtServicios.Rows.Add(dr) + End If + End If + End If + Next + + objps.Dispose() + + If DtServicios.Rows.Count > 0 Then + GVServicios.DataSource = DtServicios + GVServicios.DataBind() + GVServicios.Visible = True + Else + GVServicios.DataSource = Nothing + GVServicios.DataBind() + End If + + UpGVServicios.Update() + UpFacturas.Update() + UPGVFacturas.Update() + End Sub + Public Sub btnAgregarFlete_Click(sender As Object, e As EventArgs) Handles BtnAgregarFlete.Click Dim ListaConsecutivas As New List(Of String) 'Almacena los consecutivos que pertenecen al almacen @@ -16025,7 +16065,7 @@ Partial Class Compras_Compras ''Marcamos todos los almacenes como check 'GvInv.HeaderRow.FCCheckBox("cbAll").Checked = True 'cbAll_CheckedChanged(Nothing, Nothing) - + RegistraScript("$('#ModalFletesImportaciones').modal('hide');") End Sub Private Sub CargaGastosServicios(CvePS As Integer) @@ -18157,7 +18197,7 @@ Partial Class Compras_Compras CvePS = DdlPSAlias2.SelectedValue.ToEntero tPS = DdlPSAlias2.SelectedText - If PS.AddPSAlias(System.Web.HttpUtility.HtmlDecode(TxtPSAlias.Text.Trim), CvePS) Then + If PS.AddPSAlias(System.Web.HttpUtility.HtmlDecode(TxtPSAlias.Text.Trim), CvePS, UsuarioActual.CveUsuario) Then GlobalDTProductosServiciosAlias(-1) = PS.DtResultados TmpDT.Rows(HdnAliasInd.Value.ToEntero)("CvePS") = CvePS @@ -20058,6 +20098,9 @@ Partial Class Compras_Compras DivGastosyServicios.Visible = MostrarGastosServicios DivGastosyServiciosFooter.Visible = MostrarGastosServicios + If MostrarGastosServicios Then + CargaIndirectosServicios() + End If DivVincularCrear.Visible = Not MostrarGastosServicios DivVincularCrearFooter.Visible = Not MostrarGastosServicios diff --git a/Compras/eFacturas.aspx b/Compras/eFacturas.aspx index aef1158b7..3069747e7 100644 --- a/Compras/eFacturas.aspx +++ b/Compras/eFacturas.aspx @@ -216,7 +216,7 @@ - + diff --git a/Inventarios/RepNotasSinAlmacen.aspx.vb b/Inventarios/RepNotasSinAlmacen.aspx.vb index 95cdd8db2..d558f6498 100644 --- a/Inventarios/RepNotasSinAlmacen.aspx.vb +++ b/Inventarios/RepNotasSinAlmacen.aspx.vb @@ -146,7 +146,7 @@ Partial Class RepNotasSinAlmacen CveClienteProveedor = DdlProveedor.SelectedValue.ToEntero End If - If Reporte.RepNotasSinAlmacen(2, CveClienteProveedor, FechaInicial, FechaFinal, DdlTipoDocto2.SelectedValue.ToEntero, -1, UsuarioActual.Empresa.CveEmpresa) Then + If Reporte.RepNotasSinAlmacen(2, CveClienteProveedor, FechaInicial, FechaFinal, DdlTipoDocto2.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.Empresa.CveEmpresa) Then GvCompras.DataSource = Reporte.DtResultados DtNotasSinAlmacenCompras = Reporte.DtResultados Else diff --git a/Ventas/ActualizarPrecios.aspx.vb b/Ventas/ActualizarPrecios.aspx.vb index 54e4822da..71dd6e415 100644 --- a/Ventas/ActualizarPrecios.aspx.vb +++ b/Ventas/ActualizarPrecios.aspx.vb @@ -1,5 +1,6 @@  Option Explicit On +Option Strict On Imports Extensiones Imports System.Data @@ -293,7 +294,7 @@ Partial Class Ventas_ActualizarPrecios #Region "C A R G A R E X C E L " Private Sub BtnDescargarFormato_Click(sender As Object, e As EventArgs) Handles BtnDescargarFormato.Click - Dim DtExcel As DataTable = (From row As GridViewRow In GVPrecios.Rows + Dim DtExcel As DataTable = (From row As GridViewRow In GVPrecios.Rows.Cast(Of GridViewRow) Where row.RowType = DataControlRowType.DataRow Select New With { @@ -408,7 +409,7 @@ Partial Class Ventas_ActualizarPrecios Dim DtPS As DataTable = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) For Each row As DataRow In dt.Rows Dim Correcto As Boolean = False - Dim CvePS As Integer = DtPS.FiltroPrimeroValor("CvePS", String.Format("Codigo='{0}' AND CveEmpresa={1}", row(0).ToString(), UsuarioActual.CveEmpresa)) + Dim CvePS As Integer = DtPS.FiltroPrimeroValor("CvePS", String.Format("Codigo='{0}' AND CveEmpresa={1}", row(0).ToString(), UsuarioActual.CveEmpresa)).ToEntero Dim CvePrecioLista As Integer = DdlPrecioListaCarga.SelectedValue.ToEntero() Dim PrecioNuevo As Decimal = row("Precio").ToString().ToDecimal() Dim Porcentaje As Decimal = -1 diff --git a/Ventas/ProductosServicios.aspx.vb b/Ventas/ProductosServicios.aspx.vb index 51997adf9..e4ea4d42e 100644 --- a/Ventas/ProductosServicios.aspx.vb +++ b/Ventas/ProductosServicios.aspx.vb @@ -821,7 +821,6 @@ Partial Class ProductosyServicios lbTitulo.Text = $"{lbTitulo.Text}{ObjProductosServicios.PS}" LtProductoUnificar.Text = ObjProductosServicios.PS ddlMetodos.SelectedValue = ObjProductosServicios.CveMetodoInventario.ToString - TxtAlmacenSeccion.Text = ObjProductosServicios.AlmacenSeccion.ToString DdlConceptoRelacionado.SelectedValueExist(ObjProductosServicios.CveConceptoContable.ToString) DdlProveedor.SelectedValue = ObjProductosServicios.CveProveedorCompra.ToString diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 9d25b9949..22d27ffc1 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -2643,6 +2643,12 @@ Partial Class Ventas End If + 'rmf.2020.09.30, codigo de prueba + If UsuarioActual.CveEmpresa = 1 Then + DivMesesSinIntereses.Visible = True + DivDdlCuentaTarjetaCredito.Attributes.Add("class", "col-md-4") + DivContadoOtros.Visible = True + End If If UsuarioActual.Empresa.Funcionalidad(558).ToEntero() = 1 Then @@ -15133,7 +15139,7 @@ Partial Class Ventas If DdlTipoComprobante.SelectedValue <> "Cot" And ChkSinExistencia.Checked = False Then 'VALIDA EXISTENCIA - If UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) Then + If UsuarioActual.CveEmpresa.Contiene({72, 80, 119, 153}) Then If Existencia - TmpDT.SUM("Cantidad", $"CvePS = {CvePS} AND (EntregaDirecta IS NULL OR EntregaDirecta < 1)") < TxtCantidad.Text.ToDouble Then Alert("No cuenta con la cantidad suficiente en inventario. Cuenta con " + Existencia.FormatoNumero(2) + ".", TipoMensaje.MsgAdvertencia) Return False @@ -18497,8 +18503,8 @@ Partial Class Ventas Dim DtCC As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa) DdlCuentaEfectivo.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero()))) - DdlCuentaTarjetaCredito.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta <> 1", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero()))) - DdlCuentaTarjetaDebito.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta <> 1", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero()))) + DdlCuentaTarjetaCredito.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND (CveTipoCuenta <> 1 OR TieneTerminal = 1)", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero()))) + DdlCuentaTarjetaDebito.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND (CveTipoCuenta <> 1 OR TieneTerminal = 1)", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero()))) DdlCuentaCheque.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta = 1", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero()))) DdlCuentaTransferencia.DataSource = DtCC.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta <> 1", If(DdlMoneda.SelectedValue.ToEntero() <= 0, 1, DdlMoneda.SelectedValue.ToEntero()))) diff --git a/vwd.webinfo b/vwd.webinfo index 10e72764b..ca182e0f3 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -100,6 +100,18 @@ + + + + + + + + + + + + From f56bdba4034df33c19d79e8c7d20aea7c38b220e Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Tue, 6 Oct 2020 13:35:49 -0700 Subject: [PATCH 11/21] --- App_Code/CFDITimbre.vb | 3 +- App_Code/LogicNominas.vb | 332 +++++--------------------- App_Code/Timbrado.vb | 6 +- Ashx/SIGWeb.ashx | 2 +- Empresas/1/Formatos/ResguardoAF.rdlc | 69 +----- Empresas/1/Formatos/ResguardoAF2.rdlc | 45 ---- Nomina/Nomina2.aspx | 6 +- Nomina/Nomina2.aspx.cs | 282 +++++++++++++++------- Scripts/custom.js | 26 +- vwd.webinfo | 4 + 10 files changed, 306 insertions(+), 469 deletions(-) diff --git a/App_Code/CFDITimbre.vb b/App_Code/CFDITimbre.vb index ccccd30a6..a9509a624 100644 --- a/App_Code/CFDITimbre.vb +++ b/App_Code/CFDITimbre.vb @@ -363,7 +363,8 @@ Public Class CFDINominaOtrosPagos Public Property TipoOtroPago As String Public Property Clave As String Public Property Concepto As String - Public Property Importe As Double + Public Property Importe As Decimal + Public Property Subsidiocausado As Decimal End Class diff --git a/App_Code/LogicNominas.vb b/App_Code/LogicNominas.vb index 542714a52..9e99e3c97 100644 --- a/App_Code/LogicNominas.vb +++ b/App_Code/LogicNominas.vb @@ -107,7 +107,7 @@ Public Class LogicNominas 'Conexiones a la Base de Datos Using objNomina As ClsNominas = New ClsNominas() Using objPersonal As ClsRH = New ClsRH() - If objNomina.GetNom_Nominas(CveNomina, CvePersonal, CvePeriodo, -1, UsuarioActual.CveEmpresa) AndAlso objNomina.DtResultados.Rows.Count > 0 Then + If objNomina.GetNom_Nominas(CveNomina, -1, -1, -1, UsuarioActual.CveEmpresa) AndAlso objNomina.DtResultados.Rows.Count > 0 Then CvePersonal = objNomina.DtResultados.Rows(0)("CvePersonal").ToString().ToEntero() CvePeriodo = objNomina.DtResultados.Rows(0)("CvePeriodo").ToString().ToEntero() Serie = objNomina.Serie @@ -116,7 +116,6 @@ Public Class LogicNominas If continuar Then GetError = "No se pudo obtener la información de la nomina" 'si continuar= true el error se origino en este nodo y se le asigno el error continuar = False End If - If continuar AndAlso objPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) AndAlso objPersonal.DtResultados.Rows.Count > 0 Then RFC = objPersonal.RFC NombreCompleto = objPersonal.NombreCompleto @@ -143,11 +142,11 @@ Public Class LogicNominas If continuar Then GetError = "No se pudo obtener la información del empleado" 'si continuar= true el error se origino en este nodo y le asigno el error continuar = False End If - If continuar AndAlso objNomina.GetNom_NominasDetalles(CveNomina, CvePersonal, CvePeriodo, "-1") Then If objNomina.DtResultados.Rows.Count > 0 Then - DtPercepciones = objNomina.DtResultados.FiltraParametros("Tipo = 'P' AND EsPadre = 1 ") - DtDeducciones = objNomina.DtResultados.FiltraParametros("Tipo = 'D' AND EsPadre = 1 ") + DtPercepciones = objNomina.DtResultados.FiltraParametros("Tipo = 'P' AND EsPadre = 1 AND SoloVisible =0") + DtDeducciones = objNomina.DtResultados.FiltraParametros("Tipo = 'D' AND EsPadre = 1 AND SoloVisible =0") + DtOtrosPagos = objNomina.DtResultados.FiltraParametros(" TipoConceptoSAT='O'") TotalPercepciones = DtPercepciones.SUM("Importe").ToString().ToDecimal() TotalDeducciones = DtDeducciones.SUM("Importe").ToString().ToDecimal() Total = CType((Total + DtPercepciones.SUM("Importe")), Decimal) @@ -161,7 +160,6 @@ Public Class LogicNominas Else continuar = False End If - If continuar AndAlso objNomina.GetPeriodos(-1, UsuarioActual.CveEmpresa, -1, -1, CvePeriodo) AndAlso objNomina.DtResultados.Rows().Count > 0 Then Dim DrPeriodo As DataRow = objNomina.DtResultados.Rows(0) @@ -183,8 +181,6 @@ Public Class LogicNominas Else continuar = False End If - - If DiasIncapacitados > 0 Then If objNomina.GetIncapacidades(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa) Then If objNomina.DtResultados IsNot Nothing AndAlso objNomina.DtResultados.Rows.Count > 0 Then @@ -222,10 +218,11 @@ Public Class LogicNominas cfdi.Receptor.RFC = RFC cfdi.Receptor.Nombre = NombreCompleto + Dim ObjPercepciones As New List(Of CFDINominaPercepciones) + Dim ObjDeducciones As New List(Of CFDINominaDeducciones) + Dim ObjHorasExtras As New List(Of CFDINominaHorasExtras) + Dim ObjOtrosPagos As New List(Of CFDINominaOtrosPagos) If DtPercepciones IsNot Nothing AndAlso DtPercepciones.Rows.Count > 0 Then - Dim ObjPercepciones As New List(Of CFDINominaPercepciones) - Dim ObjHorasExtras As New List(Of CFDINominaHorasExtras) - Dim ObjOtrosPagos As New List(Of CFDINominaOtrosPagos) For Each Row As DataRow In DtPercepciones.Rows If Row("Importe").ToString().ToDecimal > 0 AndAlso Row("SATCveConcepto").ToString().ToEntero() <> 17 Then If Row("CveSATConcepto").ToString() = "" Then cfdi.AddMsg(String.Format("Concepto No registrado ({0})", Row("Concepto").ToString())) : Exit For @@ -248,11 +245,62 @@ Public Class LogicNominas .Clave = Row("Codigo").ToString(), .Concepto = Row("Concepto").ToString(), .Importe = Row("Importe").ToString().ToDecimal}) End If Next - If ObjPercepciones IsNot Nothing AndAlso ObjPercepciones.Count > 0 Then cfdi.Nomina.Percepciones = ObjPercepciones - If ObjHorasExtras IsNot Nothing AndAlso ObjHorasExtras.Count > 0 Then cfdi.Nomina.HorasExtras = ObjHorasExtras - If ObjOtrosPagos IsNot Nothing AndAlso ObjOtrosPagos.Count > 0 Then cfdi.Nomina.OtrosPagos = ObjOtrosPagos End If + + If DtDeducciones IsNot Nothing AndAlso DtDeducciones.Rows.Count > 0 Then + For Each Row As DataRow In DtDeducciones.Rows + If Row("Importe").ToString().ToDecimal > 0 Then + + If Row("CveSATConcepto").ToString() = "" Then cfdi.AddMsg(String.Format("Concepto No registrado ({0})", Row("Concepto").ToString())) : Exit For + If Row("SATCveConcepto").ToString().ToEntero().ToEntero() = 17 Then + + ObjPercepciones.Add(New CFDINominaPercepciones With {.TipoPercepcion = Row("SATCveConcepto").ToString(), .Clave = Row("Codigo").ToString(), .Concepto = Row("Concepto").ToString(), + .ImporteGravado = Row("ImporteGravado").ToString().ToDecimal(), .ImporteExento = Row("ImporteExento").ToString().ToDecimal()}) + Else + ObjDeducciones.Add(New CFDINominaDeducciones With {.TipoDeduccion = Row("SATCveConcepto").ToString(), + .Clave = Row("Codigo").ToString(), + .Concepto = Row("Concepto").ToString(), + .Importe = Row("Importe").ToString().ToDecimal()} + ) + End If + + End If + + 'subsidio al empleo + 'If Row("SATCveConcepto").ToString().ToEntero().ToEntero() = 17 AndAlso Row("Importe").ToString().ToDecimal > 0 Then 'Subsidio + ' ObjOtrosPagos.Add(New CFDINominaOtrosPagos With {.TipoOtroPago = "002", ' codigo fijo, por ser referente a subsidio al empleo + ' .Clave = Row("Codigo").ToString(), .Concepto = Row("Concepto").ToString(), .Importe = Row("Importe").ToString().ToDecimal}) + 'End If + Next + End If + + If DtOtrosPagos IsNot Nothing AndAlso DtOtrosPagos.Rows.Count > 0 Then + For Each Row As DataRow In DtOtrosPagos.Rows + If (Row("Importe").ToString().ToDecimal() > 0) OrElse (Row("SATCveConcepto").ToString().ToEntero().ToEntero() = 2 AndAlso Row("Importe").ToString().ToDecimal() < 0) Then + + If Row("CveSATConcepto").ToString() = "" Then cfdi.AddMsg(String.Format("Concepto No registrado ({0})", Row("Concepto").ToString())) : Exit For + + ObjOtrosPagos.Add(New CFDINominaOtrosPagos With {.TipoOtroPago = Row("SATCveConcepto").ToString(), .Clave = Row("Codigo").ToString(), .Concepto = Row("Concepto").ToString(), + .Importe = Row("Importe").ToString().ToDecimal().Abs(), .Subsidiocausado = Row("ImporteGravado").ToString().ToDecimal().Abs()}) + + + If Row("SATCveConcepto").ToString().ToEntero().ToEntero() = 7 AndAlso Row("Importe").ToString().ToDecimal > 0 Then 'Subsidio + ObjDeducciones.Add(New CFDINominaDeducciones With {.TipoDeduccion = "002", ' codigo fijo + .Clave = Row("Codigo").ToString(), .Concepto = "ISR", .Importe = Row("Importe").ToString().ToDecimal}) + End If + If Row("SATCveConcepto").ToString().ToEntero().ToEntero() = 8 AndAlso Row("Importe").ToString().ToDecimal > 0 Then 'Subsidio + ObjDeducciones.Add(New CFDINominaDeducciones With {.TipoDeduccion = "071", ' codigo fijo + .Clave = Row("Codigo").ToString(), .Concepto = "(Ajuste en Subsidio para el empleo (efectivamente entregado al trabajador)", .Importe = Row("Importe").ToString().ToDecimal}) + End If + End If + + Next + End If + If ObjPercepciones IsNot Nothing AndAlso ObjPercepciones.Count > 0 Then cfdi.Nomina.Percepciones = ObjPercepciones + If ObjHorasExtras IsNot Nothing AndAlso ObjHorasExtras.Count > 0 Then cfdi.Nomina.HorasExtras = ObjHorasExtras + If ObjOtrosPagos IsNot Nothing AndAlso ObjOtrosPagos.Count > 0 Then cfdi.Nomina.OtrosPagos = ObjOtrosPagos If ObjIncapacidades IsNot Nothing AndAlso ObjIncapacidades.Count > 0 Then cfdi.Nomina.Incapacidades = ObjIncapacidades + If ObjDeducciones IsNot Nothing AndAlso ObjDeducciones.Count > 0 Then cfdi.Nomina.Deducciones = ObjDeducciones cfdi.Comprobante.Version = "3.3" @@ -301,260 +349,4 @@ Public Class LogicNominas End If End Function - Private Function PreTimbrar(CveNomina As Integer, CvePersonal As Integer, CvePeriodo As Integer, UsuarioActual As Usuario) As CFDITimbre - - Dim cfdi As New CFDITimbre - Dim objPersonal As New ClsRH - Dim objNomina As New ClsNominas - objPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) - objNomina.GetNom_Nominas(CveNomina, CvePersonal, CvePeriodo, -1, UsuarioActual.CveEmpresa) - Dim DtPercepciones As Data.DataTable = Nothing - Dim DtDeducciones As Data.DataTable = Nothing - Dim DtOtrosPagos As Data.DataTable = Nothing - Dim TotalPercepciones As Decimal = 0 - Dim TotalDeducciones As Decimal = 0 - Dim TotalOtrosPagos As Decimal = 0 - Dim Total As Decimal = 0 - If objNomina.GetNom_NominasDetalles(CveNomina, CvePersonal, CvePeriodo, "-1") Then - If objNomina.DtResultados.Rows.Count > 0 Then - DtPercepciones = objNomina.DtResultados.FiltraParametros("Tipo = 'P' AND EsPadre = 1 ") - DtDeducciones = objNomina.DtResultados.FiltraParametros("Tipo = 'D' AND EsPadre = 1 ") - TotalPercepciones = DtPercepciones.SUM("Importe").ToString().ToDecimal() - TotalDeducciones = DtDeducciones.SUM("Importe").ToString().ToDecimal() - Total = CType((Total + DtPercepciones.SUM("Importe")), Decimal) - End If - End If - 'nota. siempre y cuando halla concepto 19 - Dim DtHorasExtras As Data.DataTable = Nothing - If objNomina.GetHorasExtras(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa) Then - DtHorasExtras = objNomina.DtResultados - End If - - Dim TotalExcento As Decimal = 0 - Dim TotalGravado As Decimal = 0 - - Dim AntiguedadSemanas As Integer = DateDiff(DateInterval.Weekday, objPersonal.FechaIngreso, Now).ToEntero() - Dim FormatoReciboCFDi As String = objPersonal.FormatoReciboCFDi - - Dim FechaInicio, FechaFin, FechaPago As Date - Dim DiasPagados As Integer = 0 - Dim Msg As String = String.Empty - Dim DiasIncapacitados As Integer = 0 - Dim DrPeriodo As DataRow = Nothing - If objNomina.GetPeriodos(-1, UsuarioActual.CveEmpresa, -1, -1, CvePeriodo) Then - If objNomina.DtResultados.Rows().Count > 0 Then - DrPeriodo = objNomina.DtResultados.Rows(0) - End If - End If - - 'Dim DrPeriodo As DataRow = GlobalDTNominasPeriodos(-1, CvePeriodo, -1).FiltroPrimero("") - If DrPeriodo IsNot Nothing Then - FechaInicio = DrPeriodo("FechaInicio").ToString().ToDate - FechaFin = DrPeriodo("FechaFin").ToString().ToDate - FechaPago = DrPeriodo("FechaPago").ToString().ToDate - If objPersonal.GetAsistencias(CvePersonal, -1, -1, -1, -1, -1, FechaInicio, FechaFin, UsuarioActual.CveEmpresa) Then - - Dim Asistencias As Integer = objPersonal.DtResultados.SUM("AplicaAsistencia").ToEntero() - Dim Vacaciones As Integer = objPersonal.DtResultados.SUM("AplicaVacacion").ToEntero() - DiasIncapacitados = objPersonal.DtResultados.SUM("AplicaIncapacidad").ToEntero() - DiasPagados = Asistencias - Vacaciones - If DiasPagados < 0 Then DiasPagados = 0 - - End If - - End If - - 'Tipo Nomina O de Ordinaria o E de extraordinaria - 'Dim FechaPago As Date = Now - Dim TotalSueldos As Decimal = 0 - Dim TotalIndemnizacion As Decimal = 0 - Dim TotalJubilacion As Decimal = 0 - - cfdi.Nomina = New CFDINomina - cfdi.Nomina.Version = "1.2" - cfdi.Nomina.TipoNomina = If(objNomina.CveTipoPeriodo = 6, "E", "O") - cfdi.Nomina.FechaPago = FechaPago - cfdi.Nomina.FechaInicio = FechaInicio.ToString() - cfdi.Nomina.FechaFin = FechaFin.ToString() - cfdi.Nomina.NumDiasPagados = DiasPagados - cfdi.Emisor.Nombre = UsuarioActual.Empresa.Empresa - cfdi.Emisor.RFC = UsuarioActual.Empresa.RFC - cfdi.Emisor.RegistroPatronal = UsuarioActual.Empresa.RegistroPatronal - cfdi.Emisor.RegimenFiscal = UsuarioActual.Empresa.CodigoRegimenFiscal - 'aplica persona fisica debe de tener CURP - If cfdi.Emisor.RegimenFiscal.Contiene("605", "606", "608", "611", "612", "614", "616", "621", "622", "629", "630", "615") Then - cfdi.Emisor.CURP = UsuarioActual.Empresa.CURP - End If - cfdi.Nomina.CveNomina = CveNomina - - cfdi.Receptor.UsoCFDI = "P01" - cfdi.Receptor.RFC = objPersonal.RFC - cfdi.Receptor.Nombre = objPersonal.NombreCompleto - - If DtPercepciones IsNot Nothing Then - If DtPercepciones.Rows.Count > 0 Then - Dim ObjPercepciones As New List(Of CFDINominaPercepciones) - Dim ObjHorasExtras As New List(Of CFDINominaHorasExtras) - Dim ObjOtrosPagos As New List(Of CFDINominaOtrosPagos) - - For Each Row As DataRow In DtPercepciones.Rows - If Row("Importe").ToString().ToDecimal > 0 AndAlso Row("SATCveConcepto").ToString().ToEntero() <> 17 Then - If Row("CveSATConcepto").ToString() = "" Then cfdi.AddMsg(String.Format("Concepto No registrado ({0})", Row("Concepto").ToString())) : Exit For - - ObjPercepciones.Add(New CFDINominaPercepciones With {.TipoPercepcion = Row("SATCveConcepto").ToString(), - .Clave = Row("Codigo").ToString(), - .Concepto = Row("Concepto").ToString(), - .ImporteGravado = Row("ImporteGravado").ToString().ToDecimal, - .ImporteExento = Row("ImporteExento").ToString().ToDecimal} - ) - - End If - 'RMF, falta poner el numero de horas pagadas - If Row("CveSATConcepto").ToString().ToEntero() = 19 Then 'cuando son horas extras - - 'Obtengo el desglose de horas extras - - If DtHorasExtras IsNot Nothing Then - - Dim dr As DataRow = DtHorasExtras.FiltroPrimero("") - If dr IsNot Nothing Then - - If dr("HorasDobles").ToString().ToDouble > 0 Then ObjHorasExtras.Add(New CFDINominaHorasExtras With {.Dias = dr("DiasHorasDobles").ToString().ToEntero().ToString(), .TipoHoras = "01", .HorasExtra = dr("HorasDobles").ToString().ToEntero(), .ImportePagado = Row("Importe").ToString().ToDecimal}) - If dr("HorasTriples").ToString().ToDouble > 0 Then ObjHorasExtras.Add(New CFDINominaHorasExtras With {.Dias = dr("DiasHorasTriples").ToString().ToEntero().ToString(), .TipoHoras = "02", .HorasExtra = dr("HorasTriples").ToString().ToEntero(), .ImportePagado = Row("Importe").ToString().ToDecimal}) - - End If - - End If - End If - 'subsidio al empleo - If Row("SATCveConcepto").ToString().ToEntero().ToEntero() = 17 AndAlso Row("Importe").ToString().ToDecimal > 0 Then 'Subsidio - - ObjOtrosPagos.Add(New CFDINominaOtrosPagos With {.TipoOtroPago = "002", ' codigo fijo, por ser refernte a subsidio al empleo - .Clave = Row("Codigo").ToString(), - .Concepto = Row("Concepto").ToString(), - .Importe = Row("Importe").ToString().ToDecimal} - ) - - End If - - Next - If ObjPercepciones IsNot Nothing AndAlso ObjPercepciones.Count > 0 Then cfdi.Nomina.Percepciones = ObjPercepciones - If ObjHorasExtras IsNot Nothing AndAlso ObjHorasExtras.Count > 0 Then cfdi.Nomina.HorasExtras = ObjHorasExtras - If ObjOtrosPagos IsNot Nothing AndAlso ObjOtrosPagos.Count > 0 Then cfdi.Nomina.OtrosPagos = ObjOtrosPagos - - End If - - End If - - 'cargo las incapacidades - If DiasIncapacitados > 0 Then - - If objNomina.GetIncapacidades(CvePersonal, CvePeriodo, UsuarioActual.CveEmpresa) Then - - If objNomina.DtResultados IsNot Nothing AndAlso objNomina.DtResultados.Rows.Count > 0 Then - Dim ObjIncapacidades As New List(Of CFDINominaIncapacidades) - For Each dr As DataRow In objNomina.DtResultados.Rows - ObjIncapacidades.Add(New CFDINominaIncapacidades With {.DiasIncapacidad = dr("Dias").ToString().ToEntero().ToString(), .TipoIncapacidad = dr("ClaveTipoIncapacidad").ToString(), .Importe = dr("Descuento").ToString().ToDecimal}) - Next - If ObjIncapacidades IsNot Nothing AndAlso ObjIncapacidades.Count > 0 Then cfdi.Nomina.Incapacidades = ObjIncapacidades - End If - End If - End If - - TotalExcento = 0 - TotalGravado = 0 - - If DtDeducciones IsNot Nothing Then - If DtDeducciones.Rows.Count > 0 Then - - Dim ObjDeducciones As New List(Of CFDINominaDeducciones) - For Each Row As DataRow In DtDeducciones.Rows - - If Row("Importe").ToString().ToDecimal > 0 Then - - If Row("CveSATConcepto").ToString() = "" Then cfdi.AddMsg(String.Format("Concepto No registrado ({0})", Row("Concepto").ToString())) : Exit For - - ObjDeducciones.Add(New CFDINominaDeducciones With {.TipoDeduccion = Row("SATCveConcepto").ToString(), - .Clave = Row("Codigo").ToString(), - .Concepto = Row("Concepto").ToString(), - .Importe = Row("Importe").ToString().ToDecimal} - ) - - End If - Next - If ObjDeducciones IsNot Nothing AndAlso ObjDeducciones.Count > 0 Then cfdi.Nomina.Deducciones = ObjDeducciones - End If - - End If - - - 'If DtOtrosPagos IsNot Nothing Then - ' If DtOtrosPagos.Rows.Count > 0 Then - ' ' Total = CType((Total - DtOtrosPagos.SUM("Importe")), Decimal) - ' Dim ObjOtrosPagos As New List(Of CFDINominaOtrosPagos) - ' ' End If - - ' ' For Each Row As DataRow In DtOtrosPagos.Rows - ' ' If Row("Importe").ToString().ToDecimal > 0 Then - ' ' If Row("CveSATConcepto").ToString() = "" Then - ' ' Msg = String.Format("Concepto No registrado ({0})", Row("Concepto").ToString()) - ' ' Else - ' ' Msg = cfdi.ObjCompNomina12.AgregarOtroPago(Row("SATCveConcepto").ToString(), Row("Codigo").ToString(), Row("Concepto").ToString(), 0) - ' ' 'Msg = CFDi.ObjCompNomina12.CargarSubsidioAlEmpleo(0) - ' ' 'Msg = CFDi.ObjCompNomina12.CargarCompensacionSaldosAFavor(0, 0, 0) - ' ' End If - - ' ' If Msg <> String.Empty Then - ' ' Me.OnError("El SAT regresó el siguiente mensaje: " & Msg & ". Objeto: Otros Pagos", New Exception) - ' ' Exit For - ' ' End If - ' ' End If - ' ' Next - ' If ObjOtrosPagos IsNot Nothing AndAlso ObjOtrosPagos.Count > 0 Then cfdi.Nomina.OtrosPagos = ObjOtrosPagos - ' End If - 'End If - - cfdi.Comprobante.Version = "3.3" - cfdi.Comprobante.Serie = objNomina.Serie - cfdi.Comprobante.Folio = objNomina.Folio.ToString() - cfdi.Comprobante.Fecha = Now - cfdi.Comprobante.Subtotal = cfdi.Nomina.TotalPercepciones.ToString().ToDecimal() + cfdi.Nomina.TotalOtrosPagos.ToString().ToDecimal() - cfdi.Comprobante.Descuentos = cfdi.Nomina.TotalDeducciones.ToString().ToDecimal() - cfdi.Comprobante.Total = cfdi.Comprobante.Subtotal - cfdi.Comprobante.Descuentos 'cfdi.Nomina.TotalPercepciones + cfdi.Nomina.TotalOtrosPagos - cfdi.Nomina.TotalDeducciones - cfdi.Comprobante.MotivoDescuento = "" '"Deducciones nómina" - cfdi.Comprobante.Moneda = "MXN" - cfdi.Comprobante.TipoComprobante = "N" - cfdi.Comprobante.TipoDocto = "Egs" - cfdi.Comprobante.MetodoPago = "PUE" - cfdi.Comprobante.CondicionesdePago = "" '"CONTADO" - cfdi.Comprobante.FormadePago = "99" - cfdi.Comprobante.LugarExpedicion = UsuarioActual.Empresa.CP.ToString() ' AHORITA SOLO SE REQUIERE ESPECIFICAR EL CODIGO POSTAL - cfdi.Comprobante.NumCuentaPago = "" 'objPersonal.BancoNumCuenta - - cfdi.Nomina.Receptor.CURP = objPersonal.CURP - cfdi.Nomina.Receptor.NSS = objPersonal.NumeroSS - cfdi.Nomina.Receptor.FechaInicioContrato = objPersonal.FechaInicioContrato.ToString() - cfdi.Nomina.Receptor.Antiguedad = $"P{AntiguedadSemanas}W" - cfdi.Nomina.Receptor.TipoContrato = objPersonal.CodigoTipoContrato - cfdi.Nomina.Receptor.CodigoTipoJornada = objPersonal.ClaveTipoJornada - cfdi.Nomina.Receptor.CodigoRegimenContratacion = objPersonal.CveRegimenContratacion - cfdi.Nomina.Receptor.CodigoEmpleado = objPersonal.Codigo - cfdi.Nomina.Receptor.Departamento = objPersonal.Departamento - cfdi.Nomina.Receptor.Puesto = objPersonal.Puesto - cfdi.Nomina.Receptor.CodigoRiesgoPuesto = objPersonal.CveSATRiesgoPuesto.ToString() - cfdi.Nomina.Receptor.TipoPeriodo = objPersonal.TipoPeriodoPago - cfdi.Nomina.Receptor.CodigoBanco = objPersonal.ClaveBanco - cfdi.Nomina.Receptor.NumeroCuenta = objPersonal.BancoNumCuenta - cfdi.Nomina.Receptor.SDI = objPersonal.SDI - cfdi.Nomina.Receptor.SBC = objPersonal.SDI - cfdi.Nomina.Receptor.Sindicalizado = "" - cfdi.Nomina.Receptor.CodigoEntidadFederativa = objPersonal.ClaveEstado - - cfdi.Conceptos.Add(New CFDIConceptos With {.Cantidad = 1, .ClaveUnidad = "ACT", .ClaveProdServ = "84111505", .Descripcion = "Pago de nómina", .ValorUnitario = cfdi.Comprobante.Subtotal, .Importe = cfdi.Comprobante.Subtotal, .Descuento = cfdi.Nomina.TotalDeducciones.ToString().ToDecimal()}) - - objPersonal.Dispose() - objNomina.Dispose() - - Return cfdi - End Function End Class diff --git a/App_Code/Timbrado.vb b/App_Code/Timbrado.vb index 520ae6bce..31bb637fa 100644 --- a/App_Code/Timbrado.vb +++ b/App_Code/Timbrado.vb @@ -2048,7 +2048,7 @@ Public Class Timbrado For Each otpag As CFDINominaOtrosPagos In ObjCFDITimbre.Nomina.OtrosPagos cfdi.Nomina12OtroPago(otpag.TipoOtroPago, otpag.Clave, otpag.Concepto, otpag.Importe) If otpag.TipoOtroPago = "002" Then - cfdi.Nomina12SubsidioAlEmpleo(otpag.Importe) + cfdi.Nomina12SubsidioAlEmpleo(otpag.Subsidiocausado) End If Next @@ -2895,10 +2895,10 @@ Public Class Timbrado Nom.OtrosPagos(i).TipoOtroPago = otpag.TipoOtroPago Nom.OtrosPagos(i).Clave = otpag.Clave Nom.OtrosPagos(i).Concepto = otpag.Concepto - Nom.OtrosPagos(i).Importe = otpag.Importe.ToDecimal + Nom.OtrosPagos(i).Importe = otpag.Importe If otpag.TipoOtroPago = "002" Then Nom.OtrosPagos(i).SubsidioAlEmpleo = New Profact.TimbraCFDI33.Complementos.Nomina12.NominaOtroPagoSubsidioAlEmpleo() - Nom.OtrosPagos(i).SubsidioAlEmpleo.SubsidioCausado = otpag.Importe.ToDecimal + Nom.OtrosPagos(i).SubsidioAlEmpleo.SubsidioCausado = otpag.Importe End If i += 1 Next diff --git a/Ashx/SIGWeb.ashx b/Ashx/SIGWeb.ashx index fe81513fa..88ad21772 100644 --- a/Ashx/SIGWeb.ashx +++ b/Ashx/SIGWeb.ashx @@ -52,7 +52,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState Case "sendMail" context.Response.Write(sendMail(context)) Case "sendMailLPM" - context.Response.Write(sendMail(context)) + context.Response.Write(sendMailLPM(context)) End Select Catch ex As Exception diff --git a/Empresas/1/Formatos/ResguardoAF.rdlc b/Empresas/1/Formatos/ResguardoAF.rdlc index 93ec0fd17..b6ae1303e 100644 --- a/Empresas/1/Formatos/ResguardoAF.rdlc +++ b/Empresas/1/Formatos/ResguardoAF.rdlc @@ -535,7 +535,7 @@ - 7.37187cm + 7.35216cm true true @@ -557,7 +557,7 @@ Textbox31 - 0.07053cm + 0.07054cm 0.11166cm 0.6cm 2.77516cm @@ -588,7 +588,7 @@ Textbox31 - 0.1058cm + 0.10581cm 2.9221cm 1.2cm 13.85147cm @@ -604,7 +604,7 @@ - 0.10581cm + 0.10582cm 0.05604cm 0cm 16.76689cm @@ -616,7 +616,7 @@ - 1.3058cm + 1.30581cm 0.11166cm 0cm 16.71127cm @@ -646,7 +646,7 @@ Textbox21 - 1.65886cm + 1.65887cm 0.55741cm 0.63528cm 7.11779cm @@ -692,7 +692,7 @@ Textbox21 - 2.85337cm + 2.85338cm 0.55115cm 0.90367cm 7.11779cm @@ -726,7 +726,7 @@ Textbox22 - 1.3058cm + 1.30581cm 0.56367cm 0.6cm 7.11153cm @@ -760,7 +760,7 @@ Textbox21 - 1.62358cm + 1.62359cm 9.66204cm 0.63528cm 7.11779cm @@ -806,7 +806,7 @@ Textbox21 - 2.85337cm + 2.85338cm 9.65578cm 0.90367cm 7.11779cm @@ -840,7 +840,7 @@ Textbox22 - 1.3058cm + 1.30581cm 9.66204cm 0.6cm 7.11779cm @@ -873,7 +873,7 @@ Textbox17 - 3.82759cm + 3.8276cm 0.00042cm 1.36498cm 16.77315cm @@ -888,51 +888,6 @@ 2pt - - true - true - - - - - Fecha Impresión: - - - - - - - - =Today - - - - - - 2pt - 2pt - 2pt - 2pt - - - - true - true - - - - - Fecha Impresión: - - - - - - - - =Today - - - - - - 2pt - 2pt - 2pt - 2pt - - + + + + + + + +
  • + 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/vwd.webinfo b/vwd.webinfo index 10e72764b..62e975e28 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -110,6 +110,8 @@ + + From 8be79406e1816349aa5ce3006460b0effc128b59 Mon Sep 17 00:00:00 2001 From: Rakcsle Supertramp Date: Tue, 6 Oct 2020 17:43:43 -0700 Subject: [PATCH 14/21] CveSubProyecto Reembolsos y comprobaciones 211 y 78 --- Compras/ReembolsosComprobaciones.aspx | 3 ++- Compras/ReembolsosComprobaciones.aspx.vb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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 From 7058d190b328fc650518826c6362f2ac91ef667b Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 6 Oct 2020 19:00:45 -0700 Subject: [PATCH 15/21] modifiacion de conceptos --- Bancos/FluctuacionCambiaria.aspx.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Bancos/FluctuacionCambiaria.aspx.vb b/Bancos/FluctuacionCambiaria.aspx.vb index 3a522c442..9899e201b 100644 --- a/Bancos/FluctuacionCambiaria.aspx.vb +++ b/Bancos/FluctuacionCambiaria.aspx.vb @@ -389,7 +389,7 @@ Partial Class Bancos_FluctuacionCambiaria Conta.IniciaTransacSQL() Dim ObjContPaq As New ClsContPAQi(UsuarioActual.Empresa) ObjContPaq.IniciaTransacSQL() - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/Fluctua", 1, 0, 0, 1, TxtFecha.Text.ToDate, "Fluctuación", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaB", 1, 0, 0, 1, TxtFecha.Text.ToDate, "Fluctuación Bancaria", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Dim idCta As Integer = 0 Dim CveCuenta As Integer = 0 Dim CveCuentaPerdida, CveCuentaGanancia As Integer @@ -440,7 +440,7 @@ Partial Class Bancos_FluctuacionCambiaria Exit For End If - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), " ", CveConceptoContable, "Fluctuación", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubproyecto.SelectedValue.ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), ConceptoReferencia, CveConceptoContable, ConceptoReferencia, Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubproyecto.SelectedValue.ToEntero) Then ErrorRegistrar = True End If End If From 666bfdbc92ba5777c73ee885110257045df129af Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 6 Oct 2020 19:01:16 -0700 Subject: [PATCH 16/21] -- combo de factura de costo indirecto, se quito todos --- Inventarios/RecepcionAlmacen.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Inventarios/RecepcionAlmacen.aspx.vb b/Inventarios/RecepcionAlmacen.aspx.vb index 53d9e0acb..a26ed908a 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 From ceea0448d18c24e989fad5bb14c6c4bae8ef6cbf Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 6 Oct 2020 19:02:33 -0700 Subject: [PATCH 17/21] -- si es codigosat servicios de facturacion, active el pu, slatandose e l proceso --- Ventas/Ventas.aspx.vb | 182 +++++++++++++++++++++--------------------- 1 file changed, 92 insertions(+), 90 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index c560d8455..19d9fea4b 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -14534,119 +14534,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 From 915f793ce385d257ae5f5a915a796d0e17f2e7c9 Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 6 Oct 2020 19:03:06 -0700 Subject: [PATCH 18/21] -- se quita funcionalidad 153 --- Compras/Compras.aspx.vb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index 0cbaee78a..be933f6a1 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -15051,13 +15051,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 From 58d4562a295cdc3e7970c5d34214ac134fbbd9ff Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 6 Oct 2020 19:10:01 -0700 Subject: [PATCH 19/21] - cambios en conceptos de prepolizas --- Bancos/FluctuacionCambiaria.aspx.vb | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Bancos/FluctuacionCambiaria.aspx.vb b/Bancos/FluctuacionCambiaria.aspx.vb index 0f0db8b7d..b2b635433 100644 --- a/Bancos/FluctuacionCambiaria.aspx.vb +++ b/Bancos/FluctuacionCambiaria.aspx.vb @@ -242,7 +242,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim Total As Decimal = 0 Dim Conta As New ClsContabilidad Conta.IniciaTransacSQL() - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/Fluctua", 1, 0, 0, 1, TxtFecha.Text.ToDate, "Fluctuación", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaC", 1, 0, 0, 1, TxtFecha.Text.ToDate, "Fluctuación", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Dim idCta As Integer = 0 Dim CveCuenta As Integer = 0 Dim CveCuentaPerdida, CveCuentaGanancia As Integer @@ -274,7 +274,7 @@ Partial Class Bancos_FluctuacionCambiaria - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), " ", CveConceptoContable, "Fluctuación", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubProyectoCompras.SelectedValue.ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Compras", CveConceptoContable, "Fluctuación Compras", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubProyectoCompras.SelectedValue.ToEntero) Then ErrorRegistrar = True End If @@ -317,7 +317,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim Total As Decimal = 0 Dim Conta As New ClsContabilidad Conta.IniciaTransacSQL() - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/Fluctua", 1, 0, 0, 1, TxtFecha.Text.ToDate, "Fluctuación", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaV", 1, 0, 0, 1, TxtFecha.Text.ToDate, "Fluctuación Ventas", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Dim idCta As Integer = 0 Dim CveCuenta As Integer = 0 Dim CveCuentaPerdida, CveCuentaGanancia As Integer @@ -346,11 +346,12 @@ Partial Class Bancos_FluctuacionCambiaria idCta = idCtaPerdida TipoMovto = False End If - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), " ", CveConceptoContable, "Fluctuación", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlsubProyectoVentas.SelectedValue.ToEntero) Then - ErrorRegistrar = True - End If - - Dim CveConconceptoCliente As Integer = 203 + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Ventas", CveConceptoContable, "Fluctuación Ventas", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlsubProyectoVentas.SelectedValue.ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Ventas", CveConceptoContable, "Fluctuación Ventas", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlsubProyectoVentas.SelectedValue.ToEntero) Then + ErrorRegistrar = True + End If + + Dim CveConconceptoCliente As Integer = 203 'saco las cuentas de pérdida y ganancia For Each gvr As GridViewRow In GvVentas.Rows @@ -447,7 +448,7 @@ Partial Class Bancos_FluctuacionCambiaria Exit For End If - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), " ", CveConceptoContable, "Fluctuación", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubproyectoBancos.SelectedValue.ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), ConceptoReferencia, CveConceptoContable, ConceptoReferencia, Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubproyectoBancos.SelectedValue.ToEntero) Then ErrorRegistrar = True End If End If @@ -530,7 +531,7 @@ Partial Class Bancos_FluctuacionCambiaria idCta = idCtaPerdida TipoMovto = False End If - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), " ", CveConceptoContable, ConceptoFluctuacion, Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubProyectoDeudores.SelectedValue.ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), ConceptoFluctuacion, CveConceptoContable, ConceptoFluctuacion, Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubProyectoDeudores.SelectedValue.ToEntero) Then ErrorRegistrar = True End If @@ -613,7 +614,7 @@ Partial Class Bancos_FluctuacionCambiaria idCta = idCtaPerdida TipoMovto = False End If - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), " ", CveConceptoContable, ConceptoFluctuacion, Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubProyectoFiliales.SelectedValue.ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), ConceptoFluctuacion, CveConceptoContable, ConceptoFluctuacion, Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubProyectoFiliales.SelectedValue.ToEntero) Then ErrorRegistrar = True End If @@ -669,7 +670,7 @@ Partial Class Bancos_FluctuacionCambiaria Dim Total As Decimal = 0 Dim Conta As New ClsContabilidad Conta.IniciaTransacSQL() - Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/Fluctua", 1, 0, 0, 1, TxtFecha.Text.ToDate, "Fluctuación", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim CvePrePoliza As Integer = Conta.AddPrePolizas("Banc/FluctuaA", 1, 0, 0, 1, TxtFecha.Text.ToDate, "Fluctuación", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Dim idCta As Integer = 0 Dim CveCuenta As Integer = 0 Dim CveCuentaPerdida, CveCuentaGanancia As Integer @@ -699,7 +700,7 @@ Partial Class Bancos_FluctuacionCambiaria idCta = idCtaPerdida TipoMovto = False End If - If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), " ", CveConceptoContable, "Fluctuación", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubProyectoAcreedores.SelectedValue.ToEntero) Then + If Not Conta.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Math.Abs(Total), "Fluctuación Acreedores", CveConceptoContable, "Fluctuación Acreedores", Now, idCta, 0, ImporteMX:=Math.Abs(Total), CveCuenta:=CveCuenta, CveSubProyecto:=DdlSubProyectoAcreedores.SelectedValue.ToEntero) Then ErrorRegistrar = True End If From 95ad7961c2b5a763387ebf7298a2dd15adb83ecc Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 6 Oct 2020 19:45:50 -0700 Subject: [PATCH 20/21] Desglose de IEPS en refacturacion --- App_Code/ClsVentas.vb | 3 ++- App_Code/Modelos.vb | 2 ++ Ventas/Ventas.aspx.vb | 39 +++++++++++++++++++++++++++------------ 3 files changed, 31 insertions(+), 13 deletions(-) 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/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 69bc71753..ca3d32827 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" @@ -5319,8 +5328,7 @@ Partial Class Ventas CargarAlmacenes() - If UsuarioActual.Empresa.FacturaProduccion Then - End If + CargaDocumentacionCliente() If UsuarioActual.CveEmpresa.Contiene(72, 80, 1, 119) Then @@ -8477,7 +8485,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) @@ -10042,7 +10050,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 @@ -15662,13 +15671,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 @@ -15752,12 +15758,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) From 8926286db1c5fba5a226b6d717b5ca08725f890b Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 6 Oct 2020 19:49:01 -0700 Subject: [PATCH 21/21] registro de remisiones en entrega directa --- Inventarios/RecepcionAlmacen.aspx.vb | 111 +++++++++++++++++++++------ Ventas/Ventas.aspx.vb | 15 +++- 2 files changed, 98 insertions(+), 28 deletions(-) diff --git a/Inventarios/RecepcionAlmacen.aspx.vb b/Inventarios/RecepcionAlmacen.aspx.vb index 53d9e0acb..674766529 100644 --- a/Inventarios/RecepcionAlmacen.aspx.vb +++ b/Inventarios/RecepcionAlmacen.aspx.vb @@ -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/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index ca3d32827..828e64803 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -9870,16 +9870,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