Rep personal DIM
This commit is contained in:
97
Nomina/RepPersonalDIM.aspx
Normal file
97
Nomina/RepPersonalDIM.aspx
Normal file
@@ -0,0 +1,97 @@
|
||||
<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepPersonalDIM.aspx.vb" Inherits="Nomina_RepPersonalDIM" EnableEventValidation="false" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
|
||||
<style>
|
||||
</style>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="HB" runat="Server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content4" ContentPlaceHolderID="E" runat="Server">
|
||||
Reporte Personal DIM
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content5" ContentPlaceHolderID="H" runat="Server">
|
||||
|
||||
|
||||
<li>
|
||||
<asp:LinkButton ID="LnkExportar" runat="server" Visible="true"><i class="fa fa-ad-excel"></i> Generar Excel</asp:LinkButton>
|
||||
</li>
|
||||
<li>
|
||||
<asp:LinkButton ID="LnkDescargaArchivo" runat="server" Visible="true"><i class="fa fa-ad-excel"></i> Descarga Archivo</asp:LinkButton>
|
||||
</li>
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content6" ContentPlaceHolderID="C" runat="Server">
|
||||
|
||||
<asp:UpdatePanel runat="server" ID="UpFiltros" UpdateMode="Conditional">
|
||||
<ContentTemplate>
|
||||
<div class="portlet solid grey-cascade portlet-filter">
|
||||
<div class="portlet-title portlet-filterT smalltitle">
|
||||
<div class="tools">
|
||||
<asp:Button ID="BtnConsultar" Text="Consultar" CssClass="btn btn-primary" runat="server" OnClick="BtnConsultar_Click" />
|
||||
<a href="javascript:;" class="expand"></a>
|
||||
</div>
|
||||
<div class="titlefiltros caption ">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<label class="col-md-1" runat="server" id="LiEjercicioLbl">Ejercicio: </label>
|
||||
<div class="col-md-1 " runat="server" id="LiEjercicioDdl">
|
||||
<asp:DropDownList ID="DdlEjercicio" runat="server" CssClass="select2me" DataTextField="Ejercicio" DataValueField="Ejercicio" Width="100%" >
|
||||
</asp:DropDownList>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="portlet-body" style="display: none">
|
||||
<div class="row">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<asp:UpdatePanel runat="server" ID="UpGvCargaDatos">
|
||||
<ContentTemplate>
|
||||
<asp:GridView ID="GvDatos" runat="server" AutoGenerateColumns="true" DataKeyNames="" ShowHeaderWhenEmpty="true"
|
||||
CssClass="ADSCROLLER2 table table-striped table-advance table-hover" data-cols="1" data-heightmenos="300"
|
||||
Style="margin-top: -10px; text-align: center;" GridLines="None">
|
||||
<Columns>
|
||||
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content7" ContentPlaceHolderID="JS" runat="Server">
|
||||
|
||||
|
||||
</asp:Content>
|
||||
149
Nomina/RepPersonalDIM.aspx.vb
Normal file
149
Nomina/RepPersonalDIM.aspx.vb
Normal file
@@ -0,0 +1,149 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports System.Drawing
|
||||
Imports System.IO
|
||||
Imports Extensiones
|
||||
Imports GemBox.Spreadsheet
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
|
||||
Partial Class Nomina_RepPersonalDIM
|
||||
Inherits ClsPaginas
|
||||
|
||||
Public Property Dt_Datos As DataTable
|
||||
Get
|
||||
If ViewState("Dt_Datos") Is Nothing Then
|
||||
ViewState("Dt_Datos") = New DataTable
|
||||
End If
|
||||
Return DirectCast(ViewState("Dt_Datos"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("Dt_Datos") = value
|
||||
End Set
|
||||
|
||||
End Property
|
||||
|
||||
Protected Sub Nomina_RepPersonalDIM(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not Page.IsPostBack Then
|
||||
|
||||
CargaEjercicios()
|
||||
DdlEjercicio.SelectedValueExist(UsuarioActual.Empresa.EjercicioActual)
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub CargaEjercicios()
|
||||
'Dim ClsConta As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
Dim ClsConta As New ClsContabilidad
|
||||
If ClsConta.GetEjercicios(UsuarioActual.CveEmpresa) Then
|
||||
DdlEjercicio.DataSource = ClsConta.DtResultados
|
||||
Else
|
||||
DdlEjercicio.DataSource = Nothing
|
||||
End If
|
||||
ClsConta.Dispose()
|
||||
DdlEjercicio.DataBind()
|
||||
|
||||
DdlEjercicio.SelectedValueExist(UsuarioActual.Empresa.EjercicioActual.ToString)
|
||||
|
||||
If DdlEjercicio.Items.Count = 0 Then
|
||||
DdlEjercicio.Items.Add(New ListItem(Now.Year.ToString, Now.Year.ToString))
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
||||
CargaDatos()
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub CargaDatos()
|
||||
|
||||
Dt_Datos = New DataTable
|
||||
LnkDescargaArchivo.Visible = False
|
||||
LnkExportar.Visible = False
|
||||
|
||||
Dim ObjNom As New ClsNominas
|
||||
|
||||
|
||||
If ObjNom.GetRepPersonalDIM(Ejercicio:=DdlEjercicio.SelectedValue.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa) Then
|
||||
GvDatos.DataSource = ObjNom.DtResultados
|
||||
Dt_Datos = ObjNom.DtResultados
|
||||
|
||||
If Dt_Datos.Rows.Count > 0 Then
|
||||
LnkDescargaArchivo.Visible = True
|
||||
LnkExportar.Visible = True
|
||||
End If
|
||||
|
||||
|
||||
Else
|
||||
GvDatos.DataSource = Nothing
|
||||
End If
|
||||
|
||||
ObjNom.Dispose()
|
||||
|
||||
GvDatos.DataBind()
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
#Region "DESCARGA EXCEL"
|
||||
|
||||
Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click
|
||||
Imprimir("Excel")
|
||||
End Sub
|
||||
|
||||
Private Sub Imprimir(Optional reporte As String = "PDF")
|
||||
GvDatos.ExportToExcelGembox("RepPersonalDIM", UsuarioActual, "Reporte Personal ", "", DatosFiltros:=$"Ejercicio {DdlEjercicio.SelectedItem.Text}")
|
||||
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
|
||||
End Sub
|
||||
|
||||
Protected Sub LnkDescargaArchivo_Click(ByVal sender As Object, ByVal e As EventArgs) Handles LnkDescargaArchivo.Click
|
||||
Dim tabla As DataTable = Dt_Datos ' Reemplaza esto con tu método para obtener la tabla
|
||||
|
||||
Dim contenido As String = ConvertirTablaATexto(tabla)
|
||||
|
||||
' Guardar el archivo en el servidor
|
||||
Dim nombreArchivo As String = "tabla.txt"
|
||||
Dim rutaArchivo As String = Server.MapPath("~/Descargas/" & nombreArchivo)
|
||||
File.WriteAllText(rutaArchivo, contenido)
|
||||
|
||||
' Descargar el archivo
|
||||
Response.ContentType = "text/plain"
|
||||
Response.AppendHeader("Content-Disposition", "attachment; filename=" & nombreArchivo)
|
||||
Response.TransmitFile(rutaArchivo)
|
||||
Response.End()
|
||||
End Sub
|
||||
|
||||
Public Function ConvertirTablaATexto(ByVal tabla As DataTable) As String
|
||||
Dim sb As New StringBuilder()
|
||||
|
||||
For Each fila As DataRow In tabla.Rows
|
||||
For i As Integer = 0 To tabla.Columns.Count - 1
|
||||
sb.Append(fila(i).ToString())
|
||||
|
||||
If i < tabla.Columns.Count - 1 Then
|
||||
sb.Append("|") ' Agrega el separador de pipes
|
||||
End If
|
||||
Next
|
||||
|
||||
sb.AppendLine() ' Agrega un salto de línea al final de cada fila
|
||||
Next
|
||||
|
||||
Return sb.ToString()
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user