Ver Mensaje Individual
  #1  
Antiguo 21-09-2006
ercrizeporta ercrizeporta is offline
Miembro
 
Registrado: jun 2005
Posts: 131
Reputación: 19
ercrizeporta Va por buen camino
Question campos calculados

hola, vuelvo de nuevo al mismo tema que expuse hace tiempo.
tngo una tabla que me almacena las lineas de pedidos,tiene los campos cant,pvp, codigoarticulo....el campo total (cant x pvp) lo he creado como un campo calculado. la clave primaria de esta tabla esta compuesta por dos campos (numerodelinea y numerodefactura).
El procedimiento para realizar el calculo de la columna calculada lo he puesto en el evento oncalculatefields. Y es ahora cuanod llega el problema, a la hora de insertar un registro en la tabla, justo despues de haber insertado el campo numerodefactura y antes de haber insertado el numerodelinea el programa me da un error diciendo que el Tdataset no esta en modo de edicion o inserción de datos. NO TENGO NI IDEA DE COMO ARREGLAR ESTO!!!POR FAVOR UNA AYUDA!!!

codigo
Código Delphi [-]
if (not tblinauxcant.isnull) and
     (not tblinauxpvp.isnull)then
   begin
    if tblinauxdto.IsNull then
     begin
        totallin:=
           tblinaux['cant']*tblinaux['pvp'];
     end
    else
     begin
        totallin:=
           tblinaux['cant']*tblinaux['pvp']*(100-tblinaux['dto'])/100;
    end;
     modulodatos.tblinaux.edit;
     modulodatos.tblinaux['total'].asfloat:=totallin;
  end;
   //AHORA CALCULO EL TOTAL DE TODAS LAS LINEAS
  total:=0;
  if (not modulodatos.tblinaux2.IsEmpty) then
    begin
      tblinaux2.First;
  end;
  while (not tblinaux2.Eof) do
    begin
       if (not tblinaux2cant.isnull) and
          (not tblinaux2pvp.isnull)then
        begin
          if tblinaux2dto.IsNull then
           begin
             totallinea:=
             tblinaux2['cant']*tblinaux2['pvp'];
           end
       else
        begin
          totallinea:=
          tblinaux['cant']*tblinaux['pvp']*(100-tblinaux['dto'])/100;
        end;
       end;
       total:=total+totallinea;
       tblinaux2.Next;
    end; //end while
    //guardo el total en la tabla auxiliar
    modulodatos.tbauxiliar.edit;
    tbAuxiliarneto.AsFloat:=total;
    modulodatos.tbauxiliar.post;
end;

Última edición por vtdeleon fecha: 21-09-2006 a las 19:03:49.
Responder Con Cita