This commit is contained in:
Oscar Irigoyen
2022-12-12 10:47:41 -07:00
2 changed files with 194 additions and 290 deletions

View File

@@ -96,12 +96,12 @@
</div>
</div>
<div class="row">
<%--<div class="row">
<div class="col-md-6"></div>
<div class="col-md-6 amChartsAttribution">
<a href="http://www.amcharts.com/" class="amChartsLegend" id="amChartsAttribution">JS charts by amCharts</a>
</div>
</div>
</div>--%>
<asp:UpdatePanel ID="UPPMov" runat="server" RenderMode="Inline" UpdateMode="Conditional">
<ContentTemplate>
<div class="row">
@@ -202,7 +202,7 @@
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span id="Span9" runat="server" class="caption-subject bold uppercase">Compras por Productos - Proveedor Productor - Gráfica </span>
<span id="Span9" runat="server" class="caption-subject bold uppercase">Compras Productores - Gráfica por Cantidad(Kg) </span>
</div>
<div class="actions">
<div class="btn-group">
@@ -313,7 +313,7 @@
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span id="Span5" runat="server" class="caption-subject bold uppercase">Cuentas por cobrar por Cliente - Gráfica </span>
<span id="Span5" runat="server" class="caption-subject bold uppercase">Cuentas por cobrar - Gráfica </span>
</div>
<div class="actions">
<div class="btn-group">
@@ -333,7 +333,7 @@
<div class="row">
<div class="col-md-6">
<asp:UpdatePanel ID="UPTablaCxP" runat="server" class="portlet light xspadding bordered " align="left" style="" UpdateMode="Conditional">
<asp:UpdatePanel ID="UPTablaCPxP" runat="server" class="portlet light xspadding bordered " align="left" style="" UpdateMode="Conditional">
<ContentTemplate>
<div class="portlet-title">
<div class="caption font-green">
@@ -349,7 +349,7 @@
</div>
</div>
<div class="portlet-body formnombottom">
<asp:GridView ID="GvCxP" runat="server" GridLines="None"
<asp:GridView ID="GvCPxP" runat="server" GridLines="None"
CssClass="table table-striped table-advance table-hover ScrollAD Widthall " ShowHeader="True" EmptyDataText="No se encontraron resultados." ShowHeaderWhenEmpty="true"
AutoGenerateColumns="False" AllowPaging="False" ShowFooter="False">
<Columns>
@@ -398,115 +398,119 @@
</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server">
<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<%--<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/serial.js"></script>
<script src="https://www.amcharts.com/lib/3/pie.js"></script>
<script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script>
<link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css" type="text/css" media="all" />
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>--%>
<%--<script src="https://code.highcharts.com/modules/data.js"></script>--%>
<script>
function CargaGraficasPastel(json) {
// Configuración genérica para todas las gráficas
const chartconfig = {
"hideCredits": true,
"type": "pie",
"theme": "light",
"dataProvider": [], // se sobrescribe con la sección indicada del JSON en makeChart
"valueField": "Valor",
"titleField": "Texto",
//"legend": {
// "valueLabels": {
// "text": "{value.value}"
// }
//},
"outlineAlpha": 0.4,
"depth3D": 0,
"balloonText": "[[title]]<br><span style='font-size:14px'><b>[[value]]</b> ([[percents]]% [[Moneda]])</span>",
"angle": 0,
"export": {
"enabled": true
}
Highcharts.setOptions({
lang: {
thousandsSep: ',',
decimalPoint: '.'
}
});
// document.querySelectorAll('div[id^=chartdiv]').forEach((chartdiv) => {
// AmCharts.makeChart(chartdiv, chartconfig);
// });
//AmCharts.makeChart("chartdiv_vxp", { ...chartconfig, type: "serial", dataProvider: json["VxP"] }); // Ventas x Producto
AmCharts.makeChart("chartdiv_cxp", { ...chartconfig, dataProvider: json["CxP"] }); // Compras x Producto TipoProveedor 1
AmCharts.makeChart("chartdiv_cxp192", { ...chartconfig, dataProvider: json["CxP192"] }); // Compras x Producto ProveedorClasificacion 192
AmCharts.makeChart("chartdiv_ccxc", { ...chartconfig, dataProvider: json["CCxC"] }); // Cuentas por Cobrar x Cliente
AmCharts.makeChart("chartdiv_cpxp", { ...chartconfig, dataProvider: json["CPxP"] }); // Cuentas por Pagar x Proveedor
// AmCharts.makeChart("chartdiv_indicadores", { ...chartconfig, dataProvider: json["Indicadores"] }); // Indicadores por Proveedor Productor
document.getElementById('amChartsAttribution').style.visibility = 'visible';
}
function CargaGraficasBarras(json) {
var chart = AmCharts.makeChart("chartdiv_vxp", {
"hideCredits": true,
"type": "serial",
"theme": "light",
"dataProvider": json["VxP"],
"startDuration": 2,
"valueAxes": [{
"position": "left",
"title": "Ventas"
}],
"graphs": [{
"balloonText": "[[category]]: <b>[[value]]</b> [[Moneda]]",
"colorField": "Color",
"fillAlphas": 1,
"lineAlpha": 0.1,
"type": "column",
"valueField": "Valor"
}],
"depth3D": 20,
"angle": 30,
"chartCursor": {
"categoryBalloonEnabled": false,
"cursorAlpha": 0,
"zoomable": false
const chartconfig = {
chart: {
animation: {
duration: 500
},
marginRight: 50
},
"categoryField": "Texto",
"categoryAxis": {
"labelsEnabled": false,
"forceShowField": false,
//"labelFunction": trimLabel
//"gridPosition": "start"
//"labelRotation": 90
title: {
text: undefined,
align: 'left'
},
"export": {
"enabled": true
}
});
var legend = new AmCharts.AmLegend();
legend.fontSize = 9;
legend.labelWidth = 50;
legend.enabled = false;
chart.addLegend(legend);
chart.addListener('dataUpdated', function (e) {
var legendDataItems; //used to store the legend's custom data array.
legendDataItems = e.chart.dataProvider.map(function (dataElement) {
return {
'title': dataElement.Texto.length >= 7 ? dataElement.Texto.substr(0, 6) : dataElement.Texto,
'color': dataElement.Color
legend: {
enabled: false
},
xAxis: {
type: "category"
},
yAxis: {
opposite: true,
tickPixelInterval: 150,
title: {
text: null
},
labels: {
//format: '${y} Kg'
}
});
},
tooltip: {
formatter: function (tooltip) {
var tooltiptext = tooltip.defaultFormatter.call(this, tooltip);
var isCurrency = /^(\d|-)?(\d|,)*\.?\d*$/.test(/<b>(.*?)<\/b>/.exec(tooltiptext));
if (isCurrency) {
tooltiptext = tooltiptext.replace("<b>", "<b>$");
}
tooltiptext = tooltiptext.replace("</b>", " " + this.point.unit + "</b>");
console.log(tooltiptext)
return tooltiptext
},
//footerFormat: '{point.key}'
},
plotOptions: {
series: {
animation: false,
groupPadding: 0,
pointPadding: 0.1,
borderWidth: 0,
colorByPoint: true,
dataSorting: {
enabled: false,
matchByName: true
},
type: "bar",
dataLabels: {
enabled: true,
// format: '${y}'
formatter: function () {
var defaultlabel = Highcharts.getOptions().plotOptions[this.point.series.type].dataLabels.formatter.call(this);
var isCurrency = /^(\d|-)?(\d|,)*\.?\d*$/.test(defaultlabel);
return isCurrency ? "$" + defaultlabel : defaultlabel;
}
}
}
},
series: [
{
type: 'bar',
keys: ['name', 'y', 'color', 'unit'],
data: undefined
}
]
}
// update the legend custom data and redraw the chart
e.chart.legend.data = legendDataItems;
e.chart.legend.enabled = true;
e.chart.validateNow();
});
//AmCharts.makeChart("chartdiv_vxp", { ...chartconfig, type: "serial", dataProvider: json["VxP"] }); // Ventas x Producto
$('#' + "chartdiv_vxp").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["VxP"]) }] })
$('#' + "chartdiv_cxp").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxP"]) }] })
$('#' + "chartdiv_cxp192").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], type: 'pie', data: customAccessor(json["CxP192"]) }] })
$('#' + "chartdiv_ccxc").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CCxC"]) }] })
$('#' + "chartdiv_cpxp").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CPxP"]) }] })
//AmCharts.makeChart("chartdiv_cxp192", { ...chartconfig, dataProvider: json["CxP192"] }); // Compras x Producto ProveedorClasificacion 192
//AmCharts.makeChart("chartdiv_ccxc", { ...chartconfig, dataProvider: json["CCxC"] }); // Cuentas por Cobrar x Cliente
//AmCharts.makeChart("chartdiv_cpxp", { ...chartconfig, dataProvider: json["CPxP"] }); // Cuentas por Pagar x Proveedor
//AmCharts.makeChart("chartdiv_indicadores", { ...chartconfig, dataProvider: json["Indicadores"] }); // Indicadores por Proveedor Productor
function customAccessor(data) {
const newData = [];
data.forEach(function (point, index) {
newData.push([point.Texto, point.Valor, point.Color, point.Unidad]);
});
return newData;
}
}
</script>

View File

@@ -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,34 @@ 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 = "Cantidad DESC"
GvCxP192.DataSource = ObjCitrus.DTSetResultados.Tables(0).DefaultView.ToTable
ObjCitrus.DTSetResultados.Tables(1).DefaultView.Sort = "Moneda,SubTotal DESC"
GvComprasAcreed.DataSource = ObjCitrus.DTSetResultados.Tables(1).DefaultView.ToTable
End If
ObjVentas.Dispose()
@@ -242,9 +111,10 @@ Partial Class General_RepIndicadorResumen
GvCxP192.DataBind()
GvComprasAcreed.DataBind()
GvCCxC.DataBind()
'GvCCxC.HeaderRow.Cells(1).Text = "<a href=""/CxC/RepCxC.aspx"" target=""_blank"">Saldo</a>"
GvCxP.DataBind()
If GvCCxC.DataSource IsNot Nothing Then
GvCCxC.HeaderRow.Cells(1).Text = "<a href=""/CxC/RepCxC.aspx"" target=""_blank"">Saldo</a>"
End If
GvCPxP.DataBind()
'Mostrar gráficos solo si hay datos en su respectiva tabla
If GvVxP.Rows.Count > 0 Then
@@ -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"
@@ -409,16 +279,16 @@ 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 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("Unidad") = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}"
DtVxP.Rows.Add(Row)
RowColorIndex += 1
If RowColorIndex = 17 Then
@@ -426,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 = g.Sum(Function(x) x.Valor),
.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
'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 CxP.Rows
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
@@ -461,31 +331,45 @@ 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(), .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 ProveedorClasificacion=192
DtCxP192.Reset()
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 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("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 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 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))
@@ -494,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 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()
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
@@ -511,23 +395,31 @@ 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 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()
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
@@ -535,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
@@ -543,8 +443,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()