Orçamento e itens que não existe no estoque...
14/12/2005
0
begin with BD_VENDA_ITENS do begin First; Try while not BD_VENDA_ITENS.eof do begin BD_ESTOQUE.Close; BD_ESTOQUE.SQL.Clear; BD_ESTOQUE.SQL.Add(´select * from ESTOQUE where GS_EST_CODIGO=´+inttostr(BD_VENDA_ITENSGS_VEI_CODPROD.Value)); BD_ESTOQUE.Open; BD_ESTOQUE.Edit; BD_ESTOQUEGS_EST_QNT.Value := BD_ESTOQUEGS_EST_QNT.Value - BD_VENDA_ITENSGS_VEI_QNT.Value; BD_ESTOQUE.Post; BD_VENDA_ITENS.next; end; DM1.IBTransaction1.CommitRetaining; except showmessage(´problema com o banco de dados´); DM1.IBTransaction1.rollback; end; end;
a tabela BD_VENDA_ITENS é o que recebe os valores do estoque e os avulso...
Vlw e até mais...
Gigatel
Posts
14/12/2005
Zekas
Att.
Zekas
14/12/2005
Gigatel
OI blz ?.. na verdade estva pensado em algo mais simples ( se for ) o código acima exite um filtro na tabela acossiado por um código, pensei...quando o código for executado a tabela estoque num terá nada...logo aí poderia se criar uma condição ignorando a segunda estapa onde seria a subtração do campo...
14/12/2005
Okama
update TABELA set tb_valor = tb_valor - baixa where tb_codigo = codigo
BD_ESTOQUE.ExecSql retorna a quantidade de registros afetados, logo:
I := BD_ESTOQUE.ExecSql; if I = 0 then ..nenhum item atualizado else ..atualizado item no estoque
14/12/2005
Gigatel
update TABELA set tb_valor = tb_valor - baixa where tb_codigo = codigo
I := BD_ESTOQUE.ExecSql; if I = 0 then ..nenhum item atualizado else ..atualizado item no estoque
Qunto mais idéia melhor, como isso ficaria na minha função acima ?...
14/12/2005
Marcio.theis
with BD_VENDA_ITENS do begin First; Try while not BD_VENDA_ITENS.eof do begin BD_ESTOQUE.Close; BD_ESTOQUE.SQL.Clear; BD_ESTOQUE.SQL.Add(´select * from ESTOQUE where GS_EST_CODIGO=´+inttostr(BD_VENDA_ITENSGS_VEI_CODPROD.Value)); BD_ESTOQUE.Open; [b]if not BD_ESTOQUE.IsEmpty then[/b] begin BD_ESTOQUE.Edit; BD_ESTOQUEGS_EST_QNT.Value := BD_ESTOQUEGS_EST_QNT.Value - BD_VENDA_ITENSGS_VEI_QNT.Value; BD_ESTOQUE.Post; end; BD_VENDA_ITENS.next; end; DM1.IBTransaction1.CommitRetaining; except showmessage(´problema com o banco de dados´); DM1.IBTransaction1.rollback; end; end;
14/12/2005
Okama
Var I:Integer; begin with BD_VENDA_ITENS do begin First; while not eof do begin BD_ESTOQUE.Sql.Text := ´Update ESTOQUE set GS_EST_QNT = GS_EST_QNT -´+ FieldByName( GS_VEI_QNT ).AsString+´ where GS_EST_CODIGO = ´+FieldByName( GS_VEI_CODPROD ).AsString; I := BD_ESTOQUE.ExecSql; if I = 0 then Showmessage(´Registro não encontrado! Produto Avulso´) else Showmessage(´Registro atualizado com Sucesso!´); BD_VENDA_ITENS.next; end; end;
Remova o ´showmessage´ e substitua por comandos caso queira controlar a atualização
14/12/2005
Gigatel
Var I:Integer; begin with BD_VENDA_ITENS do begin First; while not eof do begin BD_ESTOQUE.Sql.Text := ´Update ESTOQUE set GS_EST_QNT = GS_EST_QNT -´+ FieldByName( GS_VEI_QNT ).AsString+´ where GS_EST_CODIGO = ´+FieldByName( GS_VEI_CODPROD ).AsString; I := BD_ESTOQUE.ExecSql; if I = 0 then Showmessage(´Registro não encontrado! Produto Avulso´) else Showmessage(´Registro atualizado com Sucesso!´); BD_VENDA_ITENS.next; end; end;
deu este erro
[Error] Unit39.pas(161): Undeclared identifier: ´GS_VEI_QNT´
o q será ?
15/12/2005
Gigatel
Clique aqui para fazer login e interagir na Comunidade :)