Form senha

Delphi

06/02/2003

Alguém tem um formulario senha que possa me disponibilizar com fonte, para mim adaptar ao meu projeto.


Anonymous

Anonymous

Curtidas 0

Respostas

Franck.c

Franck.c

06/02/2003

[u:04debddd9a][b:04debddd9a]Coloque este código na tela inicial. Coloque no Form Principal no evento OnActivate[/b:04debddd9a][/u:04debddd9a]

unit Senha;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls;

type
TFSenha = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn2Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
FSenha: TFSenha;

implementation

uses CadSenha, Principal;

{$R *.DFM}

procedure TFSenha.BitBtn2Click(Sender: TObject);
begin
application.terminate;
end;

procedure TFSenha.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key in [´a´ .. ´z´] then
key :=UpCase(key);
begin
if key=#13 then
begin
selectnext(Sender as twincontrol,true,true);
end;
end;
end;

procedure TFSenha.BitBtn1Click(Sender: TObject);
begin
If FCadSenha.table1.Locate(´Usuario;Senha´, // verifica nos campos Usuario e Senha
VarArrayOf([edit1.Text,edit2.Text]),[]) Then // se for igual aos digitados na tela
begin
FSenha.close;
FCadSenha.close;
FPrincipal.enabled:=true;
end
else // se não for igual ao da tabela, exibe mensagem de erro
begin
Beep;
ShowMessage(´Nome de usuário e/ou senha Inválido!´);
Application.Terminate; // após mensagem fecha o form de senha
end;

end;

end.


[u:04debddd9a][b:04debddd9a]Este é o Cadastro de usuário.[/b:04debddd9a][/u:04debddd9a]

unit CadSenha;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
DBTables, Grids, DBGrids, StdCtrls, Buttons, Mask, DBCtrls, Db;

type
TFCadSenha = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
Table1Codigo: TAutoIncField;
Table1Usuario: TStringField;
Table1Senha: TStringField;
Label1: TLabel;
DBEdit1: TDBEdit;
Label2: TLabel;
DBEdit2: TDBEdit;
Label3: TLabel;
DBEdit3: TDBEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
BitBtn6: TBitBtn;
BitBtn7: TBitBtn;
BitBtn8: TBitBtn;
BitBtn9: TBitBtn;
BitBtn10: TBitBtn;
DBGrid1: TDBGrid;
Query1: TQuery;
DataSource2: TDataSource;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure BitBtn6Click(Sender: TObject);
procedure BitBtn7Click(Sender: TObject);
procedure BitBtn8Click(Sender: TObject);
procedure BitBtn9Click(Sender: TObject);
procedure BitBtn10Click(Sender: TObject);
procedure DBEdit1KeyPress(Sender: TObject; var Key: Char);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
FCadSenha: TFCadSenha;

implementation

{$R *.DFM}

procedure TFCadSenha.BitBtn1Click(Sender: TObject);
begin
if table1.bof then
begin
bitbtn1.enabled:=false;
bitbtn2.enabled:=false;
end;
bitbtn3.enabled:=true;
bitbtn4.enabled:=true;
bitbtn5.enabled:=true;
bitbtn6.enabled:=true;
bitbtn7.enabled:=false;
bitbtn8.enabled:=true;
bitbtn9.enabled:=false;
bitbtn10.enabled:=true;
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
table1.first;

end;

procedure TFCadSenha.BitBtn2Click(Sender: TObject);
begin
if table1.Bof then
begin
bitbtn1.enabled:=false;
bitbtn2.enabled:=false;
end;
bitbtn3.enabled:=true;
bitbtn4.enabled:=true;
bitbtn5.enabled:=true;
bitbtn6.enabled:=true;
bitbtn7.enabled:=false;
bitbtn8.enabled:=true;
bitbtn9.enabled:=false;
bitbtn10.enabled:=true;
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
table1.prior;
end;

procedure TFCadSenha.BitBtn3Click(Sender: TObject);
begin
if table1.Eof then
begin
bitbtn3.enabled:=false;
bitbtn4.enabled:=false;
end;
bitbtn1.enabled:=true;
bitbtn2.enabled:=true;
bitbtn5.enabled:=true;
bitbtn6.enabled:=true;
bitbtn7.enabled:=false;
bitbtn8.enabled:=true;
bitbtn9.enabled:=false;
bitbtn10.enabled:=true;
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
table1.next;
end;

procedure TFCadSenha.BitBtn4Click(Sender: TObject);
begin
if table1.Eof then
begin
bitbtn3.enabled:=false;
bitbtn4.enabled:=false;
end;
bitbtn1.enabled:=true;
bitbtn2.enabled:=true;
bitbtn5.enabled:=true;
bitbtn6.enabled:=true;
bitbtn7.enabled:=false;
bitbtn8.enabled:=true;
bitbtn9.enabled:=false;
bitbtn10.enabled:=true;
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
table1.last;
end;

procedure TFCadSenha.BitBtn5Click(Sender: TObject);
begin
bitbtn1.enabled:=false;
bitbtn2.enabled:=false;
bitbtn3.enabled:=false;
bitbtn4.enabled:=false;
bitbtn5.enabled:=false;
bitbtn6.enabled:=false;
bitbtn7.enabled:=true;
bitbtn8.enabled:=false;
bitbtn9.enabled:=true;
bitbtn10.enabled:=true;
DBEdit1.enabled:=true;
DBEdit2.enabled:=true;
DBEdit3.enabled:=true;
DBgrid1.enabled:=true;
table1.insert;
end;

procedure TFCadSenha.BitBtn6Click(Sender: TObject);
begin
bitbtn1.enabled:=false;
bitbtn2.enabled:=false;
bitbtn3.enabled:=false;
bitbtn4.enabled:=false;
bitbtn5.enabled:=false;
bitbtn6.enabled:=false;
bitbtn7.enabled:=true;
bitbtn8.enabled:=false;
bitbtn9.enabled:=true;
bitbtn10.enabled:=true;
DBEdit1.enabled:=true;
DBEdit2.enabled:=true;
DBEdit3.enabled:=true;
DBgrid1.enabled:=true;
table1.edit;
end;

procedure TFCadSenha.BitBtn7Click(Sender: TObject);
begin
bitbtn1.enabled:=true;
bitbtn2.enabled:=true;
bitbtn3.enabled:=true;
bitbtn4.enabled:=true;
bitbtn5.enabled:=true;
bitbtn6.enabled:=true;
bitbtn7.enabled:=false;
bitbtn8.enabled:=true;
bitbtn9.enabled:=false;
bitbtn10.enabled:=true;
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
table1.post;
end;

procedure TFCadSenha.BitBtn8Click(Sender: TObject);
begin
table1.delete;
bitbtn1.enabled:=true;
bitbtn2.enabled:=true;
bitbtn3.enabled:=true;
bitbtn4.enabled:=true;
bitbtn5.enabled:=true;
bitbtn6.enabled:=true;
bitbtn7.enabled:=false;
bitbtn8.enabled:=true;
bitbtn9.enabled:=false;
bitbtn10.enabled:=true;
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
end;

procedure TFCadSenha.BitBtn9Click(Sender: TObject);
begin
table1.cancel;
bitbtn1.enabled:=true;
bitbtn2.enabled:=true;
bitbtn3.enabled:=true;
bitbtn4.enabled:=true;
bitbtn5.enabled:=true;
bitbtn6.enabled:=true;
bitbtn7.enabled:=false;
bitbtn8.enabled:=true;
bitbtn9.enabled:=false;
bitbtn10.enabled:=true;
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
end;

procedure TFCadSenha.BitBtn10Click(Sender: TObject);
begin
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
close;
end;

procedure TFCadSenha.DBEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if key in [´a´ .. ´z´] then
key :=UpCase(key);
begin
if key=#13 then
begin
selectnext(Sender as twincontrol,true,true);
end;
end;
end;

procedure TFCadSenha.FormCreate(Sender: TObject);
begin
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
bitbtn7.enabled:=false;
bitbtn9.enabled:=false;
end;

end.


GOSTEI 0
Franck.c

Franck.c

06/02/2003

[quote:1353d87f26=´Franck Espíndula Costa´][u:1353d87f26][b:1353d87f26]Este é o código de pedido de senha e usuário. Coloque este código na tela inicial. Coloque no Form Principal no evento OnActivate[/b:1353d87f26][/u:1353d87f26]

unit Senha;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ExtCtrls;

type
TFSenha = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn2Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
FSenha: TFSenha;

implementation

uses CadSenha, Principal;

{$R *.DFM}

procedure TFSenha.BitBtn2Click(Sender: TObject);
begin
application.terminate;
end;

procedure TFSenha.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key in [´a´ .. ´z´] then
key :=UpCase(key);
begin
if key=#13 then
begin
selectnext(Sender as twincontrol,true,true);
end;
end;
end;

procedure TFSenha.BitBtn1Click(Sender: TObject);
begin
If FCadSenha.table1.Locate(´Usuario;Senha´, // verifica nos campos Usuario e Senha
VarArrayOf([edit1.Text,edit2.Text]),[]) Then // se for igual aos digitados na tela
begin
FSenha.close;
FCadSenha.close;
FPrincipal.enabled:=true;
end
else // se não for igual ao da tabela, exibe mensagem de erro
begin
Beep;
ShowMessage(´Nome de usuário e/ou senha Inválido!´);
Application.Terminate; // após mensagem fecha o form de senha
end;

end;

end.


[u:1353d87f26][b:1353d87f26]Este é o Cadastro de usuário.[/b:1353d87f26][/u:1353d87f26]

unit CadSenha;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
DBTables, Grids, DBGrids, StdCtrls, Buttons, Mask, DBCtrls, Db;

type
TFCadSenha = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
Table1Codigo: TAutoIncField;
Table1Usuario: TStringField;
Table1Senha: TStringField;
Label1: TLabel;
DBEdit1: TDBEdit;
Label2: TLabel;
DBEdit2: TDBEdit;
Label3: TLabel;
DBEdit3: TDBEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
BitBtn6: TBitBtn;
BitBtn7: TBitBtn;
BitBtn8: TBitBtn;
BitBtn9: TBitBtn;
BitBtn10: TBitBtn;
DBGrid1: TDBGrid;
Query1: TQuery;
DataSource2: TDataSource;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure BitBtn6Click(Sender: TObject);
procedure BitBtn7Click(Sender: TObject);
procedure BitBtn8Click(Sender: TObject);
procedure BitBtn9Click(Sender: TObject);
procedure BitBtn10Click(Sender: TObject);
procedure DBEdit1KeyPress(Sender: TObject; var Key: Char);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
FCadSenha: TFCadSenha;

implementation

{$R *.DFM}

procedure TFCadSenha.BitBtn1Click(Sender: TObject);
begin
if table1.bof then
begin
bitbtn1.enabled:=false;
bitbtn2.enabled:=false;
end;
bitbtn3.enabled:=true;
bitbtn4.enabled:=true;
bitbtn5.enabled:=true;
bitbtn6.enabled:=true;
bitbtn7.enabled:=false;
bitbtn8.enabled:=true;
bitbtn9.enabled:=false;
bitbtn10.enabled:=true;
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
table1.first;

end;

procedure TFCadSenha.BitBtn2Click(Sender: TObject);
begin
if table1.Bof then
begin
bitbtn1.enabled:=false;
bitbtn2.enabled:=false;
end;
bitbtn3.enabled:=true;
bitbtn4.enabled:=true;
bitbtn5.enabled:=true;
bitbtn6.enabled:=true;
bitbtn7.enabled:=false;
bitbtn8.enabled:=true;
bitbtn9.enabled:=false;
bitbtn10.enabled:=true;
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
table1.prior;
end;

procedure TFCadSenha.BitBtn3Click(Sender: TObject);
begin
if table1.Eof then
begin
bitbtn3.enabled:=false;
bitbtn4.enabled:=false;
end;
bitbtn1.enabled:=true;
bitbtn2.enabled:=true;
bitbtn5.enabled:=true;
bitbtn6.enabled:=true;
bitbtn7.enabled:=false;
bitbtn8.enabled:=true;
bitbtn9.enabled:=false;
bitbtn10.enabled:=true;
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
table1.next;
end;

procedure TFCadSenha.BitBtn4Click(Sender: TObject);
begin
if table1.Eof then
begin
bitbtn3.enabled:=false;
bitbtn4.enabled:=false;
end;
bitbtn1.enabled:=true;
bitbtn2.enabled:=true;
bitbtn5.enabled:=true;
bitbtn6.enabled:=true;
bitbtn7.enabled:=false;
bitbtn8.enabled:=true;
bitbtn9.enabled:=false;
bitbtn10.enabled:=true;
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
table1.last;
end;

procedure TFCadSenha.BitBtn5Click(Sender: TObject);
begin
bitbtn1.enabled:=false;
bitbtn2.enabled:=false;
bitbtn3.enabled:=false;
bitbtn4.enabled:=false;
bitbtn5.enabled:=false;
bitbtn6.enabled:=false;
bitbtn7.enabled:=true;
bitbtn8.enabled:=false;
bitbtn9.enabled:=true;
bitbtn10.enabled:=true;
DBEdit1.enabled:=true;
DBEdit2.enabled:=true;
DBEdit3.enabled:=true;
DBgrid1.enabled:=true;
table1.insert;
end;

procedure TFCadSenha.BitBtn6Click(Sender: TObject);
begin
bitbtn1.enabled:=false;
bitbtn2.enabled:=false;
bitbtn3.enabled:=false;
bitbtn4.enabled:=false;
bitbtn5.enabled:=false;
bitbtn6.enabled:=false;
bitbtn7.enabled:=true;
bitbtn8.enabled:=false;
bitbtn9.enabled:=true;
bitbtn10.enabled:=true;
DBEdit1.enabled:=true;
DBEdit2.enabled:=true;
DBEdit3.enabled:=true;
DBgrid1.enabled:=true;
table1.edit;
end;

procedure TFCadSenha.BitBtn7Click(Sender: TObject);
begin
bitbtn1.enabled:=true;
bitbtn2.enabled:=true;
bitbtn3.enabled:=true;
bitbtn4.enabled:=true;
bitbtn5.enabled:=true;
bitbtn6.enabled:=true;
bitbtn7.enabled:=false;
bitbtn8.enabled:=true;
bitbtn9.enabled:=false;
bitbtn10.enabled:=true;
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
table1.post;
end;

procedure TFCadSenha.BitBtn8Click(Sender: TObject);
begin
table1.delete;
bitbtn1.enabled:=true;
bitbtn2.enabled:=true;
bitbtn3.enabled:=true;
bitbtn4.enabled:=true;
bitbtn5.enabled:=true;
bitbtn6.enabled:=true;
bitbtn7.enabled:=false;
bitbtn8.enabled:=true;
bitbtn9.enabled:=false;
bitbtn10.enabled:=true;
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
end;

procedure TFCadSenha.BitBtn9Click(Sender: TObject);
begin
table1.cancel;
bitbtn1.enabled:=true;
bitbtn2.enabled:=true;
bitbtn3.enabled:=true;
bitbtn4.enabled:=true;
bitbtn5.enabled:=true;
bitbtn6.enabled:=true;
bitbtn7.enabled:=false;
bitbtn8.enabled:=true;
bitbtn9.enabled:=false;
bitbtn10.enabled:=true;
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
end;

procedure TFCadSenha.BitBtn10Click(Sender: TObject);
begin
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
close;
end;

procedure TFCadSenha.DBEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if key in [´a´ .. ´z´] then
key :=UpCase(key);
begin
if key=#13 then
begin
selectnext(Sender as twincontrol,true,true);
end;
end;
end;

procedure TFCadSenha.FormCreate(Sender: TObject);
begin
DBEdit1.enabled:=false;
DBEdit2.enabled:=false;
DBEdit3.enabled:=false;
DBgrid1.enabled:=false;
bitbtn7.enabled:=false;
bitbtn9.enabled:=false;
end;

end.[/quote:1353d87f26]


GOSTEI 0
POSTAR