Fabiana Freisleben

Seja bem vindo(a)ao meu blog pessoal. Nele compartilho assuntos que acho interessantes, matérias que podem ser aproveitadas por quem quiser, algumas rotinas (Delphi), Notícias da área de Informática. Também algumas outras coisas da minha rotina, como meus passa tempos ou coisas profiissionais. Navegue a vontade, comente se quiser, use a vontade.

Controlar Nivel de Acesso

public
{ Public declarations }
function ff_int_Pegar_Nivel_Acesso(): Integer;
function ff_str_Pegar_Apelido_Usuario(): String;
procedure ff_voi_Especificar_Usuario(ff_str_usuario_apelido: String ; ff_int_nivel_acesso: Integer);

//==============================================================================
procedure TFrm_Princiapal.ff_voi_Especificar_Usuario(ff_str_usuario_apelido: String ; ff_int_nivel_acesso: Integer);
begin
self.ff_str_apelido_usuario:= ff_str_usuario_apelido;
elf.ff_int_nivel_acesso:= ff_int_nivel_acesso;
self.SBar_Principal.Panels[0].Text:= 'user: [ ' + ff_str_usuario_apelido + ']';
self.SBar_Principal.Panels[1].Text:= 'nivel: [' + inttostr(ff_int_nivel_acesso) + ']';
end;
//==============================================================================
function TFrm_Princiapal.ff_int_Pegar_Nivel_Acesso(): Integer;
begin
result:= self.ff_int_nivel_acesso;end;
//==============================================================================
function TFrm_Princiapal.ff_str_Pegar_Apelido_Usuario(): String;
begin
result:= self.ff_str_apelido_usuario;end;
//==============================================================================

Habilitar edits

procedure FF_Habilitar_Edits(boo_habilitar: Boolean);

//------------------------------------------------------------------------------
procedure TF_Produtos.FF_Habilitar_Edits(boo_habilitar: Boolean);
begin
self.Edit2.ReadOnly:= true;
self.Edit3.ReadOnly:= not(boo_habilitar);
self.Edit4.ReadOnly:= not(boo_habilitar);
self.Edit5.ReadOnly:= not(boo_habilitar);
self.Edit6.ReadOnly:= not(boo_habilitar);
end;
procedure TF_Produtos.BitBtn1Click(Sender: TObject);

begin
self.Close();
end;

Limpar edits

//------------------------------------------------------------------------------
procedure TF_Produtos.FF_Limpar_Edits();
begin
self.Edit2.Text:= '';
self.Edit3.Text:= '';
self.Edit4.Text:= '';
self.Edit5.Text:= '';
self.Edit6.Text:= '';
end;

Procedure para Habilitar Botões

//------------------------------------------------------------------------------
procedure TF_Produtos.FF_Habilitar_Botoes_Insert(boo_habilitar: Boolean);
begin
self.BitBtn1.Enabled := True;
self.BitBtn2.Enabled := boo_habilitar;
self.BitBtn3.Enabled := boo_habilitar;
self.BitBtn4.Enabled := boo_habilitar;
self.BitBtn5.Enabled := boo_habilitar;
self.BitBtn6.Enabled := True; //...inserir
self.BitBtn7.Enabled := boo_habilitar; //...alterar
self.BitBtn8.Enabled := boo_habilitar;
self.BitBtn9.Enabled := True;
self.BitBtn10.Enabled:= boo_habilitar;
self.BitBtn11.Enabled:= boo_habilitar;
self.BitBtn12.Enabled:= boo_habilitar;
end;
//------------------------------------------------------------------------------

Pegar Novo ID

//------------------------------------------------------------------------------
function TF_Produtos.FF_Pegar_Novo_Produto_Id():Integer;
var ff_str_sql_texto: TStrings;
ff_int_apoio : Integer;begin
try
ff_str_sql_texto:= TStringList.Create();
ff_str_sql_texto.Add('SELECT MAX(PROD_ID) FROM PRODUTOS ');
self.ADOQuery_Produtos_Apoio.Active:= False;
self.ADOQuery_Produtos_Apoio.SQL.Clear();
self.ADOQuery_Produtos_Apoio.SQL:= ff_str_sql_texto;
self.ADOQuery_Produtos_Apoio.Active:= True;
//---------
ff_int_apoio:= self.ADOQuery_Produtos_Apoio.Fields[0].AsInteger + 1;
except on
E:Exception do begin
ff_int_apoio:= 0; ShowMessage('Ôpa, ocorreu um erro ao recuperar um novo "id" para o produto a ser inserido! Veja: ' + E.Message);
end;
end;
result:= ff_int_apoio;
end;
//------------------------------------------------------------------------------

Rotina para Popular Grid

procedure FF_Popular_Grid_Produtos();

//------------------------------------------------------------------------------
procedure TF_Produtos.FF_Popular_Grid_Produtos();
varff_str_sql_texto: TStrings;
begin
try
ff_str_sql_texto:= TStringList.Create();
ff_str_sql_texto.Add('Select * from Produtos order by Prod_Nome ');
self.ADOQuery_Produtos.Active:= False;
self.ADOQuery_Produtos.SQL.Clear();
self.ADOQuery_Produtos.SQL := ff_str_sql_texto;
self.ADOQuery_Produtos.Active:= True;
except on
E:Exception do begin
ShowMessage('Ôpa, ocorreu um erro na busca por produtos! Veja: ' + E.Message);
end;
end;
end;

Rotina para Inserção

procedure FF_Disparar_Processo_Insercao_Produto();

//------------------------------------------------------------------------------
procedure TF_Produtos.FF_Disparar_Processo_Insercao_Produto();
begin if(self.BitBtn6.Caption = 'Inserir novo produto') then begin
self.FF_Limpar_Edits(); //... limpar os edits ...
self.FF_Habilitar_Edits(true); //...habilitar os edits {3,4,5} ... self.FF_Habilitar_Botoes_Insert(False); //...impedir o funcionamento de todos os botões, com exceção do {fechar, cancelar, salvar}
self.BitBtn6.Caption:= 'Salvar novo produto';
self.Edit2.Text:= inttostr(self.FF_Pegar_Novo_Produto_Id); end else if ((self.BitBtn6.Caption = 'Salvar novo cliente') and (true)) then begin
self.FF_Popular_Grid_Produtos();
self.FF_Atualizar_Cartao_Produto();

self.FF_Habilitar_Edits(False); //...habilitar os edits {3,4,5} ...
self.FF_Habilitar_Botoes_Insert(True); //...impedir o funcionamento de todos os botões, com exceção do {fechar, cancelar, salvar}
self.BitBtn6.Caption:= 'Inserir novo cliente';
end;
end;

Pesquisar este blog

Seguidores

Sobre mim

Minha foto
Porto União, SC, Brazil
Sou Bacharel em Informática de Gestão pela UNIUV/União da Vitória-PR. Trabalho com assistência técnica em equipamentos de informática, em sua maioria impressoras.

Visitas

Desenvolvimento de sites