Ver Mensaje Individual
  #11  
Antiguo 14-07-2005
Chocoslovaco Chocoslovaco is offline
Miembro
 
Registrado: jun 2005
Ubicación: Puebla, México
Posts: 66
Reputación: 19
Chocoslovaco Va por buen camino
Abro directamente la BD

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  //Inicia While
    prNoFactura:=QActualiza.FieldValues['Factura'];
    with QKardex do
      begin   //Inicia With QKardex
      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 //SI CONSULTA KARDEX NO ES VACIA
        begin
        Edit;
        FieldValues['ImporteE']:=FieldValues['ImporteE'] + QActualiza.FieldValues['Aplicar'];
        if FieldValues['ImporteE']>=FieldValues['Totales'] then
          begin // SI ImporteE>=Totales
          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;// Fin ImporteE>Totales
          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 //Else SI ImporteE>=Totales
          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; // Termina SI ImporteE>=Totales
        end
      else // Else SI CONSULTA KARDEX NO ES VACIA
        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; //TERMINA SI CONSULTA KARDEX NO ES VACIA
        QActualiza.Next;
      end;  // Termina With QKardex
    end; // Termina While
end;//Repagado Especifico
Responder Con Cita