Al final lo resolví con dos radio button de la siguiente manera por no encontrar el erro
Código Delphi [-]procedure Tfstock.Button1Click(Sender: TObject);
begin
fmodulo.tProductos.Active := true;
if rbsumar.Checked = true
then
begin
if fmodulo.tProductos.Locate('id_producto', fmodulo.qProductos['id_producto'], [])
then
begin
fmodulo.qProductos.Active := true;
fmodulo.tProductos.Edit;
idproducto := 0;
idproducto := StrToInt(Esumrest.text);
fmodulo.tProductos.Fields.FieldByName('Stock').AsInteger := fmodulo.qProductos.Fields.FieldByName('Stock').AsInteger + idproducto;
fmodulo.tProductos.Post;
fmodulo.qProductos.Refresh;
end;
end
else
if RBrestar.Checked = true
then
if fmodulo.tProductos.Locate('id_producto', fmodulo.qProductos['id_producto'], [])
then
begin
fmodulo.qProductos.Active := true;
fmodulo.tProductos.Edit;
idproducto := 0;
idproducto := StrToInt(Esumrest.text);
fmodulo.tProductos.Fields.FieldByName('Stock').AsInteger := fmodulo.qProductos.Fields.FieldByName('Stock').AsInteger - idproducto;
fmodulo.tProductos.Post;
fmodulo.qProductos.Refresh;
end;
end;
__________________
We are told to remember the idea, not the man, because a man can fail. He can be caught, he can be killed and forgotten, but 400 years later, an idea can still change the world.
|