Cambios en el dashboard de ventas

This commit is contained in:
RPimienta
2024-11-14 23:06:09 -06:00
parent c8771a541e
commit b52fa9bc35
2 changed files with 144 additions and 35 deletions

View File

@@ -2,6 +2,7 @@
Imports System.Activities.Statements
Imports System.Data
Imports Extensiones
Imports Newtonsoft.Json.Linq
Partial Class Ventas_DashboardVentas
Inherits ClsPaginas
@@ -183,7 +184,7 @@ Partial Class Ventas_DashboardVentas
GvVentasClasificacionxMes.DataBind()
GvVentasAcumulado.DataBind()
CargaGraficas(DtVentasGrafica)
CargaGraficaNEW(DtVentasGrafica)
'Dim Ano3 = DateTime.Now.Year.ToString()
'Dim Ano2 = (DateTime.Now.Year - 1).ToString()
@@ -212,42 +213,31 @@ Partial Class Ventas_DashboardVentas
End Sub
Private Sub CargaGraficas(ByVal DtVentas As DataTable)
MuestraGrafica(div_ventas, DtVentas, "Ano", "Total", "", "", "gh2", "")
End Sub
Private Sub CargaGraficaNEW(ByVal D_T_Datos As DataTable)
Dim jsonData As JArray = New JArray()
Private Sub MuestraGrafica(ByVal divcontainer As HtmlGenericControl, ByVal DTDatos As DataTable, ByVal ColTitle As String, ByVal ColValue As String, ByVal Titulo As String, ByVal SubTitulo As String, ByVal Optional Indicador As String = "gh", ByVal Optional XReferencia As String = "", ByVal Optional YReferencia As String = "")
Dim Info As String = ""
Dim SBJSScript As StringBuilder = New StringBuilder()
For x As Integer = 1 To 12
Dim Mes As String = D_T_Datos.Columns(x).ColumnName
Dim obj As JObject = New JObject()
obj.Add(New JProperty("mes", Mes))
If DTDatos.Rows.Count > 0 Then
'For Each DbRow As DataRow In DTDatos.Rows
' Info = String.Format("{2}['{1}',{0}],", DbRow("TotalAno1"), DbRow(ColTitle), Info)
' Info = String.Format("{2}['{1}',{0}],", DbRow("TotalAno2"), DbRow(ColTitle), Info)
' Info = String.Format("{2}['{1}',{0}],", DbRow("TotalAno3"), DbRow(ColTitle), Info)
' Info = String.Format("{2}['{1}',{0}],", DbRow("TotalAno3Presupuesto"), DbRow(ColTitle), Info)
'Next
'For Each DbRow As DataRow In DTDatos.Rows
' Info = String.Format("{2}['{1}',{0}],", DbRow("TotalAno1"), DateTime.Now.Year - 2, Info)
' Info = String.Format("{2}['{1}',{0}],", DbRow("TotalAno2"), DateTime.Now.Year - 1, Info)
' Info = String.Format("{2}['{1}',{0}],", DbRow("TotalAno3"), DateTime.Now.Year, Info)
' Info = String.Format("{2}['{1}',{0}],", DbRow("TotalAno3Presupuesto"), $"PRESUPUESTO {Now.Year}", Info)
'Next
For Each DbRow As DataRow In DTDatos.Rows
Info = String.Format("{2}['{1}',{0}],", DbRow(ColValue), DbRow(ColTitle), Info)
For y As Integer = 0 To D_T_Datos.Rows.Count - 1
obj.Add(New JProperty(D_T_Datos.Rows(y)(0).ToString(), D_T_Datos.Rows(y)(x).ToString()))
Next
If Info.Length > 0 Then
'Info = Info.Remove(Info.Length - 1, 1)
SBJSScript.AppendFormat("graficahighcharts('{0}','{1}','{2}','{3}',[{4}],1,'{5}');", divcontainer.ClientID, Titulo, SubTitulo, YReferencia, Info, XReferencia)
End If
Else
SBJSScript.AppendFormat("graficahighcharts('{0}','{1}','{2}','{3}',[{4}],1,'{5}');", divcontainer.ClientID, Titulo, SubTitulo, YReferencia, " ", XReferencia)
End If
jsonData.Add(obj)
Next
RegistraScript(SBJSScript.ToString(), Indicador)
Dim jsonSeries As JArray = New JArray()
For y As Integer = 0 To D_T_Datos.Rows.Count - 1
Dim obj As JObject = New JObject(New JProperty(D_T_Datos.Rows(y)(0).ToString(), D_T_Datos.Rows(y)(0).ToString()))
jsonSeries.Add(obj)
Next
Dim jsdatos As String = jsonData.ToString()
Dim jsseries As String = jsonSeries.ToString()
RegistraScript($"generaGrafico({jsdatos},{jsseries});")
End Sub
End Class