458 lines
21 KiB
VB.net
458 lines
21 KiB
VB.net
Imports System.Data
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
Imports MoreLinq
|
|
|
|
Partial Class General_RepIndicadorResumen
|
|
Inherits ClsPaginas
|
|
#Region "propiedades"
|
|
Private Property Indicadores As DataTable
|
|
Get
|
|
|
|
If ViewState("Indicadores") Is Nothing Then
|
|
Return New DataTable
|
|
Else
|
|
Return DirectCast(ViewState("Indicadores"), DataTable)
|
|
End If
|
|
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("Indicadores") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property DtColor As DataTable
|
|
Get
|
|
|
|
If ViewState("DtColor") Is Nothing Then
|
|
Return New DataTable
|
|
Else
|
|
Return DirectCast(ViewState("DtColor"), DataTable)
|
|
End If
|
|
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtColor") = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
CargaCombos()
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaCombos()
|
|
|
|
'Carga SubProyectos
|
|
CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, lblSubProyecto)
|
|
|
|
TxtFechaI.Text = $"01/{Now.Month}/{Now.Year}"
|
|
TxtFechaF.Text = Now.ToString("dd/MM/yyyy")
|
|
|
|
CreaDataTableColor()
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles btnConsultar.Click
|
|
CargaDatos()
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaDatos()
|
|
|
|
Dim ObjVentas As New ClsVentas
|
|
Dim ObjCompras As New ClsCompras
|
|
Dim ObjMovtos As New ClsMovimientos
|
|
Dim ObjCitrus As New ClsCGame
|
|
|
|
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
|
|
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, 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
|
|
ObjMovtos.DtResultados.DefaultView.Sort = "CveMoneda,Saldo DESC"
|
|
GvCxC.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
|
|
' ObjMovtos.DtResultados.DefaultView.Sort = "CveMoneda,Saldo DESC"
|
|
' GvCPxP.DataSource = ObjMovtos.DtResultados.DefaultView.ToTable
|
|
'End If
|
|
|
|
If ObjCitrus.GetIndicadores(UsuarioActual.CveEmpresa, TxtFechaI.Text, TxtFechaF.Text, UsuarioActual.CveUsuario, DdlSubProyecto.SelectedValue.ToEntero) Then
|
|
'CxP Productores
|
|
ObjCitrus.DTSetResultados.Tables(0).DefaultView.Sort = "Cantidad DESC"
|
|
GvCxP192.DataSource = ObjCitrus.DTSetResultados.Tables(0).DefaultView.ToTable
|
|
'CxP NO productores
|
|
ObjCitrus.DTSetResultados.Tables(1).DefaultView.Sort = "Saldo DESC"
|
|
GvCxP.DataSource = ObjCitrus.DTSetResultados.Tables(1).DefaultView.ToTable
|
|
'Gastos (Compras acreedores)
|
|
ObjCitrus.DTSetResultados.Tables(2).DefaultView.Sort = "Moneda,SubTotal DESC"
|
|
GvComprasAcreed.DataSource = ObjCitrus.DTSetResultados.Tables(2).DefaultView.ToTable
|
|
End If
|
|
|
|
ObjVentas.Dispose()
|
|
ObjCompras.Dispose()
|
|
ObjMovtos.Dispose()
|
|
ObjCitrus.Dispose()
|
|
|
|
GvVxP.DataBind()
|
|
GvCxP192.DataBind() 'Compras Productores
|
|
GvCxP.DataBind() 'Compras NO productores
|
|
GvComprasAcreed.DataBind()
|
|
GvCxC.DataBind()
|
|
If GvCxC.DataSource IsNot Nothing Then
|
|
GvCxC.HeaderRow.Cells(1).Text = "<a href=""/CxC/RepCxC.aspx"" target=""_blank"">Saldo</a>"
|
|
End If
|
|
|
|
'Mostrar gráficos solo si hay datos en su respectiva tabla
|
|
If GvVxP.Rows.Count > 0 Then
|
|
UPGraficaVxP.Visible = True
|
|
Else
|
|
UPGraficaVxP.Visible = False
|
|
End If
|
|
If GvComprasAcreed.Rows.Count > 0 Then
|
|
UPGraficaComprasAcreed.Visible = True
|
|
Else
|
|
UPGraficaComprasAcreed.Visible = False
|
|
End If
|
|
If GvCxP192.Rows.Count > 0 Then
|
|
UPGraficaCxP192.Visible = True
|
|
Else
|
|
UPGraficaCxP192.Visible = False
|
|
End If
|
|
If GvCxC.Rows.Count > 0 Then
|
|
UPGraficaCxC.Visible = True
|
|
Else
|
|
UPGraficaCxC.Visible = False
|
|
End If
|
|
If GvCxP.Rows.Count > 0 Then
|
|
UPGraficaCxP.Visible = True
|
|
Else
|
|
UPGraficaCxP.Visible = False
|
|
End If
|
|
'If GvIndicadores.Rows.Count > 0 Then
|
|
' UPGraficaIndicadores.Visible = True
|
|
'Else
|
|
' UPGraficaIndicadores.Visible = False
|
|
'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 GvCxC.Rows.Count = 0 AndAlso GvCxP.Rows.Count = 0) Then Exit Sub
|
|
GraficasPastel()
|
|
'GraficasBarras()
|
|
End Sub
|
|
Protected Sub GvVxP_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvVxP.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.DBCampo("Orden") = "" Then
|
|
e.Row.CssClass = "Totales"
|
|
End If
|
|
End If
|
|
End Sub
|
|
Protected Sub GvCxP192_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxP192.RowDataBound
|
|
'If e.Row.RowType = DataControlRowType.DataRow Then
|
|
' 'e.Row.Cells(0).Text = e.Row.DBCampo("Orden")
|
|
' 'If e.Row.DBCampo("Orden") = "00ND" Then
|
|
' ' e.Row.CssClass = "Totales"
|
|
' ' e.Row.Cells(0).Text = "Total " + e.Row.DBCampo("Abreviatura")
|
|
' 'End If
|
|
'End If
|
|
End Sub
|
|
Protected Sub GvCxP_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxP.RowDataBound
|
|
'If e.Row.RowType = DataControlRowType.DataRow Then
|
|
' If e.Row.DBCampo("Orden") = "" Then
|
|
' e.Row.CssClass = "Totales"
|
|
' End If
|
|
' 'TODO: Sería mejor usar la Abreviatura de la tabla, pero habría que extender PA_Comp_RepCxP para incluir la columna Abreviatura
|
|
' ' e.Row.Cells(2).Text = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {e.Row.DBCampo("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}"
|
|
'End If
|
|
End Sub
|
|
Protected Sub GvComprasAcreed_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvComprasAcreed.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
'e.Row.Cells(0).Text = e.Row.DBCampo("Orden")
|
|
If e.Row.DBCampo("CveClasificacion") = "" Then
|
|
e.Row.CssClass = "Totales"
|
|
End If
|
|
End If
|
|
End Sub
|
|
Protected Sub GvCCxC_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxC.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.DBCampo("Orden") = "" Then
|
|
e.Row.CssClass = "Totales"
|
|
End If
|
|
'TODO: Sería mejor usar la Abreviatura de la tabla, pero habría que extender PA_Comp_RepCxP para incluir la columna Abreviatura
|
|
' e.Row.Cells(2).Text = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {e.Row.DBCampo("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}"
|
|
End If
|
|
End Sub
|
|
Private Sub CreaDataTableColor()
|
|
DtColor = New DataTable
|
|
DtColor.Columns.Add("Color")
|
|
Dim RowColor As DataRow = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#FF0F00"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#FF6600"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#FF9E01"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#FCD202"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#F8FF01"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#B0DE09"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#04D215"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#0D8ECF"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#0D52D1"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#2A0CD0"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#8A0CCF"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#CD0D74"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#754DEB"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#DDDDDD"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#999999"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#333333"
|
|
DtColor.Rows.Add(RowColor)
|
|
RowColor = Nothing
|
|
RowColor = DtColor.NewRow()
|
|
RowColor("Color") = "#000000"
|
|
DtColor.Rows.Add(RowColor)
|
|
End Sub
|
|
|
|
Private Sub GraficasPastel()
|
|
|
|
Dim DtVxP, DtCxP192, DtCxP, DtCxPA, DtCxC As New DataTable
|
|
Dim RowColorIndex As Integer = 0
|
|
|
|
'Ventas x Producto
|
|
DtVxP.Reset()
|
|
DtVxP.Columns.Add("Texto")
|
|
DtVxP.Columns.Add("Valor")
|
|
DtVxP.Columns.Add("Color")
|
|
DtVxP.Columns.Add("Unidad")
|
|
RowColorIndex = 0
|
|
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
|
|
Row("Valor") = Dr("SubTotal").ToString.FormatoNumero
|
|
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString
|
|
Row("Unidad") = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}"
|
|
DtVxP.Rows.Add(Row)
|
|
RowColorIndex += 1
|
|
If RowColorIndex = 17 Then
|
|
RowColorIndex = 0
|
|
End If
|
|
End If
|
|
Next
|
|
'Dim vxp = From s In DtVxP.AsEnumerable() Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()}
|
|
'Dim group_vxp = vxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With {
|
|
' .Texto = Function(x) x.Texto.ToString,
|
|
' .Valor = Math.Round(Function(x) x.Valor, 2), 'x Tasa de cambio
|
|
' .Color = g.Min(Function(x) x.Color),
|
|
' .Unidad = "MXN"
|
|
'})
|
|
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",
|
|
.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.Unidad}).ToList()
|
|
|
|
'Compras ProveedorClasificacion=192
|
|
DtCxP192.Reset()
|
|
DtCxP192.Columns.Add("Texto")
|
|
DtCxP192.Columns.Add("Valor")
|
|
DtCxP192.Columns.Add("Color")
|
|
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("Cantidad").ToString.FormatoNumero
|
|
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString
|
|
Row("Unidad") = "Kg"
|
|
DtCxP192.Rows.Add(Row)
|
|
RowColorIndex += 1
|
|
If RowColorIndex = 17 Then
|
|
RowColorIndex = 0
|
|
End If
|
|
Next
|
|
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)
|
|
|
|
'Compras NO proveedor
|
|
DtCxP.Reset()
|
|
DtCxP.Columns.Add("Texto")
|
|
DtCxP.Columns.Add("Valor")
|
|
DtCxP.Columns.Add("Color")
|
|
DtCxP.Columns.Add("Unidad")
|
|
RowColorIndex = 0
|
|
For Each Dr As DataRow In GvCxP.DataSource.Rows
|
|
Dim Row As DataRow = Nothing
|
|
Row = DtCxP.NewRow()
|
|
Row("Texto") = Dr("RazonSocial").ToString
|
|
Row("Valor") = Dr("Saldo").ToString.FormatoNumero
|
|
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString
|
|
Row("Unidad") = "MXN"
|
|
DtCxP.Rows.Add(Row)
|
|
RowColorIndex += 1
|
|
If RowColorIndex = 17 Then
|
|
RowColorIndex = 0
|
|
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(), .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",
|
|
.Unidad = "MXN"
|
|
})
|
|
Dim query_cxp = top_cxp.Union(group_resto_cxp)
|
|
|
|
'Compras x Producto TipoProveedor=1 Acreedores (Gastos)
|
|
DtCxPA.Reset()
|
|
DtCxPA.Columns.Add("Texto")
|
|
DtCxPA.Columns.Add("Valor")
|
|
DtCxPA.Columns.Add("Color")
|
|
DtCxPA.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 = DtCxPA.NewRow()
|
|
Row("Texto") = Dr("Clasificacion").ToString
|
|
Row("Valor") = Dr("SubTotal").ToString.FormatoNumero
|
|
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString
|
|
Row("Unidad") = Dr("Moneda").ToString
|
|
DtCxPA.Rows.Add(Row)
|
|
RowColorIndex += 1
|
|
If RowColorIndex = 17 Then
|
|
RowColorIndex = 0
|
|
End If
|
|
End If
|
|
Next
|
|
Dim top_cxpa = From s In DtCxPA.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_cxpa = From s In DtCxPA.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()}
|
|
Dim group_resto_cxpa = resto_cxpa.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_cxpa = top_cxpa.Union(group_resto_cxpa)
|
|
|
|
'Cuentas por cobrar x Cliente
|
|
DtCxC.Reset()
|
|
DtCxC.Columns.Add("Texto")
|
|
DtCxC.Columns.Add("Valor")
|
|
DtCxC.Columns.Add("Color")
|
|
DtCxC.Columns.Add("Unidad")
|
|
RowColorIndex = 0
|
|
For Each Dr As DataRow In GvCxC.DataSource.Rows
|
|
If Not Dr("Orden").ToString = "" Then
|
|
Dim Row As DataRow = Nothing
|
|
Row = DtCxC.NewRow()
|
|
Row("Texto") = Dr("GPO").ToString
|
|
Row("Valor") = Dr("Saldo").ToString.FormatoNumero
|
|
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString
|
|
Row("Unidad") = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}"
|
|
DtCxC.Rows.Add(Row)
|
|
RowColorIndex += 1
|
|
If RowColorIndex = 17 Then
|
|
RowColorIndex = 0
|
|
End If
|
|
End If
|
|
Next
|
|
Dim top_cxc = From s In DtCxC.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_cxc = From s In DtCxC.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()}
|
|
Dim group_resto_cxc = resto_cxc.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_cxc = top_cxc.Union(group_resto_cxc)
|
|
'Alert(Newtonsoft.Json.JsonConvert.SerializeObject(CxC.Rows))
|
|
|
|
'TODO: Indicadores x Proveedor -- Determinar qué poner en la gráfica con E172
|
|
|
|
'Serializar datos agrupándolos por su respectivo DataTable, todos en un solo JSON
|
|
Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(New With {.VxP = query_vxp, .CxP192 = query_cxp192, .CxP = query_cxp, .CxPA = query_cxpa, .CxC = query_cxc})
|
|
'Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(New With {.VxP = query_vxp, .CxC = New String() {}})
|
|
'Alert(json)
|
|
RegistraScript($"CargaGraficas({json})", "sdkp24223")
|
|
UPPMov.Update()
|
|
End Sub
|
|
End Class
|