266 lines
8.8 KiB
VB.net
266 lines
8.8 KiB
VB.net
Option Strict On
|
|
|
|
|
|
Imports System.Data
|
|
Imports System.IO
|
|
Imports Extensiones
|
|
Imports GemBox.Spreadsheet
|
|
|
|
|
|
|
|
|
|
Partial Class RH_RepDocumentacionVencida
|
|
Inherits ClsPaginas
|
|
|
|
|
|
|
|
Private Property DTDatos As DataTable
|
|
Get
|
|
If ViewState("DTDatos") Is Nothing Then
|
|
Return New DataTable
|
|
Else
|
|
Return DirectCast(ViewState("DTDatos"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTDatos") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property DTHeaders As DataTable
|
|
Get
|
|
If ViewState("DTHeaders") Is Nothing Then
|
|
Return New DataTable
|
|
Else
|
|
Return DirectCast(ViewState("DTHeaders"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTHeaders") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Sub RH_DocumentacionVencida_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
CargaCombos()
|
|
TxtFechaI.Text = Now.AddMonths(-3).ToString("dd/MM/yyyy")
|
|
TxtFechaF.Text = Now.ToString("dd/MM/yyyy")
|
|
LnkDescargarExcel.Visible = False
|
|
End If
|
|
'ExportaExcel()
|
|
End Sub
|
|
|
|
Private Sub CargaCombos()
|
|
|
|
Dim objEdoc As New ClsEdocumentacion
|
|
|
|
If objEdoc.DocumentacionGet(-1, -1, 1, UsuarioActual.CveEmpresa) Then
|
|
DDlDocumentacion.DataSource = objEdoc.DtResultados
|
|
DDlDocumentacion.DataBind()
|
|
DDlDocumentacion.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End If
|
|
|
|
If objEdoc.DocumentacionTipoGet(UsuarioActual.CveEmpresa) Then
|
|
DDLDocumentacionTipo.DataSource = objEdoc.DtResultados
|
|
DDLDocumentacionTipo.DataBind()
|
|
DDLDocumentacionTipo.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End If
|
|
|
|
'If objClientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.Empresa.CveEmpresa) Then
|
|
' DDLClientes.DataSource = objClientes.DtResultados 'DDlclientes
|
|
' DDLClientes.DataBind()
|
|
' DDLClientes.Items.Insert(0, New ListItem("Seleccione un cliente", "-1"))
|
|
|
|
'End If
|
|
|
|
|
|
DDLPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa)
|
|
DDLPersonal.DataBind()
|
|
DDLPersonal.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
|
|
DDLPuesto.DataSource = GlobalDTRHPuestos(UsuarioActual.CveEmpresa)
|
|
DDLPuesto.DataBind()
|
|
DDLPuesto.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
|
|
|
|
DDLSucursal.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
DDLSucursal.DataBind()
|
|
DDLSucursal.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
If UsuarioActual.CveSucursal > 0 Then
|
|
DDLSucursal.SelectedValue = (UsuarioActual.CveSucursal.ToString)
|
|
DDLSucursal.Enabled = False
|
|
End If
|
|
|
|
|
|
DdlSupervisor.DataSource = GlobalDTUsuarios.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa & " AND EsSupervisorRH = 1 ")
|
|
DdlSupervisor.DataBind()
|
|
|
|
|
|
DdlRuta.DataSource = GlobalDTRutas(UsuarioActual.CveEmpresa)
|
|
DdlRuta.DataBind()
|
|
|
|
|
|
objEdoc.Dispose()
|
|
|
|
|
|
Dim objRH As New ClsRH
|
|
|
|
|
|
If objRH.SubproyectoZonaGet(-1, -1, UsuarioActual.Empresa.CveEmpresa) Then
|
|
DdlSubproyectoZona.DataSource = objRH.DtResultados.FiltraParametros("Estatus=1")
|
|
Else
|
|
DdlSubproyectoZona.DataSource = Nothing
|
|
End If
|
|
objRH.Dispose()
|
|
DdlSubproyectoZona.DataBind()
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
Dim objEDoc As New ClsEdocumentacion
|
|
Dim DtHeaders As New DataTable
|
|
|
|
If objEDoc.DocumentacionVencidaDinamicaGet(1, DDLPersonal.SelectedValue.ToEntero, -1, -1, UsuarioActual.Empresa.CveEmpresa, DDlDocumentacion.SelectedValue.ToEntero, DDLDocumentacionTipo.SelectedValue.ToEntero, TxtFechaI.Text.ToDate, TxtFechaF.Text.ToDate, DDLSucursal.SelectedValue.ToEntero, DDLPuesto.SelectedValue.ToEntero, DDLVencidos.SelectedValue.ToEntero, DdlSupervisor.SelectedValue.ToEntero, DdlRuta.SelectedValue.ToEntero, DdlSubproyectoZona.SelectedValue.ToEntero) Then
|
|
|
|
Me.DTHeaders = Nothing
|
|
DTDatos = Nothing
|
|
|
|
If objEDoc.DSResultados.Tables.Count = 2 Then
|
|
|
|
DtHeaders = objEDoc.DSResultados.Tables(0)
|
|
GvDocumentos.DataSource = objEDoc.DSResultados.Tables(1)
|
|
|
|
Me.DTHeaders = objEDoc.DSResultados.Tables(0)
|
|
DTDatos = objEDoc.DSResultados.Tables(1)
|
|
Else
|
|
GvDocumentos.DataSource = Nothing
|
|
GvDocumentos.DataBind()
|
|
|
|
End If
|
|
|
|
|
|
If DTDatos.Rows.Count > 0 Then
|
|
LnkDescargarExcel.Visible = True
|
|
Else
|
|
LnkDescargarExcel.Visible = False
|
|
End If
|
|
UpAcciones.Update()
|
|
|
|
End If
|
|
objEDoc.Dispose()
|
|
|
|
Dim Index = 1
|
|
For Index = 1 To GvDocumentos.Columns.Count - 1
|
|
GvDocumentos.Columns(Index).Visible = False
|
|
Next Index
|
|
|
|
Index = 1
|
|
For Each Dr As DataRow In DtHeaders.Rows
|
|
GvDocumentos.Columns(Index).Visible = True
|
|
CType(GvDocumentos.Columns(Index), BoundField).DataField = Dr("CveDocumentacion").ToString
|
|
GvDocumentos.Columns(Index).HeaderText = Dr("Documentacion").ToString
|
|
Index += 1
|
|
Next
|
|
|
|
GvDocumentos.DataBind()
|
|
UpGvDatos.Update()
|
|
|
|
End Sub
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDocumentos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.Header Then
|
|
|
|
Dim Index = 1
|
|
For Index = 1 To GvDocumentos.Columns.Count - 1
|
|
e.Row.Cells(Index).ToolTip = GvDocumentos.Columns(Index).HeaderText
|
|
Next Index
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub btConsultar_Click(sender As Object, e As EventArgs) Handles btConsultar.Click
|
|
CargaDatos()
|
|
End Sub
|
|
|
|
Private Sub ExportaExcel()
|
|
|
|
|
|
SpreadsheetInfo.SetLicense(SerialGemBoxSpreadsheet)
|
|
Dim documento As ExcelFile
|
|
Dim ws As ExcelWorksheet
|
|
Dim NombreReporte As String = "REPORTE DE DOCUMENTACIÓN"
|
|
Dim TextoFecha As String = "Fecha: " & Now.ToString(" dd/MM/yyyy hh:mm:ss tt")
|
|
documento = New ExcelFile
|
|
|
|
ws = documento.Worksheets.Add("ReporteDocumentacion")
|
|
|
|
If System.IO.File.Exists(Path.Combine(UsuarioActual.Empresa.Ruta, "Logo.png")) Then
|
|
ws.Pictures.Add(Path.Combine(UsuarioActual.Empresa.Ruta, "Logo.png"), 0, 0, 170, 94, LengthUnit.Pixel)
|
|
End If
|
|
|
|
Dim mergedTitulo As CellRange = ws.Cells.GetSubrangeAbsolute(0, 2, 0, 4)
|
|
mergedTitulo.Merged = True
|
|
mergedTitulo.Value = NombreReporte
|
|
mergedTitulo.Style.Font.Weight = ExcelFont.BoldWeight
|
|
mergedTitulo.Style.Font.Size = 400
|
|
|
|
|
|
|
|
Dim mergedFecha As CellRange = ws.Cells.GetSubrangeAbsolute(0, 5, 0, 6)
|
|
mergedFecha.Merged = True
|
|
mergedFecha.Value = TextoFecha
|
|
mergedFecha.Style.Font.Weight = ExcelFont.BoldWeight
|
|
|
|
|
|
Dim y As Integer = 5
|
|
Dim xh As Integer = 2
|
|
|
|
ws.Cells(y, 0).Value = "CvePersonal"
|
|
ws.Cells(y, 0).Style.Font.Color = SpreadsheetColor.FromName(ColorName.White)
|
|
|
|
ws.Cells(y, 1).Value = "Nombre"
|
|
ws.Rows(y).Style.Font.Color = SpreadsheetColor.FromName(ColorName.White)
|
|
ws.Rows(y).Style.Font.Weight = ExcelFont.BoldWeight
|
|
ws.Rows(y).Style.FillPattern.SetPattern(FillPatternStyle.Solid, SpreadsheetColor.FromName(ColorName.Black), SpreadsheetColor.FromName(ColorName.Black))
|
|
|
|
For Each drow As DataRow In DTHeaders.Rows
|
|
ws.Cells(y, xh).Value = drow(1).ToString
|
|
xh = xh + 1
|
|
Next
|
|
|
|
y = y + 1
|
|
|
|
For Each drow As DataRow In DTDatos.Rows
|
|
For x As Integer = 0 To DTDatos.Columns.Count - 1
|
|
ws.Cells(y, x).Value = drow(x)
|
|
Next
|
|
y = y + 1
|
|
Next
|
|
|
|
Dim columnCount = ws.CalculateMaxUsedColumns()
|
|
For i As Integer = 0 To columnCount - 1
|
|
ws.Columns(i).AutoFit(1, ws.Rows(0), ws.Rows(ws.Rows.Count - 1))
|
|
Next
|
|
|
|
Dim memoryStream As New MemoryStream()
|
|
documento.Save(memoryStream, SaveOptions.XlsxDefault)
|
|
Dim bytesInStream As Byte() = memoryStream.ToArray()
|
|
|
|
Response.Clear()
|
|
Response.ContentType = "application/force-download"
|
|
Response.AddHeader("content-disposition", "attachment; filename=" & NombreReporte & "_" & Now.ToString("yyyyMMddhhmmss") & ".xlsx")
|
|
Response.BinaryWrite(bytesInStream)
|
|
Response.End()
|
|
memoryStream.Dispose()
|
|
|
|
End Sub
|
|
Protected Sub LnkDescargarExcel_Click(sender As Object, e As EventArgs) Handles LnkDescargarExcel.Click
|
|
ExportaExcel()
|
|
End Sub
|
|
End Class
|