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> </div>
<div class="row"> <%--<div class="row">
<div class="col-md-6"></div> <div class="col-md-6"></div>
<div class="col-md-6 amChartsAttribution"> <div class="col-md-6 amChartsAttribution">
<a href="http://www.amcharts.com/" class="amChartsLegend" id="amChartsAttribution">JS charts by amCharts</a> <a href="http://www.amcharts.com/" class="amChartsLegend" id="amChartsAttribution">JS charts by amCharts</a>
</div> </div>
</div> </div>--%>
<asp:UpdatePanel ID="UPPMov" runat="server" RenderMode="Inline" UpdateMode="Conditional"> <asp:UpdatePanel ID="UPPMov" runat="server" RenderMode="Inline" UpdateMode="Conditional">
<ContentTemplate> <ContentTemplate>
<div class="row"> <div class="row">
@@ -202,7 +202,7 @@
<div class="portlet-title"> <div class="portlet-title">
<div class="caption font-green"> <div class="caption font-green">
<i class="icon-pin font-green"></i> <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>
<div class="actions"> <div class="actions">
<div class="btn-group"> <div class="btn-group">
@@ -313,7 +313,7 @@
<div class="portlet-title"> <div class="portlet-title">
<div class="caption font-green"> <div class="caption font-green">
<i class="icon-pin font-green"></i> <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>
<div class="actions"> <div class="actions">
<div class="btn-group"> <div class="btn-group">
@@ -333,7 +333,7 @@
<div class="row"> <div class="row">
<div class="col-md-6"> <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> <ContentTemplate>
<div class="portlet-title"> <div class="portlet-title">
<div class="caption font-green"> <div class="caption font-green">
@@ -349,7 +349,7 @@
</div> </div>
</div> </div>
<div class="portlet-body formnombottom"> <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" 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"> AutoGenerateColumns="False" AllowPaging="False" ShowFooter="False">
<Columns> <Columns>
@@ -398,115 +398,119 @@
</asp:Content> </asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server"> <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/serial.js"></script>
<script src="https://www.amcharts.com/lib/3/pie.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> <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" /> <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> <script>
function CargaGraficasPastel(json) { Highcharts.setOptions({
lang: {
// Configuración genérica para todas las gráficas thousandsSep: ',',
const chartconfig = { decimalPoint: '.'
"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
}
} }
});
// 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) { function CargaGraficasBarras(json) {
var chart = AmCharts.makeChart("chartdiv_vxp", { const chartconfig = {
"hideCredits": true, chart: {
"type": "serial", animation: {
"theme": "light", duration: 500
"dataProvider": json["VxP"], },
"startDuration": 2, marginRight: 50
"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
}, },
"categoryField": "Texto", title: {
"categoryAxis": { text: undefined,
"labelsEnabled": false, align: 'left'
"forceShowField": false,
//"labelFunction": trimLabel
//"gridPosition": "start"
//"labelRotation": 90
}, },
"export": { legend: {
"enabled": true enabled: false
} },
}); xAxis: {
type: "category"
var legend = new AmCharts.AmLegend(); },
legend.fontSize = 9; yAxis: {
legend.labelWidth = 50; opposite: true,
legend.enabled = false; tickPixelInterval: 150,
title: {
chart.addLegend(legend); text: null
},
chart.addListener('dataUpdated', function (e) { labels: {
var legendDataItems; //used to store the legend's custom data array. //format: '${y} Kg'
legendDataItems = e.chart.dataProvider.map(function (dataElement) {
return {
'title': dataElement.Texto.length >= 7 ? dataElement.Texto.substr(0, 6) : dataElement.Texto,
'color': dataElement.Color
} }
}); },
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 //AmCharts.makeChart("chartdiv_vxp", { ...chartconfig, type: "serial", dataProvider: json["VxP"] }); // Ventas x Producto
e.chart.legend.data = legendDataItems;
e.chart.legend.enabled = true; $('#' + "chartdiv_vxp").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["VxP"]) }] })
e.chart.validateNow(); $('#' + "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> </script>

View File

@@ -6,94 +6,6 @@ Imports MoreLinq
Partial Class General_RepIndicadorResumen Partial Class General_RepIndicadorResumen
Inherits ClsPaginas Inherits ClsPaginas
#Region "propiedades" #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 Private Property Indicadores As DataTable
Get 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, 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 -1, -1, -1, -1, "-1", UsuarioActual.CveEmpresa, 5, CveUsuarioConsulta:=UsuarioActual.CveUsuario, TipoCambio:=1) Then
VxP = ObjVentas.DtResultados ObjVentas.DtResultados.DefaultView.Sort = "CveMoneda,SubTotal DESC"
VxP.DefaultView.Sort = "CveMoneda,SubTotal DESC" GvVxP.DataSource = ObjVentas.DtResultados.DefaultView.ToTable
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
End If End If
'If ObjCompras.GetRepProductosServicios(-1, DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, TxtFechaI.Text.Trim(), TxtFechaF.Text.Trim(), -1, -1, -1, '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 ' UsuarioActual.CveEmpresa, 5, -1, -1, "-1", "-1", -1, TipoCambio:=1, CveUsuarioConsulta:=UsuarioActual.CveUsuario, CveProveedorClasificacion:=192) Then
' CxP = ObjCompras.DtResultados ' GvCxP192.DataSource = ObjCompras.DtResultados.DefaultView.Sort = "CveMoneda,SubTotal DESC"
' CxP.DefaultView.Sort = "CveMoneda,SubTotal DESC"
' CxP = CxP.DefaultView.ToTable
' GvCxP.DataSource = CxP
'Else
' GvCxP.DataSource = Nothing
' CxP = Nothing
'End If 'End If
Dim FechaCorte As String = $"31/12/{Now.Year}" 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, 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 "-1", "-1", "-1", FechaCorte:=FechaCorte.ToDate, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then
ObjMovtos.DtResultados.DefaultView.Sort = "CveMoneda,Saldo DESC"
CCxC = ObjMovtos.DtResultados GvCCxC.DataSource = ObjMovtos.DtResultados.DefaultView.ToTable
CCxC.DefaultView.Sort = "CveMoneda,Saldo DESC"
CCxC = CCxC.DefaultView.ToTable
GvCCxC.DataSource = CCxC
Else
GvCCxC.DataSource = Nothing
CCxC = Nothing
End If End If
If ObjMovtos.GetCxP(MinFecha, TxtFechaF.Text, -1, DdlSubProyecto.SelectedValue.ToEntero, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa, 5, -1, 1, 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 FechaCorte:=FechaCorte.ToDate, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then
ObjMovtos.DtResultados.DefaultView.Sort = "CveMoneda,Saldo DESC"
CPxP = ObjMovtos.DtResultados GvCPxP.DataSource = ObjMovtos.DtResultados.DefaultView.ToTable
CPxP.DefaultView.Sort = "CveMoneda,Saldo DESC"
CPxP = CPxP.DefaultView.ToTable
GvCxP.DataSource = CPxP
Else
GvCxP.DataSource = Nothing
CPxP = Nothing
End If 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 If ObjCitrus.GetIndicadores(UsuarioActual.CveEmpresa, TxtFechaI.Text, TxtFechaF.Text, UsuarioActual.CveUsuario, DdlSubProyecto.SelectedValue.ToEntero) Then
ObjCitrus.DTSetResultados.Tables(0).DefaultView.Sort = "Cantidad DESC"
GvCxP192.DataSource = ObjCitrus.DTSetResultados.Tables(0) GvCxP192.DataSource = ObjCitrus.DTSetResultados.Tables(0).DefaultView.ToTable
GvComprasAcreed.DataSource = ObjCitrus.DTSetResultados.Tables(1) ObjCitrus.DTSetResultados.Tables(1).DefaultView.Sort = "Moneda,SubTotal DESC"
CxP = ObjCitrus.DTSetResultados.Tables(1) GvComprasAcreed.DataSource = ObjCitrus.DTSetResultados.Tables(1).DefaultView.ToTable
End If End If
ObjVentas.Dispose() ObjVentas.Dispose()
@@ -242,9 +111,10 @@ Partial Class General_RepIndicadorResumen
GvCxP192.DataBind() GvCxP192.DataBind()
GvComprasAcreed.DataBind() GvComprasAcreed.DataBind()
GvCCxC.DataBind() GvCCxC.DataBind()
'GvCCxC.HeaderRow.Cells(1).Text = "<a href=""/CxC/RepCxC.aspx"" target=""_blank"">Saldo</a>" If GvCCxC.DataSource IsNot Nothing Then
GvCxP.DataBind() 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 'Mostrar gráficos solo si hay datos en su respectiva tabla
If GvVxP.Rows.Count > 0 Then If GvVxP.Rows.Count > 0 Then
@@ -267,7 +137,7 @@ Partial Class General_RepIndicadorResumen
Else Else
UPGraficaCCxC.Visible = False UPGraficaCCxC.Visible = False
End If End If
If GvCxP.Rows.Count > 0 Then If GvCPxP.Rows.Count > 0 Then
UPGraficaCPxP.Visible = True UPGraficaCPxP.Visible = True
Else Else
UPGraficaCPxP.Visible = False UPGraficaCPxP.Visible = False
@@ -279,7 +149,7 @@ Partial Class General_RepIndicadorResumen
'End If 'End If
'Si no había datos en ninguna tabla no cargar función de gráficos '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() GraficasPastel()
'GraficasBarras() 'GraficasBarras()
End Sub 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}" ' e.Row.Cells(2).Text = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {e.Row.DBCampo("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}"
End If End If
End Sub 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.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("Orden") = "" Then If e.Row.DBCampo("Orden") = "" Then
e.Row.CssClass = "Totales" e.Row.CssClass = "Totales"
@@ -409,16 +279,16 @@ Partial Class General_RepIndicadorResumen
DtVxP.Columns.Add("Texto") DtVxP.Columns.Add("Texto")
DtVxP.Columns.Add("Valor") DtVxP.Columns.Add("Valor")
DtVxP.Columns.Add("Color") DtVxP.Columns.Add("Color")
DtVxP.Columns.Add("Moneda") DtVxP.Columns.Add("Unidad")
RowColorIndex = 0 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 If Not Dr("Orden").ToString = "" Then
Dim Row As DataRow = Nothing Dim Row As DataRow = Nothing
Row = DtVxP.NewRow() 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("Valor") = Dr("SubTotal").ToString.FormatoNumero
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString 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) DtVxP.Rows.Add(Row)
RowColorIndex += 1 RowColorIndex += 1
If RowColorIndex = 17 Then If RowColorIndex = 17 Then
@@ -426,34 +296,34 @@ Partial Class General_RepIndicadorResumen
End If End If
End If End If
Next 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 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(), .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(), .Unidad = s("Unidad").ToString()}
Dim group_resto_vxp = resto_vxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { Dim group_resto_vxp = resto_vxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With {
.Texto = "Otros", .Texto = "Otros",
.Valor = g.Sum(Function(x) x.Valor), .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2),
.Color = "#000000", .Color = "#000000",
.Moneda = "MXN" .Unidad = "MXN"
}) })
Dim query_vxp = top_vxp.Union(group_resto_vxp) 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 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 = 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.Reset()
DtCxP.Columns.Add("Texto") DtCxP.Columns.Add("Texto")
DtCxP.Columns.Add("Valor") DtCxP.Columns.Add("Valor")
DtCxP.Columns.Add("Color") DtCxP.Columns.Add("Color")
DtCxP.Columns.Add("Moneda") DtCxP.Columns.Add("Unidad")
RowColorIndex = 0 RowColorIndex = 0
For Each Dr As DataRow In CxP.Rows For Each Dr As DataRow In GvComprasAcreed.DataSource.Rows
If Dr("CveClasificacion").ToString <> "" Then If Dr("CveClasificacion").ToString <> "" Then
Dim Row As DataRow = Nothing Dim Row As DataRow = Nothing
Row = DtCxP.NewRow() 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("Valor") = Dr("SubTotal").ToString.FormatoNumero
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString
Row("Moneda") = Dr("Moneda").ToString Row("Unidad") = Dr("Moneda").ToString
DtCxP.Rows.Add(Row) DtCxP.Rows.Add(Row)
RowColorIndex += 1 RowColorIndex += 1
If RowColorIndex = 17 Then If RowColorIndex = 17 Then
@@ -461,31 +331,45 @@ Partial Class General_RepIndicadorResumen
End If End If
End If End If
Next 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 'Compras x Producto ProveedorClasificacion=192
DtCxP192.Reset() DtCxP192.Reset()
DtCxP192.Columns.Add("Texto") DtCxP192.Columns.Add("Texto")
DtCxP192.Columns.Add("Valor") DtCxP192.Columns.Add("Valor")
DtCxP192.Columns.Add("Color") DtCxP192.Columns.Add("Color")
DtCxP192.Columns.Add("Moneda") DtCxP192.Columns.Add("Unidad")
RowColorIndex = 0 RowColorIndex = 0
For Each Dr As DataRow In CxP192.Rows For Each Dr As DataRow In GvCxP192.DataSource.Rows
If Not Dr("Orden").ToString = "00ND" Then Dim Row As DataRow = Nothing
Dim Row As DataRow = Nothing Row = DtCxP192.NewRow()
Row = DtCxP192.NewRow() Row("Texto") = Dr("RazonSocial").ToString
Row("Texto") = $"{Dr("GPO").ToString} {GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" Row("Valor") = Dr("Cantidad").ToString.FormatoNumero
Row("Valor") = Dr("SubTotal").ToString.FormatoNumero Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString Row("Unidad") = "Kg"
Row("Moneda") = Dr("Abreviatura").ToString DtCxP192.Rows.Add(Row)
DtCxP192.Rows.Add(Row) RowColorIndex += 1
RowColorIndex += 1 If RowColorIndex = 17 Then
If RowColorIndex = 17 Then RowColorIndex = 0
RowColorIndex = 0
End If
End If End If
Next 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)) 'Alert(Newtonsoft.Json.JsonConvert.SerializeObject(CCxC.Rows))
@@ -494,16 +378,16 @@ Partial Class General_RepIndicadorResumen
DtCCxC.Columns.Add("Texto") DtCCxC.Columns.Add("Texto")
DtCCxC.Columns.Add("Valor") DtCCxC.Columns.Add("Valor")
DtCCxC.Columns.Add("Color") DtCCxC.Columns.Add("Color")
DtCCxC.Columns.Add("Moneda") DtCCxC.Columns.Add("Unidad")
RowColorIndex = 0 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 If Not Dr("Orden").ToString = "" Then
Dim Row As DataRow = Nothing Dim Row As DataRow = Nothing
Row = DtCCxC.NewRow() 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("Valor") = Dr("Saldo").ToString.FormatoNumero
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString 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) DtCCxC.Rows.Add(Row)
RowColorIndex += 1 RowColorIndex += 1
If RowColorIndex = 17 Then If RowColorIndex = 17 Then
@@ -511,23 +395,31 @@ Partial Class General_RepIndicadorResumen
End If End If
End If End If
Next 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 'Cuentas por pagar x Proveedor
DtCPxP.Reset() DtCPxP.Reset()
DtCPxP.Columns.Add("Texto") DtCPxP.Columns.Add("Texto")
DtCPxP.Columns.Add("Valor") DtCPxP.Columns.Add("Valor")
DtCPxP.Columns.Add("Color") DtCPxP.Columns.Add("Color")
DtCPxP.Columns.Add("Moneda") DtCPxP.Columns.Add("Unidad")
RowColorIndex = 0 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 If Not Dr("Orden").ToString = "" Then
Dim Row As DataRow = Nothing Dim Row As DataRow = Nothing
Row = DtCPxP.NewRow() Row = DtCPxP.NewRow()
Row("Texto") = $"{Dr("GPO").ToString} {GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}" Row("Texto") = $"{Dr("GPO").ToString} {GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}"
Row("Valor") = Dr("Saldo").ToString.FormatoNumero Row("Valor") = Dr("Saldo").ToString.FormatoNumero
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString 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) DtCPxP.Rows.Add(Row)
RowColorIndex += 1 RowColorIndex += 1
If RowColorIndex = 17 Then If RowColorIndex = 17 Then
@@ -535,7 +427,15 @@ Partial Class General_RepIndicadorResumen
End If End If
End If End If
Next 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 '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, .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() {}}) 'Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(New With {.VxP = query_vxp, .CCxC = New String() {}})
'Alert(json) 'Alert(json)
RegistraScript($"CargaGraficasPastel({json})", "22") RegistraScript($"CargaGraficasBarras({json})", "sdkp24223")
RegistraScript($"CargaGraficasBarras({json})", "223") 'RegistraScript($"CargaGraficasPastel({json})", "22")
UPPMov.Update() UPPMov.Update()
End Sub End Sub
Private Sub GraficasBarras() Private Sub GraficasBarras()