Files
SIG/RH/RepIndiceRotacionPersonal.aspx.vb
2019-12-13 14:18:34 -07:00

181 lines
5.7 KiB
VB.net

Option Strict On
Option Explicit On
Imports Extensiones
Imports System.Data
Imports Microsoft.Reporting.WebForms
Partial Class Ventas_RepIndiceRotacionPersonal
Inherits ClsPaginas
Private Property DTGvDatos As DataTable
Get
If ViewState("DTGvDatos") Is Nothing Then
Return New DataTable
Else
Return DirectCast(ViewState("DTGvDatos"), DataTable)
End If
End Get
Set(value As DataTable)
ViewState("DTGvDatos") = value
End Set
End Property
Private Sub Ventas_RepIndiceRotacionPersonal_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
txtInicio.Text = Date.Now.AddDays(-30).ToString("dd/MM/yyyy")
txtFin.Text = Date.Now.ToString("dd/MM/yyyy")
CargaProyecto()
CargaTurnos()
CargaDatos()
loadData()
End If
End Sub
Private Sub CargaTurnos()
DdlTurno.DataSource = GlobalDTTurno.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
DdlTurno.DataBind()
DdlTurno.Items.Insert(0, New ListItem("Todos", "-1"))
End Sub
Private Sub CargaProyecto()
DdlProyecto.DataSource = GlobalDTProyectos(UsuarioActual.Empresa.CveEmpresa)
DdlProyecto.DataBind()
DdlProyecto.Items.Insert(0, New ListItem("Todos", "-1"))
End Sub
Private Sub CargaSubProyecto()
DdlSubProyecto.Items.Clear()
DdlSubProyecto.DataSource = GlobalDTSubProyectos(DdlProyecto.SelectedValue.ToEntero)
DdlSubProyecto.DataBind()
DdlSubProyecto.Items.Insert(0, New ListItem("Todos", "-1"))
End Sub
Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged
CargaSubProyecto()
End Sub
Private Sub CargaDatos()
End Sub
Private Sub loadData()
Dim rh As New ClsRH
Dim dTable As New DataTable
Dim CveProyecto As Integer = -1
Dim CveSubproyecto As Integer = -1
Dim CveTurno As Integer = -1
Dim FechaInicio As Date = Date.Now.AddDays(-30)
Dim FechaFin As Date = Date.Now
Try
FechaInicio = Date.Parse(txtInicio.Text)
FechaFin = Date.Parse(txtFin.Text)
If DdlProyecto.SelectedIndex <> 0 Then
CveProyecto = DdlProyecto.SelectedValue.ToEntero
End If
If DdlSubProyecto.SelectedIndex <> 0 Then
CveSubproyecto = DdlSubProyecto.SelectedValue.ToEntero
End If
If DdlTurno.SelectedIndex <> 0 Then
CveTurno = DdlTurno.SelectedValue.ToEntero
End If
If rh.GetReporteRotacionPersonal(FechaInicio, FechaFin, CveTurno, CveProyecto, CveSubproyecto, UsuarioActual.Empresa.CveEmpresa) Then
dTable = rh.DtResultados
End If
DTGvDatos = dTable
GVRegDatos.DataSource = dTable
GVRegDatos.DataBind()
Catch ex As Exception
Dim exe As String = ex.Message
End Try
rh.Dispose()
UpDatos.Update()
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
loadData()
End Sub
Protected Sub GVRegDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVRegDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If Not (e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5) Then
Dim sPorcentaje As String = e.Row.DBCampo("IRP").Trim
Dim porcentaje As Double = Convert.ToDouble(sPorcentaje)
e.Row.FCLabel("LblIrp").CssClass = "label label-danger"
e.Row.FCLabel("LblIrp").Font.Bold = True
e.Row.FCLabel("lblIrp").Attributes.Add("dir", "rtl")
e.Row.FCLabel("LblIrp").Text = sPorcentaje & "%"
If porcentaje <= 15.0 Then
e.Row.FCLabel("LblIrp").CssClass = "label label-success"
ElseIf (porcentaje > 15.0 And porcentaje <= 30.0) Then
e.Row.FCLabel("LblIrp").CssClass = "label label-warning"
End If
End If
If e.Row.DataKey("SubProyecto").ToString.Trim = "" Then
e.Row.CssClass = "SubTotales"
' e.Row.Attributes.Add("class", "SubTotales")
End If
End If
End Sub
Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs)
'"Empresas/Grales/Formatos/ClienteHistorial.rdlc"
If GVRegDatos.Rows.Count > 0 Then
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("FechaInicial", txtInicio.Text))
params.Add(New ReportParameter("FechaFinal", txtFin.Text))
params.Add(New ReportParameter("FechaRealizado", Date.Now().ToString()))
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
If Imagen.Exists Then
params.Add(New ReportParameter("LogoPath", logouri))
Else
params.Add(New ReportParameter("LogoPath", ""))
End If
ImprimirPDF("Empresas/Grales/Formatos/RepIndiceRotacionPersonal.rdlc", DTGvDatos, params, "Reporte de Historial", "PDF")
End If
End Sub
End Class