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 = "
| Avance | % |
|---|---|
| " + VALOR + " | " + (VALOR.ToDouble * 100 / TotalRegistros).FormatoNumero(2) + "% |