diff --git a/Compras/eFacturas.aspx.vb b/Compras/eFacturas.aspx.vb index 322ac5493..481b142a8 100644 --- a/Compras/eFacturas.aspx.vb +++ b/Compras/eFacturas.aspx.vb @@ -3282,43 +3282,52 @@ Partial Class Compras_eFacturas For Each dRow As DataRow In DTGVPagosVinculacion.Rows - If HdnIdDocumento.Value = dRow("IdDocumento").ToString Then 'And dRow("CveIE").ToString.ToEntero <= 0 dRow("CveIE") = HdnCveIE.Value.ToEntero Dim ObjIE As New ClsBancos() - 'If ObjIE.GetBancosIE(HdnCveIE.Value.ToEntero, UsuarioActual.CveEmpresa) Then - ' Try - ' dRow("FolioPago") = ObjIE.Folio - ' dRow("ImportePago") = dRow("ImpPagado") - ' dRow("FechaPago") = ObjIE.FechaDocumento - ' dRow("Tipo") = "E" - ' ' dRow("Diferencia") = 0D - ' dRow("Manual") = True - - ' Catch ex As Exception - - ' End Try - - 'End If - Dim ObjCompras As New ClsCompras If ObjCompras.GetCompararComplementoPago(CveProveedor, -1, "", UsuarioActual.CveEmpresa, HdnCveIE.Value.ToEntero) Then - Try - dRow("FolioPago") = ObjCompras.DtResultados(0)("FolioIE") - dRow("ImportePago") = dRow("ImpPagado") - dRow("FechaPago") = ObjCompras.DtResultados(0)("Fecha").ToString.ToDate - dRow("CvePrePolizaDetalle") = ObjCompras.DtResultados(0)("CvePrePolizaDetalle").ToString.ToEntero - dRow("Tipo") = "E" - ' dRow("Diferencia") = 0D - dRow("Manual") = True - Catch ex As Exception - End Try + Dim CompraEncontrada As Boolean = False + + + For Each drowComparar As DataRow In ObjCompras.DtResultados.Rows + + If drowComparar("CveCompraPrePoliza").ToString.ToEntero > 0 AndAlso (dRow("CveCompra").ToString.ToEntero = drowComparar("CveCompraPrePoliza").ToString.ToEntero) Then + dRow("FolioPago") = drowComparar("FolioIE") + dRow("ImportePago") = dRow("ImpPagado") + dRow("FechaPago") = drowComparar("Fecha").ToString.ToDate + dRow("CvePrePolizaDetalle") = drowComparar("CvePrePolizaDetalle").ToString.ToEntero + dRow("Tipo") = "E" + dRow("Manual") = True + CompraEncontrada = True + Exit For + End If + + Next + + + If Not CompraEncontrada Then + + Try + dRow("FolioPago") = ObjCompras.DtResultados(0)("FolioIE") + dRow("ImportePago") = dRow("ImpPagado") + dRow("FechaPago") = ObjCompras.DtResultados(0)("Fecha").ToString.ToDate + dRow("CvePrePolizaDetalle") = ObjCompras.DtResultados(0)("CvePrePolizaDetalle").ToString.ToEntero + dRow("Tipo") = "E" + dRow("Manual") = True + Catch ex As Exception + + End Try + + End If + + End If ObjCompras.Dispose() @@ -3341,89 +3350,6 @@ Partial Class Compras_eFacturas ValidaTablaDeVinculacion() - Exit Sub - - '********************************************************************************************************************** - - - - - - 'If HdnCveIE.Value <> "-1" AndAlso IsNumeric(HdnCveIE.Value) AndAlso HdnCveIE.Value.ToEntero > 0 Then - - ' Dim ImportePago As Double = 0 - ' Dim ImporteIES As Double = 0 - ' Dim SerieFolioIE As String = "" - ' Dim ObjCompras As New ClsCompras - ' Dim ErrorVinculacion = True - - ' If ObjCompras.GetCompararComplementoPago(CveProveedor, -1, "", UsuarioActual.CveEmpresa, HdnCveIE.Value.ToEntero) Then - - ' For Each Drow As DataRow In ObjCompras.DtResultados.Rows - ' For Each GvRow As GridViewRow In GVPDocumentosRelacionadosPagos.Rows - - ' If GvRow.RowType = DataControlRowType.DataRow Then - - ' If Drow("CveCompra").ToString.ToEntero = GvRow.DataKey("CveCompra").ToEntero Then - - ' GvRow.FCLabel("LblCveIE").Text = Drow("CveIE").ToString.ToEntero.ToString - ' GvRow.FCLabel("LblCvePrePolizaDetalle").Text = Drow("CvePrePolizaDetalle").ToString.ToEntero.ToString - - ' End If - - ' End If - - ' Next - ' Next - - - ' For Each GvRow As GridViewRow In GVPDocumentosRelacionadosPagos.Rows - ' If GvRow.RowType = DataControlRowType.DataRow Then - - ' If GvRow.FCLabel("LblCveIE").Text.ToEntero > 0 And GvRow.FCLabel("LblCvePrePolizaDetalle").Text.ToEntero > 0 Then - ' ErrorVinculacion = False - - ' Else - - ' If ObjCompras.DtResultados.Rows.Count > 0 Then - ' GvRow.FCLabel("LblCveIE").Text = ObjCompras.DtResultados(0)("CveIE").ToString.ToEntero.ToString - ' GvRow.FCLabel("LblCvePrePolizaDetalle").Text = ObjCompras.DtResultados(0)("CvePrePolizaDetalle").ToString.ToEntero.ToString - ' Else - ' ErrorVinculacion = True - ' Exit For - ' End If - - ' End If - ' End If - - ' Next - - - ' Else - ' ErrorVinculacion = True - ' End If - - ' If Not ErrorVinculacion Then - ' ImporteIES = ObjCompras.DtResultados.FiltraParametros("CveIE > 0").SUM("Importe") - ' ObjCompras.Dispose() - - ' BtnVincularPago.Visible = True - - ' LblSerieFolioPago.Text = $"{SeriePago}-{FolioPago}" - ' LblImportePago.Text = ImportePago.FormatoNumero - ' 'LblSerieFolioIE.Text = SerieFolioIE - ' LblImporteIE.Text = ImporteIES.FormatoNumero - - ' GvVincularPago.DataBind() - ' UpVincularPago.Update() - ' ObjCompras.Dispose() - - ' Else - ' Alert("No se pudo realizar la vinculacion manual", TipoMensaje.MsgAdvertencia) - ' End If - - - 'End If End Sub