337 lines
13 KiB
VB.net
337 lines
13 KiB
VB.net
|
|
Imports System.Data
|
|
Imports System.Drawing
|
|
Imports Extensiones
|
|
Imports System.Web.UI.DataVisualization.Charting
|
|
|
|
Partial Class Prospectos_RedesIndicadores
|
|
Inherits ClsPaginas
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
Dim Ind As New ClsProspectos
|
|
'INDICADOR BARRAS
|
|
|
|
If Ind.GetProspectosRedesIndicadores(-1, -1, -1, -1, -1, -1, -1, -1, 2, UsuarioActual.CveEmpresa) Then
|
|
|
|
Dim yValues As New ArrayList
|
|
Dim xValues As New ArrayList
|
|
Dim MetaValues As New ArrayList
|
|
For Each dr As DataRow In Ind.DtResultados.Rows
|
|
yValues.Add(dr("Total"))
|
|
xValues.Add(dr("Coordinador"))
|
|
MetaValues.Add(dr("Meta"))
|
|
|
|
Next
|
|
ChtBarras.ChartAreas("ChartArea1").Area3DStyle.Enable3D = True
|
|
|
|
ChtBarras.Titles(1).Text = String.Format("{0} de {1} ({2}%)", Ind.DtResultados.SUM("Total"), Ind.DtResultados.SUM("Meta"), (Ind.DtResultados.SUM("Total") / Ind.DtResultados.SUM("Meta") * 100).FormatoNumero)
|
|
ChtBarras.Series("Series1")("DrawingStyle") = "Cylinder"
|
|
ChtBarras.Series("Series2")("DrawingStyle") = "Cylinder"
|
|
ChtBarras.Series("Series1").Points.DataBindXY(xValues, MetaValues)
|
|
ChtBarras.Series("Series2").Points.DataBindXY(xValues, yValues)
|
|
|
|
End If
|
|
|
|
|
|
GraficaVarios()
|
|
Ind.Dispose()
|
|
|
|
CargaAvances()
|
|
End Sub
|
|
|
|
Private Sub GraficaVarios()
|
|
Me.ChtVarios.ViewStateContent = SerializationContents.All
|
|
Me.ChtVarios.EnableViewState = True
|
|
|
|
Me.ChtVarios.Legends(0).CustomItems(0).Cells(0).PostBackValue = "LegendClick/0"
|
|
Me.ChtVarios.Legends(0).CustomItems(1).Cells(0).PostBackValue = "LegendClick/1"
|
|
Me.ChtVarios.Legends(0).CustomItems(2).Cells(0).PostBackValue = "LegendClick/2"
|
|
Me.ChtVarios.Legends(0).CustomItems(3).Cells(0).PostBackValue = "LegendClick/3"
|
|
Me.ChtVarios.Legends(0).CustomItems(4).Cells(0).PostBackValue = "LegendClick/4"
|
|
|
|
|
|
|
|
' Initialize chart settings
|
|
Dim series As System.Web.UI.DataVisualization.Charting.Series = ChtVarios.Series(0)
|
|
|
|
' Fill data
|
|
CargaPie(series, 1)
|
|
|
|
series.Legend = "Leyenda2"
|
|
|
|
' Set axis marks to be on bottom
|
|
Me.ChtVarios.ChartAreas(0).AxisX.IsMarksNextToAxis = False
|
|
|
|
' Show end labels for Y axis
|
|
Me.ChtVarios.ChartAreas(0).AxisY.LabelStyle.IsEndLabelVisible = True
|
|
|
|
' Set initial properties for border and shadows
|
|
series.BorderWidth = 1
|
|
series.ShadowOffset = 1
|
|
|
|
series.ShadowColor = Color.FromArgb(240, 64, 64, 64)
|
|
End Sub
|
|
|
|
Protected Sub ChtVarios_Click(sender As Object, e As ImageMapEventArgs)
|
|
' If user clicks on the map area attribute that corresponds to a legend item
|
|
If e.PostBackValue.StartsWith("LegendClick") Then
|
|
Dim args As String = e.PostBackValue.Split("/"c)(1)
|
|
' Identify which legend item was clicked
|
|
Dim index As Integer = Integer.Parse(args)
|
|
|
|
' Legend item result
|
|
Dim legendItem As LegendItem = Me.ChtVarios.Legends(0).CustomItems(index)
|
|
|
|
' Resets all radio button images to be unchecked
|
|
For Each item As LegendItem In Me.ChtVarios.Legends(0).CustomItems
|
|
item.Cells(0).ImageTransparentColor = Color.Black
|
|
item.Cells(0).Image = "/Imagenes/radio_button_unchecked.gif"
|
|
Next
|
|
Dim Opcion As Integer = 1
|
|
|
|
Select Case index
|
|
Case 0 : Opcion = 1
|
|
Case 1 : Opcion = 9 'Edades
|
|
Case 2 : Opcion = 4 'Supervisor
|
|
Case 3 : Opcion = 5 'Coordinador
|
|
Case 4 : Opcion = 3 'Municipio
|
|
End Select
|
|
|
|
CargaPie(ChtVarios.Series(0), Opcion)
|
|
|
|
Select Case legendItem.Cells(1).Text
|
|
|
|
End Select
|
|
|
|
'Me.ChtVarios.Series(0).ChartType = DirectCast([Enum].Parse(GetType(SeriesChartType), legendItem.Cells(1).Text, True), SeriesChartType)
|
|
Me.ChtVarios.Series(0).BorderWidth = If(Me.ChtVarios.Series(0).ChartType = SeriesChartType.Line, 3, 1)
|
|
legendItem.Cells(0).Image = "/Imagenes/radio_button_checked.gif"
|
|
legendItem.Cells(0).ImageTransparentColor = Color.Green
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaPie(series As System.Web.UI.DataVisualization.Charting.Series, Opcion As Integer)
|
|
|
|
Dim Ind As New ClsProspectos
|
|
|
|
If Ind.GetProspectosAgrupados2(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, Opcion, UsuarioActual.CveEmpresa) Then
|
|
Dim yValues As New ArrayList
|
|
Dim xValues As New ArrayList
|
|
series("PieDrawingStyle") = "Concave"
|
|
'cuando es por edades, ordena por la claverango
|
|
Dim dt As DataTable = Ind.DtResultados.FiltraParametros("CveAgrupador > 0", If(Opcion = 9, "CveRangoEdad", "Total Desc"))
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
|
|
|
|
Dim Total As Double = dt.SUM("Total")
|
|
'Dim pp As DataPoint
|
|
'Dim i As Integer = 0
|
|
'For Each dr As DataRow In dt.Rows
|
|
' pp = New DataPoint(dr("Total").ToString.ToDouble, dr("Total").ToString)
|
|
' 'series.Points.AddXY("-", POL) : .Series(0).Points(ii).AxisLabel = "POL" : .Series(0).Points(ii).Label = POL.ToString
|
|
' series.Points.Add(pp)
|
|
' series.Points(i).Label = "a"
|
|
' i += 1
|
|
' 'yValues.Add(dr("Total"))
|
|
' ''xValues.Add(dr("ProspectoClasificacionpie
|
|
' 'xValues.Add(String.Format("{0} ({1}%)", dr("Agrupador"), (dr("Total").ToString.ToDouble / Total * 100).FormatoNumero))
|
|
'Next
|
|
|
|
|
|
For Each dr As DataRow In dt.Rows
|
|
yValues.Add(dr("Total"))
|
|
'xValues.Add(dr("ProspectoClasificacion"))
|
|
xValues.Add(String.Format("{0} ({2} - {1}%)", dr("Agrupador"), (dr("Total").ToString.ToDouble / Total * 100).FormatoNumero, dr("Total")))
|
|
Next
|
|
|
|
series.Points.DataBindXY(xValues, yValues)
|
|
End If
|
|
End If
|
|
|
|
|
|
'If Ind.GetProspectosTopTen(UsuarioActual.CveEmpresa) Then
|
|
' GvTop.DataSource = Ind.DtResultados
|
|
' GvTop.DataBind()
|
|
|
|
'End If
|
|
Ind.Dispose()
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaAvances()
|
|
|
|
Dim FechaInicio As Date = DateTime.Parse("2014/03/01")
|
|
Dim FechaFin As Date = DateTime.Parse("2015/03/31")
|
|
Dim Marcador As Integer = 1
|
|
Dim Marcador1 As Integer = 1
|
|
Dim Marcador2 As Integer = 1
|
|
Dim Marcador3 As Integer = 1
|
|
Dim TotalDias As Integer = (FechaFin - FechaInicio).Days
|
|
Dim DiasTranscurridos As Integer = (DateTime.Now - FechaInicio).Days
|
|
Dim Str As New StringBuilder
|
|
|
|
Dim Total As Integer = 20000
|
|
Dim Total1 As Integer
|
|
Dim Total2 As Integer
|
|
Dim Total3 As Integer
|
|
Dim Acum1 As Integer
|
|
Dim Acum2 As Integer
|
|
Dim Acum3 As Integer
|
|
|
|
Dim Ind As New ClsProspectos
|
|
Dim Acum As Double = 0 ' Ind.DtResultados.SUM("Total").ToDouble
|
|
If Ind.GetProspectosAgrupados2(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, UsuarioActual.CveEmpresa) Then
|
|
Dim yValues As New ArrayList
|
|
Dim xValues As New ArrayList
|
|
Dim yyValues As New ArrayList
|
|
|
|
' ChtAvances.ChartAreas("ChartArea1").AxisX.IsMarginVisible = False
|
|
|
|
Dim Fechas = From s In Ind.DtResultados.AsEnumerable Where s!MesAnioIng <> "-1" Select Fecha = ("01/" & s!MesAnioIng).ToString.ToDate, Tot = s!Total.ToString.ToDouble Order By Fecha
|
|
|
|
|
|
'xValues.Add(" - ")
|
|
'yValues.Add(0)
|
|
'yyValues.Add(0)
|
|
|
|
|
|
For Each dr In Fechas.ToList
|
|
'ChtAvances.Series("Series1").Points.AddY(dr.Tot)
|
|
yValues.Add(dr.Tot)
|
|
xValues.Add(dr.Fecha.ToString("MMM yyyy"))
|
|
yyValues.Add(dr.Tot + Acum)
|
|
Acum += dr.Tot
|
|
Next
|
|
|
|
ChtAvances.Series(0).Points.DataBindXY(xValues, yValues)
|
|
ChtAvances.Series(1).Points.DataBindXY(xValues, yyValues)
|
|
|
|
End If
|
|
Dim DtZonas As DataTable
|
|
If Ind.GetProspectosSupervisor(UsuarioActual.CveEmpresa) Then
|
|
GvSup.DataSource = Ind.DtResultados
|
|
GvSup.DataBind()
|
|
DtZonas = Ind.DtResultados
|
|
Acum1 = DtZonas.SUM("Total", "CveSupervisor=3").ToEntero
|
|
Acum2 = DtZonas.SUM("Total", "CveSupervisor=4").ToEntero
|
|
Acum3 = DtZonas.SUM("Total", "CveSupervisor=5").ToEntero
|
|
Acum = Acum1 + Acum2 + Acum3
|
|
End If
|
|
|
|
Ind.Dispose()
|
|
|
|
'carga la grafica de avances
|
|
|
|
|
|
|
|
|
|
Dim dtt As DataTable = GlobalDTProspectosCoordinadores(-1, UsuarioActual.CveEmpresa)
|
|
|
|
Total1 = dtt.SUM("Meta", "CveSupervisor=3").ToEntero
|
|
Total2 = dtt.SUM("Meta", "CveSupervisor=4").ToEntero
|
|
Total3 = dtt.SUM("Meta", "CveSupervisor=5").ToEntero
|
|
Total = Total1 + Total2 + Total3
|
|
|
|
|
|
|
|
Marcador = ((Acum / DiasTranscurridos) / (Total / TotalDias) * 100).ToEntero
|
|
Marcador1 = ((Acum1 / DiasTranscurridos) / (Total1 / TotalDias) * 100).ToEntero
|
|
Marcador2 = ((Acum2 / DiasTranscurridos) / (Total2 / TotalDias) * 100).ToEntero
|
|
Marcador3 = ((Acum3 / DiasTranscurridos) / (Total3 / TotalDias) * 100).ToEntero
|
|
|
|
Str.Append(" var g = new JustGage({ ")
|
|
Str.Append(" id: ""gauge"", ")
|
|
Str.AppendFormat(" value: {0}, ", Marcador)
|
|
Str.Append(" min: 0, ")
|
|
Str.Append(" max: 200, ")
|
|
Str.Append(" title: ""Avance Gral"", ")
|
|
Str.Append(" label: ""%"", levelColors: new Array('#FF0000','#FFFF00','#00FF00') ")
|
|
Str.Append(" }); ")
|
|
|
|
Str.Append(" var g = new JustGage({ ")
|
|
Str.Append(" id: ""gauge1"", ")
|
|
Str.AppendFormat(" value: {0}, ", Marcador1)
|
|
Str.Append(" min: 0, ")
|
|
Str.Append(" max: 200, ")
|
|
Str.Append(" title: ""Norte"", ")
|
|
Str.Append(" label: ""%"", levelColors: new Array('#FF0000','#FFFF00','#00FF00') ")
|
|
Str.Append(" }); ")
|
|
|
|
Str.Append(" var g = new JustGage({ ")
|
|
Str.Append(" id: ""gauge2"", ")
|
|
Str.AppendFormat(" value: {0}, ", Marcador2)
|
|
Str.Append(" min: 0, ")
|
|
Str.Append(" max: 200, ")
|
|
Str.Append(" title: ""Centro"", ")
|
|
Str.Append(" label: ""%"", levelColors: new Array('#FF0000','#FFFF00','#00FF00') ")
|
|
Str.Append(" }); ")
|
|
|
|
Str.Append(" var g = new JustGage({ ")
|
|
Str.Append(" id: ""gauge3"", ")
|
|
Str.AppendFormat(" value: {0}, ", Marcador3)
|
|
Str.Append(" min: 0, ")
|
|
Str.Append(" max: 200, ")
|
|
Str.Append(" title: ""Sur"", ")
|
|
Str.Append(" label: ""%"", levelColors: new Array('#FF0000','#FFFF00','#00FF00') ")
|
|
Str.Append(" }); ")
|
|
|
|
|
|
RegistraScript(Str.ToString)
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub Gv_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvTop.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(250)
|
|
e.Row.Cells(1).Width = Unit.Pixel(80)
|
|
End If
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
If e.Row.DBCampo("CveSupervisor").ToEntero > 0 AndAlso e.Row.DBCampo("CveCoordinador").ToEntero = 0 Then
|
|
|
|
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Center
|
|
|
|
|
|
e.Row.CssClass = "Totales"
|
|
e.Row.Height = 22
|
|
' e.Row.Font.Size = 12
|
|
e.Row.Cells(0).Font.Size = 12
|
|
Else
|
|
If e.Row.DBCampo("CveCoordinador").ToEntero > 0 AndAlso e.Row.DBCampo("NombreCompleto") = "" Then
|
|
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.CssClass = "SubTotales"
|
|
e.Row.Height = 20
|
|
End If
|
|
End If
|
|
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvSup_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvSup.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(100)
|
|
e.Row.Cells(1).Width = Unit.Pixel(70)
|
|
e.Row.Cells(2).Width = Unit.Pixel(70)
|
|
e.Row.Cells(3).Width = Unit.Pixel(70)
|
|
e.Row.CssClass = "Totales"
|
|
e.Row.HorizontalAlign = HorizontalAlign.Center
|
|
End If
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
|
|
If e.Row.Cells(1).Text = "0" Then e.Row.Cells(1).Text = ""
|
|
If e.Row.Cells(2).Text = "0" Then e.Row.Cells(2).Text = ""
|
|
If e.Row.Cells(3).Text = "0" Then e.Row.Cells(3).Text = ""
|
|
End If
|
|
End Sub
|
|
|
|
End Class
|