Public Sub RevisaLimite(IndicadorSaldo As String)
Dim MontoDiario As Double = 0
Dim FechaActual As String
FechaActual = DateTime.GetYear(DateTime.Now) & RightStr("00" & DateTime.GetMonth(DateTime.Now), 2) & _
RightStr("00" & DateTime.GetDayOfMonth(DateTime.Now), 2)
Dim Encontrado As Boolean = False
Dim SaldoEncontrado As Double = 0
If IndicadorSaldo = "1" Then
Dim SqlTxt As String =""
Dim rs As Cursor
SqlTxt = "SELECT COALESCE(SUM(CTRMON), 0) AS CTRMON FROM CTRLIMDI WHERE CTRFEC='" & FechaActual & "' AND CTRCLI=" & Starter.Codigo
rs = Starter.SQL1.ExecQuery(SqlTxt)
If rs.RowCount>0 Then
rs.Position = 0
MontoDiario = CDbl(rs.GetString("CTRMON"))
Else
MontoDiario = 0
EndIf
rs.Close
SqlTxt = "SELECT A.LCRUT,A.OUTNUM,B.LCCRED,B.LCDEUD FROM LCRCLI AS A INNER JOIN LCTRUT AS B ON (A.LCRUT=B.LCRUT) WHERE A.OUTNUM=" & Starter.Codigo
rs = Starter.SQL1.ExecQuery(SqlTxt)
If rs.RowCount>0 Then
rs.Position = 0
SaldoEncontrado = CDbl(rs.GetString("LCCRED")) - CDbl(rs.GetString("LCDEUD"))
Encontrado = True
End If
rs.Close
If Encontrado = False Then
SqlTxt = "SELECT MONCRE,SALCRE FROM RASIGNAN WHERE CCLIE=" & Starter.Codigo & " AND FVENC>=" & FechaActual
rs = Starter.SQL1.ExecQuery(SqlTxt)
If rs.RowCount>0 Then
rs.Position = 0
SaldoEncontrado = CDbl(rs.GetString("SALCRE")) - MontoDiario
Encontrado = True
End If
rs.Close
End If
If Encontrado = True Then
Msgbox("Límite de crédito disponible " & NumberFormat(Round2(SaldoEncontrado, 2), 0, 2).Replace(".","_").Replace(",",".").Replace("_",","), "")
End If
End If
EndSub