139 lines
5.9 KiB
VB.net
139 lines
5.9 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class Contabilidad_RepIEPS
|
|
Inherits ClsPaginas
|
|
|
|
Private Property DtDatos As DataTable
|
|
Get
|
|
Return DirectCast(ViewState("DtDatos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtDatos") = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
CargaFechas()
|
|
End If
|
|
End Sub
|
|
Private Sub CargaFechas()
|
|
txtFechaI.Text = $"01/{Now.Month}/{Now.Year}"
|
|
txtFechaF.Text = Now.ToString("dd/MM/yyyy")
|
|
End Sub
|
|
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
|
Dim ObjConta As New ClsContabilidad()
|
|
If ObjConta.GetRepIEPS(txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), DdlTipoOperacion.SelectedValue, DdlModalidad.SelectedValue.ToEntero(), DdlLimite.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa) Then
|
|
DtDatos = ObjConta.DtResultados.Copy()
|
|
End If
|
|
ObjConta.Dispose()
|
|
If DtDatos IsNot Nothing AndAlso DtDatos.Rows.Count > 0 Then
|
|
LnkGenerar.Visible = True
|
|
LnkPdf.Visible = True
|
|
LnkExcel.Visible = True
|
|
If DdlTipoOperacion.SelectedValue = "C" AndAlso DdlModalidad.SelectedValue = "1" Then
|
|
DtDatos = DtDatos.FiltraParametros("TipoDato in (1,2)")
|
|
End If
|
|
GvDatos.DataSource = DtDatos
|
|
GvDatos.DataBind()
|
|
Else
|
|
Alert("No se encontraron resultados en la consulta")
|
|
End If
|
|
UpDatos.Update()
|
|
UpLnkAcciones.Update()
|
|
End Sub
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
'If e.Row.RowType = DataControlRowType.Header Then
|
|
' For i = 0 To e.Row.Cells.Count - 1
|
|
' e.Row.Cells(i).ToolTip = e.Row.Cells(i).Text.Replace("ó", "ó").Replace("í", "í")
|
|
' Next
|
|
'End If
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.DBCampo("TipoDato") = "1" Then
|
|
e.Row.CssClass = "SubTotales"
|
|
ElseIf e.Row.DBCampo("TipoDato") = "2" Then
|
|
e.Row.CssClass = "Totales"
|
|
End If
|
|
If e.Row.DBCampo("Num") = "0" Then
|
|
e.Row.Cells(0).Text = ""
|
|
End If
|
|
If UsuarioActual.CveRol = 1 AndAlso e.Row.DBCampo("TipoDato") = "0" Then
|
|
If Math.Abs(e.Row.DBCampo("SubTotalPorcentaje").ToDecimal - e.Row.DBCampo("ValorAntesDeImpuestos").ToDecimal) > 1000 Then
|
|
e.Row.ForeColor = Drawing.Color.Red
|
|
e.Row.ToolTip = String.Format("IEPSPagado:{0} - Porcentaje:{1} - SubTotalPorcentaje: {2} - SubTotal: {3}", e.Row.DBCampo("IEPSPagado").FormatoNumero, e.Row.DBCampo("ClaveGenericaPorcentaje").FormatoNumero, e.Row.DBCampo("SubTotalPorcentaje").FormatoNumero, e.Row.DBCampo("ValorAntesDeImpuestos").FormatoNumero)
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
End Sub
|
|
Protected Sub LnkGenerar_Click(sender As Object, e As EventArgs)
|
|
Dim txtFile As New StringBuilder()
|
|
|
|
Dim DtExportar As DataTable = DtDatos.FiltraParametros("TipoDato = 0")
|
|
For Each row As DataRow In DtExportar.Rows
|
|
txtFile.Append(row("Layout").ToString())
|
|
txtFile.Append(vbCrLf)
|
|
Next
|
|
Dim NombreArchivo As String = $"LayoutIEPS-{DdlTipoOperacion.SelectedItem.Text}.txt"
|
|
Response.Clear()
|
|
Response.Buffer = True
|
|
Response.AddHeader("content-disposition", $"attachment;filename={NombreArchivo}")
|
|
Response.Charset = ""
|
|
Response.ContentType = "application/text"
|
|
Response.Output.Write(txtFile.ToString())
|
|
Response.Flush()
|
|
Response.End()
|
|
End Sub
|
|
Public Sub Imprimir(ByVal Opcion As String)
|
|
Dim FechaF As String
|
|
|
|
If txtFechaF.Text = "" OrElse txtFechaF.Text = "__/__/____" Then
|
|
FechaF = ""
|
|
Else
|
|
FechaF = $" <b>Fecha Final:</b> {txtFechaF.Text}"
|
|
End If
|
|
|
|
Dim FechaI As String
|
|
|
|
If txtFechaI.Text = "" OrElse txtFechaI.Text = "__/__/____" Then
|
|
FechaI = ""
|
|
Else
|
|
FechaI = $" <b>Fecha Inicial:</b> {txtFechaI.Text}"
|
|
End If
|
|
|
|
Dim TipoOperacion As String = $" <b>Tipo de Operación:</b> {DdlTipoOperacion.SelectedItem.Text}"
|
|
Dim Modalidad As String = $" <b>Modalidad:</b> {DdlModalidad.SelectedItem.Text}"
|
|
|
|
If DtDatos.Rows.Count > 0 Then
|
|
Dim Imagen As System.IO.FileInfo = New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
|
Dim logouri As String = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
|
Dim para As List(Of ReportParameter) = New List(Of ReportParameter)()
|
|
para.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
para.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
para.Add(New ReportParameter("FechaImpresion", DateTime.Now.ToString()))
|
|
para.Add(New ReportParameter("Filtros", $"<b>Filtros:</b> {FechaI}{FechaF}{TipoOperacion}{Modalidad}"))
|
|
|
|
If Imagen.Exists Then
|
|
para.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
para.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepIEPS.rdlc", DtDatos, para, "Reporte de IEPS", Opcion)
|
|
Else
|
|
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
Protected Sub LnkPdf_Click(sender As Object, e As EventArgs)
|
|
Imprimir("PDF")
|
|
End Sub
|
|
Protected Sub LnkExcel_Click(sender As Object, e As EventArgs)
|
|
Imprimir("EXCEL")
|
|
End Sub
|
|
End Class
|