unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
ADOQuery1: TADOQuery;
ADOConnection1: TADOConnection;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject;
var Key: Char);
procedure Edit2KeyPress(Sender: TObject;
var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure
TForm1.Button1Click(Sender: TObject);
begin
with ADOQuery1
do
begin
Close;
SQL.Clear;
SQL.Add('select
* from table1 where username='+QuotedStr(Edit1.Text));
Open;
end;
if
ADOQuery1.RecordCount = 0 then
Application.MessageBox('Maaf,Username
tersebut tidak ada !','Informasi',mb_ok or mb_Iconinformation)
else
begin
if
ADOQuery1.FieldByName('password').AsString<>Edit2.Text then
Application.MessageBox('Pastikan
Username dan Password Anda Benar','Error',mb_ok or mb_Iconerror)
else
begin
Form2.Show;
Form1.Visible:=False;
end
end;
end;
procedure
TForm1.FormCreate(Sender: TObject);
var a:char;
begin
screen.Cursors[crSQlWait]:=Screen.Cursors[crDefault];
a:='*';
Edit1.Text:='';
Edit2.PasswordChar:=a;
Edit2.Text:='';
end;
procedure
TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if #13=key then
begin
Edit2.SetFocus;
end;
end;
procedure
TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if #13=key then
begin
Button1.SetFocus;
end;
end;
end.
Tidak ada komentar:
Posting Komentar