From 38c5ce2735182ee0546adc89e268f759733c1801 Mon Sep 17 00:00:00 2001 From: MLopez Date: Fri, 9 Dec 2022 19:40:50 -0700 Subject: [PATCH 1/2] =?UTF-8?q?E172=20Rep=20Indicador:=20Se=20cambi=C3=B3?= =?UTF-8?q?=20de=20motor=20de=20gr=C3=A1ficos=20de=20AmCharts=20a=20Highch?= =?UTF-8?q?arts=20-=20Highcharts=20es=20m=C3=A1s=20estable=20que=20AmChart?= =?UTF-8?q?s=20aparentemente=20el=20cual=20tuvo=20problemas=20al=20mostrar?= =?UTF-8?q?=20varios=20tipos=20de=20graficas=20simultaneamente=20-=20Se=20?= =?UTF-8?q?refactoriz=C3=B3=20el=20c=C3=B3digo=20para=20reducir=20las=20l?= =?UTF-8?q?=C3=ADneas=20de=20c=C3=B3digo=20innecesarias?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- General/RepIndicadorResumen.aspx | 194 ++++++++++++------------ General/RepIndicadorResumen.aspx.vb | 220 ++++++---------------------- 2 files changed, 144 insertions(+), 270 deletions(-) diff --git a/General/RepIndicadorResumen.aspx b/General/RepIndicadorResumen.aspx index fb5953c69..032e123d6 100644 --- a/General/RepIndicadorResumen.aspx +++ b/General/RepIndicadorResumen.aspx @@ -96,12 +96,12 @@ -
+ <%-- +
--%>
@@ -333,7 +333,7 @@
- +
@@ -349,7 +349,7 @@
- @@ -398,115 +398,113 @@ - + <%-- - + --%> + <%----%> + diff --git a/General/RepIndicadorResumen.aspx.vb b/General/RepIndicadorResumen.aspx.vb index 230c5c227..37d32ec33 100644 --- a/General/RepIndicadorResumen.aspx.vb +++ b/General/RepIndicadorResumen.aspx.vb @@ -6,94 +6,6 @@ Imports MoreLinq Partial Class General_RepIndicadorResumen Inherits ClsPaginas #Region "propiedades" - - Private Property VxP As DataTable - Get - - If ViewState("VxP") Is Nothing Then - Return New DataTable - Else - Return DirectCast(ViewState("VxP"), DataTable) - End If - - End Get - Set(value As DataTable) - ViewState("VxP") = value - End Set - End Property - Private Property CxP As DataTable - Get - - If ViewState("CxP") Is Nothing Then - Return New DataTable - Else - Return DirectCast(ViewState("CxP"), DataTable) - End If - - End Get - Set(value As DataTable) - ViewState("CxP") = value - End Set - End Property - Private Property CxP192 As DataTable - Get - - If ViewState("CxP192") Is Nothing Then - Return New DataTable - Else - Return DirectCast(ViewState("CxP192"), DataTable) - End If - - End Get - Set(value As DataTable) - ViewState("CxP192") = value - End Set - End Property - - Private Property CCxC As DataTable - Get - - If ViewState("CCxC") Is Nothing Then - Return New DataTable - Else - Return DirectCast(ViewState("CCxC"), DataTable) - End If - - End Get - Set(value As DataTable) - ViewState("CCxC") = value - End Set - End Property - Private Property CPxP As DataTable - Get - - If ViewState("CPxP") Is Nothing Then - Return New DataTable - Else - Return DirectCast(ViewState("CPxP"), DataTable) - End If - - End Get - Set(value As DataTable) - ViewState("CPxP") = value - End Set - End Property -#If False Then - Private Property gv1 As DataTable - Get - - If ViewState("gv1") Is Nothing Then - Return New DataTable - Else - Return DirectCast(ViewState("gv1"), DataTable) - End If - - End Get - Set(value As DataTable) - ViewState("gv1") = value - End Set - End Property -#End If Private Property Indicadores As DataTable Get @@ -160,77 +72,35 @@ Partial Class General_RepIndicadorResumen If ObjVentas.GetRepProductosServicios(-1, DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, TxtFechaI.Text.Trim(), TxtFechaF.Text.Trim(), MinFecha, MaxFecha, -1, -1, -1, -1, -1, "-1", UsuarioActual.CveEmpresa, 5, CveUsuarioConsulta:=UsuarioActual.CveUsuario, TipoCambio:=1) Then - VxP = ObjVentas.DtResultados - VxP.DefaultView.Sort = "CveMoneda,SubTotal DESC" - VxP = VxP.DefaultView.ToTable - GvVxP.DataSource = VxP - Else - GvVxP.DataSource = Nothing - VxP = Nothing - End If - - If ObjCompras.GetRepProductosServicios(-1, DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, TxtFechaI.Text.Trim(), TxtFechaF.Text.Trim(), -1, -1, -1, - UsuarioActual.CveEmpresa, 5, -1, -1, "-1", "-1", -1, TipoCambio:=1, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveProveedorClasificacion:=192) Then - CxP192 = ObjCompras.DtResultados - CxP192.DefaultView.Sort = "CveMoneda,SubTotal DESC" - CxP192 = CxP192.DefaultView.ToTable - GvCxP192.DataSource = CxP192 - Else - GvCxP192.DataSource = Nothing - CxP192 = Nothing + ObjVentas.DtResultados.DefaultView.Sort = "CveMoneda,SubTotal DESC" + GvVxP.DataSource = ObjVentas.DtResultados.DefaultView.ToTable End If 'If ObjCompras.GetRepProductosServicios(-1, DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, TxtFechaI.Text.Trim(), TxtFechaF.Text.Trim(), -1, -1, -1, - ' UsuarioActual.CveEmpresa, 5, -1, -1, "-1", "-1", -1, TipoCambio:=1, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveTipoProveedor:=1) Then - ' CxP = ObjCompras.DtResultados - ' CxP.DefaultView.Sort = "CveMoneda,SubTotal DESC" - ' CxP = CxP.DefaultView.ToTable - ' GvCxP.DataSource = CxP - 'Else - ' GvCxP.DataSource = Nothing - ' CxP = Nothing + ' UsuarioActual.CveEmpresa, 5, -1, -1, "-1", "-1", -1, TipoCambio:=1, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveProveedorClasificacion:=192) Then + ' GvCxP192.DataSource = ObjCompras.DtResultados.DefaultView.Sort = "CveMoneda,SubTotal DESC" 'End If Dim FechaCorte As String = $"31/12/{Now.Year}" If ObjMovtos.GetCxC(TxtFechaI.Text, TxtFechaF.Text, -1, DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, "-1", UsuarioActual.CveEmpresa, 5, -1, 1, -1, "-1", "-1", "-1", FechaCorte:=FechaCorte.ToDate, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then - - CCxC = ObjMovtos.DtResultados - CCxC.DefaultView.Sort = "CveMoneda,Saldo DESC" - CCxC = CCxC.DefaultView.ToTable - GvCCxC.DataSource = CCxC - Else - GvCCxC.DataSource = Nothing - CCxC = Nothing + ObjMovtos.DtResultados.DefaultView.Sort = "CveMoneda,Saldo DESC" + GvCCxC.DataSource = ObjMovtos.DtResultados.DefaultView.ToTable End If If ObjMovtos.GetCxP(MinFecha, TxtFechaF.Text, -1, DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa, 5, -1, 1, FechaCorte:=FechaCorte.ToDate, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then - - CPxP = ObjMovtos.DtResultados - CPxP.DefaultView.Sort = "CveMoneda,Saldo DESC" - CPxP = CPxP.DefaultView.ToTable - GvCxP.DataSource = CPxP - Else - GvCxP.DataSource = Nothing - CPxP = Nothing + ObjMovtos.DtResultados.DefaultView.Sort = "CveMoneda,Saldo DESC" + GvCPxP.DataSource = ObjMovtos.DtResultados.DefaultView.ToTable End If - 'If ObjCompras.GetRepProductosServicios(-1, DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, TxtFechaI.Text.Trim(), TxtFechaF.Text.Trim(), -1, -1, -1, - ' UsuarioActual.CveEmpresa, 5, -1, -1, "-1", "-1", -1, TipoCambio:=1, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveProveedorClasificacion:=192) Then - ' gv1 = ObjCompras.DtResultados - ' GridView1.DataSource = gv1 - 'Else - ' GridView1.DataSource = Nothing - ' gv1 = Nothing - 'End If - If ObjCitrus.GetIndicadores(UsuarioActual.CveEmpresa, TxtFechaI.Text, TxtFechaF.Text, UsuarioActual.CveUsuario, DdlSubProyecto.SelectedValue.ToEntero) Then - - GvCxP192.DataSource = ObjCitrus.DTSetResultados.Tables(0) - GvComprasAcreed.DataSource = ObjCitrus.DTSetResultados.Tables(1) - CxP = ObjCitrus.DTSetResultados.Tables(1) + 'ObjCitrus.DTSetResultados.Tables(0).DefaultView.Sort = "CveMoneda,SubTotal DESC" + GvCxP192.DataSource = ObjCitrus.DTSetResultados.Tables(0).DefaultView.ToTable + 'ObjCitrus.DTSetResultados.Tables(1).DefaultView.Sort = "CveMoneda,SubTotal DESC" + GvComprasAcreed.DataSource = ObjCitrus.DTSetResultados.Tables(1).DefaultView.ToTable + 'GvCPxP.DataSource = ObjCitrus.DTSetResultados.Tables(1).DefaultView.ToTable End If ObjVentas.Dispose() @@ -243,7 +113,7 @@ Partial Class General_RepIndicadorResumen GvComprasAcreed.DataBind() GvCCxC.DataBind() 'GvCCxC.HeaderRow.Cells(1).Text = "Saldo" - GvCxP.DataBind() + GvCPxP.DataBind() 'Mostrar gráficos solo si hay datos en su respectiva tabla @@ -267,7 +137,7 @@ Partial Class General_RepIndicadorResumen Else UPGraficaCCxC.Visible = False End If - If GvCxP.Rows.Count > 0 Then + If GvCPxP.Rows.Count > 0 Then UPGraficaCPxP.Visible = True Else UPGraficaCPxP.Visible = False @@ -279,7 +149,7 @@ Partial Class General_RepIndicadorResumen 'End If 'Si no había datos en ninguna tabla no cargar función de gráficos - If (GvVxP.Rows.Count = 0 AndAlso GvComprasAcreed.Rows.Count = 0 AndAlso GvCxP192.Rows.Count = 0 AndAlso GvCCxC.Rows.Count = 0 AndAlso GvCxP.Rows.Count = 0) Then Exit Sub + If (GvVxP.Rows.Count = 0 AndAlso GvComprasAcreed.Rows.Count = 0 AndAlso GvCxP192.Rows.Count = 0 AndAlso GvCCxC.Rows.Count = 0 AndAlso GvCPxP.Rows.Count = 0) Then Exit Sub GraficasPastel() 'GraficasBarras() End Sub @@ -316,7 +186,7 @@ Partial Class General_RepIndicadorResumen ' e.Row.Cells(2).Text = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {e.Row.DBCampo("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" End If End Sub - Protected Sub GvCxP_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxP.RowDataBound + Protected Sub GvCPxP_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCPxP.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DBCampo("Orden") = "" Then e.Row.CssClass = "Totales" @@ -411,14 +281,14 @@ Partial Class General_RepIndicadorResumen DtVxP.Columns.Add("Color") DtVxP.Columns.Add("Moneda") RowColorIndex = 0 - For Each Dr As DataRow In VxP.Rows + For Each Dr As DataRow In GvVxP.DataSource.Rows If Not Dr("Orden").ToString = "" Then Dim Row As DataRow = Nothing Row = DtVxP.NewRow() - Row("Texto") = $"{Dr("GPO").ToString} {GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" + Row("Texto") = Dr("GPO").ToString Row("Valor") = Dr("SubTotal").ToString.FormatoNumero Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString - 'Row("Moneda") = Dr("Abreviatura").ToString + Row("Moneda") = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" DtVxP.Rows.Add(Row) RowColorIndex += 1 If RowColorIndex = 17 Then @@ -430,7 +300,7 @@ Partial Class General_RepIndicadorResumen Dim resto_vxp = From s In DtVxP.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} Dim group_resto_vxp = resto_vxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { .Texto = "Otros", - .Valor = g.Sum(Function(x) x.Valor), + .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2), .Color = "#000000", .Moneda = "MXN" }) @@ -439,14 +309,14 @@ Partial Class General_RepIndicadorResumen 'Dim group_resto_vxp = From e In resto_vxp Group e By e.Texto Into gpo = Group 'Dim group_resto_vxp = resto_vxp.GroupBy(Function(e) New With {Key e.Texto, Key e.Valor, Key e.Color, Key e.Moneda}).ToList() - 'Compras x Producto TipoProveedor=1 + 'Compras x Producto TipoProveedor=1 Acreedores (Gastos) DtCxP.Reset() DtCxP.Columns.Add("Texto") DtCxP.Columns.Add("Valor") DtCxP.Columns.Add("Color") DtCxP.Columns.Add("Moneda") RowColorIndex = 0 - For Each Dr As DataRow In CxP.Rows + For Each Dr As DataRow In GvComprasAcreed.DataSource.Rows If Dr("CveClasificacion").ToString <> "" Then Dim Row As DataRow = Nothing Row = DtCxP.NewRow() @@ -461,7 +331,15 @@ Partial Class General_RepIndicadorResumen End If End If Next - Dim query_cxp = From s In DtCxP.AsEnumerable().Take(20) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} + Dim top_cxp = From s In DtCxP.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} + Dim resto_cxp = From s In DtCxP.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} + Dim group_resto_cxp = resto_cxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { + .Texto = "Otros", + .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2), + .Color = "#000000", + .Moneda = "MXN" + }) + Dim query_cxp = top_cxp.Union(group_resto_cxp) 'Compras x Producto ProveedorClasificacion=192 DtCxP192.Reset() @@ -470,22 +348,20 @@ Partial Class General_RepIndicadorResumen DtCxP192.Columns.Add("Color") DtCxP192.Columns.Add("Moneda") RowColorIndex = 0 - For Each Dr As DataRow In CxP192.Rows - If Not Dr("Orden").ToString = "00ND" Then - Dim Row As DataRow = Nothing - Row = DtCxP192.NewRow() - Row("Texto") = $"{Dr("GPO").ToString} {GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" - Row("Valor") = Dr("SubTotal").ToString.FormatoNumero - Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString - Row("Moneda") = Dr("Abreviatura").ToString - DtCxP192.Rows.Add(Row) - RowColorIndex += 1 - If RowColorIndex = 17 Then - RowColorIndex = 0 - End If + For Each Dr As DataRow In GvCxP192.DataSource.Rows + Dim Row As DataRow = Nothing + Row = DtCxP192.NewRow() + Row("Texto") = $"{Dr("RazonSocial").ToString}" + Row("Valor") = Dr("SubTotal").ToString.FormatoNumero + Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString + 'Row("Moneda") = "MXN" + DtCxP192.Rows.Add(Row) + RowColorIndex += 1 + If RowColorIndex = 17 Then + RowColorIndex = 0 End If Next - Dim query_cxp192 = From s In DtCxP192.AsEnumerable().Take(20) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} + Dim query_cxp192 = From s In DtCxP192.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} 'Alert(Newtonsoft.Json.JsonConvert.SerializeObject(CCxC.Rows)) @@ -496,7 +372,7 @@ Partial Class General_RepIndicadorResumen DtCCxC.Columns.Add("Color") DtCCxC.Columns.Add("Moneda") RowColorIndex = 0 - For Each Dr As DataRow In CCxC.Rows + For Each Dr As DataRow In GvCCxC.DataSource.Rows If Not Dr("Orden").ToString = "" Then Dim Row As DataRow = Nothing Row = DtCCxC.NewRow() @@ -520,7 +396,7 @@ Partial Class General_RepIndicadorResumen DtCPxP.Columns.Add("Color") DtCPxP.Columns.Add("Moneda") RowColorIndex = 0 - For Each Dr As DataRow In CPxP.Rows + For Each Dr As DataRow In GvCPxP.DataSource.Rows If Not Dr("Orden").ToString = "" Then Dim Row As DataRow = Nothing Row = DtCPxP.NewRow() @@ -543,8 +419,8 @@ Partial Class General_RepIndicadorResumen Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(New With {.VxP = query_vxp, .CxP = query_cxp, .CxP192 = query_cxp192, .CCxC = query_ccxc, .CPxP = query_cpxp}) 'Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(New With {.VxP = query_vxp, .CCxC = New String() {}}) 'Alert(json) - RegistraScript($"CargaGraficasPastel({json})", "22") - RegistraScript($"CargaGraficasBarras({json})", "223") + RegistraScript($"CargaGraficasBarras({json})", "sdkp24223") + 'RegistraScript($"CargaGraficasPastel({json})", "22") UPPMov.Update() End Sub Private Sub GraficasBarras() From a995be08335bceea1c07f17386529fa13c73b724 Mon Sep 17 00:00:00 2001 From: MLopez Date: Sat, 10 Dec 2022 11:17:27 -0700 Subject: [PATCH 2/2] =?UTF-8?q?E172=20Rep=20Indicadores=20-=20Compras=20Pr?= =?UTF-8?q?oductores=20Gr=C3=A1fica=20por=20Kg,=20ordenar=20y=20agrupar=20?= =?UTF-8?q?(top=2010=20y=20resto)=20correctamente=20en=20todas=20las=20tab?= =?UTF-8?q?las?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- General/RepIndicadorResumen.aspx | 24 +++++---- General/RepIndicadorResumen.aspx.vb | 82 +++++++++++++++++++---------- 2 files changed, 68 insertions(+), 38 deletions(-) diff --git a/General/RepIndicadorResumen.aspx b/General/RepIndicadorResumen.aspx index 032e123d6..54da8233f 100644 --- a/General/RepIndicadorResumen.aspx +++ b/General/RepIndicadorResumen.aspx @@ -202,7 +202,7 @@
- Compras por Productos - Proveedor Productor - Gráfica + Compras Productores - Gráfica por Cantidad(Kg)
@@ -313,7 +313,7 @@
- Cuentas por cobrar por Cliente - Gráfica + Cuentas por cobrar - Gráfica
@@ -441,12 +441,18 @@ title: { text: null }, + labels: { + //format: '${y} Kg' + } }, tooltip: { formatter: function (tooltip) { var tooltiptext = tooltip.defaultFormatter.call(this, tooltip); - tooltiptext = tooltiptext.replace("", "$"); - tooltiptext = tooltiptext.replace("", " " + this.point.currency + ""); + var isCurrency = /^(\d|-)?(\d|,)*\.?\d*$/.test(/(.*?)<\/b>/.exec(tooltiptext)); + if (isCurrency) { + tooltiptext = tooltiptext.replace("", "$"); + } + tooltiptext = tooltiptext.replace("", " " + this.point.unit + ""); console.log(tooltiptext) return tooltiptext }, @@ -466,11 +472,11 @@ type: "bar", dataLabels: { enabled: true, - // format: '${y}' + // format: '${y}' formatter: function () { var defaultlabel = Highcharts.getOptions().plotOptions[this.point.series.type].dataLabels.formatter.call(this); - var isNumber = /^(\d|-)?(\d|,)*\.?\d*$/.test(defaultlabel); - return isNumber ? "$" + defaultlabel : defaultlabel; + var isCurrency = /^(\d|-)?(\d|,)*\.?\d*$/.test(defaultlabel); + return isCurrency ? "$" + defaultlabel : defaultlabel; } } } @@ -478,7 +484,7 @@ series: [ { type: 'bar', - keys: ['name', 'y', 'color', 'currency'], + keys: ['name', 'y', 'color', 'unit'], data: undefined } ] @@ -501,7 +507,7 @@ function customAccessor(data) { const newData = []; data.forEach(function (point, index) { - newData.push([point.Texto, point.Valor, point.Color, point.Moneda]); + newData.push([point.Texto, point.Valor, point.Color, point.Unidad]); }); return newData; } diff --git a/General/RepIndicadorResumen.aspx.vb b/General/RepIndicadorResumen.aspx.vb index 37d32ec33..c9d29639c 100644 --- a/General/RepIndicadorResumen.aspx.vb +++ b/General/RepIndicadorResumen.aspx.vb @@ -96,11 +96,10 @@ Partial Class General_RepIndicadorResumen End If If ObjCitrus.GetIndicadores(UsuarioActual.CveEmpresa, TxtFechaI.Text, TxtFechaF.Text, UsuarioActual.CveUsuario, DdlSubProyecto.SelectedValue.ToEntero) Then - 'ObjCitrus.DTSetResultados.Tables(0).DefaultView.Sort = "CveMoneda,SubTotal DESC" + ObjCitrus.DTSetResultados.Tables(0).DefaultView.Sort = "Cantidad DESC" GvCxP192.DataSource = ObjCitrus.DTSetResultados.Tables(0).DefaultView.ToTable - 'ObjCitrus.DTSetResultados.Tables(1).DefaultView.Sort = "CveMoneda,SubTotal DESC" + ObjCitrus.DTSetResultados.Tables(1).DefaultView.Sort = "Moneda,SubTotal DESC" GvComprasAcreed.DataSource = ObjCitrus.DTSetResultados.Tables(1).DefaultView.ToTable - 'GvCPxP.DataSource = ObjCitrus.DTSetResultados.Tables(1).DefaultView.ToTable End If ObjVentas.Dispose() @@ -112,10 +111,11 @@ Partial Class General_RepIndicadorResumen GvCxP192.DataBind() GvComprasAcreed.DataBind() GvCCxC.DataBind() - 'GvCCxC.HeaderRow.Cells(1).Text = "Saldo" + If GvCCxC.DataSource IsNot Nothing Then + GvCCxC.HeaderRow.Cells(1).Text = "Saldo" + End If GvCPxP.DataBind() - 'Mostrar gráficos solo si hay datos en su respectiva tabla If GvVxP.Rows.Count > 0 Then UPGraficaVxP.Visible = True @@ -279,7 +279,7 @@ Partial Class General_RepIndicadorResumen DtVxP.Columns.Add("Texto") DtVxP.Columns.Add("Valor") DtVxP.Columns.Add("Color") - DtVxP.Columns.Add("Moneda") + DtVxP.Columns.Add("Unidad") RowColorIndex = 0 For Each Dr As DataRow In GvVxP.DataSource.Rows If Not Dr("Orden").ToString = "" Then @@ -288,7 +288,7 @@ Partial Class General_RepIndicadorResumen Row("Texto") = Dr("GPO").ToString Row("Valor") = Dr("SubTotal").ToString.FormatoNumero Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString - Row("Moneda") = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" + Row("Unidad") = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" DtVxP.Rows.Add(Row) RowColorIndex += 1 If RowColorIndex = 17 Then @@ -296,34 +296,34 @@ Partial Class General_RepIndicadorResumen End If End If Next - Dim top_vxp = From s In DtVxP.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} - Dim resto_vxp = From s In DtVxP.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} + Dim top_vxp = From s In DtVxP.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()} + Dim resto_vxp = From s In DtVxP.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()} Dim group_resto_vxp = resto_vxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { .Texto = "Otros", .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2), .Color = "#000000", - .Moneda = "MXN" + .Unidad = "MXN" }) Dim query_vxp = top_vxp.Union(group_resto_vxp) 'Dim query_vxp = top_vxp.Concat(From e In resto_vxp Group e By e.Texto Into gpo = Group) 'Dim group_resto_vxp = From e In resto_vxp Group e By e.Texto Into gpo = Group - 'Dim group_resto_vxp = resto_vxp.GroupBy(Function(e) New With {Key e.Texto, Key e.Valor, Key e.Color, Key e.Moneda}).ToList() + 'Dim group_resto_vxp = resto_vxp.GroupBy(Function(e) New With {Key e.Texto, Key e.Valor, Key e.Color, Key e.Unidad}).ToList() 'Compras x Producto TipoProveedor=1 Acreedores (Gastos) DtCxP.Reset() DtCxP.Columns.Add("Texto") DtCxP.Columns.Add("Valor") DtCxP.Columns.Add("Color") - DtCxP.Columns.Add("Moneda") + DtCxP.Columns.Add("Unidad") RowColorIndex = 0 For Each Dr As DataRow In GvComprasAcreed.DataSource.Rows If Dr("CveClasificacion").ToString <> "" Then Dim Row As DataRow = Nothing Row = DtCxP.NewRow() - Row("Texto") = Dr("Clasificacion").ToString ' $"{Dr("GPO").ToString} {GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" + Row("Texto") = Dr("Clasificacion").ToString Row("Valor") = Dr("SubTotal").ToString.FormatoNumero Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString - Row("Moneda") = Dr("Moneda").ToString + Row("Unidad") = Dr("Moneda").ToString DtCxP.Rows.Add(Row) RowColorIndex += 1 If RowColorIndex = 17 Then @@ -331,13 +331,13 @@ Partial Class General_RepIndicadorResumen End If End If Next - Dim top_cxp = From s In DtCxP.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} - Dim resto_cxp = From s In DtCxP.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} + Dim top_cxp = From s In DtCxP.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()} + Dim resto_cxp = From s In DtCxP.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()} Dim group_resto_cxp = resto_cxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { .Texto = "Otros", .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2), .Color = "#000000", - .Moneda = "MXN" + .Unidad = "MXN" }) Dim query_cxp = top_cxp.Union(group_resto_cxp) @@ -346,22 +346,30 @@ Partial Class General_RepIndicadorResumen DtCxP192.Columns.Add("Texto") DtCxP192.Columns.Add("Valor") DtCxP192.Columns.Add("Color") - DtCxP192.Columns.Add("Moneda") + DtCxP192.Columns.Add("Unidad") RowColorIndex = 0 For Each Dr As DataRow In GvCxP192.DataSource.Rows Dim Row As DataRow = Nothing Row = DtCxP192.NewRow() - Row("Texto") = $"{Dr("RazonSocial").ToString}" - Row("Valor") = Dr("SubTotal").ToString.FormatoNumero + Row("Texto") = Dr("RazonSocial").ToString + Row("Valor") = Dr("Cantidad").ToString.FormatoNumero Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString - 'Row("Moneda") = "MXN" + Row("Unidad") = "Kg" DtCxP192.Rows.Add(Row) RowColorIndex += 1 If RowColorIndex = 17 Then RowColorIndex = 0 End If Next - Dim query_cxp192 = From s In DtCxP192.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} + Dim top_cxp192 = From s In DtCxP192.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()} + Dim resto_cxp192 = From s In DtCxP192.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()} + Dim group_resto_cxp192 = resto_cxp192.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { + .Texto = "Otros", + .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2), + .Color = "#000000", + .Unidad = "MXN" + }) + Dim query_cxp192 = top_cxp192.Union(group_resto_cxp192) 'Alert(Newtonsoft.Json.JsonConvert.SerializeObject(CCxC.Rows)) @@ -370,16 +378,16 @@ Partial Class General_RepIndicadorResumen DtCCxC.Columns.Add("Texto") DtCCxC.Columns.Add("Valor") DtCCxC.Columns.Add("Color") - DtCCxC.Columns.Add("Moneda") + DtCCxC.Columns.Add("Unidad") RowColorIndex = 0 For Each Dr As DataRow In GvCCxC.DataSource.Rows If Not Dr("Orden").ToString = "" Then Dim Row As DataRow = Nothing Row = DtCCxC.NewRow() - Row("Texto") = $"{Dr("GPO").ToString} {GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" + Row("Texto") = Dr("GPO").ToString Row("Valor") = Dr("Saldo").ToString.FormatoNumero Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString - Row("Moneda") = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" + Row("Unidad") = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" DtCCxC.Rows.Add(Row) RowColorIndex += 1 If RowColorIndex = 17 Then @@ -387,14 +395,22 @@ Partial Class General_RepIndicadorResumen End If End If Next - Dim query_ccxc = From s In DtCCxC.AsEnumerable().Take(20) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} + Dim top_ccxc = From s In DtCCxC.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()} + Dim resto_ccxc = From s In DtCCxC.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()} + Dim group_resto_ccxc = resto_ccxc.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { + .Texto = "Otros", + .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2), + .Color = "#000000", + .Unidad = "MXN" + }) + Dim query_ccxc = top_ccxc.Union(group_resto_ccxc) 'Cuentas por pagar x Proveedor DtCPxP.Reset() DtCPxP.Columns.Add("Texto") DtCPxP.Columns.Add("Valor") DtCPxP.Columns.Add("Color") - DtCPxP.Columns.Add("Moneda") + DtCPxP.Columns.Add("Unidad") RowColorIndex = 0 For Each Dr As DataRow In GvCPxP.DataSource.Rows If Not Dr("Orden").ToString = "" Then @@ -403,7 +419,7 @@ Partial Class General_RepIndicadorResumen Row("Texto") = $"{Dr("GPO").ToString} {GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" Row("Valor") = Dr("Saldo").ToString.FormatoNumero Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString - Row("Moneda") = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" + Row("Unidad") = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" DtCPxP.Rows.Add(Row) RowColorIndex += 1 If RowColorIndex = 17 Then @@ -411,7 +427,15 @@ Partial Class General_RepIndicadorResumen End If End If Next - Dim query_cpxp = From s In DtCPxP.AsEnumerable().Take(20) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} + Dim top_cpxp = From s In DtCPxP.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()} + Dim resto_cpxp = From s In DtCPxP.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()} + Dim group_resto_cpxp = resto_cpxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { + .Texto = "Otros", + .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2), + .Color = "#000000", + .Unidad = "MXN" + }) + Dim query_cpxp = top_cpxp.Union(group_resto_cpxp) 'TODO: Indicadores x Proveedor -- Determinar qué poner en la gráfica con E172