Carregar bd em novo form

16/04/2003

0

unit uMain

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, Aligrid, Gauges, ExtCtrls, MPlayer, StdCtrls,uAlteraItem;

type
TfMain = class(TForm)
sgComp: TStringAlignGrid;
bt: TBitBtn;
linha:Tedit;

var
fMain: TfMain;
proxcodigo: codigo;

implementation

procedure TFMain.btClick(Sender: TObject);
begin
if linha = ´mostraitens´ then
begin
Movimentacao.limpaclasse;---> naum coloquei essas funções para naum deichar o tópico extenso demais :p
if not(Movimentacao.ItemEstoque.ler_SUS(doacao.sus,componente.ChaveCompSanguineo)) then
begin
exit;
end;

if not (limpo = true)then
begin
falteraitem.ShowModal;
fAlteraItem:=TfAlteraItem.Create(fAlteraItem);
fAlteraItem.CriaObjetos(Usuario.ChaveFuncionario);
fAlteraItem.Parent:= fAlteraItem;
fAlteraItem.CarregaItem(Movimentacao.ItemEstoque.ChaveItemEstoque);
end;
end;
end;

*********************************************

unit UAlteraItem;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, uTMovimentacao,uTColecaoTipoSAngue,
uTColecaoStatusEstoque, uTColecaoMotivoInutilizacao, uTColecaoUnidade,
Mask, ExtCtrls;

type
TFAlteraItem = class(TForm)
Panel1: TPanel;
BitSair: TBitBtn;
BitCancel: TBitBtn;
BitGrava: TBitBtn;
gbIDItem: TGroupBox;
Label12: TLabel;
Label11: TLabel;
Label7: TLabel;
Label10: TLabel;
lbSUS: TLabel;
lCodItem: TLabel;
lOrigem: TLabel;
lbTipoOrigem: TLabel;
gbDadosItem: TGroupBox;
Label4: TLabel;
Label2: TLabel;
lQtd: TLabel;
Label9: TLabel;
Label8: TLabel;
Label6: TLabel;
Label5: TLabel;
Label1: TLabel;
Label3: TLabel;
lbHemoComp: TLabel;
lbRespProd: TLabel;
lDataProd: TLabel;
cbABO: TComboBox;
cbUnidade: TComboBox;
meValidade: TMaskEdit;
cbStatusEstoque: TComboBox;
cbMotivoInutilizacao: TComboBox;
pnTitulo: TPanel;
eQtd: TEdit;

private
{ Private declarations }
fMovimentacao:TMovimentacao;
fColecaoTipoSangue:TColecaoTipoSAngue;
fColecaoStatusEstoque:TColStatusEstoque;
fColecaoMotivoInutilizacao:TColecaoMotivoInutilizacao;
fCOlecaoUnidade:TColUnidade;
fAlterou:Boolean;
frmAlterou: Boolean;
public
{ Public declarations }
function CarregaItem(xCodItem:integer):Boolean;
procedure PreencheTela;
end;


function TFAlteraItem.CarregaItem(xCodItem: integer): Boolean;
begin
result:=false;
if fMovimentacao.ItemEstoque.ler(xCodItem) then
begin
result:=true;
PreencheTela;
end;
frmAlterou:=false;
end;

procedure TFAlteraItem.PreencheTela;
var x:integer;
begin
lCodItem.Caption:=inttostr(fMovimentacao.ItemEstoque.ChaveItemEstoque);
lOrigem.caption:=inttostr(fMovimentacao.ItemEstoque.ChaveOrigem);
lbSUS.caption:=fMovimentacao.ItemEstoque.SUS;
//TiposOrigem
lbTipoOrigem.Caption := fMovimentacao.ItemEstoque.TipoOrigem.Descricao;
lbHemoComp.Caption:=fMovimentacao.ItemEstoque.CompSanguineo.Descricao;
cbABO.Items.Clear;
if fColecaoTipoSangue.Listar then
for x:=0 to fColecaoTipoSangue.Cont-1 do
begin
cbABO.Items.Add(fColecaoTipoSAngue.Lista.cells[2,x]);
if fMovimentacao.ItemEstoque.TipoSangue.ChavetipoSAngue = strtoint(fColecaoTipoSangue.Lista.cells[1,x]) then
cbABO.itemindex := x;
end;
eQtd.Text:=inttostr(fMovimentacao.ItemEstoque.Qtde);
cbUnidade.Items.Clear;
if fColecaoUnidade.Listar(´ChaveUnidade´) then
for x:=0 to fCOlecaoUnidade.Lista.RowCount-1 do
begin
cbUnidade.Items.Add(fCOlecaoUnidade.Lista.cells[2,x]);
if fMovimentacao.ItemEstoque.Unidade.ChaveUnidade = strtoint(fCOlecaoUnidade.Lista.Cells[0,x]) then
cbUnidade.ItemIndex:=x;
end;
lDataProd.Caption:=DateToStr(fMovimentacao.ItemEstoque.DataProducao);
meValidade.Text:=DatetoStr(fMovimentacao.ItemEstoque.Validade);
cbStatusEstoque.Items.Clear;
if fColecaoStatusEstoque.Listar then
for x:=0 to fColecaoStatusEstoque.Lista.RowCount-1 do
begin
cbStatusEstoque.Items.Add(fColecaoStatusEstoque.Lista.Cells[1,x]);
if fMovimentacao.ItemEstoque.Statusestoque.ChaveStatusEstoque = strtoint(fColecaoStatusEstoque.Lista.cells[0,x]) then
cbStatusEstoque.ItemIndex:=x;
end;
cbMotivoInutilizacao.Items.Clear;
if fColecaoMotivoInutilizacao.listarprod(true) then
for x:=0 to fColecaoMotivoInutilizacao.Lista.RowCount - 1 do
begin
cbMotivoInutilizacao.Items.add(fColecaoMotivoInutilizacao.Lista.Cells[1,x]);
if fMovimentacao.ItemEstoque.MotivoInutilizacao.ChaveMotivoInutilizacao = strtoint(fcolecaomotivoinutilizacao.lista.cells[0,x]) then
cbMotivoInutilizacao.ItemIndex:=x;
end;
lbRespProd.Caption:=fMovimentacao.ItemEstoque.RespProducao.Nome;
end;

[color=blue:ee1887fadc]na hora de rodar o programa ele passa pelas funções certin, mas no form naum aparece as informações carregadas...
pq ocorre isso?
[/color:ee1887fadc]


Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar