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/{NowADS().Month}/{NowADS().Year}" txtFechaF.Text = NowADS().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() If ObjConta.GetProductosSinIEPS(txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), UsuarioActual.CveEmpresa) Then Dim DtProductos As DataTable = ObjConta.DtResultados.Copy If DtProductos.Rows.Count > 0 Then Dim ProductosIEPS As String = "Los siguientes productos o servicios no tienen especificado alguno de los siguientes campos en relación al IEPS: Empaque, presentación o toxicidad

" For Each producto As DataRow In DtProductos.Rows ProductosIEPS = String.Format("{0}
{1}", ProductosIEPS, producto("CodigoPS")) Next Alert(ProductosIEPS, TipoMensaje.MsgAdvertencia) End If End If 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 = $" Fecha Final: {txtFechaF.Text}" End If Dim FechaI As String If txtFechaI.Text = "" OrElse txtFechaI.Text = "__/__/____" Then FechaI = "" Else FechaI = $" Fecha Inicial: {txtFechaI.Text}" End If Dim TipoOperacion As String = $" Tipo de Operación: {DdlTipoOperacion.SelectedItem.Text}" Dim Modalidad As String = $" Modalidad: {DdlModalidad.SelectedItem.Text}" If DtDatos.Rows.Count > 0 Then Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png") '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", NowADS().ToString())) para.Add(New ReportParameter("Filtros", $"Filtros: {FechaI}{FechaF}{TipoOperacion}{Modalidad}")) para.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", ""))) 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