diff --git a/App_Code/ClsGenerales.vb b/App_Code/ClsGenerales.vb
index 1e444e23b..37a62c152 100644
--- a/App_Code/ClsGenerales.vb
+++ b/App_Code/ClsGenerales.vb
@@ -748,55 +748,55 @@ Public Class ClsGenerales
End Try
Return Retorno
- End Function
-
+ End Function
+
#End Region
-
- '#Region " E S T A D O S"
- ' Public Function GetGralEstados() As Boolean
- ' Dim Retorno As Boolean = False
- ' DataAdapter("PA_Gral_EstadoGet")
- ' Try
- ' SqlAdapter.Fill(Data)
- ' Retorno = True
- ' Catch ex As Exception
- ' OnError("Ocurrió un error al obtener el Catálogo de Estados.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
- ' End Try
-
- ' Return Retorno
- ' End Function
- '#End Region
-
- '#Region " M U N I C I P I O S"
- ' Public Function GetGralMunicipios() As Boolean
- ' Dim Retorno As Boolean = False
- ' DataAdapter("PA_Gral_MunicipioGet")
- ' Try
- ' SqlAdapter.Fill(Data)
- ' Retorno = True
- ' Catch ex As Exception
- ' OnError("Ocurrió un error al obtener el Catálogo de Municipios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
- ' End Try
-
- ' Return Retorno
- ' End Function
- '#End Region
-
- '#Region " P A I S E S"
- ' Public Function GetGralPaises() As Boolean
- ' Dim Retorno As Boolean = False
- ' DataAdapter("PA_Gral_PaisGet")
- ' Try
- ' SqlAdapter.Fill(Data)
- ' Retorno = True
- ' Catch ex As Exception
- ' OnError("Ocurrió un error al obtener el Catálogo de Paises.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
- ' End Try
-
- ' Return Retorno
- ' End Function
- '#End Region
-
+
+ '#Region " E S T A D O S"
+ ' Public Function GetGralEstados() As Boolean
+ ' Dim Retorno As Boolean = False
+ ' DataAdapter("PA_Gral_EstadoGet")
+ ' Try
+ ' SqlAdapter.Fill(Data)
+ ' Retorno = True
+ ' Catch ex As Exception
+ ' OnError("Ocurrió un error al obtener el Catálogo de Estados.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
+ ' End Try
+
+ ' Return Retorno
+ ' End Function
+ '#End Region
+
+ '#Region " M U N I C I P I O S"
+ ' Public Function GetGralMunicipios() As Boolean
+ ' Dim Retorno As Boolean = False
+ ' DataAdapter("PA_Gral_MunicipioGet")
+ ' Try
+ ' SqlAdapter.Fill(Data)
+ ' Retorno = True
+ ' Catch ex As Exception
+ ' OnError("Ocurrió un error al obtener el Catálogo de Municipios.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
+ ' End Try
+
+ ' Return Retorno
+ ' End Function
+ '#End Region
+
+ '#Region " P A I S E S"
+ ' Public Function GetGralPaises() As Boolean
+ ' Dim Retorno As Boolean = False
+ ' DataAdapter("PA_Gral_PaisGet")
+ ' Try
+ ' SqlAdapter.Fill(Data)
+ ' Retorno = True
+ ' Catch ex As Exception
+ ' OnError("Ocurrió un error al obtener el Catálogo de Paises.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo())
+ ' End Try
+
+ ' Return Retorno
+ ' End Function
+ '#End Region
+
#Region " P O B L A C I O N E S"
Public Function GetGralPoblaciones() As Boolean
Dim Retorno As Boolean = False
diff --git a/Contabilidad/RepAnexoCatalogoCC.aspx b/Contabilidad/RepAnexoCatalogoCC.aspx
index 0e105651a..d05a8aad4 100644
--- a/Contabilidad/RepAnexoCatalogoCC.aspx
+++ b/Contabilidad/RepAnexoCatalogoCC.aspx
@@ -574,7 +574,7 @@
@@ -1049,6 +1866,166 @@
}
+ function generarGraficaSucursales() {
+ // 1) Obtener la tabla completa
+ var $grid = $('table[id$="gvResumenSucursales"]');
+
+ // 2) Buscar TODOS los checkbox marcados
+ var $checks = $grid.find('input.header-checkbox:checked');
+ if ($checks.length === 0) {
+ alert('Por favor, seleccione al menos una columna para graficar.');
+ return false;
+ }
+
+ // 3) Filas de datos: todas las
que tengan
+ var $dataRows = $grid.find('tr').has('td');
+
+ // 4) Categorías = texto de la primera celda (Sucursal)
+ var categorias = $dataRows.map(function () {
+ return $(this).find('td').eq(0).text().trim();
+ }).get();
+
+ // 5) Localizar tus subheaders (segunda fila de encabezado)
+ var $headerRows = $grid.find('tr').filter(function () {
+ return $(this).find('th').length > 1;
+ });
+ var $subThs = $headerRows.eq(1).find('th'); // esos 4
+
+ // 6) Construir las series
+ var series = $checks.map(function () {
+ var $chk = $(this);
+ var $th = $chk.closest('th');
+ // idxSub = posición dentro de los 4 subheaders (0..3)
+ var idxSub = $subThs.index($th);
+ // +1 porque la columna 0 es "Sucursal"
+ var colIndex = idxSub + 1;
+ // Leer data-field (VentaAnual, UtilidadAnual, etc.) y formatear nombre
+ var field = $chk.data('field');
+ var name = field.replace(/([a-z])([A-Z])/g, '$1 $2');
+ // Mapear los valores de cada fila para esta columna
+ var data = $dataRows.map(function () {
+ var txt = $(this).find('td').eq(colIndex).text().replace(/,/g, '');
+ return parseFloat(txt) || 0;
+ }).get();
+ return { name: name, data: data };
+ }).get();
+
+ // 7) Dibujar Highcharts
+ Highcharts.chart('chartContainer', {
+ chart: { type: 'line' },
+ title: { text: 'Comparativo por Sucursal' },
+ xAxis: {
+ categories: categorias,
+ title: { text: 'Sucursal' }
+ },
+ yAxis: {
+ title: { text: 'Monto' },
+ labels: {
+ formatter: function () {
+ return '$' + Highcharts.numberFormat(this.value, 0);
+ }
+ }
+ },
+ tooltip: {
+ headerFormat: '{series.name} ',
+ pointFormat: 'Sucursal: {point.category} Valor: ${point.y:,.2f}'
+ },
+ plotOptions: {
+ series: { marker: { enabled: true } }
+ },
+ series: series
+ });
+
+ // 8) Mostrar el modal
+ $('#DivModalGrafica').modal('show');
+ return false;
+ }
+
+ function generarGrafica(gridId) {
+ var $grid = $('#' + gridId);
+
+ // Encuentra las filas de encabezado (donde están los checkboxes)
+ var $headerRows = $grid.find('tr:has(th)');
+ var $subHeader = $headerRows.length > 1 ? $headerRows.eq(1) : $headerRows.eq(0);
+ var $subThs = $subHeader.find('th');
+
+ // Buscar checkboxes marcados
+ var $checks = $grid.find('input.header-checkbox:checked');
+ if ($checks.length === 0) {
+ alert('Por favor, seleccione al menos una columna para graficar.');
+ return false;
+ }
+
+ // Filas de datos
+ var $dataRows = $grid.find('tr').has('td');
+
+ // Categorías (eje X)
+ var categorias = $dataRows.map(function () {
+ return $(this).find('td').eq(0).text().trim();
+ }).get();
+
+ // Construir series
+ var series = [];
+ $checks.each(function () {
+ var $chk = $(this);
+ var field = $chk.data('field');
+
+ // Buscar el índice de la columna que tiene ese data-field
+ var colIndex = -1;
+ $subThs.each(function (i) {
+ var $input = $(this).find('input.header-checkbox');
+ if ($input.length && $input.data('field') === field) {
+ colIndex = i + 1; // +1 porque la primera columna es la de las categorías
+ }
+ });
+
+ if (colIndex === -1) return; // No encontrado, saltar
+
+ var name = field.replace(/([a-z])([A-Z])/g, '$1 $2');
+ var data = $dataRows.map(function () {
+ var txt = $(this).find('td').eq(colIndex).text().replace(/,/g, '');
+ return parseFloat(txt) || 0;
+ }).get();
+
+ series.push({ name: name, data: data });
+ });
+
+ // Título dinámico
+ var titulo = $grid.closest('.portlet').find('.caption-subject').text();
+ var modalTitulo = document.getElementById('modalTitulo');
+ if (modalTitulo) modalTitulo.innerText = 'Comparativo: ' + titulo;
+
+ // Dibujar gráfica
+ Highcharts.chart('chartContainer', {
+ chart: { type: 'line' },
+ title: { text: titulo }, // Usar el título dinámico
+ xAxis: {
+ categories: categorias,
+ title: { text: 'Categoría' } // Título genérico para el eje X
+ },
+ yAxis: {
+ title: { text: 'Monto (MXN)' },
+ labels: {
+ formatter: function () {
+ return '$' + Highcharts.numberFormat(this.value, 0);
+ }
+ }
+ },
+ tooltip: {
+ headerFormat: '{series.name} ',
+ pointFormat: 'Categoría: {point.category} Valor: ${point.y:,.2f}'
+ },
+ plotOptions: {
+ series: { marker: { enabled: true } }
+ },
+ series: series
+ });
+
+ $('#DivModalGrafica').modal('show');
+ return false;
+ }
+
+
diff --git a/General/Dashboard.aspx.vb b/General/Dashboard.aspx.vb
index b3f4a34bc..5fe165fe6 100644
--- a/General/Dashboard.aspx.vb
+++ b/General/Dashboard.aspx.vb
@@ -373,50 +373,411 @@ Partial Class General_Dashboard
Protected Sub gvResumenSucursales_RowCreated(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.Header Then
- ' Limpiar celdas originales
e.Row.Cells.Clear()
+ Dim grid As GridView = DirectCast(sender, GridView)
- ' Crear primera fila de encabezado (grupos)
- Dim headerRow As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
+ ' --- Fila 1 ---
+ Dim headerRow1 As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
- ' Celda para "Sucursal" (ocupa 2 filas)
Dim cellSucursal As New TableHeaderCell()
cellSucursal.RowSpan = 2
- cellSucursal.Text = "Sucursal"
- headerRow.Cells.Add(cellSucursal)
+ cellSucursal.VerticalAlign = VerticalAlign.Middle
+ cellSucursal.Controls.Add(New LiteralControl("Sucursal "))
+ Dim hypGrafica As New HyperLink()
+ hypGrafica.NavigateUrl = "javascript:void(0);"
+ hypGrafica.Attributes.Add("onclick", "return generarGraficaSucursales();")
+ hypGrafica.CssClass = "grafica-icon"
+ hypGrafica.Controls.Add(New LiteralControl(""))
+ cellSucursal.Controls.Add(hypGrafica)
+ headerRow1.Cells.Add(cellSucursal)
- ' Celda para "Año" (abarca 2 columnas)
- Dim cellAño As New TableHeaderCell()
- cellAño.ColumnSpan = 2
- cellAño.Text = "Año"
- headerRow.Cells.Add(cellAño)
+ Dim cellAnio As New TableHeaderCell()
+ cellAnio.ColumnSpan = 2
+ cellAnio.HorizontalAlign = HorizontalAlign.Center
+ cellAnio.Text = "Año"
+ headerRow1.Cells.Add(cellAnio)
- ' Celda para "Mes" (abarca 2 columnas)
Dim cellMes As New TableHeaderCell()
cellMes.ColumnSpan = 2
+ cellMes.HorizontalAlign = HorizontalAlign.Center
cellMes.Text = "Mes"
- headerRow.Cells.Add(cellMes)
+ headerRow1.Cells.Add(cellMes)
- ' Añadir fila al GridView
- Dim grid As GridView = DirectCast(sender, GridView)
- grid.Controls(0).Controls.AddAt(0, headerRow)
+ headerRow1.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(0, headerRow1)
- ' Crear segunda fila de encabezado (subtítulos)
- Dim subHeaderRow As New GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Normal)
-
- ' Subtítulos para "Año"
- subHeaderRow.Cells.Add(New TableHeaderCell() With {.Text = "Venta"})
- subHeaderRow.Cells.Add(New TableHeaderCell() With {.Text = "Utilidad"})
-
- ' Subtítulos para "Mes"
- subHeaderRow.Cells.Add(New TableHeaderCell() With {.Text = "Venta"})
- subHeaderRow.Cells.Add(New TableHeaderCell() With {.Text = "Utilidad"})
-
- grid.Controls(0).Controls.AddAt(1, subHeaderRow)
+ ' --- Fila 2 ---
+ Dim headerRow2 As New GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Normal)
+ headerRow2.Cells.Add(CreateSubHeaderCell("Venta", "chkVentaAnual", "VentaAnual"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Utilidad", "chkUtilidadAnual", "UtilidadAnual"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Venta", "chkVentaMensual", "VentaMensual"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Utilidad", "chkUtilidadMensual", "UtilidadMensual"))
+ headerRow2.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(1, headerRow2)
End If
End Sub
+ Protected Sub gvVentasPorSucursal_RowCreated(sender As Object, e As GridViewRowEventArgs)
+ If e.Row.RowType = DataControlRowType.Header Then
+ e.Row.Cells.Clear()
+ Dim grid As GridView = DirectCast(sender, GridView)
+
+ ' --- Fila 1 ---
+ Dim headerRow1 As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Celda principal (Sucursal)
+ Dim cellSucursal As New TableHeaderCell()
+ cellSucursal.RowSpan = 2
+ cellSucursal.VerticalAlign = VerticalAlign.Middle
+ cellSucursal.Controls.Add(New LiteralControl("Sucursal "))
+ Dim hypGrafica As New HyperLink()
+ hypGrafica.NavigateUrl = "javascript:void(0);"
+ hypGrafica.Attributes.Add("onclick", "return generarGrafica('" & grid.ClientID & "');")
+ hypGrafica.CssClass = "grafica-icon"
+ hypGrafica.Controls.Add(New LiteralControl(""))
+ cellSucursal.Controls.Add(hypGrafica)
+ headerRow1.Cells.Add(cellSucursal)
+
+ headerRow1.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(0, headerRow1)
+
+ ' --- Fila 2 (Subheaders) ---
+ Dim headerRow2 As New GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Subheaders con checkboxes
+ headerRow2.Cells.Add(CreateSubHeaderCell("Año", "chkAño", "Año"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Mes", "chkMes", "Mes"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Semana", "chkSemana", "Semana"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Día", "chkDia", "Dia"))
+
+ headerRow2.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(1, headerRow2)
+ End If
+ End Sub
+
+ Protected Sub gvVentasPorVendedor_RowCreated(sender As Object, e As GridViewRowEventArgs)
+ If e.Row.RowType = DataControlRowType.Header Then
+ e.Row.Cells.Clear()
+ Dim grid As GridView = DirectCast(sender, GridView)
+
+ ' --- Fila 1 ---
+ Dim headerRow1 As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Celda principal (Sucursal)
+ Dim cellSucursal As New TableHeaderCell()
+ cellSucursal.RowSpan = 2
+ cellSucursal.VerticalAlign = VerticalAlign.Middle
+ cellSucursal.Controls.Add(New LiteralControl("Vendedor "))
+ Dim hypGrafica As New HyperLink()
+ hypGrafica.NavigateUrl = "javascript:void(0);"
+ hypGrafica.Attributes.Add("onclick", "return generarGrafica('" & grid.ClientID & "');")
+ hypGrafica.CssClass = "grafica-icon"
+ hypGrafica.Controls.Add(New LiteralControl(""))
+ cellSucursal.Controls.Add(hypGrafica)
+ headerRow1.Cells.Add(cellSucursal)
+
+ headerRow1.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(0, headerRow1)
+
+ ' --- Fila 2 (Subheaders) ---
+ Dim headerRow2 As New GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Subheaders con checkboxes
+ headerRow2.Cells.Add(CreateSubHeaderCell("Año", "chkAño", "Año"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Mes", "chkMes", "Mes"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Semana", "chkSemana", "Semana"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Día", "chkDia", "Dia"))
+
+ headerRow2.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(1, headerRow2)
+ End If
+ End Sub
+
+ Protected Sub gvVentasPorClasificacion_RowCreated(sender As Object, e As GridViewRowEventArgs)
+ If e.Row.RowType = DataControlRowType.Header Then
+ e.Row.Cells.Clear()
+ Dim grid As GridView = DirectCast(sender, GridView)
+
+ ' --- Fila 1 ---
+ Dim headerRow1 As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Celda principal (Sucursal)
+ Dim cellSucursal As New TableHeaderCell()
+ cellSucursal.RowSpan = 2
+ cellSucursal.VerticalAlign = VerticalAlign.Middle
+ cellSucursal.Controls.Add(New LiteralControl("Clasificación "))
+ Dim hypGrafica As New HyperLink()
+ hypGrafica.NavigateUrl = "javascript:void(0);"
+ hypGrafica.Attributes.Add("onclick", "return generarGrafica('" & grid.ClientID & "');")
+ hypGrafica.CssClass = "grafica-icon"
+ hypGrafica.Controls.Add(New LiteralControl(""))
+ cellSucursal.Controls.Add(hypGrafica)
+ headerRow1.Cells.Add(cellSucursal)
+
+ headerRow1.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(0, headerRow1)
+
+ ' --- Fila 2 (Subheaders) ---
+ Dim headerRow2 As New GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Subheaders con checkboxes
+ headerRow2.Cells.Add(CreateSubHeaderCell("Año", "chkAño", "Año"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Mes", "chkMes", "Mes"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Semana", "chkSemana", "Semana"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Día", "chkDia", "Dia"))
+
+ headerRow2.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(1, headerRow2)
+ End If
+ End Sub
+
+ Protected Sub gvVentasPorMarca_RowCreated(sender As Object, e As GridViewRowEventArgs)
+ If e.Row.RowType = DataControlRowType.Header Then
+ e.Row.Cells.Clear()
+ Dim grid As GridView = DirectCast(sender, GridView)
+
+ ' --- Fila 1 ---
+ Dim headerRow1 As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Celda principal (Sucursal)
+ Dim cellSucursal As New TableHeaderCell()
+ cellSucursal.RowSpan = 2
+ cellSucursal.VerticalAlign = VerticalAlign.Middle
+ cellSucursal.Controls.Add(New LiteralControl("Marca "))
+ Dim hypGrafica As New HyperLink()
+ hypGrafica.NavigateUrl = "javascript:void(0);"
+ hypGrafica.Attributes.Add("onclick", "return generarGrafica('" & grid.ClientID & "');")
+ hypGrafica.CssClass = "grafica-icon"
+ hypGrafica.Controls.Add(New LiteralControl(""))
+ cellSucursal.Controls.Add(hypGrafica)
+ headerRow1.Cells.Add(cellSucursal)
+
+ headerRow1.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(0, headerRow1)
+
+ ' --- Fila 2 (Subheaders) ---
+ Dim headerRow2 As New GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Subheaders con checkboxes
+ headerRow2.Cells.Add(CreateSubHeaderCell("Año", "chkAño", "Año"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Mes", "chkMes", "Mes"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Semana", "chkSemana", "Semana"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Día", "chkDia", "Dia"))
+
+ headerRow2.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(1, headerRow2)
+ End If
+ End Sub
+
+ Protected Sub gvVentasPorPS_RowCreated(sender As Object, e As GridViewRowEventArgs)
+ If e.Row.RowType = DataControlRowType.Header Then
+ e.Row.Cells.Clear()
+ Dim grid As GridView = DirectCast(sender, GridView)
+
+ ' --- Fila 1 ---
+ Dim headerRow1 As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Celda principal (Sucursal)
+ Dim cellSucursal As New TableHeaderCell()
+ cellSucursal.RowSpan = 2
+ cellSucursal.VerticalAlign = VerticalAlign.Middle
+ cellSucursal.Controls.Add(New LiteralControl("PS "))
+ Dim hypGrafica As New HyperLink()
+ hypGrafica.NavigateUrl = "javascript:void(0);"
+ hypGrafica.Attributes.Add("onclick", "return generarGrafica('" & grid.ClientID & "');")
+ hypGrafica.CssClass = "grafica-icon"
+ hypGrafica.Controls.Add(New LiteralControl(""))
+ cellSucursal.Controls.Add(hypGrafica)
+ headerRow1.Cells.Add(cellSucursal)
+
+ headerRow1.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(0, headerRow1)
+
+ ' --- Fila 2 (Subheaders) ---
+ Dim headerRow2 As New GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Subheaders con checkboxes
+ headerRow2.Cells.Add(CreateSubHeaderCell("Año", "chkAño", "Año"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Mes", "chkMes", "Mes"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Semana", "chkSemana", "Semana"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Día", "chkDia", "Dia"))
+
+ headerRow2.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(1, headerRow2)
+ End If
+ End Sub
+
+ Protected Sub gvVentasPorCliente_RowCreated(sender As Object, e As GridViewRowEventArgs)
+ If e.Row.RowType = DataControlRowType.Header Then
+ e.Row.Cells.Clear()
+ Dim grid As GridView = DirectCast(sender, GridView)
+
+ ' --- Fila 1 ---
+ Dim headerRow1 As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Celda principal (Sucursal)
+ Dim cellSucursal As New TableHeaderCell()
+ cellSucursal.RowSpan = 2
+ cellSucursal.VerticalAlign = VerticalAlign.Middle
+ cellSucursal.Controls.Add(New LiteralControl("Cliente "))
+ Dim hypGrafica As New HyperLink()
+ hypGrafica.NavigateUrl = "javascript:void(0);"
+ hypGrafica.Attributes.Add("onclick", "return generarGrafica('" & grid.ClientID & "');")
+ hypGrafica.CssClass = "grafica-icon"
+ hypGrafica.Controls.Add(New LiteralControl(""))
+ cellSucursal.Controls.Add(hypGrafica)
+ headerRow1.Cells.Add(cellSucursal)
+
+ headerRow1.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(0, headerRow1)
+
+ ' --- Fila 2 (Subheaders) ---
+ Dim headerRow2 As New GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Subheaders con checkboxes
+ headerRow2.Cells.Add(CreateSubHeaderCell("Año", "chkAño", "Año"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Mes", "chkMes", "Mes"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Semana", "chkSemana", "Semana"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Día", "chkDia", "Dia"))
+
+ headerRow2.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(1, headerRow2)
+ End If
+ End Sub
+
+ Protected Sub gvVentasPorProveedor_RowCreated(sender As Object, e As GridViewRowEventArgs)
+ If e.Row.RowType = DataControlRowType.Header Then
+ e.Row.Cells.Clear()
+ Dim grid As GridView = DirectCast(sender, GridView)
+
+ ' --- Fila 1 ---
+ Dim headerRow1 As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Celda principal (Sucursal)
+ Dim cellSucursal As New TableHeaderCell()
+ cellSucursal.RowSpan = 2
+ cellSucursal.VerticalAlign = VerticalAlign.Middle
+ cellSucursal.Controls.Add(New LiteralControl("Proveedor "))
+ Dim hypGrafica As New HyperLink()
+ hypGrafica.NavigateUrl = "javascript:void(0);"
+ hypGrafica.Attributes.Add("onclick", "return generarGrafica('" & grid.ClientID & "');")
+ hypGrafica.CssClass = "grafica-icon"
+ hypGrafica.Controls.Add(New LiteralControl(""))
+ cellSucursal.Controls.Add(hypGrafica)
+ headerRow1.Cells.Add(cellSucursal)
+
+ headerRow1.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(0, headerRow1)
+
+ ' --- Fila 2 (Subheaders) ---
+ Dim headerRow2 As New GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Subheaders con checkboxes
+ headerRow2.Cells.Add(CreateSubHeaderCell("Año", "chkAño", "Año"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Mes", "chkMes", "Mes"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Semana", "chkSemana", "Semana"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Día", "chkDia", "Dia"))
+
+ headerRow2.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(1, headerRow2)
+ End If
+ End Sub
+
+ Protected Sub gvCarteraPorSucursal_RowCreated(sender As Object, e As GridViewRowEventArgs)
+ If e.Row.RowType = DataControlRowType.Header Then
+ e.Row.Cells.Clear()
+ Dim grid As GridView = DirectCast(sender, GridView)
+
+ ' --- Fila 1 ---
+ Dim headerRow1 As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Celda principal (Sucursal)
+ Dim cellSucursal As New TableHeaderCell()
+ cellSucursal.RowSpan = 2
+ cellSucursal.VerticalAlign = VerticalAlign.Middle
+ cellSucursal.Controls.Add(New LiteralControl("Sucursal "))
+ Dim hypGrafica As New HyperLink()
+ hypGrafica.NavigateUrl = "javascript:void(0);"
+ hypGrafica.Attributes.Add("onclick", "return generarGrafica('" & grid.ClientID & "');")
+ hypGrafica.CssClass = "grafica-icon"
+ hypGrafica.Controls.Add(New LiteralControl(""))
+ cellSucursal.Controls.Add(hypGrafica)
+ headerRow1.Cells.Add(cellSucursal)
+
+ headerRow1.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(0, headerRow1)
+
+ ' --- Fila 2 (Subheaders) ---
+ Dim headerRow2 As New GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Subheaders con checkboxes
+ headerRow2.Cells.Add(CreateSubHeaderCell("TotalCxC", "chkTotalCxC", "Total CxC"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Vencido", "chkVencido", "Vencido"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("PorVencer", "chkPorVencer", "Por Vencer"))
+
+ headerRow2.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(1, headerRow2)
+ End If
+ End Sub
+
+ Protected Sub gvCarteraPorVendedor_RowCreated(sender As Object, e As GridViewRowEventArgs)
+ If e.Row.RowType = DataControlRowType.Header Then
+ e.Row.Cells.Clear()
+ Dim grid As GridView = DirectCast(sender, GridView)
+
+ ' --- Fila 1 ---
+ Dim headerRow1 As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Celda principal (Sucursal)
+ Dim cellSucursal As New TableHeaderCell()
+ cellSucursal.RowSpan = 2
+ cellSucursal.VerticalAlign = VerticalAlign.Middle
+ cellSucursal.Controls.Add(New LiteralControl("Vendedor "))
+ Dim hypGrafica As New HyperLink()
+ hypGrafica.NavigateUrl = "javascript:void(0);"
+ hypGrafica.Attributes.Add("onclick", "return generarGrafica('" & grid.ClientID & "');")
+ hypGrafica.CssClass = "grafica-icon"
+ hypGrafica.Controls.Add(New LiteralControl(""))
+ cellSucursal.Controls.Add(hypGrafica)
+ headerRow1.Cells.Add(cellSucursal)
+
+ headerRow1.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(0, headerRow1)
+
+ ' --- Fila 2 (Subheaders) ---
+ Dim headerRow2 As New GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Normal)
+
+ ' Subheaders con checkboxes
+ headerRow2.Cells.Add(CreateSubHeaderCell("TotalCxC", "chkTotalCxC", "Total CxC"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("Vencido", "chkVencido", "Vencido"))
+ headerRow2.Cells.Add(CreateSubHeaderCell("PorVencer", "chkPorVencer", "Por Vencer"))
+
+ headerRow2.TableSection = TableRowSection.TableHeader
+ grid.Controls(0).Controls.AddAt(1, headerRow2)
+ End If
+ End Sub
+
+ '''
+ ''' Ahora emitimos HTML puro para el checkbox + label,
+ ''' así el label realmente dispara el toggle del input.
+ '''
+ Private Function CreateSubHeaderCell(text As String, checkboxId As String, dataField As String) As TableHeaderCell
+ Dim cell As New TableHeaderCell()
+ cell.HorizontalAlign = HorizontalAlign.Center
+
+ ' Construimos un pequeño bloque HTML con y