E172 Rep Indicadores agrupar pesos y dolares en las gráficas
This commit is contained in:
@@ -6,63 +6,37 @@ 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
|
||||
|
||||
#If False Then
|
||||
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 If
|
||||
#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()
|
||||
'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
|
||||
@@ -72,53 +46,30 @@ 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
|
||||
ObjVentas.DtResultados.DefaultView.Sort = "CveMoneda,SubTotal DESC"
|
||||
GvVxP.DataSource = ObjVentas.DtResultados.DefaultView.ToTable
|
||||
GvVxP.DataSource = ObjVentas.DtResultados.FiltraParametros("", "CveMoneda,SubTotal DESC")
|
||||
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
|
||||
'Compras Productores
|
||||
GvCompProductores.DataSource = ObjCitrus.DTSetResultados.Tables(0).FiltraParametros("", "RazonSocial DESC")
|
||||
'CxP Productores
|
||||
ObjCitrus.DTSetResultados.Tables(0).DefaultView.Sort = "Cantidad DESC"
|
||||
GvCxP192.DataSource = ObjCitrus.DTSetResultados.Tables(0).DefaultView.ToTable
|
||||
GvCxP192.DataSource = ObjCitrus.DTSetResultados.Tables(1).FiltraParametros("", "CveMoneda,Saldo DESC")
|
||||
'CxP NO productores
|
||||
ObjCitrus.DTSetResultados.Tables(1).DefaultView.Sort = "Saldo DESC"
|
||||
GvCxP.DataSource = ObjCitrus.DTSetResultados.Tables(1).DefaultView.ToTable
|
||||
GvCxP.DataSource = ObjCitrus.DTSetResultados.Tables(2).FiltraParametros("", "CveMoneda,Saldo DESC")
|
||||
'Gastos (Compras acreedores)
|
||||
ObjCitrus.DTSetResultados.Tables(2).DefaultView.Sort = "Moneda,SubTotal DESC"
|
||||
GvComprasAcreed.DataSource = ObjCitrus.DTSetResultados.Tables(2).DefaultView.ToTable
|
||||
GvCompAcreed.DataSource = ObjCitrus.DTSetResultados.Tables(3).FiltraParametros("", "CveMoneda,SubTotal DESC")
|
||||
'Cuentas x Cobrar
|
||||
ObjCitrus.DTSetResultados.Tables(3).DefaultView.Sort = "SaldoMN DESC"
|
||||
GvCxC.DataSource = ObjCitrus.DTSetResultados.Tables(3).DefaultView.ToTable
|
||||
GvCxC.DataSource = ObjCitrus.DTSetResultados.Tables(4).FiltraParametros("", "CveMoneda,Saldo DESC")
|
||||
End If
|
||||
|
||||
ObjVentas.Dispose()
|
||||
ObjCompras.Dispose()
|
||||
ObjMovtos.Dispose()
|
||||
ObjCitrus.Dispose()
|
||||
|
||||
GvVxP.DataBind()
|
||||
GvCxP192.DataBind() 'Compras Productores
|
||||
GvCxP.DataBind() 'Compras NO productores
|
||||
GvComprasAcreed.DataBind()
|
||||
GvCompProductores.DataBind()
|
||||
GvCompAcreed.DataBind()
|
||||
GvCxP192.DataBind()
|
||||
GvCxP.DataBind()
|
||||
GvCxC.DataBind()
|
||||
If GvCxC.DataSource IsNot Nothing Then
|
||||
GvCxC.HeaderRow.Cells(1).Text = "<a href=""/CxC/RepCxC.aspx"" target=""_blank"">Saldo</a>"
|
||||
@@ -131,15 +82,15 @@ Partial Class General_RepIndicadorResumen
|
||||
Else
|
||||
UPGraficaVxP.Visible = False
|
||||
End If
|
||||
If GvComprasAcreed.Rows.Count > 0 Then
|
||||
UPGraficaComprasAcreed.Visible = True
|
||||
If GvCompProductores.Rows.Count > 0 Then
|
||||
UPGraficaCompProductores.Visible = True
|
||||
Else
|
||||
UPGraficaComprasAcreed.Visible = False
|
||||
UPGraficaCompProductores.Visible = False
|
||||
End If
|
||||
If GvCxP192.Rows.Count > 0 Then
|
||||
UPGraficaCxP192.Visible = True
|
||||
If GvCompAcreed.Rows.Count > 0 Then
|
||||
UPGraficaCompAcreed.Visible = True
|
||||
Else
|
||||
UPGraficaCxP192.Visible = False
|
||||
UPGraficaCompAcreed.Visible = False
|
||||
End If
|
||||
If GvCxC.Rows.Count > 0 Then
|
||||
UPGraficaCxC.Visible = True
|
||||
@@ -148,21 +99,27 @@ Partial Class General_RepIndicadorResumen
|
||||
UPGraficaCxC.Visible = False
|
||||
'UPGraficaCxCRec.Visible = False
|
||||
End If
|
||||
If GvCxP192.Rows.Count > 0 Then
|
||||
UPGraficaCxP192.Visible = True
|
||||
Else
|
||||
UPGraficaCxP192.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
|
||||
If GvVxP.Rows.Count = 0 _
|
||||
AndAlso GvCompProductores.Rows.Count = 0 _
|
||||
AndAlso GvCompAcreed.Rows.Count = 0 _
|
||||
AndAlso GvCxC.Rows.Count = 0 _
|
||||
AndAlso GvCxP192.Rows.Count = 0 _
|
||||
AndAlso GvCxP.Rows.Count = 0 _
|
||||
Then Exit Sub
|
||||
|
||||
Graficas()
|
||||
'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
|
||||
@@ -172,26 +129,21 @@ Partial Class General_RepIndicadorResumen
|
||||
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
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If e.Row.DBCampo("CveProveedor") = "" Then
|
||||
e.Row.CssClass = "Totales"
|
||||
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("CveProveedor") = "" Then
|
||||
e.Row.CssClass = "Totales"
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
Protected Sub GvComprasAcreed_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCompAcreed.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If e.Row.DBCampo("CveClasificacion") = "" Then
|
||||
e.Row.CssClass = "Totales"
|
||||
End If
|
||||
@@ -201,128 +153,72 @@ Partial Class General_RepIndicadorResumen
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If e.Row.DBCampo("CveCliente") = "" 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(0).Text = $"Total {GlobalDTMonedas().FiltraParametros($"CveMoneda = {e.Row.DBCampo("CveMoneda").ToString}").Rows(0)("Moneda").ToString}"
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
#If False Then
|
||||
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)
|
||||
DtColor.Rows.Add("#FF0F00")
|
||||
DtColor.Rows.Add("#FF6600")
|
||||
DtColor.Rows.Add("#FF9E01")
|
||||
DtColor.Rows.Add("#FCD202")
|
||||
DtColor.Rows.Add("#F8FF01")
|
||||
DtColor.Rows.Add("#B0DE09")
|
||||
DtColor.Rows.Add("#04D215")
|
||||
DtColor.Rows.Add("#0D8ECF")
|
||||
DtColor.Rows.Add("#0D52D1")
|
||||
DtColor.Rows.Add("#2A0CD0")
|
||||
DtColor.Rows.Add("#8A0CCF")
|
||||
DtColor.Rows.Add("#CD0D74")
|
||||
DtColor.Rows.Add("#754DEB")
|
||||
DtColor.Rows.Add("#DDDDDD")
|
||||
DtColor.Rows.Add("#999999")
|
||||
DtColor.Rows.Add("#333333")
|
||||
DtColor.Rows.Add("#000000")
|
||||
End Sub
|
||||
#End If
|
||||
|
||||
Private Sub Graficas()
|
||||
|
||||
Dim DtVxP, DtCxP192, DtCxP, DtCxPA, DtCxC, DtCxCR As New DataTable
|
||||
Dim RowColorIndex As Integer = 0
|
||||
Dim DtVxP, DtCxP192, DtCxP, DtCompProductores, DtCompAcreed, DtCxC, DtCxCR 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("Color")
|
||||
DtVxP.Columns.Add("Unidad")
|
||||
RowColorIndex = 0
|
||||
If GvVxP.datasource IsNot Nothing Then
|
||||
For Each Dr As DataRow In GvVxP.DataSource.Rows
|
||||
'RowColorIndex = 0
|
||||
If GvVxP.DataSource IsNot Nothing Then
|
||||
For Each Dr As DataRow In CType(GvVxP.DataSource, DataTable).FiltraParametros("", "SubTotalMN DESC").Rows
|
||||
If Not Dr("Orden").ToString = "" Then
|
||||
Dim Row As DataRow = Nothing
|
||||
Row = DtVxP.NewRow()
|
||||
Dim 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}"
|
||||
Row("Valor") = Dr("SubTotalMN").ToString.FormatoNumero
|
||||
Row("Unidad") = "MXN" '$"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}"
|
||||
DtVxP.Rows.Add(Row)
|
||||
RowColorIndex += 1
|
||||
If RowColorIndex = 17 Then
|
||||
RowColorIndex = 0
|
||||
End If
|
||||
'RowColorIndex += 1
|
||||
'If RowColorIndex = 17 Then
|
||||
' RowColorIndex = 0
|
||||
'End If
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
'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 vxp = From s In DtVxP.AsEnumerable() Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .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),
|
||||
' .Valor = Math.Round(Function(x) x.Valor, 2),
|
||||
' .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 top_vxp = From s In DtVxP.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Unidad = s("Unidad").ToString()}
|
||||
Dim resto_vxp = From s In DtVxP.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .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)
|
||||
@@ -331,168 +227,144 @@ Partial Class General_RepIndicadorResumen
|
||||
'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()
|
||||
DtCompProductores.Reset()
|
||||
DtCompProductores.Columns.Add("Texto")
|
||||
DtCompProductores.Columns.Add("Valor")
|
||||
DtCompProductores.Columns.Add("Unidad")
|
||||
For Each Dr As DataRow In GvCompProductores.DataSource.Rows
|
||||
Dim Row = DtCompProductores.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
|
||||
DtCompProductores.Rows.Add(Row)
|
||||
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 {
|
||||
Dim top_comp_productores = From s In DtCompProductores.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Unidad = s("Unidad").ToString()}
|
||||
Dim resto_comp_productores = From s In DtCompProductores.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Unidad = s("Unidad").ToString()}
|
||||
Dim group_resto_comp_productores = resto_comp_productores.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)
|
||||
Dim query_comp_productores = top_comp_productores.Union(group_resto_comp_productores)
|
||||
|
||||
'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
|
||||
'Compras TipoProveedor=1 Acreedores (Gastos)
|
||||
DtCompAcreed.Reset()
|
||||
DtCompAcreed.Columns.Add("Texto")
|
||||
DtCompAcreed.Columns.Add("Valor")
|
||||
DtCompAcreed.Columns.Add("Unidad")
|
||||
For Each Dr As DataRow In CType(GvCompAcreed.DataSource, DataTable).FiltraParametros("", "SubTotalMN DESC").Rows
|
||||
If Dr("CveClasificacion").ToString <> "" Then
|
||||
Dim Row As DataRow = Nothing
|
||||
Row = DtCxPA.NewRow()
|
||||
Dim Row = DtCompAcreed.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
|
||||
Row("Valor") = Dr("SubTotalMN").ToString.FormatoNumero
|
||||
Row("Unidad") = "MXN" 'Dr("Moneda").ToString
|
||||
DtCompAcreed.Rows.Add(Row)
|
||||
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 {
|
||||
Dim top_comp_acreed = From s In DtCompAcreed.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Unidad = s("Unidad").ToString()}
|
||||
Dim resto_comp_acreed = From s In DtCompAcreed.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Unidad = s("Unidad").ToString()}
|
||||
Dim group_resto_comp_acreed = resto_comp_acreed.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)
|
||||
Dim query_comp_acreed = top_comp_acreed.Union(group_resto_comp_acreed)
|
||||
|
||||
'Cuentas por cobrar x Cliente -- Saldo
|
||||
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
|
||||
For Each Dr As DataRow In CType(GvCxC.DataSource, DataTable).FiltraParametros("", "SaldoMN DESC").Rows
|
||||
If Not Dr("CveCliente").ToString = "" Then
|
||||
Dim Row As DataRow = Nothing
|
||||
Row = DtCxC.NewRow()
|
||||
Dim Row = DtCxC.NewRow()
|
||||
Row("Texto") = Dr("RazonSocial").ToString
|
||||
Row("Valor") = Dr("SaldoMN").ToString.FormatoNumero
|
||||
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString
|
||||
Row("Unidad") = "MXN" '$"{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 top_cxc = From s In DtCxC.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Unidad = s("Unidad").ToString()}
|
||||
Dim resto_cxc = From s In DtCxC.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .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))
|
||||
|
||||
'Cuentas por cobrar x Cliente -- Recuperado
|
||||
DtCxCR.Reset()
|
||||
DtCxCR.Columns.Add("Texto")
|
||||
DtCxCR.Columns.Add("Valor")
|
||||
DtCxCR.Columns.Add("Color")
|
||||
DtCxCR.Columns.Add("Unidad")
|
||||
RowColorIndex = 0
|
||||
For Each Dr As DataRow In GvCxC.DataSource.Rows
|
||||
For Each Dr As DataRow In CType(GvCxC.DataSource, DataTable).FiltraParametros("", "SaldoMN DESC").Rows
|
||||
If Not Dr("CveCliente").ToString = "" Then
|
||||
Dim Row As DataRow = Nothing
|
||||
Row = DtCxCR.NewRow()
|
||||
Dim Row = DtCxCR.NewRow()
|
||||
Row("Texto") = Dr("RazonSocial").ToString
|
||||
Row("Valor") = Dr("RecuperadoMN").ToString.FormatoNumero
|
||||
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString
|
||||
Row("Unidad") = "MXN" '$"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}"
|
||||
DtCxCR.Rows.Add(Row)
|
||||
RowColorIndex += 1
|
||||
If RowColorIndex = 17 Then
|
||||
RowColorIndex = 0
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
Dim top_cxcr = From s In DtCxCR.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_cxcr = From s In DtCxCR.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()}
|
||||
Dim top_cxcr = From s In DtCxCR.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Unidad = s("Unidad").ToString()}
|
||||
Dim resto_cxcr = From s In DtCxCR.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Unidad = s("Unidad").ToString()}
|
||||
Dim group_resto_cxcr = resto_cxcr.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_cxcr = top_cxcr.Union(group_resto_cxcr)
|
||||
|
||||
'Alert(Newtonsoft.Json.JsonConvert.SerializeObject(CxC.Rows))
|
||||
'CxP proveedores
|
||||
DtCxP192.Reset()
|
||||
DtCxP192.Columns.Add("Texto")
|
||||
DtCxP192.Columns.Add("Valor")
|
||||
DtCxP192.Columns.Add("Unidad")
|
||||
For Each Dr As DataRow In CType(GvCxP192.DataSource, DataTable).FiltraParametros("", "SaldoMN DESC").Rows
|
||||
If Not Dr("CveProveedor").ToString = "" Then
|
||||
Dim Row = DtCxP192.NewRow()
|
||||
Row("Texto") = Dr("RazonSocial").ToString
|
||||
Row("Valor") = Dr("SaldoMN").ToString.FormatoNumero
|
||||
Row("Unidad") = "MXN"
|
||||
DtCxP192.Rows.Add(Row)
|
||||
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(), .Unidad = s("Unidad").ToString()}
|
||||
Dim resto_cxp192 = From s In DtCxP192.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .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),
|
||||
.Unidad = "MXN"
|
||||
})
|
||||
Dim query_cxp192 = top_cxp192.Union(group_resto_cxp192)
|
||||
|
||||
'TODO: Indicadores x Proveedor -- Determinar qué poner en la gráfica con E172
|
||||
'CxP NO proveedor
|
||||
DtCxP.Reset()
|
||||
DtCxP.Columns.Add("Texto")
|
||||
DtCxP.Columns.Add("Valor")
|
||||
DtCxP.Columns.Add("Unidad")
|
||||
For Each Dr As DataRow In CType(GvCxP.DataSource, DataTable).FiltraParametros("", "SaldoMN DESC").Rows
|
||||
If Not Dr("CveProveedor").ToString = "" Then
|
||||
Dim Row = DtCxP.NewRow()
|
||||
Row("Texto") = Dr("RazonSocial").ToString
|
||||
Row("Valor") = Dr("SaldoMN").ToString.FormatoNumero
|
||||
Row("Unidad") = "MXN"
|
||||
DtCxP.Rows.Add(Row)
|
||||
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(), .Unidad = s("Unidad").ToString()}
|
||||
Dim resto_cxp = From s In DtCxP.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .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),
|
||||
.Unidad = "MXN"
|
||||
})
|
||||
Dim query_cxp = top_cxp.Union(group_resto_cxp)
|
||||
|
||||
'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, .CxCR = query_cxcr})
|
||||
'Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(New With {.VxP = query_vxp, .CxC = New String() {}})
|
||||
Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(New With {.VxP = query_vxp, .CompProductores = query_comp_productores, .CompAcreed = query_comp_acreed, .CxC = query_cxc, .CxCR = query_cxcr, .CxP192 = query_cxp192, .CxP = query_cxp})
|
||||
'Alert(json)
|
||||
RegistraScript($"CargaGraficas({json})", "sdkp24223")
|
||||
UPPMov.Update()
|
||||
|
||||
Reference in New Issue
Block a user