E172 Rep Indicadores agrupar pesos y dolares en las gráficas

This commit is contained in:
MLopez
2022-12-13 15:25:49 -07:00
parent d4a35481db
commit 1f635cef0f
2 changed files with 405 additions and 463 deletions

View File

@@ -163,12 +163,12 @@
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<asp:UpdatePanel ID="UPTablaCxP192" runat="server" class="portlet light xspadding bordered " align="left" UpdateMode="Conditional"> <asp:UpdatePanel ID="UPTablaCompProductores" runat="server" class="portlet light xspadding bordered " align="left" UpdateMode="Conditional">
<ContentTemplate> <ContentTemplate>
<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="Span8" runat="server" class="caption-subject bold uppercase">Cuentas por Pagar Productores</span> <span id="Span8" runat="server" class="caption-subject bold uppercase">Compras Productores</span>
</div> </div>
<div class="actions"> <div class="actions">
<div class="btn-group"> <div class="btn-group">
@@ -179,7 +179,7 @@
</div> </div>
</div> </div>
<div class="portlet-body formnombottom"> <div class="portlet-body formnombottom">
<asp:GridView ID="GvCxP192" runat="server" GridLines="None" <asp:GridView ID="GvCompProductores" 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>
@@ -196,13 +196,204 @@
</asp:UpdatePanel> </asp:UpdatePanel>
</div> </div>
<div class="col-md-6">
<asp:UpdatePanel ID="UPGraficaCompProductores" runat="server" class="portlet light xspadding bordered " align="center" style="" UpdateMode="Conditional" Visible="false">
<ContentTemplate>
<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 Productores - Gráfica por Cantidad(Kg) </span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body formnombottom">
<div id="chartdiv_compproductores"></div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
<div class="row">
<div class="col-md-6">
<asp:UpdatePanel ID="UPTablaCompAcreed" runat="server" class="portlet light xspadding bordered " align="left" UpdateMode="Conditional">
<ContentTemplate>
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span id="Span1" runat="server" class="caption-subject bold uppercase">Gastos </span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body formnombottom">
<asp:GridView ID="GvCompAcreed" 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>
<asp:BoundField DataField="Clasificacion" HeaderText="Clasificación" ItemStyle-Width="300px" />
<asp:BoundField DataFormatString="{0:n}" DataField="Cantidad" ItemStyle-CssClass="margenbound" HeaderText="Cantidad" />
<asp:BoundField DataFormatString="{0:c}" DataField="SubTotal" ItemStyle-CssClass="margenbound" HeaderText="Importe" />
</Columns>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="col-md-6">
<asp:UpdatePanel ID="UPGraficaCompAcreed" runat="server" class="portlet light xspadding bordered " align="center" style="" UpdateMode="Conditional" Visible="false">
<ContentTemplate>
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span id="Span2" runat="server" class="caption-subject bold uppercase">Compras por clasificación - Gráfica </span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body formnombottom">
<div id="chartdiv_compacreed"></div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
<div class="row">
<div class="col-md-6">
<asp:UpdatePanel ID="UPTablaCxC" runat="server" class="portlet light xspadding bordered " align="left" style="" UpdateMode="Conditional">
<ContentTemplate>
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span id="Span3" runat="server" class="caption-subject bold uppercase">Cuentas por cobrar</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body formnombottom">
<asp:GridView ID="GvCxC" 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>
<asp:BoundField DataField="RazonSocial" HeaderText="Cliente" />
<asp:BoundField DataFormatString="{0:c}" DataField="Saldo" ItemStyle-CssClass="margenbound" HeaderText="Saldo" />
<asp:BoundField DataFormatString="{0:c}" DataField="Recuperado" ItemStyle-CssClass="margenbound" HeaderText="Recuperado" />
</Columns>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="col-md-6">
<asp:UpdatePanel ID="UPGraficaCxC" runat="server" class="portlet light xspadding bordered " align="center" style="" UpdateMode="Conditional" Visible="false">
<ContentTemplate>
<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 - Gráfica Saldo VS Recuperado</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body formnombottom">
<div id="chartdiv_cxc"></div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="col-md-6">
<asp:UpdatePanel ID="UPGraficaCxCRec" runat="server" class="portlet light xspadding bordered " align="center" style="" UpdateMode="Conditional" Visible="false">
<ContentTemplate>
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span id="Span10" runat="server" class="caption-subject bold uppercase">Cuentas por cobrar - Gráfica Recuperado</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body formnombottom">
<div id="chartdiv_cxcrec"></div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
<div class="row">
<div class="col-md-6">
<asp:UpdatePanel ID="UPTablaCxP192" runat="server" class="portlet light xspadding bordered " align="left" style="" UpdateMode="Conditional">
<ContentTemplate>
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span id="Span11" runat="server" class="caption-subject bold uppercase">Cuentas por Pagar productores</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body formnombottom">
<asp:GridView ID="GvCxP192" 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>
<asp:BoundField DataField="RazonSocial" HeaderText="Proveedor" />
<asp:BoundField DataFormatString="{0:c}" DataField="Saldo" ItemStyle-CssClass="margenbound" HeaderText="Saldo" />
</Columns>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="col-md-6"> <div class="col-md-6">
<asp:UpdatePanel ID="UPGraficaCxP192" runat="server" class="portlet light xspadding bordered " align="center" style="" UpdateMode="Conditional" Visible="false"> <asp:UpdatePanel ID="UPGraficaCxP192" runat="server" class="portlet light xspadding bordered " align="center" style="" UpdateMode="Conditional" Visible="false">
<ContentTemplate> <ContentTemplate>
<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">Cuentas por Pagar Productores - Gráfica por Cantidad(Kg) </span> <span id="Span12" runat="server" class="caption-subject bold uppercase">Cuentas por Pagar productores - Gráfica </span>
</div> </div>
<div class="actions"> <div class="actions">
<div class="btn-group"> <div class="btn-group">
@@ -275,142 +466,6 @@
</div> </div>
</div> </div>
<div class="row">
<div class="col-md-6">
<asp:UpdatePanel ID="UPTablaComprasAcreed" runat="server" class="portlet light xspadding bordered " align="left" UpdateMode="Conditional">
<ContentTemplate>
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span id="Span1" runat="server" class="caption-subject bold uppercase">Gastos </span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body formnombottom">
<asp:GridView ID="GvComprasAcreed" 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>
<asp:BoundField DataField="Clasificacion" HeaderText="Clasificación" ItemStyle-Width="300px" />
<asp:BoundField DataFormatString="{0:n}" DataField="Cantidad" ItemStyle-CssClass="margenbound" HeaderText="Cantidad" />
<asp:BoundField DataFormatString="{0:c}" DataField="SubTotal" ItemStyle-CssClass="margenbound" HeaderText="Importe" />
</Columns>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="col-md-6">
<asp:UpdatePanel ID="UPGraficaComprasAcreed" runat="server" class="portlet light xspadding bordered " align="center" style="" UpdateMode="Conditional" Visible="false">
<ContentTemplate>
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span id="Span2" runat="server" class="caption-subject bold uppercase">Compras por clasificación - Gráfica </span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body formnombottom">
<div id="chartdiv_cxpa"></div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
<div class="row">
<div class="col-md-6">
<asp:UpdatePanel ID="UPTablaCxC" runat="server" class="portlet light xspadding bordered " align="left" style="" UpdateMode="Conditional">
<ContentTemplate>
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span id="Span3" runat="server" class="caption-subject bold uppercase">Cuentas por cobrar</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body formnombottom">
<asp:GridView ID="GvCxC" 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>
<asp:BoundField DataField="RazonSocial" HeaderText="Cliente" />
<asp:BoundField DataFormatString="{0:c}" DataField="Saldo" ItemStyle-CssClass="margenbound" HeaderText="Saldo" />
<asp:BoundField DataFormatString="{0:c}" DataField="Recuperado" ItemStyle-CssClass="margenbound" HeaderText="Recuperado" />
</Columns>
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="col-md-6">
<asp:UpdatePanel ID="UPGraficaCxC" runat="server" class="portlet light xspadding bordered " align="center" style="" UpdateMode="Conditional" Visible="false">
<ContentTemplate>
<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 - Gráfica Saldo(MXN)</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body formnombottom">
<div id="chartdiv_cxc"></div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="col-md-6">
<asp:UpdatePanel ID="UPGraficaCxCRec" runat="server" class="portlet light xspadding bordered " align="center" style="" UpdateMode="Conditional" Visible="false">
<ContentTemplate>
<div class="portlet-title">
<div class="caption font-green">
<i class="icon-pin font-green"></i>
<span id="Span10" runat="server" class="caption-subject bold uppercase">Cuentas por cobrar - Gráfica Recuperado</span>
</div>
<div class="actions">
<div class="btn-group">
</div>
</div>
<div class="tools">
<a href="javascript:;" class="collapse"></a>
</div>
</div>
<div class="portlet-body formnombottom">
<div id="chartdiv_cxcrec"></div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</ContentTemplate> </ContentTemplate>
<Triggers> <Triggers>
<asp:AsyncPostBackTrigger ControlID="btnConsultar" EventName="Click" /> <asp:AsyncPostBackTrigger ControlID="btnConsultar" EventName="Click" />
@@ -431,14 +486,14 @@
<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 src="https://code.highcharts.com/modules/data.js"></script>--%>
<script> <script>
Highcharts.setOptions({ Highcharts.setOptions({
lang: { lang: {
thousandsSep: ',', thousandsSep: ',',
decimalPoint: '.' decimalPoint: '.'
} },
colors: ["#FF0F00", "#FF6600", "#FF9E01", "#FCD202", "#F8FF01", "#B0DE09", "#04D215", "#0D8ECF", "#0D52D1", "#2A0CD0", "#8A0CCF", "#CD0D74", "#754DEB", "#DDDDDD", "#999999", "#333333"]
}); });
function CargaGraficas(json) { function CargaGraficas(json) {
@@ -466,23 +521,34 @@
title: { title: {
text: null text: null
}, },
labels: { stackLabels: {
//format: '${y} Kg' enabled: true,
formatter: function () {
return Highcharts.numberFormat(this.total, null, null, ',');
} }
}, },
tooltip: { labels: {
formatter: function (tooltip) { style: {
var tooltiptext = tooltip.defaultFormatter.call(this, tooltip); color: 'red'
//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}' formatter: function () {
return Highcharts.numberFormat(this.value, null, null, ',');
}
}
}, },
//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: { plotOptions: {
series: { series: {
animation: false, animation: false,
@@ -490,26 +556,30 @@
pointPadding: 0.1, pointPadding: 0.1,
borderWidth: 0, borderWidth: 0,
colorByPoint: true, colorByPoint: true,
dataSorting: { //dataSorting: {
enabled: false, // enabled: false,
matchByName: true // matchByName: true
}, //},
stacking: 'normal',
type: "bar", type: "bar",
dataLabels: { dataLabels: {
enabled: true, enabled: true,
// format: '${y}' // format: '${y}'
formatter: function () { // formatter: function () {
var defaultlabel = Highcharts.getOptions().plotOptions[this.point.series.type].dataLabels.formatter.call(this); // var defaultlabel = Highcharts.getOptions().plotOptions[this.point.series.type].dataLabels.formatter.call(this);
var isCurrency = /^(\d|-)?(\d|,)*\.?\d*$/.test(defaultlabel); // var isCurrency = /^(\d|-)?(\d|,)*\.?\d*$/.test(defaultlabel);
return isCurrency ? "$" + defaultlabel : defaultlabel; // return isCurrency ? "$" + defaultlabel : defaultlabel;
} // }
// formatter: function () {
// return this.total;
// },
} }
} }
}, },
series: [ series: [
{ {
type: 'bar', type: 'bar',
keys: ['name', 'y', 'color', 'unit'], keys: ['name', 'y', 'unit'],
data: undefined data: undefined
} }
] ]
@@ -518,20 +588,20 @@
//AmCharts.makeChart("chartdiv_vxp", { ...chartconfig, type: "serial", dataProvider: json["VxP"] }); // Ventas x Producto //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_vxp").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["VxP"]) }] })
$('#' + "chartdiv_cxp192").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], type: 'pie', data: customAccessor(json["CxP192"]) }] }) $('#' + "chartdiv_compproductores").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], type: 'pie', data: customAccessor(json["CompProductores"]) }] })
$('#' + "chartdiv_compacreed").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CompAcreed"]) }] })
$('#' + "chartdiv_cxp192").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxP192"]) }] })
$('#' + "chartdiv_cxp").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxP"]) }] }) $('#' + "chartdiv_cxp").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxP"]) }] })
$('#' + "chartdiv_cxpa").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxPA"]) }] }) $('#' + "chartdiv_cxc").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxC"]) }, { type: 'line', data: customAccessor(json["CxCR"]) }] })
$('#' + "chartdiv_cxc").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxC"]) }, { type: 'line', keys: ['name', 'y', 'ignore', 'unit'], data: customAccessor(json["CxCR"]) }] })
//AmCharts.makeChart("chartdiv_cxp192", { ...chartconfig, dataProvider: json["CxP192"] }); // Compras x Producto ProveedorClasificacion 192
//AmCharts.makeChart("chartdiv_cxc", { ...chartconfig, dataProvider: json["CxC"] }); // Cuentas por Cobrar x Cliente
//AmCharts.makeChart("chartdiv_cxp", { ...chartconfig, dataProvider: json["CxP"] }); // Cuentas por Pagar x Proveedor
//AmCharts.makeChart("chartdiv_indicadores", { ...chartconfig, dataProvider: json["Indicadores"] }); // Indicadores por Proveedor Productor
function customAccessor(data) { function customAccessor(data) {
const newData = []; const newData = [];
data.forEach(function (point, index) { data.forEach(function (point, index) {
newData.push([point.Texto, point.Valor, point.Color, point.Unidad]); if (point.Texto == "Otros") {
newData.push({name:point.Texto, y:point.Valor, unit:point.Unidad, color:'#000000'});
} else {
newData.push([point.Texto, point.Valor, point.Unidad]);
}
}); });
return newData; return newData;
} }

View File

@@ -6,63 +6,37 @@ Imports MoreLinq
Partial Class General_RepIndicadorResumen Partial Class General_RepIndicadorResumen
Inherits ClsPaginas Inherits ClsPaginas
#Region "propiedades" #Region "propiedades"
Private Property Indicadores As DataTable #If False Then
Get
If ViewState("Indicadores") Is Nothing Then
Return New DataTable
Else
Return DirectCast(ViewState("Indicadores"), DataTable)
End If
End Get
Set(value As DataTable)
ViewState("Indicadores") = value
End Set
End Property
Private Property DtColor As DataTable Private Property DtColor As DataTable
Get Get
If ViewState("DtColor") Is Nothing Then If ViewState("DtColor") Is Nothing Then
Return New DataTable Return New DataTable
Else Else
Return DirectCast(ViewState("DtColor"), DataTable) Return DirectCast(ViewState("DtColor"), DataTable)
End If End If
End Get End Get
Set(value As DataTable) Set(value As DataTable)
ViewState("DtColor") = value ViewState("DtColor") = value
End Set End Set
End Property End Property
#End If
#End Region #End Region
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then If Not IsPostBack Then
CargaCombos() CargaCombos()
CargaDatos() CargaDatos()
End If End If
End Sub End Sub
Private Sub CargaCombos() Private Sub CargaCombos()
'Carga SubProyectos 'Carga SubProyectos
CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, lblSubProyecto) CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, lblSubProyecto)
TxtFechaI.Text = $"01/{Now.Month}/{Now.Year}" TxtFechaI.Text = $"01/{Now.Month}/{Now.Year}"
TxtFechaF.Text = Now.ToString("dd/MM/yyyy") TxtFechaF.Text = Now.ToString("dd/MM/yyyy")
'CreaDataTableColor()
CreaDataTableColor()
End Sub End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles btnConsultar.Click Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles btnConsultar.Click
CargaDatos() CargaDatos()
End Sub End Sub
Private Sub CargaDatos() Private Sub CargaDatos()
Dim ObjVentas As New ClsVentas 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, 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
ObjVentas.DtResultados.DefaultView.Sort = "CveMoneda,SubTotal DESC" GvVxP.DataSource = ObjVentas.DtResultados.FiltraParametros("", "CveMoneda,SubTotal DESC")
GvVxP.DataSource = ObjVentas.DtResultados.DefaultView.ToTable
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
' 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 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 'CxP Productores
ObjCitrus.DTSetResultados.Tables(0).DefaultView.Sort = "Cantidad DESC" GvCxP192.DataSource = ObjCitrus.DTSetResultados.Tables(1).FiltraParametros("", "CveMoneda,Saldo DESC")
GvCxP192.DataSource = ObjCitrus.DTSetResultados.Tables(0).DefaultView.ToTable
'CxP NO productores 'CxP NO productores
ObjCitrus.DTSetResultados.Tables(1).DefaultView.Sort = "Saldo DESC" GvCxP.DataSource = ObjCitrus.DTSetResultados.Tables(2).FiltraParametros("", "CveMoneda,Saldo DESC")
GvCxP.DataSource = ObjCitrus.DTSetResultados.Tables(1).DefaultView.ToTable
'Gastos (Compras acreedores) 'Gastos (Compras acreedores)
ObjCitrus.DTSetResultados.Tables(2).DefaultView.Sort = "Moneda,SubTotal DESC" GvCompAcreed.DataSource = ObjCitrus.DTSetResultados.Tables(3).FiltraParametros("", "CveMoneda,SubTotal DESC")
GvComprasAcreed.DataSource = ObjCitrus.DTSetResultados.Tables(2).DefaultView.ToTable
'Cuentas x Cobrar 'Cuentas x Cobrar
ObjCitrus.DTSetResultados.Tables(3).DefaultView.Sort = "SaldoMN DESC" GvCxC.DataSource = ObjCitrus.DTSetResultados.Tables(4).FiltraParametros("", "CveMoneda,Saldo DESC")
GvCxC.DataSource = ObjCitrus.DTSetResultados.Tables(3).DefaultView.ToTable
End If End If
ObjVentas.Dispose() ObjVentas.Dispose()
ObjCompras.Dispose()
ObjMovtos.Dispose()
ObjCitrus.Dispose() ObjCitrus.Dispose()
GvVxP.DataBind() GvVxP.DataBind()
GvCxP192.DataBind() 'Compras Productores GvCompProductores.DataBind()
GvCxP.DataBind() 'Compras NO productores GvCompAcreed.DataBind()
GvComprasAcreed.DataBind() GvCxP192.DataBind()
GvCxP.DataBind()
GvCxC.DataBind() GvCxC.DataBind()
If GvCxC.DataSource IsNot Nothing Then If GvCxC.DataSource IsNot Nothing Then
GvCxC.HeaderRow.Cells(1).Text = "<a href=""/CxC/RepCxC.aspx"" target=""_blank"">Saldo</a>" GvCxC.HeaderRow.Cells(1).Text = "<a href=""/CxC/RepCxC.aspx"" target=""_blank"">Saldo</a>"
@@ -131,15 +82,15 @@ Partial Class General_RepIndicadorResumen
Else Else
UPGraficaVxP.Visible = False UPGraficaVxP.Visible = False
End If End If
If GvComprasAcreed.Rows.Count > 0 Then If GvCompProductores.Rows.Count > 0 Then
UPGraficaComprasAcreed.Visible = True UPGraficaCompProductores.Visible = True
Else Else
UPGraficaComprasAcreed.Visible = False UPGraficaCompProductores.Visible = False
End If End If
If GvCxP192.Rows.Count > 0 Then If GvCompAcreed.Rows.Count > 0 Then
UPGraficaCxP192.Visible = True UPGraficaCompAcreed.Visible = True
Else Else
UPGraficaCxP192.Visible = False UPGraficaCompAcreed.Visible = False
End If End If
If GvCxC.Rows.Count > 0 Then If GvCxC.Rows.Count > 0 Then
UPGraficaCxC.Visible = True UPGraficaCxC.Visible = True
@@ -148,21 +99,27 @@ Partial Class General_RepIndicadorResumen
UPGraficaCxC.Visible = False UPGraficaCxC.Visible = False
'UPGraficaCxCRec.Visible = False 'UPGraficaCxCRec.Visible = False
End If End If
If GvCxP192.Rows.Count > 0 Then
UPGraficaCxP192.Visible = True
Else
UPGraficaCxP192.Visible = False
End If
If GvCxP.Rows.Count > 0 Then If GvCxP.Rows.Count > 0 Then
UPGraficaCxP.Visible = True UPGraficaCxP.Visible = True
Else Else
UPGraficaCxP.Visible = False UPGraficaCxP.Visible = False
End If 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 '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() Graficas()
'GraficasBarras()
End Sub End Sub
Protected Sub GvVxP_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvVxP.RowDataBound Protected Sub GvVxP_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvVxP.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowType = DataControlRowType.DataRow Then
@@ -172,26 +129,21 @@ Partial Class General_RepIndicadorResumen
End If End If
End Sub End Sub
Protected Sub GvCxP192_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxP192.RowDataBound Protected Sub GvCxP192_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxP192.RowDataBound
'If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowType = DataControlRowType.DataRow Then
' 'e.Row.Cells(0).Text = e.Row.DBCampo("Orden") If e.Row.DBCampo("CveProveedor") = "" Then
' 'If e.Row.DBCampo("Orden") = "00ND" Then e.Row.CssClass = "Totales"
' ' e.Row.CssClass = "Totales" End If
' ' e.Row.Cells(0).Text = "Total " + e.Row.DBCampo("Abreviatura") End If
' '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 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 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 If e.Row.DBCampo("CveClasificacion") = "" Then
e.Row.CssClass = "Totales" e.Row.CssClass = "Totales"
End If End If
@@ -201,128 +153,72 @@ Partial Class General_RepIndicadorResumen
If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("CveCliente") = "" Then If e.Row.DBCampo("CveCliente") = "" Then
e.Row.CssClass = "Totales" 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 If End If
End Sub End Sub
#If False Then
Private Sub CreaDataTableColor() Private Sub CreaDataTableColor()
DtColor = New DataTable DtColor = New DataTable
DtColor.Columns.Add("Color") DtColor.Columns.Add("Color")
Dim RowColor As DataRow = Nothing DtColor.Rows.Add("#FF0F00")
RowColor = DtColor.NewRow() DtColor.Rows.Add("#FF6600")
RowColor("Color") = "#FF0F00" DtColor.Rows.Add("#FF9E01")
DtColor.Rows.Add(RowColor) DtColor.Rows.Add("#FCD202")
RowColor = Nothing DtColor.Rows.Add("#F8FF01")
RowColor = DtColor.NewRow() DtColor.Rows.Add("#B0DE09")
RowColor("Color") = "#FF6600" DtColor.Rows.Add("#04D215")
DtColor.Rows.Add(RowColor) DtColor.Rows.Add("#0D8ECF")
RowColor = Nothing DtColor.Rows.Add("#0D52D1")
RowColor = DtColor.NewRow() DtColor.Rows.Add("#2A0CD0")
RowColor("Color") = "#FF9E01" DtColor.Rows.Add("#8A0CCF")
DtColor.Rows.Add(RowColor) DtColor.Rows.Add("#CD0D74")
RowColor = Nothing DtColor.Rows.Add("#754DEB")
RowColor = DtColor.NewRow() DtColor.Rows.Add("#DDDDDD")
RowColor("Color") = "#FCD202" DtColor.Rows.Add("#999999")
DtColor.Rows.Add(RowColor) DtColor.Rows.Add("#333333")
RowColor = Nothing DtColor.Rows.Add("#000000")
RowColor = DtColor.NewRow()
RowColor("Color") = "#F8FF01"
DtColor.Rows.Add(RowColor)
RowColor = Nothing
RowColor = DtColor.NewRow()
RowColor("Color") = "#B0DE09"
DtColor.Rows.Add(RowColor)
RowColor = Nothing
RowColor = DtColor.NewRow()
RowColor("Color") = "#04D215"
DtColor.Rows.Add(RowColor)
RowColor = Nothing
RowColor = DtColor.NewRow()
RowColor("Color") = "#0D8ECF"
DtColor.Rows.Add(RowColor)
RowColor = Nothing
RowColor = DtColor.NewRow()
RowColor("Color") = "#0D52D1"
DtColor.Rows.Add(RowColor)
RowColor = Nothing
RowColor = DtColor.NewRow()
RowColor("Color") = "#2A0CD0"
DtColor.Rows.Add(RowColor)
RowColor = Nothing
RowColor = DtColor.NewRow()
RowColor("Color") = "#8A0CCF"
DtColor.Rows.Add(RowColor)
RowColor = Nothing
RowColor = DtColor.NewRow()
RowColor("Color") = "#CD0D74"
DtColor.Rows.Add(RowColor)
RowColor = Nothing
RowColor = DtColor.NewRow()
RowColor("Color") = "#754DEB"
DtColor.Rows.Add(RowColor)
RowColor = Nothing
RowColor = DtColor.NewRow()
RowColor("Color") = "#DDDDDD"
DtColor.Rows.Add(RowColor)
RowColor = Nothing
RowColor = DtColor.NewRow()
RowColor("Color") = "#999999"
DtColor.Rows.Add(RowColor)
RowColor = Nothing
RowColor = DtColor.NewRow()
RowColor("Color") = "#333333"
DtColor.Rows.Add(RowColor)
RowColor = Nothing
RowColor = DtColor.NewRow()
RowColor("Color") = "#000000"
DtColor.Rows.Add(RowColor)
End Sub End Sub
#End If
Private Sub Graficas() Private Sub Graficas()
Dim DtVxP, DtCxP192, DtCxP, DtCxPA, DtCxC, DtCxCR As New DataTable Dim DtVxP, DtCxP192, DtCxP, DtCompProductores, DtCompAcreed, DtCxC, DtCxCR As New DataTable
Dim RowColorIndex As Integer = 0 'Dim RowColorIndex As Integer = 0
'Ventas x Producto 'Ventas x Producto
DtVxP.Reset() DtVxP.Reset()
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("Unidad") DtVxP.Columns.Add("Unidad")
RowColorIndex = 0 'RowColorIndex = 0
If GvVxP.datasource IsNot Nothing Then If GvVxP.DataSource IsNot Nothing Then
For Each Dr As DataRow In GvVxP.DataSource.Rows For Each Dr As DataRow In CType(GvVxP.DataSource, DataTable).FiltraParametros("", "SubTotalMN DESC").Rows
If Not Dr("Orden").ToString = "" Then If Not Dr("Orden").ToString = "" Then
Dim Row As DataRow = Nothing Dim Row = DtVxP.NewRow()
Row = DtVxP.NewRow()
Row("Texto") = Dr("GPO").ToString Row("Texto") = Dr("GPO").ToString
Row("Valor") = Dr("SubTotal").ToString.FormatoNumero Row("Valor") = Dr("SubTotalMN").ToString.FormatoNumero
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString Row("Unidad") = "MXN" '$"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}"
Row("Unidad") = $"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}"
DtVxP.Rows.Add(Row) DtVxP.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 End If
Next Next
End If 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 { 'Dim group_vxp = vxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With {
' .Texto = Function(x) x.Texto.ToString, ' .Texto = Function(x) x.Texto.ToString,
' .Valor = Math.Round(Function(x) x.Valor, 2), 'x Tasa de cambio ' .Valor = Math.Round(Function(x) x.Valor, 2),
' .Color = g.Min(Function(x) x.Color),
' .Unidad = "MXN" ' .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 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(), .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(), .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 = Math.Round(g.Sum(Function(x) x.Valor), 2), .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2),
.Color = "#000000",
.Unidad = "MXN" .Unidad = "MXN"
}) })
Dim query_vxp = top_vxp.Union(group_resto_vxp) 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() '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 'Compras ProveedorClasificacion=192
DtCxP192.Reset() DtCompProductores.Reset()
DtCxP192.Columns.Add("Texto") DtCompProductores.Columns.Add("Texto")
DtCxP192.Columns.Add("Valor") DtCompProductores.Columns.Add("Valor")
DtCxP192.Columns.Add("Color") DtCompProductores.Columns.Add("Unidad")
DtCxP192.Columns.Add("Unidad") For Each Dr As DataRow In GvCompProductores.DataSource.Rows
RowColorIndex = 0 Dim Row = DtCompProductores.NewRow()
For Each Dr As DataRow In GvCxP192.DataSource.Rows
Dim Row As DataRow = Nothing
Row = DtCxP192.NewRow()
Row("Texto") = Dr("RazonSocial").ToString Row("Texto") = Dr("RazonSocial").ToString
Row("Valor") = Dr("Cantidad").ToString.FormatoNumero Row("Valor") = Dr("Cantidad").ToString.FormatoNumero
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString
Row("Unidad") = "Kg" Row("Unidad") = "Kg"
DtCxP192.Rows.Add(Row) DtCompProductores.Rows.Add(Row)
RowColorIndex += 1
If RowColorIndex = 17 Then
RowColorIndex = 0
End If
Next 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 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_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 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_cxp192 = resto_cxp192.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { Dim group_resto_comp_productores = resto_comp_productores.GroupBy(Function(x) x.Texto).[Select](Function(g) New With {
.Texto = "Otros", .Texto = "Otros",
.Valor = Math.Round(g.Sum(Function(x) x.Valor), 2), .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2),
.Color = "#000000",
.Unidad = "MXN" .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 'Compras TipoProveedor=1 Acreedores (Gastos)
DtCxP.Reset() DtCompAcreed.Reset()
DtCxP.Columns.Add("Texto") DtCompAcreed.Columns.Add("Texto")
DtCxP.Columns.Add("Valor") DtCompAcreed.Columns.Add("Valor")
DtCxP.Columns.Add("Color") DtCompAcreed.Columns.Add("Unidad")
DtCxP.Columns.Add("Unidad") For Each Dr As DataRow In CType(GvCompAcreed.DataSource, DataTable).FiltraParametros("", "SubTotalMN DESC").Rows
RowColorIndex = 0
For Each Dr As DataRow In GvCxP.DataSource.Rows
Dim Row As DataRow = Nothing
Row = DtCxP.NewRow()
Row("Texto") = Dr("RazonSocial").ToString
Row("Valor") = Dr("Saldo").ToString.FormatoNumero
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString
Row("Unidad") = "MXN"
DtCxP.Rows.Add(Row)
RowColorIndex += 1
If RowColorIndex = 17 Then
RowColorIndex = 0
End If
Next
Dim top_cxp = From s In DtCxP.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()}
Dim resto_cxp = From s In DtCxP.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Unidad = s("Unidad").ToString()}
Dim group_resto_cxp = resto_cxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With {
.Texto = "Otros",
.Valor = Math.Round(g.Sum(Function(x) x.Valor), 2),
.Color = "#000000",
.Unidad = "MXN"
})
Dim query_cxp = top_cxp.Union(group_resto_cxp)
'Compras x Producto TipoProveedor=1 Acreedores (Gastos)
DtCxPA.Reset()
DtCxPA.Columns.Add("Texto")
DtCxPA.Columns.Add("Valor")
DtCxPA.Columns.Add("Color")
DtCxPA.Columns.Add("Unidad")
RowColorIndex = 0
For Each Dr As DataRow In GvComprasAcreed.DataSource.Rows
If Dr("CveClasificacion").ToString <> "" Then If Dr("CveClasificacion").ToString <> "" Then
Dim Row As DataRow = Nothing Dim Row = DtCompAcreed.NewRow()
Row = DtCxPA.NewRow()
Row("Texto") = Dr("Clasificacion").ToString Row("Texto") = Dr("Clasificacion").ToString
Row("Valor") = Dr("SubTotal").ToString.FormatoNumero Row("Valor") = Dr("SubTotalMN").ToString.FormatoNumero
Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString Row("Unidad") = "MXN" 'Dr("Moneda").ToString
Row("Unidad") = Dr("Moneda").ToString DtCompAcreed.Rows.Add(Row)
DtCxPA.Rows.Add(Row)
RowColorIndex += 1
If RowColorIndex = 17 Then
RowColorIndex = 0
End If
End If End If
Next 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 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_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 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_cxpa = resto_cxpa.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { Dim group_resto_comp_acreed = resto_comp_acreed.GroupBy(Function(x) x.Texto).[Select](Function(g) New With {
.Texto = "Otros", .Texto = "Otros",
.Valor = Math.Round(g.Sum(Function(x) x.Valor), 2), .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2),
.Color = "#000000",
.Unidad = "MXN" .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 'Cuentas por cobrar x Cliente -- Saldo
DtCxC.Reset() DtCxC.Reset()
DtCxC.Columns.Add("Texto") DtCxC.Columns.Add("Texto")
DtCxC.Columns.Add("Valor") DtCxC.Columns.Add("Valor")
DtCxC.Columns.Add("Color")
DtCxC.Columns.Add("Unidad") DtCxC.Columns.Add("Unidad")
RowColorIndex = 0 For Each Dr As DataRow In CType(GvCxC.DataSource, DataTable).FiltraParametros("", "SaldoMN DESC").Rows
For Each Dr As DataRow In GvCxC.DataSource.Rows
If Not Dr("CveCliente").ToString = "" Then If Not Dr("CveCliente").ToString = "" Then
Dim Row As DataRow = Nothing Dim Row = DtCxC.NewRow()
Row = DtCxC.NewRow()
Row("Texto") = Dr("RazonSocial").ToString Row("Texto") = Dr("RazonSocial").ToString
Row("Valor") = Dr("SaldoMN").ToString.FormatoNumero 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}" Row("Unidad") = "MXN" '$"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}"
DtCxC.Rows.Add(Row) DtCxC.Rows.Add(Row)
RowColorIndex += 1
If RowColorIndex = 17 Then
RowColorIndex = 0
End If
End If End If
Next 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 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(), .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(), .Unidad = s("Unidad").ToString()}
Dim group_resto_cxc = resto_cxc.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { Dim group_resto_cxc = resto_cxc.GroupBy(Function(x) x.Texto).[Select](Function(g) New With {
.Texto = "Otros", .Texto = "Otros",
.Valor = Math.Round(g.Sum(Function(x) x.Valor), 2), .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2),
.Color = "#000000",
.Unidad = "MXN" .Unidad = "MXN"
}) })
Dim query_cxc = top_cxc.Union(group_resto_cxc) Dim query_cxc = top_cxc.Union(group_resto_cxc)
'Alert(Newtonsoft.Json.JsonConvert.SerializeObject(CxC.Rows))
'Cuentas por cobrar x Cliente -- Recuperado 'Cuentas por cobrar x Cliente -- Recuperado
DtCxCR.Reset() DtCxCR.Reset()
DtCxCR.Columns.Add("Texto") DtCxCR.Columns.Add("Texto")
DtCxCR.Columns.Add("Valor") DtCxCR.Columns.Add("Valor")
DtCxCR.Columns.Add("Color")
DtCxCR.Columns.Add("Unidad") DtCxCR.Columns.Add("Unidad")
RowColorIndex = 0 For Each Dr As DataRow In CType(GvCxC.DataSource, DataTable).FiltraParametros("", "SaldoMN DESC").Rows
For Each Dr As DataRow In GvCxC.DataSource.Rows
If Not Dr("CveCliente").ToString = "" Then If Not Dr("CveCliente").ToString = "" Then
Dim Row As DataRow = Nothing Dim Row = DtCxCR.NewRow()
Row = DtCxCR.NewRow()
Row("Texto") = Dr("RazonSocial").ToString Row("Texto") = Dr("RazonSocial").ToString
Row("Valor") = Dr("RecuperadoMN").ToString.FormatoNumero 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}" Row("Unidad") = "MXN" '$"{GlobalDTMonedas().FiltraParametros($"CveMoneda = {Dr("CveMoneda").ToString}").Rows(0)("Abreviatura").ToString}"
DtCxCR.Rows.Add(Row) DtCxCR.Rows.Add(Row)
RowColorIndex += 1
If RowColorIndex = 17 Then
RowColorIndex = 0
End If
End If End If
Next 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 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(), .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(), .Unidad = s("Unidad").ToString()}
Dim group_resto_cxcr = resto_cxcr.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { Dim group_resto_cxcr = resto_cxcr.GroupBy(Function(x) x.Texto).[Select](Function(g) New With {
.Texto = "Otros", .Texto = "Otros",
.Valor = Math.Round(g.Sum(Function(x) x.Valor), 2), .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2),
.Color = "#000000",
.Unidad = "MXN" .Unidad = "MXN"
}) })
Dim query_cxcr = top_cxcr.Union(group_resto_cxcr) 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 '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, .CompProductores = query_comp_productores, .CompAcreed = query_comp_acreed, .CxC = query_cxc, .CxCR = query_cxcr, .CxP192 = query_cxp192, .CxP = query_cxp})
'Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(New With {.VxP = query_vxp, .CxC = New String() {}})
'Alert(json) 'Alert(json)
RegistraScript($"CargaGraficas({json})", "sdkp24223") RegistraScript($"CargaGraficas({json})", "sdkp24223")
UPPMov.Update() UPPMov.Update()