pues bien despues de unas horas de desvelo y de unas cuantas llamadas de mi linda esposa a dormir he resuelto el problema, pongo el codigo por si algun dia le sirve.... gracias esposita por aguantarme jejejeje.
Código Delphi
[-]procedure TFfactura.txtcodigoExit(Sender: TObject);
var wcodigobarras: string;
wprecio_total
ouble;
wprecio_venta
ouble;
i:Integer;
wcodigomodificar,wdescripcionmodificar:string;
wcantidadmodificar,wventa_totalmodificada:Integer;
wdescuentomodificar,wpreciomodificar
ouble;
wtotalmodificar
ouble;
begin
wcodigobarras:=Trim(Ffactura.txtcodigo.Text);
Ffactura.txtcodigo.Text:='';
if wcodigobarras<>'' then
begin
For i:=1 to Ffactura.SGFact.RowCount-1 do
begin
if Ffactura.SGFact.Cells[0,i]= Trim(wcodigobarras) then
begin
wcodigomodificar:=Ffactura.SGFact.Cells[0,i]; wdescripcionmodificar:=Ffactura.SGFact.Cells[1,i]; wcantidadmodificar:=StrToInt(Ffactura.SGFact.Cells[2,i]); wpreciomodificar:=wprecioventa;
wdescuentomodificar:=StrToFloat(Ffactura.SGFact.Cells[4,i]);
if wcantidad_venta<>0 then
begin
Ffactura.SGFact.Cells[0,i]:=wcodigobarras; Ffactura.SGFact.Cells[1,i]:=wdescripcionmodificar; wventa_totalmodificada:=wcantidadmodificar+wcantidad_venta; Ffactura.SGFact.Cells[2,i]:=IntToStr(wventa_totalmodificada); wprecio_total:=(wventa_totalmodificada*wprecioventa); Ffactura.SGFact.Cells[5,i] := Format('%8.2f',[wprecio_total]);
calcula_totales;
wcantidad_venta:=0;
Ffactura.txtcodigo.SetFocus;
wcodigobarras:='';
Exit;
end
else
begin
Ffactura.SGFact.Cells[0,i]:=wcodigobarras; Ffactura.SGFact.Cells[1,i]:=wdescripcionmodificar; wventa_totalmodificada:=wcantidadmodificar+1; Ffactura.SGFact.Cells[2,i]:=IntToStr(wventa_totalmodificada); wprecio_total:=(wventa_totalmodificada*wprecioventa); Ffactura.SGFact.Cells[5,i] := Format('%8.2f',[wprecio_total]);
calcula_totales;
wcantidad_venta:=0;
Ffactura.txtcodigo.SetFocus;
wcodigobarras:='';
Exit;
end;
end;
end;
end;
if wcodigobarras<>'' then
begin
with fmodulo.Qry_Temp2 do
begin
Close;
sql.clear;
SQL.Add('select * from articulo');
SQL.Add('where codigobarras=:Pcodigobarras');
Parameters.ParamByName('pcodigobarras').Value:=Trim(wcodigobarras);
try
Open;
if not Fmodulo.Qry_Temp2.IsEmpty then
begin
while not Fmodulo.Qry_Temp2.Eof do
begin
If Cuenta > 1 then SGFact.RowCount := SGFact.RowCount + 1;
wprecioventa:=StrToFloat(FieldByname('precioventa').AsVariant);
Ffactura.SGFact.Cells[0,cuenta] := wcodigobarras;
Ffactura.SGFact.Cells[1,Cuenta]:=(FieldByname('nombre').AsString);
if wcantidad_venta<>0 then
begin
Ffactura.SGFact.Cells[2,Cuenta]:=IntToStr(wcantidad_venta);
wprecio_total:=(wcantidad_venta*wprecioventa);
end
else
begin
Ffactura.SGFact.Cells[2,Cuenta]:='1';
wcantidad_venta:=StrToInt(SGFact.Cells[2,cuenta]);
wprecio_total:=(wcantidad_venta*wprecioventa);
end;
wprecio_venta:=FieldByname('precioventa').AsFloat;
Ffactura.SGFact.Cells[3,Cuenta]:=Format('%8.2n',[wprecio_venta]);
wcantidad_venta:=StrToInt(SGFact.Cells[2,cuenta]);
SGFact.Cells[4,Cuenta]:='0.00';
Ffactura.SGFact.Cells[5,Cuenta] := Format('%8.2f',[wprecio_total]);
Cuenta:=cuenta+1;
calcula_totales;
Next;
Ffactura.txtcodigo.SetFocus;
wcodigobarras:='';
wcantidad_venta:=0;
Exit;
end;
end
else
begin
MessageDlg('Registro'+chr(13)+'No localizado', mtError, [MBOK], 0);
Ffactura.txtcodigo.Text:='';
Ffactura.txtcodigo.SetFocus;
Exit;
end;
except
on E:EOleException do
begin
MessageDlg(Format('Error: %s Codigo: %d', [E.Message, E.ErrorCode]), mtError, [mbOK], 0);
end;
end;
end;
end;
end;
Aveces creo que mi esposa tiene razon, jejeje prefiero a mi amante(PC) que a ella, segun ella esta viendo quien se queda conmigo pero creo que ya elegi jajajaja