From 477741c448f18ba474d70113f14bba6264d9057a Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 24 Mar 2021 10:01:21 -0700 Subject: [PATCH 01/16] Complementaria de clientes, validacion de usados --- Ventas/Ventas.aspx.vb | 165 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 144 insertions(+), 21 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index 871ba36d3..5d1cd4b98 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -3946,7 +3946,7 @@ Partial Class Ventas If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then Dim ObjUsados As New ClsVentas - If ObjUsados.GetVentasUsados(CveVenta, DdlSubProyectoDatos.SelectedValue.ToEntero(), DbRowVenta("Fecha").ToString().ToDateTime, UsuarioActual.CveEmpresa) Then + If ObjUsados.GetVentasUsados(CveVenta, -1, DbRowVenta("Fecha").ToString().ToDateTime, UsuarioActual.CveEmpresa) Then DtUsados = ObjUsados.DtResultados End If ObjUsados.Dispose() @@ -11299,6 +11299,9 @@ Partial Class Ventas Dim CveCuentaIVAxTrasladar As Integer = 0 Dim CveCuentaIVATrasladado As Integer = 0 Dim SeContabiliza As Boolean = True + + Dim SimplificarPrePoliza As Boolean = False + If (UsuarioActual.Empresa.Funcionalidad(343) = "1" AndAlso ObjFactura.TipoDocto = "Ant") Or (ChkAntEspecial.Checked AndAlso ObjFactura.TipoDocto = "Ant") Then SeContabiliza = False End If @@ -12614,7 +12617,7 @@ Partial Class Ventas If CveIEPago > 0 Then importeMovimiento = DrPago("Importe").ToString().ToDecimal * ValorMultiplicador - importeMX = importeMovimiento * tipoCambio * Multiplicador + importeMX = (importeMovimiento * tipoCambio * Multiplicador).RoundSQL IdCtaContable = 0 CveCuenta = 0 CveSubProyectoContabilizar = CveSubProyectoVenta @@ -12633,20 +12636,61 @@ Partial Class Ventas ' CuentasContablesInvalidasSIG.AppendFormat("
{0}", GlobalDTBancosCuentas(UsuarioActual.CveUsuario, DrPago("CveCuenta").ToString().ToEntero()).Rows(0)("NumCuentaMoneda").ToString().ToEntero()) ' CveCuentaContabilizacion = 0 'End If + 'MONEDA EXTRANJERA + If ObjFactura.CveMoneda > 1 Then + 'BANCOS + Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 30, NombreCliente, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString()) + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=importeMovimiento, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + Exit For + End If + + 'BANCOS COMPLEMENTARIA + If UsaComplementariaClientes Then + Dim ImporteComplementaria As Decimal = ((importeMovimiento * tipoCambio) - importeMovimiento).RoundSQL + + Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 204, NombreCliente, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString()) + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, 204, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEPago, ImporteMX:=ImporteComplementaria, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, TipoCambioPago:=tipoCambio, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + End If + + 'PAGO CLIENTES + Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 2, NombreCliente, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString()) + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 2, Concepto, Fecha, IdCtaContableCliente, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=importeMovimiento, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuentaCliente, CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + Exit For + End If + + 'PAGO CLIENTES COMPLEMENTARIA + If UsaComplementariaClientes Then + Dim ImporteComplementaria As Decimal = ((importeMovimiento * tipoCambio) - importeMovimiento).RoundSQL + + Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 207, NombreCliente, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString()) + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, 0, Referencia, 207, Concepto, FechaMovimiento, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=ObjFactura.CveCliente, CveIE:=CveIEPago, ImporteMX:=ImporteComplementaria, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), TipoCambio:=tipoCambio, TipoCambioPago:=tipoCambio, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar, Contabilizable:=SeContabiliza) Then + ErrorPrepoliza = True + End If + End If + + SimplificarPrePoliza = True + + Else + 'BANCOS + Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 30, NombreCliente, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString()) + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + Exit For + End If + + 'PAGO CLIENTES + Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 2, NombreCliente, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString()) + If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 2, Concepto, Fecha, IdCtaContableCliente, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuentaCliente, CveSubProyecto:=CveSubProyectoContabilizar) Then + ErrorPrepoliza = True + Exit For + End If - 'BANCOS - Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 30, NombreCliente, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString()) - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, TipoMovimiento, importeMovimiento, Referencia, ConceptoContable, Concepto, Fecha, IdCtaContable, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuenta) Then - ErrorPrepoliza = True - Exit For End If - 'CLIENTES - Concepto = ObjConta.ObtenerConceptoEmpresa(UsuarioActual.CveEmpresa, 2, NombreCliente, $"{ObjFactura.Serie}-{ObjFactura.Folio}", FolioIE.ToString()) - If Not ObjConta.AddPrePolizasDetalle(ObjFactura.CvePrePoliza, Not TipoMovimiento, importeMovimiento, Referencia, 2, Concepto, Fecha, IdCtaContableCliente, -1, CveVenta:=ObjFactura.CveVenta, CveCliente:=CveCliente, CveIE:=CveIEPago, ImporteMX:=importeMX, ImporteME:=If(tipoCambio = 1, 0, importeMovimiento), CveCuenta:=CveCuentaCliente, CveSubProyecto:=CveSubProyectoContabilizar) Then - ErrorPrepoliza = True - Exit For - End If If ObjFactura.IVA <> 0 Then @@ -12795,7 +12839,7 @@ Partial Class Ventas End If 'Simplificacion de PrePolizas - If ObjFactura.TipoDocto.Contiene("Egs", "Dev") Then + If ObjFactura.TipoDocto.Contiene("Egs", "Dev") OrElse SimplificarPrePoliza Then If Not ObjConta.PrePolizaSimplificacion(ObjFactura.CvePrePoliza, UsuarioActual.CveEmpresa) Then Alert("No se pudo simplificar los movimientos", TipoMensaje.MsgError) End If @@ -27328,11 +27372,29 @@ Partial Class Ventas RemisionesLista.Clear() + Dim MsgUsados As New StringBuilder + Dim UsadosValidados As Boolean = True + If dtSeleccionadas.Rows.Count > 0 Then Select Case RblTipo.SelectedValue Case "1" 'T O T A L G E N E R A L For Each row As DataRow In dtSeleccionadas.Rows - RemisionesLista.Add(row("CveVenta").ToString().ToEntero()) + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + Using ObjUsados As New ClsVentas + If ObjUsados.GetVentasUsados(row("CveVenta").ToString().ToEntero(), -1, row("Fecha").ToString().ToDateTime, UsuarioActual.CveEmpresa) Then + If ObjUsados.DtResultados.Rows.Count > 0 Then + UsadosValidados = False + MsgUsados.AppendFormat("{0},", row("Folio").ToString()) + End If + End If + End Using + End If + + If UsadosValidados Then + RemisionesLista.Add(row("CveVenta").ToString().ToEntero()) + End If + Next IsTotalxConcepto = False Dim PU As Decimal = dtSeleccionadas.SUM("SubTotal").ToDecimal @@ -27347,7 +27409,22 @@ Partial Class Ventas CalculaTotalesVenta() Case "2" 'T O T A L X R E M I S I O N For Each row As DataRow In dtSeleccionadas.Rows - RemisionesLista.Add(row("CveVenta").ToString().ToEntero()) + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + Using ObjUsados As New ClsVentas + If ObjUsados.GetVentasUsados(row("CveVenta").ToString().ToEntero(), -1, row("Fecha").ToString().ToDateTime, UsuarioActual.CveEmpresa) Then + If ObjUsados.DtResultados.Rows.Count > 0 Then + UsadosValidados = False + MsgUsados.AppendFormat("{0},", row("Folio").ToString()) + End If + End If + End Using + End If + + If UsadosValidados Then + RemisionesLista.Add(row("CveVenta").ToString().ToEntero()) + End If + Next Dim PS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa)(0) Dim rowSP As DataRow = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa)(0) @@ -27368,17 +27445,51 @@ Partial Class Ventas For Each row As DataRow In dtSeleccionadas.Rows sb.Append($"{row("CveVentaDetalle").ToString()},") Next - For Each row As DataRow In dtSeleccionadas.FiltraParametros("", DistinctColumns:={"CveVenta"}).Rows - RemisionesLista.Add(row("CveVenta").ToString().ToEntero()) + For Each row As DataRow In dtSeleccionadas.FiltraParametros("", DistinctColumns:={"CveVenta", "Fecha", "Folio"}).Rows + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + Using ObjUsados As New ClsVentas + If ObjUsados.GetVentasUsados(row("CveVenta").ToString().ToEntero(), -1, row("Fecha").ToString().ToDateTime, UsuarioActual.CveEmpresa) Then + If ObjUsados.DtResultados.Rows.Count > 0 Then + UsadosValidados = False + MsgUsados.AppendFormat("{0},", row("Folio").ToString()) + End If + End If + End Using + End If + + If UsadosValidados Then + RemisionesLista.Add(row("CveVenta").ToString().ToEntero()) + End If Next Else For Each row As DataRow In dtSeleccionadas.Rows sb.Append($"{row("CveVenta").ToString()},") - RemisionesLista.Add(row("CveVenta").ToString().ToEntero()) + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + Using ObjUsados As New ClsVentas + If ObjUsados.GetVentasUsados(row("CveVenta").ToString().ToEntero(), -1, row("Fecha").ToString().ToDateTime, UsuarioActual.CveEmpresa) Then + If ObjUsados.DtResultados.Rows.Count > 0 Then + UsadosValidados = False + MsgUsados.AppendFormat("{0},", row("Folio").ToString()) + End If + End If + End Using + End If + + If UsadosValidados Then + RemisionesLista.Add(row("CveVenta").ToString().ToEntero()) + End If Next End If + + sb.Remove(sb.Length - 1, 1) - CargaConceptosRemisionPorFacturar(sb.ToString(), If(ChkRemProductos.Checked, 2, 1)) + + If UsadosValidados Then + CargaConceptosRemisionPorFacturar(sb.ToString(), If(ChkRemProductos.Checked, 2, 1)) + End If + sb.Clear() End Select @@ -27430,6 +27541,15 @@ Partial Class Ventas ObsPedido.Clear() ObsInv.Clear() End If + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso Not UsadosValidados Then + If MsgUsados.Length > 0 Then + MsgUsados.Remove(MsgUsados.Length - 1, 1) + End If + Alert($"Las siguientes remisiones no se pueden facturar porque no se ha recibido el usado correspondiente:
{MsgUsados.ToString()}", TipoMensaje.MsgAdvertencia) + BtnEmitirImprimir.Visible = False + End If + End If TxtFechaPago.Text = If(EsDiasCreditoFijo, Now.AddDays(DiasCredito).ToShortDateString, TxtFechaPago.Text) @@ -28570,7 +28690,10 @@ Partial Class Ventas Else Row("PorcentajeIVA") = DrPS("IVA") End If - Dim TotalCalculableImpuestos As Decimal = (Row("Cantidad").ToString().ToDecimal * Row("PU").ToString().ToDecimal) - Row("Descuento").ToString().ToDecimal + + Dim PU = Row("PU").ToString().ToDecimal().RoundSQL(6) ' el precio unitario puede llevar hasta 6 decimales permitidos + + Dim TotalCalculableImpuestos As Decimal = (Row("Cantidad").ToString().ToDecimal * PU) - Row("Descuento").ToString().ToDecimal Dim TotalCalculableImpuestosIVA As Decimal = TotalCalculableImpuestos * (1 + Row("PorcentajeIEPS").ToString().ToDecimal) Row("IVA") = Row("PorcentajeIVA").ToString().ToDouble From 78c93110472d85af6e3471e68171aa51d5158e52 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 24 Mar 2021 10:02:37 -0700 Subject: [PATCH 02/16] Content Disposition Dinamico --- App_Code/ClsPaginas.vb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 990a3e2f5..95e161692 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -5444,13 +5444,13 @@ Public Class ClsPaginas ''' Opcional Nombre del archivo que se descarga ''' Optional, Formato de Generacion PDF o Excel ''' - Public Sub ImprimirPDF(RutaReporte As String, DtDatos As DataTable, Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional RDSName As String = "DataSet1", Optional MR As ReportViewer = Nothing) + Public Sub ImprimirPDF(RutaReporte As String, DtDatos As DataTable, Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional RDSName As String = "DataSet1", Optional MR As ReportViewer = Nothing, Optional Content_Disposition As String = "attachment") Dim lrds As New List(Of ReportDataSource) Dim rds As New ReportDataSource rds.Name = RDSName rds.Value = DtDatos lrds.Add(rds) - ImprimirPDF(RutaReporte, lrds, Parametros, NombreArchivo, Formato, MR) + ImprimirPDF(RutaReporte, lrds, Parametros, NombreArchivo, Formato, MR, Content_Disposition) End Sub Public Sub ImprimirPDFMultiDS(RutaReporte As String, lrds As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional RDSName As String = "DataSet1", Optional MR As ReportViewer = Nothing) ImprimirPDF(RutaReporte, lrds, Parametros, NombreArchivo, Formato, MR) @@ -5465,9 +5465,9 @@ Public Class ClsPaginas ''' Opcional Nombre del archivo que se descarga ''' Optional, Formato de Generacion PDF o Excel ''' - Public Sub ImprimirPDF(RutaReporte As String, DataSource As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportViewer = Nothing) + Public Sub ImprimirPDF(RutaReporte As String, DataSource As List(Of ReportDataSource), Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional MR As ReportViewer = Nothing, Optional Content_Disposition As String = "attachment") 'limpio ReportViwer - ImprimirbytesPDF(StreamPDF(RutaReporte, DataSource, Parametros, NombreArchivo, Formato, MR), NombreArchivo, Formato) + ImprimirbytesPDF(StreamPDF(RutaReporte, DataSource, Parametros, NombreArchivo, Formato, MR), NombreArchivo, Formato, Content_Disposition:=Content_Disposition) End Sub Public Function StreamPDF(RutaReporte As String, DtDatos As DataTable, Parametros As List(Of ReportParameter), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional RDSName As String = "DataSet1", Optional MR As ReportViewer = Nothing) As Byte() Dim lrds As New List(Of ReportDataSource) @@ -5857,7 +5857,7 @@ Public Class ClsPaginas ''' ''' ''' - Public Sub ImprimirbytesPDF(bytes As Byte(), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional Descarga As Boolean = False) + Public Sub ImprimirbytesPDF(bytes As Byte(), Optional NombreArchivo As String = "Reporte", Optional Formato As String = "PDF", Optional Descarga As Boolean = False, Optional Content_Disposition As String = "attachment") 'limpio ReportViwer Dim mimeType As String = Nothing Dim extension As String = Nothing @@ -5880,7 +5880,7 @@ Public Class ClsPaginas Response.Buffer = True Response.Clear() Response.ContentType = mimeType - Response.AddHeader("content-disposition", String.Format("attachment; filename={0}.{1}", NombreArchivo, If(Formato = "PDF", "pdf", "xls"))) + Response.AddHeader("content-disposition", String.Format("{0}; filename={1}.{2}", Content_Disposition, NombreArchivo, If(Formato = "PDF", "pdf", "xls"))) Response.BinaryWrite(bytes) ' create the file Response.Flush() ' send it to the client to download HttpContext.Current.Response.SuppressContent = True From cd78ba711c5f344a5be27aec3ec6ec56532e69d0 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 24 Mar 2021 10:02:55 -0700 Subject: [PATCH 03/16] Correciones de redondeo --- App_Code/modExtensiones.vb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/App_Code/modExtensiones.vb b/App_Code/modExtensiones.vb index 9a18a5716..fbe97480e 100644 --- a/App_Code/modExtensiones.vb +++ b/App_Code/modExtensiones.vb @@ -968,25 +968,25 @@ Namespace Extensiones - Public Function RoundAD(Valor As Double, Optional Decimales As Integer = 2) As Double - Return Math.Round(Valor, Decimales) - End Function - - Public Function RoundAD(Valor As Decimal, Optional Decimales As Integer = 2) As Decimal - Return Math.Round(Valor, Decimales) + Public Function RoundAD(Valor As Double, Optional Decimales As Integer = 2) As Double + Return Math.Round(Valor, Decimales, MidpointRounding.AwayFromZero) + End Function + + Public Function RoundAD(Valor As Decimal, Optional Decimales As Integer = 2) As Decimal + Return Math.Round(Valor, Decimales, MidpointRounding.AwayFromZero) End Function - Public Function RoundSQL(Valor As Double, Optional Decimales As Integer = 2) As Double - 'Return Math.Round(Valor, Decimales, MidpointRounding.AwayFromZero) - 'primero, se redondea a 4, para que concuerde al redondeo de sql, si se redondea a 2 decimales por ejemplo - Return If(Decimales < 4, Math.Round(Math.Round(Valor, 4, MidpointRounding.AwayFromZero), Decimales, MidpointRounding.AwayFromZero), Math.Round(Valor, Decimales, MidpointRounding.AwayFromZero)) + Public Function RoundSQL(Valor As Double, Optional Decimales As Integer = 2) As Double + 'Return Math.Round(Valor, Decimales, MidpointRounding.AwayFromZero) + 'primero, se redondea a 4, para que concuerde al redondeo de sql, si se redondea a 2 decimales por ejemplo + Return Math.Round(Valor, Decimales, MidpointRounding.AwayFromZero) End Function Public Function RoundSQL(Valor As Decimal, Optional Decimales As Integer = 2) As Decimal 'primero, se redondea a 4, para que concuerde al redondeo de sql - Return If(Decimales < 4, Math.Round(Math.Round(Valor, 4, MidpointRounding.AwayFromZero), Decimales, MidpointRounding.AwayFromZero), Math.Round(Valor, Decimales, MidpointRounding.AwayFromZero)) + Return Math.Round(Valor, Decimales, MidpointRounding.AwayFromZero) End Function Public Function Abs(Valor As Double) As Double From b6864c53b3a3e9d0ae7aee232416195f76f7bdc1 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 24 Mar 2021 10:03:24 -0700 Subject: [PATCH 04/16] Abrir automaticamente PDF de ajuste --- Compras/PopUpVerFactura.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Compras/PopUpVerFactura.aspx.vb b/Compras/PopUpVerFactura.aspx.vb index 6bae061c3..f477a8d99 100644 --- a/Compras/PopUpVerFactura.aspx.vb +++ b/Compras/PopUpVerFactura.aspx.vb @@ -4696,7 +4696,7 @@ Partial Class PopUpVerFactura params.Add(New ReportParameter("LogoPath", "")) End If - ImprimirPDF("Empresas/Grales/Formatos/Ajuste.rdlc", DtDatos, params, "Reporte de Ajuste", "PDF") + ImprimirPDF("Empresas/Grales/Formatos/Ajuste.rdlc", DtDatos, params, "Reporte de Ajuste", "PDF", Content_Disposition:="inline") End Sub #End Region From 8baa8de71c625296b3c12b07572c21f69d548b79 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 24 Mar 2021 10:04:53 -0700 Subject: [PATCH 05/16] Filtro y correciones en reporte de georeferencias --- GPS/RepGeoReferencias.aspx | 586 +++++++++++++++++----------------- GPS/RepGeoReferencias.aspx.vb | 153 ++++++--- 2 files changed, 411 insertions(+), 328 deletions(-) diff --git a/GPS/RepGeoReferencias.aspx b/GPS/RepGeoReferencias.aspx index 35aefb23b..03362e238 100644 --- a/GPS/RepGeoReferencias.aspx +++ b/GPS/RepGeoReferencias.aspx @@ -1,8 +1,8 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/SiteGPS.master" AutoEventWireup="false" CodeFile="RepGeoReferencias.aspx.vb" Inherits="GPS_RepGeoReferencias" %> - - - - +<%@ Page Title="" Language="VB" MasterPageFile="~/SiteGPS.master" AutoEventWireup="false" CodeFile="RepGeoReferencias.aspx.vb" Inherits="GPS_RepGeoReferencias" %> + + + + - - -
  • - - Volver a Consultar - -
  • -
    - -
    - - - - - - + + +
    + + - - - + + +
    + diff --git a/GPS/RepGeoReferencias.aspx.vb b/GPS/RepGeoReferencias.aspx.vb index b322bcf74..3c4c9a164 100644 --- a/GPS/RepGeoReferencias.aspx.vb +++ b/GPS/RepGeoReferencias.aspx.vb @@ -12,6 +12,14 @@ Partial Class GPS_RepGeoReferencias Set(value As Integer) ViewState("CveGeoReferencia") = value End Set + End Property + Private Property DtGeoReferencias As DataTable + Get + Return CType(ViewState("DtGeoReferencias"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtGeoReferencias") = value + End Set End Property Private Property DtPosiciones As DataTable Get @@ -49,13 +57,27 @@ Partial Class GPS_RepGeoReferencias Private Sub CargaGeoReferencias() Dim Estatus = If(ChkEstatusGeocerca.Checked, 1, 0) - Dim GPS As New ClsGPS - If GPS.GeoReferenciaGet(-1, Estatus, "-1", UsuarioActual.CveCliente) Then - GVGeoreferencias.DataSource = GPS.DtResultados - Else - GVGeoreferencias.DataSource = Nothing + + Using GPS As New ClsGPS + If GPS.GeoReferenciaGet(-1, Estatus, "-1", UsuarioActual.CveCliente) Then + DtGeoReferencias = GPS.DtResultados.Copy() + End If + End Using + + If DtGeoReferencias IsNot Nothing Then + Dim TotalRegistros As Integer = DtGeoReferencias.Rows.Count + Dim TotalRowsPage As Integer = GVGeoreferencias.PageSize + If TotalRegistros > TotalRowsPage Then + GVGeoreferencias.DataSource = DtGeoReferencias.FiltraPorIndices(0, TotalRowsPage - 1) + DivPaginacion.Visible = True + LblRegistros.Text = $"Distribución de datos desde 0 hasta {TotalRowsPage.ToString().ToDecimal().FormatoNumero(0)}. Total de registros: {TotalRegistros.ToString().ToDecimal().FormatoNumero(0)}" + Else + GVGeoreferencias.DataSource = DtGeoReferencias + End If + Else + GVGeoreferencias.DataSource = DtGeoReferencias End If - GPS.Dispose() + GVGeoreferencias.DataBind() End Sub Private Sub CargaDispositivos() @@ -190,16 +212,11 @@ Partial Class GPS_RepGeoReferencias TxtHoraF.Text = GvRow.DataKey("HoraFin").ToString.ToDateTime.ToString("HH:mm") Using ObjGPS As New ClsGPS - If ObjGPS.GetReferenciaDetalle(-1, CveGeoReferencia, -1, UsuarioActual.CveCliente) Then - If ObjGPS.DtResultados.Rows.Count > 0 Then - DtDetalle = ObjGPS.DtResultados - GvEquiposDetalle.DataSource = DtDetalle - Else - DtDetalle = Nothing - DtDetalleEliminar = Nothing - GvEquiposDetalle.DataSource = Nothing - End If - + If ObjGPS.GetReferenciaDetalle(-1, CveGeoReferencia, -1, UsuarioActual.CveCliente) Then + DtDetalle = ObjGPS.DtResultados.Copy() + DtDetalleEliminar = ObjGPS.DtResultados.Copy() + + GvEquiposDetalle.DataSource = DtDetalle End If End Using GvEquiposDetalle.DataBind() @@ -239,27 +256,22 @@ Partial Class GPS_RepGeoReferencias Dim HoraF As Date = ($"{Date.Now.ToString("dd/MM/yyyy")} {TxtHoraF.Text}").ToDate If ObjGPS.GeoReferenciaUpdate(CveGeoReferencia, TxtNombre.Text, -1, chkEstatus.Checked, txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, chkLunes.Checked, chkMartes.Checked, chkMiercoles.Checked, chkJueves.Checked, chkViernes.Checked, - chkSabado.Checked, chkDomingo.Checked, HoraI, HoraF, TxtTolerancia.Text.ToEntero, UsuarioActual.CveCliente) Then - - For Each Dr As DataRow In DtDetalle.Rows - Dim CveGeoReferenciaDetalle = Dr("CveDispositivoGeoreferenciaDetalle").ToString.ToEntero - If CveGeoReferenciaDetalle > 0 Then - If Not ObjGPS.UpdateReferenciaDetalle(CveGeoReferenciaDetalle, CveGeoReferencia, Dr("CveDispositivo").ToString.ToEntero) Then - TieneError = True - Exit For - End If - Else - If Not ObjGPS.AddGeoReferenciaDetalle(CveGeoReferencia, Dr("CveDispositivo").ToString.ToEntero) Then - TieneError = True - Exit For - End If - End If - Next + chkSabado.Checked, chkDomingo.Checked, HoraI, HoraF, TxtTolerancia.Text.ToEntero, UsuarioActual.CveCliente) Then If Not TieneError Then For Each DrE As DataRow In DtDetalleEliminar.Rows - TieneError = Not ObjGPS.RemoveferenciaDetalle(DrE("CveDispositivoGeoreferenciaDetalle").ToString.ToEntero) + If DrE("CveDispositivoGeoreferenciaDetalle").ToString.ToEntero > 0 Then + TieneError = Not ObjGPS.RemoveferenciaDetalle(DrE("CveDispositivoGeoreferenciaDetalle").ToString.ToEntero) + End If Next End If + + For Each Dr As DataRow In DtDetalle.Rows + If Not ObjGPS.AddGeoReferenciaDetalle(CveGeoReferencia, Dr("CveDispositivo").ToString.ToEntero) Then + TieneError = True + Exit For + End If + Next + Else TieneError = True End If @@ -336,14 +348,15 @@ Partial Class GPS_RepGeoReferencias Dim Dr As DataRow = DtDetalle.Rows(e.RowIndex) Dim CveGeoReferenciaDetalle = Dr("CveDispositivoGeoreferenciaDetalle").ToString.ToEntero If CveGeoReferenciaDetalle > 0 Then - - Dim DrEliminar = DtDetalleEliminar.NewRow - DrEliminar("CveDispositivoGeoreferenciaDetalle") = CveGeoReferenciaDetalle - DrEliminar("CveDispositivo") = Dr("CveDispositivo").ToString.ToEntero - DrEliminar("NoEconomico") = Dr("NoEconomico").ToString - DtDetalleEliminar.Rows.Add(DrEliminar) - DtDetalleEliminar.AcceptChanges() - + If DtDetalleEliminar.COUNT("CveDispositivo", $"CveDispositivoGeoreferenciaDetalle={CveGeoReferenciaDetalle}") <= 0 Then + Dim DrEliminar = DtDetalleEliminar.NewRow + DrEliminar("CveDispositivoGeoreferenciaDetalle") = CveGeoReferenciaDetalle + DrEliminar("CveDispositivo") = Dr("CveDispositivo").ToString.ToEntero + DrEliminar("NoEconomico") = Dr("NoEconomico").ToString + DtDetalleEliminar.Rows.Add(DrEliminar) + DtDetalleEliminar.AcceptChanges() + End If + End If DtDetalle.Rows.RemoveAt(e.RowIndex) @@ -415,5 +428,63 @@ Partial Class GPS_RepGeoReferencias Protected Sub ChkEstatusGeocerca_CheckedChanged(sender As Object, e As EventArgs) CargaGeoReferencias() + End Sub + + Protected Sub btnPagePrev_Click(sender As Object, e As EventArgs) + Dim TotalRegistros As Integer = DtGeoReferencias.Rows.Count + Dim TotalRowsPage As Integer = GVGeoreferencias.PageSize + Dim PrevIndex As Integer = HdnIndexPage.Value.ToEntero - 1 + Dim CurrentIndex As Integer = PrevIndex + 1 + + Dim PrevIndexDT As Integer = (TotalRowsPage) * PrevIndex + Dim CurrentIndexDT As Integer = (TotalRowsPage) * CurrentIndex + + HdnIndexPage.Value = PrevIndex.ToString + + If Not btnPageNext.Enabled Then + btnPageNext.Enabled = True + End If + + If PrevIndexDT <= 0 Then + btnPagePrev.Enabled = False + GVGeoreferencias.DataSource = DtGeoReferencias.FiltraPorIndices(0, CurrentIndexDT) + LblRegistros.Text = $"Distribución de datos desde 0 hasta {CurrentIndexDT.ToString.FormatoNumero(0)}. Total de registros: {DtGeoReferencias.Rows.Count.ToString.FormatoNumero(0)}" + Else + LblRegistros.Text = $"Distribución de datos desde {PrevIndexDT.ToString.FormatoNumero(0)} hasta {CurrentIndexDT.ToString.FormatoNumero(0)}. Total de registros: {DtGeoReferencias.Rows.Count.ToString.FormatoNumero(0)}" + GVGeoreferencias.DataSource = DtGeoReferencias.FiltraPorIndices(PrevIndexDT, CurrentIndexDT) + End If + + GVGeoreferencias.DataBind() + UPGV.Update() + + End Sub + + Protected Sub btnPageNext_Click(sender As Object, e As EventArgs) + Dim TotalRegistros As Integer = DtGeoReferencias.Rows.Count + Dim TotalRowsPage As Integer = GVGeoreferencias.PageSize + Dim Index As Integer = HdnIndexPage.Value.ToEntero + 1 + Dim NextIndex As Integer = Index + 1 + + Dim CurrentIndexDT As Integer = (TotalRowsPage) * Index + Dim NextIndexDT As Integer = (TotalRowsPage) * NextIndex + + HdnIndexPage.Value = Index.ToString + + If Not btnPagePrev.Enabled Then + btnPagePrev.Enabled = True + End If + + If NextIndexDT >= TotalRegistros Then + btnPageNext.Enabled = False + GVGeoreferencias.DataSource = DtGeoReferencias.FiltraPorIndices(CurrentIndexDT, TotalRegistros - 1) + LblRegistros.Text = $"Distribución de datos desde {CurrentIndexDT.ToString.FormatoNumero(0)} hasta {DtGeoReferencias.Rows.Count.ToString.FormatoNumero(0)}. Total de registros: {DtGeoReferencias.Rows.Count.ToString.FormatoNumero(0)}" + Else + GVGeoreferencias.DataSource = DtGeoReferencias.FiltraPorIndices(CurrentIndexDT, NextIndexDT) + LblRegistros.Text = $"Distribución de datos desde {CurrentIndexDT.ToString.FormatoNumero(0)} hasta {NextIndexDT.ToString.FormatoNumero(0)}. Total de registros: {DtGeoReferencias.Rows.Count.ToString.FormatoNumero(0)}" + End If + + GVGeoreferencias.DataBind() + UPGV.Update() + End Sub End Class From d10f6802884d5c87ec92e325f2e4b4ed092ee6a2 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 24 Mar 2021 10:07:02 -0700 Subject: [PATCH 06/16] Pruebas para consulta por API --- Ventas/Clientes.aspx | 7 ++ Ventas/Clientes.aspx.vb | 160 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 153 insertions(+), 14 deletions(-) diff --git a/Ventas/Clientes.aspx b/Ventas/Clientes.aspx index 590b08157..cfbf57233 100644 --- a/Ventas/Clientes.aspx +++ b/Ventas/Clientes.aspx @@ -6263,6 +6263,13 @@