Commit inicial Ventas Productivo
This commit is contained in:
390
Ventas/RepDocumentacionVencidaClientes.aspx.vb
Normal file
390
Ventas/RepDocumentacionVencidaClientes.aspx.vb
Normal file
@@ -0,0 +1,390 @@
|
||||
Option Strict On
|
||||
|
||||
|
||||
Imports System.Data
|
||||
Imports System.IO
|
||||
Imports Extensiones
|
||||
Imports GemBox.Spreadsheet
|
||||
|
||||
|
||||
|
||||
|
||||
Partial Class Vta_RepDocumentacionVencidaClientes
|
||||
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 Property MuestraSINO As Boolean
|
||||
Get
|
||||
If ViewState("MuestraSINO") Is Nothing Then
|
||||
Return False
|
||||
Else
|
||||
Return Boolean.Parse(ViewState("MuestraSINO").ToString)
|
||||
End If
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
ViewState("MuestraSINO") = 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()
|
||||
|
||||
' LnkDescargarExcel.Visible = False
|
||||
|
||||
|
||||
|
||||
End If
|
||||
'ExportaExcel()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaCombos()
|
||||
|
||||
Dim objEdoc As New ClsEdocumentacion
|
||||
|
||||
If objEdoc.DocumentacionGet(-1, -1, 1, UsuarioActual.CveEmpresa, Modulo:=2) Then
|
||||
DDlDocumentacion.DataSource = objEdoc.DtResultados
|
||||
DDlDocumentacion.DataBind()
|
||||
DDlDocumentacion.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
End If
|
||||
|
||||
If objEdoc.DocumentacionTipoGet(UsuarioActual.CveEmpresa, Modulo:=2) Then
|
||||
DDLDocumentacionTipo.DataSource = objEdoc.DtResultados
|
||||
DDLDocumentacionTipo.DataBind()
|
||||
DDLDocumentacionTipo.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
End If
|
||||
|
||||
|
||||
DdlCliente.setEsWebService(True)
|
||||
DdlCliente.Attributes.Add("data-metodo", "getcliente")
|
||||
|
||||
|
||||
|
||||
DDLSucursal.DataSource = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, 1).FiltraParametros("EsSucursal = 1", "", {"CveSubProyecto", "SubProyecto"})
|
||||
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
|
||||
|
||||
objEdoc.Dispose()
|
||||
Dim objRH As New ClsRH
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatos()
|
||||
Dim objEDoc As New ClsEdocumentacion
|
||||
Dim DtHeaders As New DataTable
|
||||
Dim Porcentaje As Double = 0
|
||||
Dim TotalRegistros As Double = 0
|
||||
|
||||
Dim CveCliente As Integer = -1
|
||||
|
||||
If DdlCliente.txtValue.Value.ToString.ToEntero > 0 Then
|
||||
|
||||
CveCliente = DdlCliente.txtValue.Value.ToString.ToEntero
|
||||
|
||||
End If
|
||||
|
||||
Dim FechaInicio As Date = MinFecha
|
||||
Dim FechaFin As Date = MaxFecha
|
||||
|
||||
If DDlDocumentacion.SelectedValue.ToEntero > 0 Then
|
||||
|
||||
|
||||
If txtFechaVI.Text.Length = 10 Then
|
||||
FechaInicio = txtFechaVI.Text.ToDate
|
||||
End If
|
||||
|
||||
If txtFechaVF.Text.Length = 10 Then
|
||||
FechaFin = txtFechaVF.Text.ToDate
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If objEDoc.DocumentacionVencidaDinamicaGet(1, -1, CveCliente, -1, UsuarioActual.Empresa.CveEmpresa, DDlDocumentacion.SelectedValue.ToEntero, DDLDocumentacionTipo.SelectedValue.ToEntero,
|
||||
Now, Now, DDLSucursal.SelectedValue.ToEntero, -1, DDLVencidos.SelectedValue.ToEntero,
|
||||
-1, -1, -1, Modulo:=2, GPO:=DdlGpo.SelectedValue.ToEntero, PermiteCredito:=If(ChkPermiteCredito.Checked, 1, -1),
|
||||
FechaVI:=FechaInicio, FechaVF:=FechaFin) Then
|
||||
|
||||
Me.DTHeaders = Nothing
|
||||
DTDatos = Nothing
|
||||
|
||||
If objEDoc.DSResultados.Tables.Count = 2 Then
|
||||
|
||||
DtHeaders = objEDoc.DSResultados.Tables(0)
|
||||
|
||||
|
||||
|
||||
DTDatos = objEDoc.DSResultados.Tables(1)
|
||||
Dim Drow As DataRow = DTDatos.NewRow
|
||||
|
||||
DTDatos.Rows.InsertAt(Drow, 0)
|
||||
|
||||
Dim Cocol As DataColumnCollection = DTDatos.Columns
|
||||
If Cocol.Contains("Completo") Then
|
||||
DTDatos.Columns.Remove(DTDatos.Columns("Completo"))
|
||||
End If
|
||||
|
||||
If DDlDocumentacion.SelectedValue.ToEntero > 0 Then
|
||||
|
||||
DTDatos.Columns.Add("Completo")
|
||||
CType(GvDocumentos.Columns(4), BoundField).DataField = "Completo"
|
||||
|
||||
For Each drowi As DataRow In DTDatos.Rows
|
||||
|
||||
If drowi(1).ToString.ToEntero = drowi(5).ToString.ToEntero Then
|
||||
drowi("Completo") = "SI"
|
||||
Else
|
||||
drowi("Completo") = "NO"
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
|
||||
|
||||
GvDocumentos.Columns(4).Visible = True
|
||||
|
||||
|
||||
If DdlEstadoSiNo.SelectedValue.ToEntero = 0 Then
|
||||
DTDatos = DTDatos.FiltraParametros("Completo = 'NO'")
|
||||
ElseIf DdlEstadoSiNo.SelectedValue.ToEntero = 1 Then
|
||||
DTDatos = DTDatos.FiltraParametros("Completo = 'SI'")
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If DDlDocumentacion.SelectedValue.ToEntero > 0 Then
|
||||
Try
|
||||
DTDatos.Rows(0)("Completo") = ""
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
End If
|
||||
|
||||
GvDocumentos.DataSource = DTDatos
|
||||
|
||||
Me.DTHeaders = objEDoc.DSResultados.Tables(0)
|
||||
|
||||
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 = 2
|
||||
For Index = 2 To GvDocumentos.Columns.Count - 1
|
||||
GvDocumentos.Columns(Index).Visible = False
|
||||
Next Index
|
||||
|
||||
Index = 2
|
||||
|
||||
If DDlDocumentacion.SelectedValue.ToEntero > 0 Then
|
||||
|
||||
GvDocumentos.Columns(4).Visible = True
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
Try
|
||||
TotalRegistros = DTDatos.SUM("CONTADOR")
|
||||
DTDatos.Rows(0)(0) = "TOTALES"
|
||||
DTDatos.Rows(0)(1) = TotalRegistros
|
||||
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
|
||||
|
||||
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()
|
||||
|
||||
Index = 2
|
||||
|
||||
|
||||
If DTDatos.Rows.Count > 0 Then
|
||||
For Each Dr As DataRow In DtHeaders.Rows
|
||||
|
||||
Dim VALOR As String = DTDatos.SUM("[" + Dr("CveDocumentacion").ToString + "]").ToString
|
||||
|
||||
'GvDocumentos.Rows(0).Cells(Index).Text = "" + VALOR + " - " + (VALOR.ToDouble * 100 / TotalRegistros).FormatoNumero(2) + "%"
|
||||
GvDocumentos.Rows(0).Cells(Index).Text = "<table><tr><th>Avance</th> <th>%</th> </tr><tr><td>" + VALOR + " </t><td> " + (VALOR.ToDouble * 100 / TotalRegistros).FormatoNumero(2) + "% </td></tr></table>"
|
||||
|
||||
'GvDocumentos.Columns(Index).HeaderText = Dr("Documentacion").ToString
|
||||
|
||||
Index += 1
|
||||
Next
|
||||
GvDocumentos.Rows(0).BackColor = Drawing.Color.FromArgb(221, 221, 221)
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
If DdlEstadoSiNo.SelectedValue.ToEntero > 0 Then
|
||||
|
||||
|
||||
|
||||
|
||||
End If
|
||||
|
||||
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 = 2
|
||||
For Index = 2 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()
|
||||
|
||||
If DTDatos.Rows.Count > 0 Then
|
||||
GvDocumentos.ExportToExcel("AvanceDocumentacion" & Now.ToString("yyyyMMddhhmmss") & ".xls")
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user