Contar qtde de produtos com ClientdataSet e XML
Ola, estou com um problema, tenho um clientdataset que gera um arquivo XML.
Tenho os seguintes campos id, descricao, qtde e data.
E uma grid mostrando os dados.
Gostaria que quando digitasse um código de produto já existente ele cancelasse o registro atual ele editasse o registro referente a este produto existente incrementando a qtde do registro.
Ex: Se id já existe então
Localizar Id
Qtd = Qtd+ QtdRegistroCancelado
Agradeço se alguém puder ajudar.
Tenho os seguintes campos id, descricao, qtde e data.
E uma grid mostrando os dados.
Gostaria que quando digitasse um código de produto já existente ele cancelasse o registro atual ele editasse o registro referente a este produto existente incrementando a qtde do registro.
Ex: Se id já existe então
Localizar Id
Qtd = Qtd+ QtdRegistroCancelado
Agradeço se alguém puder ajudar.
Frostlost
Curtidas 0
Respostas
Marcosrocha
29/10/2007
Amigo você pode usar o Locate
O modo de usar é simples
Só pra constar:
[quote:814629b57f=´Delphi 7 Help´]Value: Description
loCaseInsensitive: Key fields and key values are matched without regard to case.
loPartialKey: Key values can include only part of the matching key field value; for example, ´HAM´ would match both ´HAMM´ and ´HAMMER.´[/quote:814629b57f]
function Locate(const KeyFields: String; const KeyValues: Variant; Options: TLocateOptions): Boolean;
O modo de usar é simples
if Locate(´pro_codigo´; DBEdit1.Text; [loCaseInsensitive]) then MessageDlg(´Registro já inserido, a quantidade será acrescentada!´);
Só pra constar:
[quote:814629b57f=´Delphi 7 Help´]Value: Description
loCaseInsensitive: Key fields and key values are matched without regard to case.
loPartialKey: Key values can include only part of the matching key field value; for example, ´HAM´ would match both ´HAMM´ and ´HAMMER.´[/quote:814629b57f]
GOSTEI 0
Frostlost
29/10/2007
Obrigado pela dica! Valeu!
Amigo você pode usar o Locate
O modo de usar é simples
Só pra constar:
[quote:5fefe14958=´Delphi 7 Help´]Value: Description
loCaseInsensitive: Key fields and key values are matched without regard to case.
loPartialKey: Key values can include only part of the matching key field value; for example, ´HAM´ would match both ´HAMM´ and ´HAMMER.´
[/quote:5fefe14958]function Locate(const KeyFields: String; const KeyValues: Variant; Options: TLocateOptions): Boolean;
if Locate(´pro_codigo´; DBEdit1.Text; [loCaseInsensitive]) then MessageDlg(´Registro já inserido, a quantidade será acrescentada!´);
GOSTEI 0