Efectivamente los cambios ya deberian estar hechos.
Para revisar he abierto despues de que termina mi aplicacion,
la BD, y consultado directamente las tablas, y solo las tablas
que afecte haciendo un UPDATE o DELETE, son las que registraron
los cambios, en las tablas donde utilize modificaciones a traves del
ADOQuery....Edit.....Update... no pasó absolutamente nada.
coloco de nuevo el codigo (espero no se torne muy tedioso)
y agradezco la atencion prestada y los comentarios que me
puedan hacer al respecto. Saludos
Código Delphi
[-]
procedure TInicio.RepagadoEspecifico(Cliente:string);
var
IdCliente,prNoFactura:integer;
AbonoP:Real;
begin
with QActualiza do
begin
SQL.Clear; SQL.Text:='DELETE * FROM [Abonos no Aplicados]'; ExecSQL;
SQL.Clear; SQL.Text:='DELETE * FROM [Abonos Pendientes]'; ExecSQL;
SQL.Clear; SQL.Text:='SELECT Id AS Registro FROM Clientes WHERE '+
'NombreCompañía=' + Quotedstr(Cliente); Open;
IdCliente:=FieldValues['Registro']; SQL.Clear;
SQL.Text:='UPDATE Tabla7 SET '+
'Pagada=0,PagadaE=0,Parcial=0,PArcialE=0,Importe=0,ImporteE=0 '+
'WHERE ((Pedido="Cargo") OR (Pedido="Nota de Cargo") ' +
'OR (Pedido="CargoF") OR (Pedido="Abono")) '+
'AND NombreCompañía='+ Quotedstr(Cliente);
ExecSQL; SQL.Clear;
If IdCliente <> 0 Then
begin
SQL.Text:='UPDATE Pedidos SET Pagada=0,PagadaE=0,ParcialE=0,ImporteE=0 WHERE Idpor=3 And IdCliente='+ IntToStr(IdCliente);
ExecSQL; SQL.Clear;
SQL.Text:='SELECT IdMovimiento, Aplicar, Factura FROM [Consulta A&B PagadoEspecifico] '+
'WHERE NombreCompañía=' + Quotedstr(Cliente) +' ORDER BY Fecha';
Open;
end;
end;
while Not(QActualiza.Eof) do
begin prNoFactura:=QActualiza.FieldValues['Factura'];
with QKardex do
begin Close; SQL.Clear;
SQL.Text:='SELECT IdCrédito,Pagada,PagadaE,Parcial,ParcialE,Importe,ImporteE,Totales FROM Tabla7 '+
'WHERE ((Pedido="Cargo") OR (Pedido="Nota de Cargo") OR (Pedido="CargoF")) '+
'AND NoFactura=' + IntToStr(prNoFactura) + 'AND NombreCompañía='+ Quotedstr(Cliente);
Open;
if Not(Eof) then begin
Edit;
FieldValues['ImporteE']:=FieldValues['ImporteE'] + QActualiza.FieldValues['Aplicar'];
if FieldValues['ImporteE']>=FieldValues['Totales'] then
begin if FieldValues['ImporteE']>FieldValues['Totales'] then
begin
AbonoP:=FieldValues['ImporteE'].AsReal - FieldValues['Totales'].AsReal;
QInsertados.Close;
QInsertados.SQL.Clear;
QInsertados.SQL.Text:='INSERT INTO [Abonos Pendientes] (Cliente,Importe,IdAbono) VALUES('+ Quotedstr(Cliente) + ',' + CurrToStr(AbonoP)+ ',' + IntToStr(prNoFactura) +')';
QInsertados.ExecSQL;
FieldValues['ImporteE']:= FieldValues['Totales'].AsCurrency;
Update;
QInsertados.Close;
end; FieldValues['Pagada']:=True; FieldValues['PagadaE']:=True;
FieldValues['Parcial']:=False; FieldValues['ParcialE']:=False;
FieldValues['Importe']:=FieldValues['ImporteE'];
Update;
QInsertados.SQL.Clear;
QInsertados.SQL.Text:='UPDATE Pedidos SET Pagada=-1,PagadaE=-1,ParcialE=0,ImporteE='+ CurrToStr(FieldValues['Importe']) + ' WHERE IdPedido=' + IntToStr(FieldValues['IdCrédito']);
QInsertados.ExecSQL;
QInsertados.Close;
end
else begin
FieldValues['Pagada']:=False; FieldValues['PagadaE']:=False;
FieldValues['Parcial']:=True; FieldValues['ParcialE']:=True;
FieldValues['Importe']:=FieldValues['ImporteE'];
Update;
QInsertados.SQL.Clear;
QInsertados.SQL.Text:='UPDATE Pedidos SET Pagada=-1,PagadaE=-1,ParcialE=0,ImporteE='+ CurrToStr(FieldValues['Importe']) +' WHERE IdPedido=' + IntToStr(FieldValues['IdCrédito']);
QInsertados.ExecSQL;
QInsertados.Close;
end; end
else begin
Close; SQL.Clear;
SQL.Text:='SELECT IdCrédito,Pagada,PagadaE,Parcial,ParcialE,Importe,ImporteE,Totales '+
'FROM Tabla7 '+
'WHERE IdCrédito=1 AND ((Pedido="CargoF") OR (Pedido="Nota de Cargo") OR (Pedido="Cargo")) AND NombreCompañía=' + QuotedStr(Cliente);
Open;
If Eof then
begin
QInsertados.SQL.Clear;
QInsertados.SQL.Text:='INSERT INTO [Abonos Pendientes](Cliente,Importe,IdAbono) VALUES ('+ QuotedStr(Cliente) + ',' + CurrToStr(QActualiza.FieldValues['Aplicar']) + ',' + IntToStr(QActualiza.FieldValues['Factura']) + ')';
QInsertados.ExecSQL;
QInsertados.Close;
end
else
begin
Edit;
FieldValues['ImporteE']:=FieldValues['ImporteE']+FieldValues['Haber'];
if FieldValues['ImporteE']>=FieldValues['Totales'] then
begin
if FieldValues['ImporteE']>=FieldValues['Totales'] then
begin
AbonoP:=FieldValues['ImporteE'].AsReal - FieldValues['Totales'];
QInsertados.SQL.Clear;
QInsertados.SQL.Text:='INSERT INTO [Abonos Pendientes] (Cliente, Importe, IdAbono) VALUES ('+ QuotedStr(Cliente) + ','+ CurrToStr(AbonoP) + ','+ IntToStr(prNoFactura) +',';
QInsertados.ExecSQL;
QInsertados.Close;
FieldValues['ImporteE']:= FieldValues['Totales'].AsCurrency;
end;
FieldValues['Pagada']:=true; FieldValues['PagadaE']:=true;
FieldValues['Parcial']:=false; FieldValues['ParcialE']:=false;
FieldValues['Importe']:= FieldValues['ImporteE'].AsCurrency;
end
else
begin
FieldValues['Pagada']:=false; FieldValues['PagadaE']:=false;
FieldValues['Parcial']:=true; FieldValues['ParcialE']:=true;
FieldValues['Importe']:= FieldValues['ImporteE'].AsCurrency;
end;
Update;
end
end; QActualiza.Next;
end; end; end;